Android OS Forum banner

[how to][TUT]softkey mod

25K views 121 replies 18 participants last post by  ArrTooDeeToo  
#1 · (Edited by Moderator)
Hey guys,This is a small tut for all of you askng for itFirst off you will need to have apktool setup and working for decompiling ICS apks.Another tool you will want and will make life a lot easier is notepad++Im not going to go into detail about how to do that, there are plenty forums and thread the cover that.Once you get everything set follow these steps and you will be on your way to making what every you want .Because there are already so many different roms out there u already probably know what you cannot take a systemui.apk from say DroidTh3orys rom and install it on a stock 4.0.2 base. This is for a few reasons, first the systemui and the framework-res kinda go hand and hand, So say that droidtheory has notification toggles, and u flash a stock systemui that u added a search softkey, you will likely have a systemui force close on boot, the two apks depend on each other to work properly. That said you MUST use the framework-res.apk from the rom you will be working on.So pull the framework-res.apk and the systemui.apk from the rom you are wanting to modify and place them in your folder you have setup for apktoolType apktool if framework-res.apkThis will install the framework and nextApktool d SystemUI.apkAnd this will decompile the systemuiOnce that is done it is a good idea to rebuild right away without changing anything to confirm that your apktool is working, you would rather know now that it is not working than after you edit stuff and have fail errors and send you on a ghost chase looking for bugs when it never worked in the first place.After we know that your apktool setup is working here are some places to start playing withThe common is the icons, changing icons is easy, do what u want with them, just keep in mind a few things.
  • Pngs have to be over a transparent backround
  • Do not change the size of the png, the portrait are 96x160 and 160x96 for landscape
After than comes the fun stuffFor adding buttons, there a few things that need to be added,Starting at /res/layout/navigation_bar.xmlHere is where you would add another icon to the nav bar. This is where u want to use notepad++If you read the line a few times it will start to make sense. From top to bottom on the first layout is left to right in portrait mode, then followed by the "lights out" , then landscape icons and their order, and again the "lights out"Keep in mind if you add another icon u will want to add another lights out dot so that when the softkeys time out you will have four dots for your four keys. Follow this process for both portrait and landscape.Il give an example for adding the search key seeing as how this is the most popularIn the navigation_bar.xml you will want to add this to start, add in both port and similar one to port only change the @ drawable/ic_sysbar_search to ic_sysbar_search_landThis will add the button to the bar, it's a good idea to add the invisible 0dip in between to get the spacing right if you are only going to have a total of four keys, because keep in mind there needs to be room for the menu to show up when an app calls for it.Next you need to add the values for the key u just added,So jump over the res/values and find the followingIn ids.xml you need to add the search id:falseIn the strings we need to add the @strings/accessibility_search that we added in the navigation_bar.xml:SearchNow here is where it gets trickyWe need to public also, but by adding to public we need to tell it where to get the smali info from, so we need to do a few things now, first add the public code so jump to /res/value/public.xmlAnd add :Now the "0x7f0e0095" this is where it will be identified in the nav in the smali.So we need to add a .method in the correct smaliSo jump over to SystemUIsmalicomandroidsystemuistatusbarphone.NavigationBarView.smaliAnd add the .method public as follows, but one warning, you need to make sure that the number we are adding is not already taken, a simple search of the file will verify it does not already exist, if nothing pulls up add this:.method public getSearchButton()Landroid/view/View; .locals 2 .prologue .line 73 iget-object v0, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mCurrentView:Landroid/view/View; const v1, 0x7f0e0095 invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View; move-result-object v0 return-object v0.end methodLast thing to do would be to create you actual icon for your search, remember you need two one port and one land and name ic_sysbar_search_land and ic_sysbar_search and these go in the drawable-xhdpi folder and your good to goNow, you are all done, you have just added a search key to your systemui.apk

and dont forget to check out my original thread here for over 55 different mods just for Axi0m plus links in op for 4.0.2 and 4.0.3 base roms too
http://rootzwiki.com/topic/12333-mod-axi0m-21-softkey-1-mods-55-and-counting/page__pid__337823__st__870#entry337823
 
#7 ·
OK, I tried doing this, but I'm still running into a problem. When I copy the SystemUI.apk back into /system/app and reboot the phone, the navbar at the bottom completely disappears, and the wallpaper goes black. Just to make sure that I wasn't screwing something up, I decompiled SystemUI.apk, then immediately recompiled it without making any changes, and pushed it back to the phone. But I lost the navbar anyway, so it looks like something isn't comiling/decompiling properly. I'm using P3Droid's Tanquil Ice v5.1, and here is what I did to decompile / recompile:

1. Pull framework-res.apk from the phone
2. run "apktool if framework-res.apk"
3. run "apktool d SystemUI.apk"
4. after it decompiles, run "apktool b"
5. then push SystemUI.apk back to /system/app
6. chmod 644 /system/app/SystemUI.apk

And then I reboot the phone, but the navbar disappears. Am I doing something wrong?
 
#9 ·
I was definitely not re-signing it, but I was pushing it in recovery mode, not normal mode, so that shouldn't have been a problem. To re-sign it, what signature should I use? Shouldn't it be the same as the rest of the ROM? And in that case how can I get that signature? Or can I just use testsign.jar?
 
#12 ·
Nice tutorial but it is hard to read. Maybe you could reformat it to make it easier to read?
 
#18 ·
Great write up!

You can push the files over as well though

Code:
<br />
adb shell stop<br />
adb remount<br />
adb push SystemUI.apk /system/app/SystemUI,apk<br />
adb remount<br />
adb shell start<br />
** if the phone doesnt hot-reboot on its own<br />
adb reboot<br />
 
#22 ·
ok, i was saying that u can not use win7 to extract or open in archive to edit anything other than change pngs, which this tut is not about, its about adding keys,
using apktool will unpack properly, from there make your changes, then apktool b ( read apktool website for apktool for beginers ( i think its labeled noobs but i not calling you one by no means))
when you apktool b two things happen two new folders are created in the systemui folder a build and a distro, inside the distro folder is now your new changed rebuilt apk. this apk is not signed! from here, the simply way that i KNOW WITHOUT A DOUBT works is to put it into a zip and flash it in recovery. if you want to try to abd push it thats ok, it may or may not work, if you have tried several times and it does not work... well stop and just flash the damn thing..lol
 
#23 ·
You cannot just push to /system without mounting it and enabling r/w. You also need to check permissions on your apk. The signing part I'll have to take some else word for it.

Sent from my Galaxy Nexus using RootzWiki
 
#29 ·
I wish I had seen this thread earlier before I spent a few hours looking at various SystemUI.apk's to figure out how to make everything work.
Anyway I had a question, when I am editing xml, for example res/drawable/stat_sys_battery.xml and there is a line such as @drawable/"file", does the file always refer to res/drawable-xhdpi?
 
#32 ·
OK, I tried just using an update zip, but still having the same issues. And since I tried doing it with an unmodified SystemUI.apk (only decompiled/recompiled), I ahve to think that there is something up with the way that apktool is doing its tihng. I made sure that I'm using the latest APKtool (1.4.3), and the latest aapt. Any other suggestions as to what may be causing the problem?
 
#34 ·
I got it fixed (kind of) -- I'm running Trnquility Ice 5.1, and I was using the correct framework. But there must be a problem with my Win7 x64 machine because I loaded WinXP in VMWare, installed all the Android stuff, and used APKtool there, and it worked.

The only problem I'm still having is that after I added the search key, the menu key completely disappeared. I'm sure that I messed something up in the navbar xml, so I'll play around with it and see what happens.

Thanks for the help and the tutorial, runandhide05
 
#35 ·
@runandhide05: I figured it out -- since all the buttons are in a Linerlayout, adding another one makes the menu button go off screen. I removed the blank 40dip view at the beginning of the layout, and then changed the widths of all the buttons to 70dip instead of 80dip, and noe everything worls perfectly. Also, you might want to update the tutorial a little bit - if you add the
Code:
systemui:keyCode="84"
parameter to the new search button, it will make the system recognize it as such, and long-pressing it will launch the voice command (or any other app that registers for the search key long-press)
 
#40 ·
on my three key mods for back home and search i ended up just making "recent" call the keyevent code for search to keep it fome showing on lock screen, until i can get some time to read, build, try, reread edit, build try...and so on and so on until i can get it right
 
#41 ·
Could you add the long press options to the OP. I know you have been swamped with request so I was going to try to modify one of your long press files to remove the long press from home for recent and add the recent button back in. I've come quite accustomed to it and now cannot live without that dedicated button
Image
. I do still want the long press search for voice commands though. Thank you!

Sent from my Galaxy Nexus
 
#49 · (Edited by Moderator)
Hello,

First off, Thank you for the tutorial....

Im having a bit of trouble getting the SystemUI.apk to decompile...

I followed a tutorial on how to set up apktools,
I also used the commands to install the framework apk into apktools....

But every time I try to decompile the SystemUI.apk it gives me an error...

Also, when I run the command "apktool if framework-res.apk" it gives me a bunch of invalid config flags, but at the end it still says "framework installed"

Here is a screen shot of the two commands.... First me running "apktool if framework-res.apk" to install the framework into apktools, and then the screen shot of me running "Apktool d SystemUI.apk" in which case it gives me the error that I keep receiving every time I try to decompile.

Can anyone tell me what I might be doing wrong here? Maybe its a bad framework-res file? I pulled it straight from my current rom.

 
#51 ·
@runandhide05

Did you figure out how to hide the menu buttons from the lockscreen? I tried what @btdk7 suggested, but it's not working for me. I pm'd him, but he may be busy and hasn't replied yet.
 
#61 · (Edited by Moderator)
Ok,

for my first edit, I really didn't do much.

I just took a SystemUI.apk of one somebody already made with 4 icons, and I just changed the order of the icons... ( I didn't like the order, and plus its a good first edit)

But now I try to "Apktool b" and it keeps saying "Exception in thread main".

Am I missing something here on how to recompile these?

I already know how to add the edited systemUI.apk to a zip folder and flash it, because I have done that with a few mods that I did for changing the soft key icons. I just cant get the apk to recompile now.