Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,814,393 Members 53,443 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE]How to OG BatteryMod

Tip us?
 
sidharth.gtm
Old
(Last edited by sidharth.gtm; 2nd June 2014 at 05:51 PM.)
#1  
sidharth.gtm's Avatar
Senior Member - OP
Thanks Meter 328
Posts: 214
Join Date: May 2012
Location: Patna
Default [GUIDE]How to OG BatteryMod

Things you will need

1. Apktool 2.0
2. NotePad ++
3. Xposed Installed on Your Mobile

STEPS :
1. Decompile your SystemUI.apk

2. Open the file (\SystemUI\smali\com\android\systemui\statusbar\ph one\PhoneStatusBar.smali)

3. Find the Line(around at 36)
Code:
.field mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
Replace with
Code:
.field mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
Then find (around at 8511)
Code:
new-instance v0, Lcom/android/systemui/statusbar/policy/BatteryController;
Replace with
Code:
new-instance v0, Lcom/ghareeb/BatteryMod/BatteryController;
Then find
Code:
invoke-direct {v0, v2}, Lcom/android/systemui/statusbar/policy/BatteryController;-><init>(Landroid/content/Context;)V
Replace with
Code:
invoke-direct {v0, v2}, Lcom/ghareeb/BatteryMod/BatteryController;-><init>(Landroid/content/Context;)V
Then find
Code:
iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
Replace with
Code:
iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
4. Now add these lines below above line
Code:
iget-object v3, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;

iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

const v4, 0x7f07002d   #  public id of battery

invoke-virtual {v0, v4}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;

move-result-object v0

check-cast v0, Landroid/widget/ImageView;

invoke-virtual {v3, v0}, Lcom/ghareeb/BatteryMod/BatteryController;->addIconView(Landroid/widget/ImageView;)V
5.Find around line 9033
Code:
iget-object v3, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
replace with
Code:
iget-object v3, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
and around line 9553

Code:
iget-object v3, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
replace with
Code:
iget-object v3, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
Note : the concept here is to replace all
Code:
Lcom/android/systemui/statusbar/policy/BatteryController
with
Code:
Lcom/ghareeb/BatteryMod/BatteryController
6. extract and copy the attached smali.zip to /smali/com/

7.Open res/layout/msim_status_bar.xml or status_bar.xml
find
Code:
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="10.5dip" android:layout_height="16.0dip" android:layout_marginBottom="0.33000004dip" android:layout_marginStart="4.0dip" />
replace with
Code:
<ImageView android:id="@id/battery" android:paddingLeft="2.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />
NOTE: android:layout_height="wrap_content" renders big battery icon you can instead use android:layout_height="18.dip"

8. compile the SystemUI

9. Now download OG BatteryMod and put it in (system\app) folder.

ORIGINAL GUIDE ADAPTED FOR MOTO G

BUGS :
0% text always in Quick Setting Battery Icon

Temporary Fix :
Disable the Text by : editing quick_settings_title_battery.xml
Code:
<TextView android:gravity="top|center" android:layout_gravity="top|center" android:id="@id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" style="@style/TextAppearance.QuickSettings.TileView" />
to

Code:
<TextView android:gravity="top|center" android:layout_gravity="top|center" android:id="@id/text" android:layout_width="0.0dip" android:layout_height="0.0dip" style="@style/TextAppearance.QuickSettings.TileView" />
Attached Files
File Type: zip smali.zip - [Click for QR Code] (8.3 KB, 54 views)
I AM VERY BUSY THESE DAYS SO PLEASE DON'T PM ME TO PORT THINGS TO 4.4.4 ..


 
सारे जहाँ से अच्छा हिन्दोस्तान हमारा

Proud to be an Indian

MY DEVICE
XPERIA MINI ST15i - UNLOCKED CM11
XPERIA U - ROOTED LOCKED
DELL XCD 35
MOTO G
The Following 7 Users Say Thank You to sidharth.gtm For This Useful Post: [ Click to Expand ]
 
S0bes
Old
(Last edited by S0bes; 2nd June 2014 at 09:18 AM.)
#2  
S0bes's Avatar
Senior Member
Thanks Meter 268
Posts: 271
Join Date: Jan 2012
Location: Tomsk

 
DONATE TO ME
@sidharth.gtm
xt1032
com.android.systemui has stopped
That's what I see after applying modded SystemUI

I compared mine PhoneStatusBar.smali and your http://forum.xda-developers.com/show....php?t=2769177
They're the same.
I also changed msim_status_bar.xml and status_bar.xml (ImageView android:id="@id/battery") but it didn't help
___
Replaced BatteryController.smali still error :I
 
XT-107
Old
#3  
XT-107's Avatar
Member
Thanks Meter 16
Posts: 64
Join Date: Sep 2012
its not working if xposed framework isn't installed . systemui crashes .
The Following User Says Thank You to XT-107 For This Useful Post: [ Click to Expand ]
 
sidharth.gtm
Old
#4  
sidharth.gtm's Avatar
Senior Member - OP
Thanks Meter 328
Posts: 214
Join Date: May 2012
Location: Patna
Quote:
Originally Posted by XT-107 View Post
its not working if xposed framework isn't installed . systemui crashes .
Yes Xposed is needed .. i think Og battery mod hooks with Xposed.. i will myself logcat and find out.. watch this space
I AM VERY BUSY THESE DAYS SO PLEASE DON'T PM ME TO PORT THINGS TO 4.4.4 ..


 
सारे जहाँ से अच्छा हिन्दोस्तान हमारा

Proud to be an Indian

MY DEVICE
XPERIA MINI ST15i - UNLOCKED CM11
XPERIA U - ROOTED LOCKED
DELL XCD 35
MOTO G
The Following User Says Thank You to sidharth.gtm For This Useful Post: [ Click to Expand ]
 
S0bes
Old
(Last edited by S0bes; 2nd June 2014 at 01:46 PM.)
#5  
S0bes's Avatar
Senior Member
Thanks Meter 268
Posts: 271
Join Date: Jan 2012
Location: Tomsk

 
DONATE TO ME
Quote:
Originally Posted by XT-107 View Post
its not working if xposed framework isn't installed . systemui crashes .
when I tested it I had turned off all xposed modules.
Now I turned on gravitibox and it's working!
But I still have something strange. Battery icon is smaller than usual (twice size smaller) and battery tile shows 0 %.
____
I changed status_bar.xml and icon seems to be fine now. But still 0% battery tile.
<ImageView android:id="@id/battery" androidaddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />

@sidharth.gtm I think you should mention about status_bar.xml (msim_status_bar.xml) editing as well as gravitibox module is required
Anyway thank you for this guide
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2014-06-02-19-40-27[1].png
Views:	391
Size:	72.4 KB
ID:	2776468   Click image for larger version

Name:	Screenshot_2014-06-02-19-40-09[1].png
Views:	303
Size:	64.4 KB
ID:	2776469  
 
sidharth.gtm
Old
(Last edited by sidharth.gtm; 2nd June 2014 at 05:37 PM.)
#6  
sidharth.gtm's Avatar
Senior Member - OP
Thanks Meter 328
Posts: 214
Join Date: May 2012
Location: Patna
Quote:
Originally Posted by S0bes View Post
when I tested it I had turned off all xposed modules.
Now I turned on gravitibox and it's working!
But I still have something strange. Battery icon is smaller than usual (twice size smaller) and battery tile shows 0 %.
____
I changed status_bar.xml and icon seems to be fine now. But still 0% battery tile.
<ImageView android:id="@id/battery" androidaddingLeft="4.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" />

@sidharth.gtm I think you should mention about status_bar.xml (msim_status_bar.xml) editing as well as gravitibox module is required
Anyway thank you for this guide
Thanks for pointing out .. added in OP
for that 0% bug .. i don't have any fix right now
U can disable that by editing quick_settings_title_battery.xml
I AM VERY BUSY THESE DAYS SO PLEASE DON'T PM ME TO PORT THINGS TO 4.4.4 ..


 
सारे जहाँ से अच्छा हिन्दोस्तान हमारा

Proud to be an Indian

MY DEVICE
XPERIA MINI ST15i - UNLOCKED CM11
XPERIA U - ROOTED LOCKED
DELL XCD 35
MOTO G
 
coldflid
Old
#7  
Senior Member
Thanks Meter 784
Posts: 1,561
Join Date: Dec 2010

 
DONATE TO ME
Nice info, i tried to get it to work a few weeks back and wasn't able to, now i realised it was because of the xposed requirement
 
sidharth.gtm
Old
#8  
sidharth.gtm's Avatar
Senior Member - OP
Thanks Meter 328
Posts: 214
Join Date: May 2012
Location: Patna
Quote:
Originally Posted by S0bes View Post
@sidharth.gtm
xt1032
com.android.systemui has stopped
That's what I see after applying modded SystemUI

I compared mine PhoneStatusBar.smali and your http://forum.xda-developers.com/show....php?t=2769177
They're the same.
I also changed msim_status_bar.xml and status_bar.xml (ImageView android:id="@id/battery") but it didn't help
___
Replaced BatteryController.smali still error :I
share your logcat ..
because without logcat i can't help.
I AM VERY BUSY THESE DAYS SO PLEASE DON'T PM ME TO PORT THINGS TO 4.4.4 ..


 
सारे जहाँ से अच्छा हिन्दोस्तान हमारा

Proud to be an Indian

MY DEVICE
XPERIA MINI ST15i - UNLOCKED CM11
XPERIA U - ROOTED LOCKED
DELL XCD 35
MOTO G
 
yeshwanthvshenoy
Old
#9  
yeshwanthvshenoy's Avatar
Senior Member
Thanks Meter 570
Posts: 449
Join Date: Aug 2012
Location: Chennai
Quote:
Originally Posted by sidharth.gtm View Post
....
awesome guide bro just what i wanted!! thanks a lot hope u keep modding more things for xt1033!! keep it going!
Official facebook group for Moto G Devs : https://www.facebook.com/groups/motogdevshub/


 
 
XT-107
Old
#10  
XT-107's Avatar
Member
Thanks Meter 16
Posts: 64
Join Date: Sep 2012
not working on stock 4.4.3 ( even with xposed framework and gb installed ).
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA Xposed Tuesday: How to Shut Up Your Phone – XDA Developer TV

So many different applications want to send us notifications that … more

Add Some Power to First Generation Snapdragon CPUs

Some older devices still remain very popular. Phones like theHTC Desire, Sony Ericsson … more

Android M Mentions Spotted in Android Code Review

While we are still waiting for Android L to be officially released, the first mentions of … more

Create a Simple Custom Launcher from Scratch

When you are starting your journey intoany sort of development, it’s never easy at the … more