# Please help me edit statusbarpolicy.smali (remove battery from statusbar)



## cliMAKtic (Mar 16, 2012)

So I recently found the awesome "battery bar" in the market, and now I am looking to remove the battery icon from the status bar, not just replace it with a blank spot mind you, but have the other icons shift right. I've gotten as far as to pull systemui.apk, decompile with baksmali, and open statusbarpolicy.smali. I've tried to edit the codes myself based on other threads but they are all slightly different (android versions/roms?) and I keep demolishing my status bar, as well as getting some other funky unwanted homescreen action. 

Anyway, am I correct in finding that it is one of these two sets of code? Or possibly both that I have to edit? And what do I change it to?(Im running GB 2.3.6):


```
iget-object v0, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;<br />
<br />
    const-string v1, "battery"<br />
<br />
    const v2, 0x10802da<br />
<br />
    invoke-virtual {v0, v1, v2, v4}, Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;II)V
```
*or this..*


```
iget-object v2, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;<br />
<br />
    const-string v3, "battery"<br />
<br />
    invoke-virtual {v2, v3, v0, v1}, Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;II)V
```
Also, i've been using ninjamorph to sign the systemui.apk before I push it, is there another preferred way to sign the apk (by command line) while I am smali compiling after I'm done editing it?

Any help would be greatly appreciated


----------



## CraigL (Jun 17, 2011)

Is this from the stock GB or another?

I personally use apktool for signing.


----------



## dwitherell (Jul 23, 2011)

Two things:
1) Not sure if it's right or wrong but I never sign SystemUI.apk or any system app for that matter unless I've tinkered with Androidmanifest.xml. 
2) I've had luck hunting down where the visibility of the icons are set and tweaking there. I'm pretty sure it's something along the lines of SetVisibility. Hope that helps, and have fun tinkering.


----------



## cliMAKtic (Mar 16, 2012)

> Is this from the stock GB or another?


Actually this is from the latest InfinityRom (GB2.3.6)



> Two things:
> 1) Not sure if it's right or wrong but I never sign SystemUI.apk or any system app for that matter unless I've tinkered with Androidmanifest.xml.
> 2) I've had luck hunting down where the visibility of the icons are set and tweaking there. I'm pretty sure it's something along the lines of SetVisibility. Hope that helps, and have fun tinkering.


Thanks for the tips, so you've successfully pushed a replacement systemUI.apk without signing it? Interesting.. I've seen in other threads that I need to change 'setIcon' to 'setIconVisibility' like so:

```
<br />
invoke-virtual {v2, v3, v0, v1}, Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;II)V<br />
TO<br />
invoke-virtual {v2, v3, v0, v1}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V<br />
```
Is this the visibility that you meant?


----------



## imnuts (Jun 9, 2011)

No, you don't change the method, you have to hide the icon by changing the setvisibility() line related to the battery to hide the icon rather than show the icon. And he is correct in that you don't sign the app. Just retain the original META-INF info, otherwise you're asking for a whole host of other issues.


----------



## motcher41 (Dec 19, 2011)

cliMAKtic said:


> So I recently found the awesome "battery bar" in the market, and now I am looking to remove the battery icon from the status bar, not just replace it with a blank spot mind you, but have the other icons shift right. I've gotten as far as to pull systemui.apk, decompile with baksmali, and open statusbarpolicy.smali. I've tried to edit the codes myself based on other threads but they are all slightly different (android versions/roms?) and I keep demolishing my status bar, as well as getting some other funky unwanted homescreen action.
> 
> Anyway, am I correct in finding that it is one of these two sets of code? Or possibly both that I have to edit? And what do I change it to?(Im running GB 2.3.6):
> 
> ...




```
const-string v3, "battery"<br />
<br />
	invoke-virtual {v2, v3, v5}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
```
Change the second one to how I have it above I am using it now. Recompile and yank the classes.dex from the recompiled SystemUI and place it in your original overriding the original classes.dex with 7zip. Or sign it and use it. I just yank and move. Never signed the apk and used the recompiled one lol

if anyone knows how to edit out the e911 icon in the status bar point me in the right direction. I cant find anything no matter how many google searches I use.


----------



## cliMAKtic (Mar 16, 2012)

motcher41 said:


> ```
> const-string v3, "battery"<br />
> <br />
> invoke-virtual {v2, v3, v5}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
> ...


EDIT: AHHH I GOT IT! I was using the apk that APKtool spit out into the "dist" output folder which is apparently an unsigned version of the apk? (the smaller size of the file is what tipped me off) as opposed to the loose classes.dex file in the "build" output folder, which I manually zipped into the old apk. All is well, thanks everyone for your help!


----------

