yashsingh1/xdaforums huggingface dataset:
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] ra3al:
WOW! Great job havocgb! I can definitely learn some tricks from this :)

I generally avoid writing complex methods completely in smali. (Especially ones that involve loops, if / else and switch statements. It is so easy to screw something up :p)

I prefer to write complex new methods in Java (in a dummy project in Eclipse), compile the project, decompile it to smali and copy-paste the new method.

Example:

If, let's say you want to write the method:

.method private interceptOneFingerStatusBarRightTap(Landroid/view/MotionEvent;)V

in the file:

smali/com/sonymobile/some_app/Class1.smali

In an Eclipse project:

1. Create the package com.sonymobile.some_app in the directory src

2. Create a new Java class (Class1) in the package you created in step 1.

3. Add your new method in the newly created Class1.java file

package com.sonymobile.some_app;

public class Class1
{
private void interceptOneFingerStatusBarRightTap(android.view.MotionEvent event)
{
//...
//add your logic here
//...

// Example
int action = event.getAction();
action = action+1;
}
}

4. Compile the project

5. Decompile the resulting apk file to smali

6. This is what the smali code will look like:

.class public Lcom/sonymobile/some_app/Class1;
.super Ljava/lang/Object;
.source "Class1.java"

# direct methods
.method public constructor <init>()V
.locals 0

.line 3
invoke-direct {p0}, Ljava/lang/Object;-><init>()V

#p0=(Reference,Lcom/sonymobile/some_app/Class1;);
return-void
.end method

.method private interceptOneFingerStatusBarRightTap(Landroid/view/MotionEvent;)V
.locals 1
.parameter "event"

.line 12
invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

move-result v0

.line 13
.local v0, action:I
#v0=(Integer);
add-int/lit8 v0, v0, 0x1

.line 14
return-void
.end method

7. Copy the new method from the smali file you've just produced to the original smali file you are trying to modify.

If you think this is off topic or irrelevant, please let me know and I'll delete it :D

Congrats again for the great thread!
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
Hey ra3al! So glad to see great devs like you at this thread. Man I'm a biiiiiiig fan of your launchers! Still using your Z launcher! It's great! Thanks a lot for your post! I was talking about the same thing in my posts earlier. I referred to this as starting from the opposite end. As this is the best way to figure out smali hex equivalents for numbers I had also uploaded the source for a dummy apk over there.

But you gave a really nice step by step guide to do it. I have put a link to your post in my earlier post where I introduced the concept of using eclipse. Thanks again :)
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] ra3al:
Oops. Sorry, I did not read all the posts carefully.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] sheraro:
Sorry to dig out an old thread but can someone help me with this :

[SIZE="4"].method public runningButton(Landroid/view/View;)V
.locals 3
.parameter "v"

.prologue
.line 1717
invoke-virtual {p1}, Landroid/view/View;->getContext()Landroid/content/Context;

move-result-object v0

new-instance v1, Landroid/content/Intent;

const-string v2, "[B][COLOR="Red"]android.settings.SETTINGS[/COLOR][/B]"

invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

const/high16 v2, 0x1000

invoke-virtual {v1, v2}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

move-result-object v1

invoke-virtual {v0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

invoke-virtual {p0}, Lcom/android/systemui/statusbar/StatusBarService;->animateCollapse()V

.line 1720
return-void
.end method[/SIZE]

This method is called by a shortcut in systemui and it launchs the settings , the problem with this is that the red code can only be an "intent" , and some activities don't have intents like "com.android.settings/.RunningServices".

so my question is is it possible to start an activity directly using smalis. in shell for example runningservices can be launched with :

[SIZE="4"]am start -a android.intent.action.MAIN -n com.android.settings/.RunningServices[/SIZE]
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
Hmmm its been a long time so don't consider this as the best advice. But what I would do is find out how to start an activity in java code in Eclipse or another android IDE,as I said in my starting from the opposite end post. Then you can baksmali and see how that looks in smali and use it where you want in systemui.apk smali. I dont have any IDE in my machine now. You can use the dummy apk source I shared in this post :)
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] sheraro:
will try thanks for the concern :good:
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] adityaf:
Need a help!

Hey im smaling android.policy got this error

PhoneWindowManager.smali[0,0] The maximum allowed register in this context is list of registers is v15
android.policy/smali/com/android/internal/policy/impl/PhoneWindowManager.smali[0,0] null

Here the erro is at 0,0 i didn't got this so can anyone helpo me?
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
Hmm probably you have some inconsistencies in the naming of the local registers. Have you double checked that you have used the correct names?
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] adityaf:
Nope I just patched the smali! What u suggest me? What should i change?

Sent Using Nokia 1100 like a boss :D
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
I mean check if you haven't declared say 3 registers and then used 4. If all that is correct, share your PhoneWindowManager.smali here, you will get some help.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] adityaf:
Okay i will chk! If im unable i will share here!

Sent Using Nokia 1100 like a boss :D
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] adityaf:
PhoneWindow.smali[1787,4] The register number must be less than v16
android.policy.jar.out/smali/com/android/internal/policy/impl/PhoneWindow.smali[1789,4] All register args must fit in 4 bits
android.policy.jar.out/smali/com/android/internal/policy/impl/PhoneWindow.smali[1794,4] mismatched tree node: I_STATEMENT_FORMAT22c_FIELD expecting I_CATCHES
android.policy.jar.out/smali/com/android/internal/policy/impl/PhoneWindow.smali[1805,4] mismatched tree node: I_STATEMENT_FORMAT21t expecting <UP>
android.policy.jar.out/smali/com/android/internal/policy/impl/PhoneWindowManager.smali[0,0] The maximum allowed register in this context is list of registers is v15
android.policy.jar.out/smali/com/android/internal/policy/impl/PhoneWindowManager.smali[0,0] null
android.policy.jar.out/smali/com/android/internal/policy/impl/LockPatternKeyguardView.smali[3668,4] The register number must be less than v16

These errors im getting! I have given link to these files! Please tell me what things i have done! :)

https://www.dropbox.com/s/l8gm06rid73rmi2/PhoneWindow.smali

https://www.dropbox.com/s/u3rq7oxbk376h5q/PhoneWindowManager.smali

https://www.dropbox.com/s/pmy89z7n161bnj4/LockPatternKeyguardView.smali

Hope you tell me some solution for these type of problem! So i would not do these things again and agian! :) Thanks in advance!
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
Man that is a lot of code. How can I know what changes you made? :P It looks like there is some problem when there are more than 15 registers right? (Although I have no idea why) Were there originally more than 15 registers in 'method private getUnlockMode()' and 'method private installDecor()'? Or did you declare more registers?
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
With a quick search found that arguments can't be more than the v15 registers. And p registers come after v registers. So try moving p0 value to some other register like v0,v1,....,v15 that is free and then passing it as an argument.

Check out these threads to know more:

http://xdaforums.com/showthread.php?t=733275

http://xdaforums.com/showthread.php?t=2279872
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] adityaf:
Ummmm! Okay I cleared these! :D thanks!

Sent Using Nokia 1100 like a boss :D
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Kalpit Nathwani:
Hello havocgb

Can you please tell me for which purpose keyguardstatusviewmanager.smali uses and how to modify this file as I am trying port Miui ROM and I have taken base ROM as a CM10.1 and this file is totally different in both this ROMs.

Thanks in advance

Kalpit Nathwani
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] adityaf:
Depends on which phone you are porting!
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
I would add the strings myself and add the continuation of public string id's for you additional lines in the public.xml, then use those new id's in smali.

There might be an better way but that worked for me when I was modding the framework.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] sieuan:
Thanks sir!

But I have a problem with my framework-res.apk. I can not recompile it, even when I keep it original without editing anything after decompile it.

And I contact with iBotPeaches, who dev the apktool, ask him for test my framework-res.apk. And after he looked over that 20,000 line file and found 0 error within aapt, he said that "it is bad apk", so I can not recompile it to get a public string id's for use in smali.

So i think that I can change the public id of string name with the text in smali file.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
I don't think your gonna be able to override the string.xml using smali. Best to fix your compile issue. Framework should ALWAYS compile. What version of android are you using and is it sense or TouchWiz ?

Sent from my Nexus 7 2013 using ClearJellyed Tapatalk 4
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Ticklefish:
What errors were you getting when you tried to recompile?
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] mscreater:
do you have resolve the problem? i have the same problem, i don't know how to fix that..
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] The Scientist95:
How to edit over scrolling color in framework-res.apk? I use Virtuous ten studio to decompile. I couldn't get the smali code for framework-res.apk. Please help. Thanks.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] 1brainsurgeon:
Your oversroll glow should be a png in drawable-xhdpi, assuming you're on that version of android. There's no smali in framework...

Sent from my SPH-L710 using Xparent Purple Tapatalk 2
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] z720:
i managed to compile and get it show, but the problem I found is the value either 0B/s or ∞MB/s. :confused:
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] b10011:
I edited one .smali file by adding there command (Log.d in smali syntax). The app works (Even that part, no crashes) but how can I read logs on real device?

v0 is value I want out, v7 is unused slot in that method:

invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v7

invoke-static {v7}, Landroid/util/Log;->d(Ljava/lang/String;)I

Thank you for answering!
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Aciong.Aksaya:
Hi I am on GIn2kitkat I just wanna know how to capitlized AM/PM in status bar. Erhany tipped that its a smali edit. I browse the smalis of SystemUI.apk and I think the edit should be done in clock.smali or clock$.smali if I am right but I am not sure what code will I write. Can I get a lil help?

Thanks...
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
This is your issue:

ERROR: Failure processing PNG image D:\rsms_dev\Android\Development\APK-Multi-Tool-Stable-RELEASE\projects\com.optimum.unity.mobile-1.apk\res\drawable-hdpi\subtitles.png

Fix the .9.png from the bad decompile.

Sent from my Nexus 5 with the KlearKat tapatalk app! ;)
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] marsui:
OK, I actually didn't realize that error was from the decompile and not the recompile. I didn't realize how flaky the decompile process is, but I guess it was kind of naive of me to think it would work without issues.

So I did some searching on this whole 9patch thing, and I am utterly confused....are you saying I have to open that png file in some image editor and do something with it? I can't believe the problem is an image and not code lol, this is my first time decompiling so I might just not understand what it means to fix a png file.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Apktool decodes .9 images with patch lines that allow the image to stretch and guide where text and icons are located within that image. On decode that errors because it was not properly coded. To fix it you can use the drawpatch editor in the android Sdk or use an image decompiler like Xultimate to just decode that image and see if a copy of it from the original apk decodes right. Then replace the bad one with that one. I've used both methods to fix this error.

Sent from my N7 using a KlearKat tapatalk
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] marsui:
Thanks that's very useful, will try both methods
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] marsui:
So I've successfully decompiled the apk I want to mod (the optimum app) I found the smali code I wanted to modify, modified it, and it seems to work. (I'm trying to remove the restriction that the optimum app will not allow you to have an HDMI cable [mhl] connected)

So the app starts up, and its mirroring great (usually it would have error'd out saying that the app does not support HDMI output). I'm all excited until I go to actually stream one of the channels, and the app just completely reboots =(

So II decided just to decompile, recompile and sign without my code modifications, and it does the same thing. I have no idea what could possible be causing this to occur specifically but its obviously not decompiling perfectly. Is this THE goto decompiler for APKs? Do APKs generally decompile/recompile without issues?

I'm thinking I just have to pour over the code and fix it, but its probably going to be quite difficult without really being able to debug what is going on.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Try moving just the classes.dex to an untouched apk. Delete the META-INF folder and resign the apk.

If that doesn't work try moving the dex file but leave the signature and move the apk to system/app.

Those tricks work theming Google apps so it might work in your case.

Sent from my Nexus 5 with the KlearKat tapatalk app! ;)
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] marsui:
That sounds like a good idea, so just to be clear, I'm going to take the Original APK, move my recompiled classes.dex into the original apk (using a tool like winrar)?

Edit: Well I tried both, and the app crashes instantly with both methods =(

Thank you though
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Damn, well that stinks. :-\

Sent from my Nexus 5 with the KlearKat tapatalk app! ;)
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] mikk_11:
I tried to mod my SuystemUI of my Z1c.

When I want to compile it again Smali Manager writes this Error:

..\project\SystemUI.apk_classout\com\android\systemui\statusbar\phone\PhoneStatusBar.smali[12843,3] Error for input '.parameter': Invalid directive
..\project\SystemUI.apk_classout\com\android\systemui\statusbar\phone\PhoneStatusBar.smali[12843,14] mismatched input '"event"' expecting END_METHOD_DIRECTIVE

What do I wrong?
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Pankaj Rai:
thanksssss
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] kingdj:
hai mate i have few question hope you can help me.

i try to mod my system ui for that i have to modified my phone statusbar smali but i get confuse when some line i search can.t be found on my phone statusbar smali. here the code im looking for.

method private setpile layer

) iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mMediaEjectBroadcastReceiver:Landroid/content/BroadcastReceiver;

.method private showAlwaysAskOrInternetCall(J)V

.method private setIntruderAlertVisibility(Z)V

anyway im on cm11 .maybe its override by new code. but i can.t find it please help which code is override that code on cm11.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Status bar code was moved, you trying to get a translucent one?

There are styles attributes in kitkat you can enable.

Look here:

http://www.doubleencore.com/2013/11/expand-your-brand-with-translucent-system-ui/
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] kingdj:
hmmm not what im looking exactly mate but thanks for response. what im asking is the code above is on cm10.1 and cm10.2 i try to apply some mod from cm10.1 and cm10.2 and can.t find the line above. so its must be override by new code but same function as code above but i can.t find the new code on cm11 that have same function like code above
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
A far as i know it's changed dramatically, so I would say that mod needs to be reworked.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] afah_me:
Can anyone help me how to fix this?

thank's...:good::good::good:
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] :
Hi. I'm actually stuck. I made an app with an online service now I've been trying to edit it and customize it more. Today I've done all but one. I even changed the package name. It works but one thing. The server removed my files and I have two Picture buttons called "Button2" and "Button5" and I tried doing everything to change both their height and width from 30 pxls to 70pxls. Now I tried searching, converting smali to java and etc but I didn't succeed. And it doesn't have no layout folder in /res so that I could change it from there...

Any Suggestions?

All I see is this nonesense. I tried finding these buttons but it only has got their names and actions and I'm sure there's no other place that it could be because of some reasons....

Now I know that it is in either Screen1.smali or Screen1$frame.smali.

Anyone knows anything? I developed it with MIT App inventor.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] josephpatrick:
error?

hi, what does this following error actually mean....there is no line number

06-09 07:04:33.970 2648 2660 I am_crash: [10329,0,com.android.contacts,1083752133,java.lang.VerifyError,com/android/contacts/activities/PeopleActivity,Class.java,-2]
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] TheDriller:
Verify errors are hard to run down. But in the apk you modified you probably messed up a register somewhere or tried to reuse one that can't be reused. Or you forgot to add new locals if you added new registers. Or it could be that you have too many registers for a simple const. You may need a const/4 if your registers are high enough
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
The volume sliders are set in Drawable folder with a tint added...that's why there's no reference in smali.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Rick1684:
Yes it is controlled by drawables and I have that themed but when headphones are plugged in it gets overlayed back to stock blue with a red high volume area. Unplug them and back to normal. Do you have any ideas on where this tint could be added. I have looked through xmls and drawables. Then seen this in smali about setdualcolorseekbar. Thanks for the help.

Edit.. I would be happy simply disabling this method if thats possible.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Oh then it's a possible color map or overlay, try searching the color code for those colors in smali hex. There's a few converters out there, I'm on CM so they must have it disabled. Never seen that before.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Rick1684:
Ive tried that too unfortunatly nothing. I loaded up all smalis in the com/android/systemui folder and did a search all for

-0x16b0ee, -0xff5f32, and -0xb4f6a. Those are the three colors being used.

Im wondering if it could be set in rgb or something. Are there any other places to look?
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Hmm, try looking in arrays? Google been hiding colors there too. I suppose monitor.bat gave you the smali you're looking in..so I'm thinking you've tried most common searches. It can be rgb coded with three entries for each. Worth a shot.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Rick1684:
Yea I learnt the hard way about the arrays and also seen some in integers. Spend all day blacking out an app and see is_black_mode>0 in arrays. Thats a duh moment. But anyway am I correct to search for -0x16 in rgb for example -0x16b0ee and then the other digits the same way? Or is it numbers like 266, 238, 112.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Usually it's -0x16 then right below -0xB0 then -0xEE unless it's argb with the alpha defined too.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Rick1684:
Ok Im loading up every smali in the apk now. Thanks for the help. Just to be clear that smali in my first post doesnt have any thing to do with colors?

Edit.. No luck on the rgb either. I think theres a reason no ones done this mod.

Dont worry about it. Merry Christmas and thanks for all you do.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Rick1684:
[MENTION=2126467]djdarkknight96[/MENTION] I was able to disable the slider turning red. Now I am looking for the media slider handle. It has a tint set somewhere that I cannot find Ive seached most everything. My question to you is is there a way to make a png not accept a tint. Or a different image format that will not accept tints.

BTW the edit was to the smali i posted, had to change if eqz v0, cond_1 to if nez v0, cond_4 Under setdualcolormediaslider. Basically just disabled it.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] djdarkknight96:
Ah very good, smali is a pain. The tint should be in the same smali. Try disabling it, I hate they added tint to smali. Look to see if it has touch states. Pressed selected..etc then look for those values too.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] remuntada78:
try to remove the following line from both methods

invoke-virtual {v0, v1}, Landroid/widget/SeekBar;->setOverlapPointForDualColor(I)V
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] Rick1684:
To all of you here thanks. Ive learned so much from you. Getting that volume slider taking care of means alot. [MENTION=5292754]remuntada78[/MENTION] I really appreciate all the help. Its nice to have someone take the time to help. THATS TO ALL OF YOU. Much Love.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] newbreedsoftware:
I'm trying to modify some smali code and I'm not exactly sure I'm doing it correctly. I am trying to bypass root detection on a game I want to play on my tablet. I found where the root detection process happens. My question is do I need to just change the const-string lines to if-nez v0, :cond_0 or do I need to edit the other files as well? Any ideas would be much appreciated, thank you. I have attached a screen shot of the smali source as well.
[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] RealWelder:
Need some help/information. I am trying to port the 4 way reboot mod to an LG phone, with no luck. I noticed that it seems like the LG phone uses a different method for createDialog. I think that is why this mod isn't working. I guess my question is does anyone know anything about GlobalActions$GlobalActionsCreateDialog instead of Landroid/app/AlertDialog$builder?