yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] pvyParts:
[APP] or [MOD] Battery Bar for All ROMs - Updated 16/1/12

Hiding the battery Icons on your beloved ROM's

tested on 2.3.* ROMS (Stock ROMS, AOSP, CM, MIUI) may sork on others aswell but 2.2 and below have a different process.

for anyone who understands this stuff a bit this code here is what i edited for our TEAM ROM. this is hiding with an option from an app that sets a "global" setting.

look in the statusbarpolicy.smali

i commented the part with "hide battery icon";

For everyone else what you will need to do is,

1. Decompile your SystemUI.apk

2. Open /smali/com/android/systemui/statusbar/StatusBarPolicy.smali

3. Find the UpdateBattery function.

this can be a long way down.

just do a search for "battery" and you will find it eventually.

Option A - Lock out the battery icon forever!

basicaly to perma hide the icon add this to the start of the update battery function after the bit that looks like this.

Code:

.locals 12
.parameter "intent"

.prologue

add this!

Code:

iget-object v1, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;

const-string v2, "battery"

const v0, 0x0

invoke-virtual {v1, v2, v0}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
return-void

then recompile and push back to phone.

that will perma hide the battery icon

Option B - Make it optional! ( my preferred way of doing things )

basically the same process but with different code and an app to set the settings.

i will add this soon and i will put the option to toggle into the BatteryBar settings app.

Aaron.
[Android Software/Hacking General [Developers Only]] Mjergen:
hi there ; tried it on a SGS2 with the latest CM nightly and then with CheckROM 3.1.1 -- didn't work. no serious hang nor crash, just...nothing happens (I've done the decompiling and recompiling with APKTool)
[Android Software/Hacking General [Developers Only]] Scratch0805:
Worked perfect, Thanks.
[Android Software/Hacking General [Developers Only]] pvyParts:
It has to be enabled from the app. Did you turn it on?

Pvy

Sent from my TEAM powered x10
[Android Software/Hacking General [Developers Only]] Mjergen:
sure, I installed the app and when first running the app, the "activate" box was already ticked. un-ticking and ticking it again did not help either :-l
[Android Software/Hacking General [Developers Only]] pvyParts:
Doesn't cm have it'd own bar? could be fighting.

Any chance of sending me your systemui and maybe grabbing some logs at boot and when you change the settings.

Pvy

Sent from my TEAM powered x10
[Android Software/Hacking General [Developers Only]] Mjergen:
well I thought it had it, hence me flashing it, but apparently not. either that or it's really really ... really well hidden. neither the latest SGS2 nightly (116), nor the stable rls (7.1) seem to have the top bar. i flashed the stable CM 7.1 yesterday evening and didn't apply your mod to the stable version just yet. gonna try that today and keep you posted (i'm in Czech, GMT+1, if you're australian, we might have quite the time difference here :D ).

what I'll do is i'll send you the unaltered systemui from the stable CM7.1 AND the same systemui with your mod, if that's okay with you ?

what is your method of choice for decompiling and recompiling, btw ?

sure thing, i'll do as I said hereabove. also, which logs, pre- or post-mod ?
[Android Software/Hacking General [Developers Only]] Ditamae:
Hey there. First, thank you so much for this.

I apologize for the noob question, but I've never decompiled an apk before, but I'm eager to learn.

I used apkTool to unpack SystemUI.apk, and then added the files per your instructions, and then repacked. I then pushed SystemUI.apk to /system/app and rebooted. Upon reboot the status bar didn't work at all. When I looked at the apk itself it says "Parse error: There is a problem parsing the package."

I'm assuming I've not recompiled properly. I've attached the apkTool version I used. Perhaps I've some made obvious error? Any help you could provide would be much appreciated! I'll try again and see what happens in the meantime.
[Android Software/Hacking General [Developers Only]] pvyParts:
I use APK Manager v5

then drag/ drop updated files into the apks. to replace the old ones.

i cant find a decent guide atm but i know there is one.

Pvy
[Android Software/Hacking General [Developers Only]] Mjergen:
I used & followed this tuto : http://youtu.be/YgWd0jsDtH0

if I used the plain SystemUI from APKTool\SystemUI\dist , I get neverending FC. upon reboot, the status bar is simply gone and even the launcher's "Notifications" soft menu option doesn't make it appear. gotta reflash the ROM to set things straight & get the statusbar back.

if I copy/paste "resources.arsc" from APKTool\SystemUI\build\apk into the fresh SystemUI I obtain in APKTool\SystemUI\dist, there are no FC and the status bar shows, but your top bar mod isn't present, not even when repeatedly checking/unchecking/rechecking "show battery bar" in your app.

it doesn't take a rocket scientist to understand & follow your tutorial, so I believe that my problem comes from somewhere in the recompiling process...

at work now, whenever I have 10min, I'll upload my systemUI apks
[Android Software/Hacking General [Developers Only]] pvyParts:
OK my gimme 5 i'll edit the op with my full decompile/compile process

EDIT*** all done. hope it is enough... i really had to think on how to word it all LOL!

also the file in apktool/[apk name]/dist

has no signatures and will not run (from memory)

Pvy.
[Android Software/Hacking General [Developers Only]] Mjergen:
pt 2 of the log is basically repeating the pt1 above with different "name=" values

it goes on like that for a while and then at the very end of the log :

Exception in thread "main" brut.androlib.AndrolibException: Multiple resources: spec=0x01030065 style/TextAppearance.StatusBar.Title, config=[DEFAULT]
at brut.androlib.res.data.ResConfig.addResource(Unknown Source)
at brut.androlib.res.data.ResConfig.addResource(Unknown Source)
at brut.androlib.res.decoder.ARSCDecoder.readEntry(Unknown Source)
at brut.androlib.res.decoder.ARSCDecoder.readConfig(Unknown Source)
at brut.androlib.res.decoder.ARSCDecoder.readType(Unknown Source)
at brut.androlib.res.decoder.ARSCDecoder.readPackage(Unknown Source)
at brut.androlib.res.decoder.ARSCDecoder.readTable(Unknown Source)
at brut.androlib.res.decoder.ARSCDecoder.decode(Unknown Source)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(Unknown Source)
at brut.androlib.res.AndrolibResources.loadFrameworkPkg(Unknown Source)
at brut.androlib.res.data.ResTable.getPackage(Unknown Source)
at brut.androlib.res.data.ResTable.getResSpec(Unknown Source)
at brut.androlib.res.data.ResTable.getResSpec(Unknown Source)
at brut.androlib.res.data.value.ResReferenceValue.getReferent(Unknown Source)
at brut.androlib.res.data.value.ResReferenceValue.toResXmlFormat(Unknown Source)
at brut.androlib.res.data.value.ResStyleValue.serializeToXml(Unknown Source)
at brut.androlib.res.AndrolibResources.generateValuesFile(Unknown Source)
at brut.androlib.res.AndrolibResources.decode(Unknown Source)
at brut.androlib.Androlib.decodeResourcesFull(Unknown Source)
at brut.androlib.ApkDecoder.decode(Unknown Source)
at brut.apktool.Main.cmdDecode(Unknown Source)
at brut.apktool.Main.main(Unknown Source)

i tried reducing memory size (option 20) or running the .bat as Admin (Win 7 x64) but the same error kept coming back in the log. and before you ask, I do have ADB installed but APK Manager doesn't find it.

i'll try flashing a stock SGS2 ROM or a non-CM ROM, who knows, maybe it's CM's SystemUI's fault...i'll also try doing the procedure on a more powerful PC than the curent one I got at work :rolleyes:
[Android Software/Hacking General [Developers Only]] iridaki:
APK Manager relies on apktool and it seems you haven't installed the appropriate framework. Check here for more details. ;)
[Android Software/Hacking General [Developers Only]] iridaki:
Trust me, pulling the framework is as harmless as it gets!

Pushing a modified one is somewhat a risk, but if you have working adb and/or recovery, you should have nothing to worry about. :)

Good luck!

PS: I am more of a madam, than a sir! :D

You certainly did not install the framework by renaming it to 1.apk.

The link I posted nowhere does it mention this is what you should do. :p

apktool if framework-res.apk

;)
[Android Software/Hacking General [Developers Only]] Mjergen:
actually, for 95% of what I do, I only need CWM recovery and samsung's download mode, sooo...

:eek: my apologies, I couldn't have guessed !

yup, I'll re-do it all this afternoon and take my time. now I'm trying to install Pvy's MOD at work, when I have 5 free minutes between two tasks... :o
[Android Software/Hacking General [Developers Only]] Mjergen:
so... i solved this the lazy way :P

I actually found a package that's flashable in recovery that did the trick ! it was lying around on a Polish Samsung forum (link : http://s5830.pl/thread-242.html). it is intended only for CyanogenMod and apparently the Galaxy Ace, but it works perfect on the latest CM 7.1 and a Galaxy S2 !

link to the mod flashable, in CWM recovery : http://db.tt/79ytqshA

maybe some of you brainiacs could make a universal, flashable zip ? :) all credit goes to Konsky from http://s5830.pl (and to Lady Luck for not f@µ*& up my phone...)

anyway, BIG thanks to Pvy and the rest of you guys for the immediate follow-up customer care and i'm bookmarking this thread nonetheless for when I'll change my SGS2 - hopefully by then I'll be experienced enough not to fumble over de/re-compiling :P
[Android Software/Hacking General [Developers Only]] marc0012001:
Looks good and works without Problems in my X10mini with GingerDX v17 and naa Kernel06.

Good job, a little nice Customisation:D
[Android Software/Hacking General [Developers Only]] LfcFan1977:
Yes thank you. However I was unsuccessful.

Sorry for not posting about it but I was unsure if it was my editting skills, my apkmanager set-up or a difference between android builds.

.method private final updateBattery(Landroid/content/Intent;)V
.locals 8
.parameter "intent"

.prologue
[COLOR="Green"]I added your code here but perhaps I needed to edit the "const-string v2"? Or change something further down, where it indicates "const-string v5, "battery""[/COLOR]
[COLOR="Red"]iget-object v1, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;

const-string v2, "battery"

const v0, 0x0

invoke-virtual {v1, v2, v0}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
return-void[/COLOR]
const/4 v6, 0x0

const-string v7, "level"

.line 540
const-string v4, "icon-small"

invoke-virtual {p1, v4, v6}, Landroid/content/Intent;->getIntExtra(Ljava/lang/String;I)I

move-result v0

.line 541
.local v0, id:I
const-string v4, "level"

invoke-virtual {p1, v7, v6}, Landroid/content/Intent;->getIntExtra(Ljava/lang/String;I)I

move-result v1

.line 542
.local v1, level:I
iget-object v4, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;

[COLOR="Red"]const-string v5, "battery"[/COLOR]

invoke-virtual {v4, v5, v0, v1}, Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;II)V

.line 544

Either way, I wasn't to bothered because I edit some of the default battery icons to Lfc club crests and swithched the settings in interface to stock.

I was just to wait for the "Option B - Make it optional!" choice and try that but I quite like my icon edits.
[Android Software/Hacking General [Developers Only]] pvyParts:
what error were you getting?
[Android Software/Hacking General [Developers Only]] LfcFan1977:
That is part of my puzzle. Everything appears to compile, I don't get an error in the log, no statusbar crash and the icons remain visible.

Then if I pull the SystemUI and decompile it again, those edits have been removed.

After editting the icons, I feel it probably isn't worth spending time troubleshooting this.

Although, if it will beneficial to you or other people, then I am happy to try anything you suggest.
[Android Software/Hacking General [Developers Only]] pvyParts:
sounds like you didn't update the apk properly or something :P it's cool i was just curious if anyone had made it work :)

Pvy.
[Android Software/Hacking General [Developers Only]] LfcFan1977:
[Solved] No battery icons

Sorry, I completely forgot that if editting (ANY) smali in SystemUI with apkmanager I need to take the classes.dex from the build folder and drop it into the original SystemUI with 7zip.

So, in answer to your original question, yes I have (now :o ) followed your tutorial in the second post and have hidden by battery icons.

Thanks again

[edit]

Because it was slightly different to the location in pvyParts [TUT], this is where I found it in aosp 2.3.5

SystemUI.apk/smali/com/android/systemui/statusbar/policy/StatusBarPolicy.smali

Opened with notepad++ and down at row 2098, added the code to look like this.

.method private final updateBattery(Landroid/content/Intent;)V
.locals 8
.parameter "intent"

.prologue
[COLOR="Red"]iget-object v1, p0, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->mService:Landroid/app/StatusBarManager;

const-string v2, "battery"

const v0, 0x0

invoke-virtual {v1, v2, v0}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V
return-void[/COLOR]
const/4 v6, 0x0

const-string v7, "level"

.line 540
[Android Software/Hacking General [Developers Only]] pvyParts:
Awesome! i'm glad it worked :D

Pvy.
[Android Software/Hacking General [Developers Only]] creeve4:
I am using the Mod version, it does not display when the status bar is hidden (full screen apps and games).

Am I wrong in assuming it should work in these situations?
[Android Software/Hacking General [Developers Only]] shoman94:
Excellent work! 100% successful into my Firmware.

One request if at all possible. Do you have a charging animation planned for the future?
[Android Software/Hacking General [Developers Only]] ppmal:
Wow! Great! I will try and make it out! Thanks for the support.
[Android Software/Hacking General [Developers Only]] xornx:
Its just what i wanted ure great!
[Android Software/Hacking General [Developers Only]] pvyParts:
Correct the mod version is PART of the statusbar :) so less RAM usage and no running service.

Yes it is planned :)

Pvy.
[Android Software/Hacking General [Developers Only]] creeve4:
How much RAM and CPU does the APP version use? I assume it's pretty minimal...
[Android Software/Hacking General [Developers Only]] pvyParts:
Runs @ 3mb on my phone. spikes to 7 when in the menus.

no idea about CPU but it never shows up in my battery statistics

as it the bar uses listeners and only wakes when the battery level changes.

Pvy.
[Android Software/Hacking General [Developers Only]] creeve4:
Perfect!

I've been using the mod version, but I like the added features of the app version and that it is displayed even in fullscreen apps.

Great work, thank you!
[Android Software/Hacking General [Developers Only]] shoman94:
So you have 2 versions?

I added the battery bar smali files and the app...so I have the app version?

The mod version is what now? Permanent and not adjustable?

Also I have the code from edt that I incorporated into my firmware for toggling the battery. Would you like it?
[Android Software/Hacking General [Developers Only]] pvyParts:
i Have the code, as i have a heap of features simmilar to EDT in my rom. (original idea was from EDT TBH)

i have been looking for a way of hiding it with out adding the smali to the framework. as smali edits can be complicated for guys who have not done it before

My 2 versions are the mod version (Smali files and the settings app)

App version just a single app that needs no mod, uses a system overlay to put the bar on the screen over everything. ( just the app "TEAM Battery Bar" no smali files needed )

Pvy.
[Android Software/Hacking General [Developers Only]] shoman94:
gotchya.... what would be sweet is if you added the clock and battery tweaks in your app then I wouldnt even need the edt app.
[Android Software/Hacking General [Developers Only]] pvyParts:
Romans EDT mods a rather different to my mods. ;) it's not as easy ass adding a menu to the app.

Pvy.
[Android Software/Hacking General [Developers Only]] NuriJ:
I can translate this to danish & Turkish could that be useful for u?
[Android Software/Hacking General [Developers Only]] pvyParts:
Sure thing dude! :)

Pvy.
[Android Software/Hacking General [Developers Only]] NuriJ:
Done, See attachments
[Android Software/Hacking General [Developers Only]] dafunk2:
....And here it is Italian Lang mate ;).

Cheers Pvy,

dafunk
[Android Software/Hacking General [Developers Only]] pvyParts:
Thanks guys i'll ad into next version.

( as well as the new russian )

Pvy.
[Android Software/Hacking General [Developers Only]] dafunk2:
Ok Pvy. If you add in the next version some more strings to be translated you can post them here.

Ciao ;)
[Android Software/Hacking General [Developers Only]] darren91teo:
some suggestion

Would be nice if it have charging animation.
[Android Software/Hacking General [Developers Only]] creeve4:
pvy's working on it
[Android Software/Hacking General [Developers Only]] pvyParts:
Hey guys,

Animation is added to App Version :) i forgot the new languages tho :P my bad :D i'll be sure to update it asap.

Mod Version will be updated asap

Change Notes,

Added basic Animation options to free version

New Lighter Service

Released Pro/Donate Version to complement free version with enhanced Animation Options.

Added button to pro app in market.

grab it in the OP

or Go Pro on the market here

Edit* also i am gonna move the App Version to it's own thread soon. :) as it needs it :)

Pvy.
[Android Software/Hacking General [Developers Only]] shoman94:
So all need to do is update the app? I'm using the mod version.
[Android Software/Hacking General [Developers Only]] pvyParts:
mod version is not updated just yet mate gimme a day :)

sorry i'll clarify my post
[Android Software/Hacking General [Developers Only]] shoman94:
OK thanks... looking forward to it.
[Android Software/Hacking General [Developers Only]] creeve4:
The app version uses an excessive amount of RAM: before upgrading it regularly used about 9 mb. Now that I have v1.6 (which is supposed to be lighter) it is still using 9+ mb.

I'm running CM7.2 on a Samsung Vibrant.
[Android Software/Hacking General [Developers Only]] pvyParts:
Image won't load for me. But the Ram is that high when the actual app is still open awell. The service uses 2.2 meg on all the phones I've tested on and id the same for all my beta testers. Android has to clean the memory first top it will drop once it needs to.

Pvy

Sent from my TEAM Powered Arc S
[Android Software/Hacking General [Developers Only]] shoman94:
Anxiously awaiting the mod version update. :D
[Android Software/Hacking General [Developers Only]] creeve4:
Aside from charging animation options, is there anything else different in the paid app?
[Android Software/Hacking General [Developers Only]] pvyParts:
Some small changes to the service, other than that atm no. Plan to add more tho.

Pvy

Sent from my TEAM Powered Arc S
[Android Software/Hacking General [Developers Only]] suleiman.aql:
Just reporting that the new update doesn't work on landscape mode... Aka my tablet.

Other than that, I love the app.
[Android Software/Hacking General [Developers Only]] pvyParts:
Thanks for the report. Roll back to 1.5 for now am working on it. I didn't change any thing, to do with it tho... Lol....

Pvy

Sent from my TEAM Powered Arc S
[Android Software/Hacking General [Developers Only]] Dunc001:
Bought the Pro version yesterday. Bit disappointed that the charging animation doesn't have the original MIUI pulse as an option :( Hey ho, can't have everything ;)
[Android Software/Hacking General [Developers Only]] pvyParts:
I've built that optionv already but need to fix the landscape bug b4 I update. :)

Sent from my TEAM Powered Arc S
[Android Software/Hacking General [Developers Only]] creeve4:
I appreciate your work, definitely worth a few $'s
[Android Software/Hacking General [Developers Only]] shoman94:
So did the mod version get updated?
[Android Software/Hacking General [Developers Only]] pvyParts:
I have induced a bug in all versions :) so i am tracking that down :) it seams the animations do not like the high resolution screens in ICS

PVy.
[Android Software/Hacking General [Developers Only]] ZeroManArmy:
The animation kills my speed. When its charging.
[Android Software/Hacking General [Developers Only]] pvyParts:
maybe you could tell me more about about what you are using....

Pvy.
[Android Software/Hacking General [Developers Only]] pvyParts:
Ok i think i have fixed the size bug :) much RAGE was had :D but it is now working with 0 issues on my tablet so i hope that it is working for everyone else too!

let me know both app versions updated on the market (new apk in the OP too)going back to work on the mod version settings.apk now.

Pvy.
[Android Software/Hacking General [Developers Only]] Dunc001:
How long does it take for Market to update? Still not showing any update available...

So does the update have the other animation you mentioned earlier? Still loving this BTW :cool:
[Android Software/Hacking General [Developers Only]] shoman94:
So are you planning on adding the adjustments to settings.apk instead of a desperate app? That would be sweet.
[Android Software/Hacking General [Developers Only]] pvyParts:
Sorry i left it out as i forgot the menu option :) will be in next

Yes it will be part of the mod version i am gonna move the app version out of this thread to stop the confusion :)

Pvy.
[Android Software/Hacking General [Developers Only]] viskey:
Is there a way to add in 1% battery changes to override whatever the stock/rom version is on our phones. some phones are 10% others 20%. if not thats cool. just curious
[Android Software/Hacking General [Developers Only]] pvyParts:
for motorola phones? yes i have planned to fix this :) but have not had time to yet.

PVy.
[Android Software/Hacking General [Developers Only]] ZeroManArmy:
Sorry. The charging animation. It makes my phone lagg really bad. Only when it's on though.

I'm running at a 1.3 kernel.

Posted with SwiftKeyX on my CM9 Motorola Photon!
[Android Software/Hacking General [Developers Only]] pvyParts:
Thats ICS being a biatch :) i am looking into it. ( i now have a device with ICS to test on YA! )

Pvy.
[Android Software/Hacking General [Developers Only]] viskey:
Ya but no Biggy. Just curious. I'm happy with it already!