[MOD] Battery Bar for All ROMs - Updated 31/3/12

Search This thread

LfcFan1977

Senior Member
Nov 7, 2010
452
164
Has any one used the tutorial in the second post to hide the battey icon ???
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.
Code:
.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.
 

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
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.
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.

what error were you getting?
 
  • Like
Reactions: LfcFan1977

LfcFan1977

Senior Member
Nov 7, 2010
452
164
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.
 

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
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.

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.
 
  • Like
Reactions: LfcFan1977

LfcFan1977

Senior Member
Nov 7, 2010
452
164
[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 :eek: ) 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.
Code:
.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
 
Last edited:

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
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 :eek: ) followed your tutorial in the second post and have hidden by battery icons.

Thanks again

Awesome! i'm glad it worked :D

Pvy.
 
  • Like
Reactions: LfcFan1977

creeve4

Senior Member
Jan 5, 2011
2,871
596
Bountiful
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?
 

shoman94

Recognized Contributor
Mar 27, 2009
8,926
12,323
Maine
Excellent work! 100% successful into my Firmware.

One request if at all possible. Do you have a charging animation planned for the future?
 

ppmal

Member
Jul 28, 2011
28
3

APP Version
Version 1.5
Howdy Guys i have built the Battery Bar into an app and put it on the market :D
it has all the features of the MOD version :D but you don't have to mess around with modding your system files.
it uses as service and overlays the battery bar on the top or bottom of the screen.

Android Police were Kind Enough to Feature it on there Blog

As Was 4Tablet PC (Russian)

More on Android HDBlog (Italian)

This is my Blog

Features
Selectable Colors
Static Color
Auto-Magicaly Color (Low Med Reg Charge)
Auto Detection of screen Width ( Bar works in Portrait and Landscape Mode on any phone! )
Selectable Height
Selectable Alignment ( Top or Bottom )

Here is the link to the market
as always it's free
https://market.android.com/details?id=com.pvy.batterybar

Change Log
Code:
v1.5
Added Low% / Med% Colour Cutoff options
Small changes in batterybar to make the new cutoffs work correctly
Fixed the options view as it didn't load properly
Made the auto colour options hide when using a static color and vise versa.

v1.4
Fixed the height issues
You can now set what ever height you like
Fixed the issue with the bar not moving when the alignment is set
removed the notification sound
small code rewrite in the service

v1.3 
( sorry about mass updates guys will do it once a week from now on :D )
Added Hungarian

v1.2
Added Japanese Localisation

v1.1
Fixed Boot Persistence
Added Greek Localisation
Small Code Tidy Up

screenshot_2012-01-03_1613.png


more SS's can be found here.
http://s789.photobucket.com/albums/yy180/aaronkable/TEAM Battery Bar/?albumview=slideshow

Enjoy!


MOD Version


Howdy All,

Few people have been asking me how i got the Miui Battery Bar into my ROM on the x10! short answer is i didn't i wrote my own battery bar! and here is how you can use it!

Features
Hide / Show
Selectable Colors
Static Color
Auto-Magicaly Color (Low Med Reg Charge)
Auto Detection of screen Width ( Bar works in Portrait and Landscape Mode )
Selectable Height ( 1 to 5 px )

Screen Shots
device-2011-12-01-213858.png


Change Log
Code:
[B]Options App[/B]
v2.0
added height options.

v3.0
added new color dialogs.

v4.0
fixed default color of med level to be non-transparent.
Code:
[B]Battery Bar[/B]
v2
added height options and fixed default colors.


How To!

Ok so there are 2 files attached

First is a Zip with the files needed to add to the SystemUI.apk (THIS IS NOT FLASHABLE)

Second is an the Settings app for the Battery Bar.













Thats it ( I think )!

all i ask is you don't modify the about section of the app if you choose to use it! and give credits where credits due. feel free to change my dodgy icon and if anyone has a better one ;) i will also put the sources for the settings app up on my git when i get git back up ( and when i tidy up and add comments ) and running in the next few days so that those of you running on source versions can cook it in from scratch. ( i don't think i need to explain how to do that if you are compiling sources i think you'll know what to do )

with some help i can probably port this to older android versions (<2.3) as needed but i dont have access to a rom to test it on currently. so if you can help me there let me know :D

Hope you found this helpfull! Let me know if this is not clear enough!

Q&A




Pvy


Credits
Color Picker
http://xdaforums.com/showthread.php?p=10739805#post10739805
Thanks to Devmil



Wow! Great! I will try and make it out! Thanks for the support.
 

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
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?

Correct the mod version is PART of the statusbar :) so less RAM usage and no running service.

Excellent work! 100% successful into my Firmware.

One request if at all possible. Do you have a charging animation planned for the future?

Yes it is planned :)

Pvy.
 

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
How much RAM and CPU does the APP version use? I assume it's pretty minimal...

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.
 
Last edited:
  • Like
Reactions: creeve4

creeve4

Senior Member
Jan 5, 2011
2,871
596
Bountiful
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.

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!
 

shoman94

Recognized Contributor
Mar 27, 2009
8,926
12,323
Maine
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.

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?

Sent from my Transformer Prime TF201 using Tapatalk
 

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
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?
Sent from my Transformer Prime TF201 using Tapatalk

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.
 

shoman94

Recognized Contributor
Mar 27, 2009
8,926
12,323
Maine
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.

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.

Sent from my Transformer Prime TF201 using Tapatalk
 

pvyParts

Inactive Recognized Developer
Oct 11, 2010
1,858
2,341
35
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.

Sent from my Transformer Prime TF201 using Tapatalk

Romans EDT mods a rather different to my mods. ;) it's not as easy ass adding a menu to the app.

Pvy.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 117

    MOD Version

    App Version Here - http://xdaforums.com/showthread.php?t=1568318

    Howdy All,

    Few people have been asking me how i got the Miui Battery Bar into my ROM on the x10! short answer is i didn't i wrote my own battery bar! and here is how you can use it!

    Features
    Hide / Show
    Selectable Colors
    Static Color
    Auto-Magicaly Color (Low Med Reg Charge)
    Auto Detection of screen Width ( Bar works in Portrait and Landscape Mode )
    Selectable Height
    Charge Animation options.

    Screen Shots
    device-2011-12-01-213858.png


    Change Log
    Code:
    [B]Options App[/B]
    v2.0
    added height options.
    
    v3.0
    added new color dialogs.
    
    v4.0
    fixed default color of med level to be non-transparent.
    Code:
    [B]Battery Bar[/B]
    v2
    added height options and fixed default colors.


    How To!

    Ok so there are 2 files attached

    First is a Zip with the files needed to add to the SystemUI.apk (THIS IS NOT FLASHABLE)

    Second is an the Settings app for the Battery Bar.

    Step 1
    decompile your SystemUI.apk

    i use Apk Manager

    Step 2
    Navigate to smali\com\android\systemui\statusbar\ Folder
    Place the 3 Smali Files from the zip here
    BatteryBar.smali
    BatteryBar$1.smali
    BatteryBar$SettingsObserver.smali

    Step 3
    You need to Navigate to the res\layouts\ Folder
    open your statusbar.xml

    Step 4
    Underneath the line with

    Code:
    com.android.systemui.statusbar.DateView

    add this
    *** CHANGED ON v3 ***
    Code:
    <com.android.systemui.statusbar.BatteryBar android:textAppearance="@android:style/TextAppearance.StatusBar.Icon" android:gravity="center_vertical" android:orientation="horizontal" android:layout_width="wrap_content" [B][COLOR="Red"]android:layout_height="wrap_content"[/COLOR][/B] />


    it should be right at the bottom above the

    Code:

    i have added my statusbar.xml for reference if yours is in a different order no big deal just put it last and above this line
    Code:
    </com.android.systemui.statusbar.StatusBarView>


    Step 5
    Recompile the apk however you normaly would (there are so many ways i wont cover this here)
    then push it to your phone and reboot.

    If you don't know how or are having issues this is how I do it!

    Notes:
    a. i have a file on my desctop that i edit this is a copy of the file pulled from my phone.

    Steps:
    1. after all mods are done open up apk manager
    2. type 22 hit enter and pick the file you were editing ( SystemUI.apk )
    3. type 11 hit enter and the app will recompile.
    - 4. Open a copy of the SystemUI.apk ( see note a ) in winnra or 7zip ect put that window on one side of your screen ( windows 7 snap too (windows key + -> or <- ) is awesome for this )
    5. Navigate to the projects folder of APK Manager and then navigate to the app you edited (SystemUI.apk)
    6. Navigate to the /build/apk folder ( snap this to the other side of your screen ) ( Note that the build/apk folder has the same structure as the apk file open in winnra / 7zip )
    7. for THIS MOD only! you will need these files simply drag the 2 files listed below into the same folder location in the open apk in winnra / 7zip
    - /res/layouts/status_bar.xml
    - /classes.dex

    8. Push the apk that you draged the files into to your phone with adb like this

    adb push [where ever your apk is]/SystemUI.apk system/app/SystemUI.apk
    adb shell chmod 0644 system/app/SystemUI.apk

    9. whilst you have adb up reboot :)
    adb reboot
    + 4. Open a copy of the SystemUI.apk ( see note a ) in winnra or 7zip ect put that window on one side of your screen ( windows 7 snap too (windows key + -> or

    - 10. Proceed to next step
    -
    Step 6
    Once your status bar is back and running (you will have no battery bar yet)
    Simply install "BatteryBarSettings.apk" then open the app and pick your settings!

    Thats it ( I think )!

    all i ask is you don't modify the about section of the app if you choose to use it! and give credits where credits due. feel free to change my dodgy icon and if anyone has a better one ;) i will also put the sources for the settings app up on my git when i get git back up ( and when i tidy up and add comments ) and running in the next few days so that those of you running on source versions can cook it in from scratch. ( i don't think i need to explain how to do that if you are compiling sources i think you'll know what to do )
    Vissit My Git to have a Look


    with some help i can probably port this to older android versions (<2.3) as needed but i dont have access to a rom to test it on currently. so if you can help me there let me know :D

    Hope you found this helpfull! Let me know if this is not clear enough!

    Q&A
    Q: I am getting a FC on this or that, can you help me!
    A: NO. We can't help you. Because what you just said means nothing to us.
    We want to help you SO much, but in order to do that you need to report the bug properly.
    We took care of that too, see here:
    http://xdaforums.com/showthread.php?t=1292625

    Q:OMG YOU STOLE MY WORK! YOU A!@#$!% etc etc etc
    A: I kindly ask you that if you have an issue with anything above to PM me so i can sort it out politely. There is no need to flame in the thread.

    Pvy


    Credits
    Color Picker
    http://xdaforums.com/showthread.php?p=10739805#post10739805
    Thanks to Devmil

    19
    [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:
    Code:
    .locals 12
    .parameter "intent"
    
    .prologue

    add this!

    Code:
    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.

    If you don't know how or are having issues this is how I do it!

    Notes:
    a. i have a file on my desctop that i edit this is a copy of the file pulled from my phone.

    Steps:
    1. after all mods are done open up apk manager
    2. type 22 hit enter and pick the file you were editing ( SystemUI.apk )
    3. type 11 hit enter and the app will recompile.
    4. Open a copy of the SystemUI.apk ( see note a ) in winnra or 7zip ect put that window on one side of your screen ( windows 7 snap too (windows key + -> or <- ) is awesome for this )
    5. Navigate to the projects folder of APK Manager and then navigate to the app you edited (SystemUI.apk)
    6. Navigate to the /build/apk folder ( snap this to the other side of your screen ) ( Note that the build/apk folder has the same structure as the apk file open in winnra / 7zip )
    7. for THIS MOD only! you will need these files simply drag the 2 files listed below into the same folder location in the open apk in winnra / 7zip
    - /classes.dex

    8. Push the apk that you draged the files into to your phone with adb like this

    adb push [where ever your apk is]/SystemUI.apk system/app/SystemUI.apk
    adb shell chmod 0644 system/app/SystemUI.apk

    9. whilst you have adb up reboot
    adb reboot
    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.
    5
    Howdy Guys

    I built My Battery Bar into an app.

    grab it on the market. has all the same features without the need to mod it into system. am going to update the OP now :D

    https://market.android.com/details?id=com.pvy.batterybar

    Pvy.
    4
    Updated to V1.4

    Howdy All!

    Updated the "App Version" today with these changes!

    V1.4
    1. Fixed the height issues
    2. You can now set what ever height you like
    3. Fixed the issue with the bar not moving when the alignment is set
    4. removed the notification sound
    5. small code rewrite in the service

    Grab it in the OP or on the market :D

    Pvy.
    3
    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

    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.