Android Play series: Modify the assembly code to support native HD call dashboard (3)

Source: Internet
Author: User

This article is divided into three parts. This article describes more complex customization processes.

]

(Next to further refine the previous modification, the first six sections see: http://blog.csdn.net/aimingoo/article/details/7939116)

7. Modification of some legacy problems
========

The above is the lite version, only to highlight the implementation of core functions, but there are still a lot of problems left behind. The following is an example.

1) Ah. It was successful, but it was changed later.
---------

[Modify, 2012.09.04. The method name is incorrect. It should be updateincallbackground () instead of updatescreen ()].
This is not a universal problem. Some dial-ups have backgrounds, while others have transparent backgrounds that directly display desktops. For a dial-up panel with a background, phone.apk usually has an updateincallbackground () method in incallscreen. smali. Locate the call points and comment them out. Or simply change updateincallbackground () to an empty function.

If you cannot find the updateincallbackground () function, try to find a setbackgroundresource () method to redraw the background of mmainframe.

2) The next incoming call will be followed by a large sticker used by the phone.
---------
Yes. This should be cleared at the end of the call. This is simple. Modify incallscreen. smali and find

.method private delayedCleanupAfterDisconnect()V

This method. Then find the return-void line of code, and insert the following code in several lines above:

... # Fixed by aimingoo # reset the background const/4 v0, 0x0 iget-object V1, P0, lcom/Android/phone/incallscreen;-> mmainframe: landroid/View/viewgroup; invoke-virtual {v1, V0}, landroid/View/viewgroup;-> setbackgroundresource (I) V ## for details about setpersoninfostyle (), see const/4 v0, 0x1 iget-object V1, P0, lcom/Android/phone/incallscreen in section 5th of the issues left over; -> mcallcard: lcom/Android/phone/callcard; invoke-virtual {v1, V0}, lcom/Android/phone/callcard;-> setpersoninfostyle (z) V ## end fix.: cond_3: goto_0 return-void ##<-pay attention to finding the code from this line...

3) Does the original Avatar still flash?
---------
The original profile picture is like this:
-Start answering or calling
-The dial-up program displays the Panel. The position of the Avatar in the panel is displayed as an icon with no Avatar.
-Initiate an asynchronous call to read the profile picture from the contact database
-When the above asynchronous call is returned, the "no Avatar" icon above is updated to indicate the real Avatar image.

In fact, the native application will take two steps in "Show avatar" to draw a dial-up panel more quickly for user operation. In fact, our code also relies on this principle. After the above process asynchronously gets the data of "HD dashboard", it is displayed on the background.

In general, the Avatar will always flash. Before asynchronously reading the Avatar, the native interface displays an "No Avatar" icon. Although this process is usually very short, most of the time you have flashed the phone call, but for those who are staring at the phone to see the effect of play, it is still uncomfortable.

Basically, you can comment out all the changes to mphoto. If necessary, retain some code that is used to display the original mphoto without a large post. As an example, you can simply modify showcachedimage (). First, find showcachedimage () in callcard. smaIl, and comment out the following two lines:

# You do not have to update the Avatar in cardcard when getting the Avatar #. method Private Static final showcachedimage (landroid/widget/imageview; lcom/Android/Internal/telephony/callerinfo;) Z... # iget-object v0, P1, lcom/Android/Internal/telephony/callerinfo;-> cachedphoto: landroid/graphics/drawable; #### invoke-static {P0, V0}, lcom/Android/phone/callcard;-> showimage (landroid/widget/imageview; landroid/graphics/drawable ;) v...

In this example, showcachedimage(example, because phone.apk only calls showcachedimage () for the mphoto Member, others directly call showimage ().

4) the screen is not completely displayed and hidden by some elements. It would be nice if they have transparency.
---------
Sometimes, the elements on the interface are drawn through textures, that is, in the resource file, its background is an image. For the background of a specified color, for example, # xxrrggbb, we can specify the XX value in the resource file to make it transparent. However, if the background is a graph, the resource file of the lower Android version does not support the Alpha attribute, so it can only be transparent in the source code through setalpha.

In this case later (including the previous case of setting the color code), you can go to callcard. smali and incalltouchui. in smali, you may need to change the code to incallscreen. code in smali. In general, it is related to the specific phone.apk. The following is the code I used to modify mokee's phone.apk. Note that the Code should be written in the onfinishinflate () method. The interface is initialized and the interface elements are associated with the Java object members.

# --------- # Process Background after initialization #-callcard. smali # ---------. Method protected onfinishinflate () V ...... Iput-object v0, P0, lcom/Android/phone/callcard;-> mprimarycallinfo: landroid/View/viewgroup; ## fixed by aimingoo ## for callcardpersoninfo. clild (0) const v0, 0x7f070020 invoke-virtual {P0, V0}, lcom/Android/phone/callcard;-> findviewbyid (I) landroid/View/view; move-result-object V0 check-cast v0, landroid/View/viewgroup; const V1, 0x0 invoke-virtual {v0, V1}, landroid/View/viewgroup; -> getchildat (I) La Ndroid/View/view; move-result-object V0 invoke-virtual {v0}, landroid/View/view;-> getbackground () landroid/graphics/drawable; move-result-object V0 const/16 V1, 0x40 invoke-virtual {v0, V1}, landroid/graphics/drawable;-> setalpha (I) V ## for phonemsgcontainer const v0, 0x7f070028 invoke-virtual {P0, V0}, lcom/Android/phone/callcard;-> findviewbyid (I) landroid/View/view; move-result-OB Ject V0 invoke-virtual {v0}, landroid/View/view;-> getbackground () landroid/graphics/drawable; move-result-object V0 invoke-virtual {v0, v1}, landroid/graphics/drawable;-> setalpha (I) V # end fix. # --------- # process Background after initialization #-incalltouchui. smali #---------. method protected onfinishinflate () V ...... Iput-object V1, P0, lcom/Android/phone/incalltouchui;-> stop_layout: landroid/widget/linearlayout; # fixed by aimingoo # For bottombuttons @ mincallcontrols iget-object V1, P0, lcom/Android/phone/incalltouchui;-> mincallcontrols: landroid/View/view; const V2, 0x7f070074 invoke-virtual {V1, V2}, landroid/View/view;-> findviewbyid (I) landroid/View/view; move-result-object V0 const/16 V1, 0x40 invoke-virtual {v0}, landroid/View/view;-> getbackground () landroid/graphics/drawable; move-result-object V0 invoke-virtual {v0, V1}, landroid/graphics/drawable;-> setalpha (I) V ## for endbutton @ mendbutton iget-object V1, P0, lcom/Android/phone/incalltouchui;-> mendbutton: landroid/widget/button; invoke-virtual {v1 }, landroid/widget/button;-> getbackground () landroid/graphics/drawable; move-result-object V0 const/16 V1, 0x60 invoke-virtual {v0, v1}, landroid/graphics/drawable;-> setalpha (I) V # end fix.

5) The above mphoto is not displayed, but it seems to be still in the position, it is still difficult to see.
[In other words, it is really necessary to adjust the style through assembly code. wow? GG, why not modify the resource file directly ?]
---------
If we really want to implement:
-Mphoto
-If there are no headers, display the "No Avatar" icon or
-Because the Avatar picture is not big enough, it is better to display the picture to the middle of the Avatar mphoto in some cases.

In fact, in the implementation code of showcachedbackground (), the size of the Avatar image is indeed checked. When one of its lengths and widths is smaller than PX, we will not display it as a full screen dashboard. Therefore, we still need to process mphoto as follows: hide a large post; otherwise, we need to display it when necessary.

In this case, the resource file cannot be changed. You have to change the code.

We left a setpersoninfostyle () in showcachedbackground. That method is actually used here. The input parameter todefault. When todefault is set to false, the customized dashboard is displayed. Otherwise, the dashboard is switched back to the Native Interface (that is, the small Avatar. This feature is related to the specific phone.apk. because the call Panel Interface of each phone.apk is different, it depends on the programmer to analyze the resource file and modify it slightly. Despite the trouble, the results are amazing. The following is a setpersoninfostyle () method I wrote for The lezo interface:

.method public setPersonInfoStyle(Z)V    .locals 2    .parameter "toDefault"    if-nez p1, :cond_0    ## 42.0F    const/high16 v0, 0x4228    ## CallCard.pA == mName    iget-object v1, p0, Lcom/android/phone/CallCard;->pA:Landroid/widget/TextView;    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V    ## 28.0F    const/high16 v0, 0x41b8    ## CallCard.pC == mPhoneNumber    iget-object v1, p0, Lcom/android/phone/CallCard;->pC:Landroid/widget/TextView;    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V    ## CallCard.pB == mLocation    iget-object v1, p0, Lcom/android/phone/CallCard;->pB:Landroid/widget/TextView;    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V    ## bacground    const v0, 0x80CCCCCC    invoke-virtual {v1}, Landroid/widget/TextView;->getParent()Landroid/view/ViewParent;    move-result-object v1    check-cast v1, Landroid/view/ViewGroup;    invoke-virtual {v1, v0}, Landroid/view/ViewGroup;->setBackgroundColor(I)V    :goto_0    return-void    :cond_0    ## 25.0F    const/high16 v0, 0x41c8    ## CallCard.pA == mName    iget-object v1, p0, Lcom/android/phone/CallCard;->pA:Landroid/widget/TextView;    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V    ## 18.0F    const/high16 v0, 0x4190    ## CallCard.pC == mPhoneNumber    iget-object v1, p0, Lcom/android/phone/CallCard;->pC:Landroid/widget/TextView;    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V    ## CallCard.pB == mLocation    iget-object v1, p0, Lcom/android/phone/CallCard;->pB:Landroid/widget/TextView;    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V    ## bacground    const v0, 0x0    invoke-virtual {v1}, Landroid/widget/TextView;->getParent()Landroid/view/ViewParent;    move-result-object v1    check-cast v1, Landroid/view/ViewGroup;    invoke-virtual {v1, v0}, Landroid/view/ViewGroup;->setBackgroundResource(I)V    goto :goto_0.end method

This setpersoninfostyle () function will call and pass in the false value in showcachedbackground (). It should also be called in the delayedcleanupafterdisconnect () method of incallscreen. smali. In the latter case, the value of true should be input so that the "Next" Incoming call panel will be opened by default.

6) full screen !! To be real full screen !!!
---------
In fact, most dial-up panels do not support "full screen", which usually leaves a status bar. Now that we are talking about "full screen call dashboard", we can add the following code:

# --------- # Enable full screen of the dial-up panel #-In incallscreen. smali #-the code to be modified must be in incallscreen;-> setcontentview () before calling !!! # ---------. Method protected oncreate (landroid/OS/bundle;) V ...... # Fixed by aimingoo. invoke-virtual {P0}, lcom/Android/phone/incallscreen;-> getwindow () landroid/View/window; move-result-object V2 const/16 V1, 0x400 invoke-virtual {V2, V1, V1}, landroid/View/window;-> setflags (ii) V # Fix end. ...... Const V1, 0x7f030012 invoke-virtual {P0, V1}, lcom/Android/phone/incallscreen;-> setcontentview (I) V

7) You forgot how to change the HD contact photos!
---------
Hmm. Yes, yes. Sorry. Completed.

It is actually very simple. Decompile it and find
Smali \ com \ jgarrison \ hdcontacts \ newentry. smali

This file. Comment out the following code:

# --------- # Comment out the following code to display a "free" box when opening the Image Selection ##-. code like line XXX may be related to specific decompilation, so you don't have to worry about it. ##---------##. Line 406 ## const-string V12, "outputx" #### const/16 v13, 0x100 ### invoke-virtual {V8, V12, v13 }, landroid/content/intent;-> putextra (ljava/lang/string; I) landroid/content/intent ;####. line 407 ## const-string V12, "outputy" #### const/16 v13, 0x100 ### invoke-virtual {V8, V12, v13 }, landroid/content/intent;-> putextra (ljava/lang/string; I) landroid/content/intent ;####. line 408 ## const-string V12, "aspectx" #### const/4 v13, 0x1 ### invoke-virtual {V8, V12, v13 }, landroid/content/intent;-> putextra (ljava/lang/string; I) landroid/content/intent ;####. line 409 ## const-string V12, "aspecty" #### const/4 v13, 0x1 ### invoke-virtual {V8, V12, v13 }, landroid/content/intent;-> putextra (ljava/lang/string; I) landroid/content/intent;

Then re-compile it, so that we can freely select the image size when we use it to set the top sticker. Of course, we can also use the tool to get a large post of "exactly a full screen size. We strongly recommend "quick graph browsing", which can be used to set the screenshot frame by size and aspect ratio. If you set the size by size, for example, the screen size of X, no matter how large the captured image is, it will eventually be scaled to this size-very easy to use!

N) Others
---------
! Emphasize !!!

1: always remember: when inserting code, make sure you are using the appropriate register!

2: different versions of phone.apk are different. The above code is mainly based on cyanogenmod and its derivative Rom, which can be generally used between them. But pay attention to the differences in details, especially (again) the registers may be different in the disassembly code!

3: A lot of Rom derived from cyanogenmod, including Lewa, lezo, dianxinos, mokee, shendu, Norma, joyos, and some miui customized versions.

4: Unlike the phone.apk in rom, most of them cannot be used in other Rom. One of the main reasons is that phone.apkrelies on resources in framework-res.apk to implement the touchui in the lock screen state, rather than the framework-res of Rom. In addition, the telephonyprovider.apk versions used by the users are different. Try another one and try again.

5: You must use two keys of platform. * To sign phone.apk. It must be the signature of this permission.

6: there is no need to change the original factory's phone.apk, for example, sesen Native Interface. Because you cannot get their private platform keys. So you cannot sign it, so you cannot change it to native Rom. Use other Rom? You forgot, the Framework-res is different.

7: Write a program. It's just a compilation. Don't worry!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.