Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE]OGBattery Mod for KK

OP meawww

24th April 2014, 10:32 PM   |  #1  
meawww's Avatar
OP Senior Member
Flag Rome
Thanks Meter: 528
 
408 posts
Join Date:Joined: Dec 2013
Donate to Me
More
This is a guide how to add OG Battery Mod for kitkat 4.4 based on ND3 files,
Working with Galaxy S5 too tested by @SandeepEmekar

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

3: Search the line (Around line 102 stock ND3)
Code:
.field mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
Replace with
Code:
.field mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
4: Search the line (Around line 10689 stock ND3)
Code:
invoke-direct/range {v25 .. v26}, Lcom/android/systemui/statusbar/policy/BatteryController;-><init>(Landroid/content/Context;)V
Replace with
Code:
invoke-direct/range {v25 .. v26}, Lcom/ghareeb/BatteryMod/BatteryController;-><init>(Landroid/content/Context;)V
5: Search the line (Around line 10681 stock ND3)
Code:
.line 723
    new-instance v25, Lcom/android/systemui/statusbar/policy/BatteryController;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

    move-object/from16 v26, v0

    invoke-direct/range {v25 .. v26}, Lcom/android/systemui/statusbar/policy/BatteryController;-><init>(Landroid/content/Context;)V

    move-object/from16 v0, v25

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
Replace with
Code:
    .line 723
    new-instance v25, Lcom/ghareeb/BatteryMod/BatteryController;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

    move-object/from16 v26, v0

    invoke-direct/range {v25 .. v26}, Lcom/ghareeb/BatteryMod/BatteryController;-><init>(Landroid/content/Context;)V

    move-object/from16 v0, v25

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
FOR S5 USERS!!! Follow this red line to the end of other red line
______________________________________

Find the line
Code:
.line 827
    new-instance v29, Lcom/android/systemui/statusbar/policy/BatteryController;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

    move-object/from16 v30, v0

    invoke-direct/range {v29 .. v30}, Lcom/ghareeb/BatteryMod/BatteryController;-><init>(Landroid/content/Context;)V

    move-object/from16 v0, v29

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
Replace with
Code:
.line 827
    new-instance v29, Lcom/ghareeb/BatteryMod/BatteryController;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

    move-object/from16 v30, v0

    invoke-direct/range {v29 .. v30}, Lcom/ghareeb/BatteryMod/BatteryController;-><init>(Landroid/content/Context;)V

    move-object/from16 v0, v29

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;
______________________________________

6: Now right under the last line you just changed paste this whole code.
Code:
.line 724
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;

    move-object/from16 v27, v0

    move-object/from16 v0, p0

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

    move-object/from16 v26, v0

    const v28, 0x7f070078

    move-object/from16 v0, v26

    move/from16 v1, v28

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

    move-result-object v26

    check-cast v26, Landroid/widget/ImageView;

    move-object/from16 v0, v27

    move-object/from16 v1, v26

    invoke-virtual {v0, v1}, Lcom/ghareeb/BatteryMod/BatteryController;->addIconView(Landroid/widget/ImageView;)V

    .line 725
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/ghareeb/BatteryMod/BatteryController;

    move-object/from16 v26, v0

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

    move-object/from16 v27, v0

    invoke-virtual/range {v26 .. v27}, Lcom/ghareeb/BatteryMod/BatteryController;->addLabelView(Landroid/widget/TextView;)V
FOR S5 USERS!!! Follow this red line to the end of other red line
______________________________________

From the codes above Change the .line 724 to .line 828 and .line 725 to .line 829

______________________________________

7: In the code we just added above you will see the line const v28, 0x7f070078 now check the public.xml under the folder (\SystemUI\res\values\public.xml) and look for the line <public type="id" name="battery" id=" check if you have same number, In my case i have <public type="id" name="battery" id="0x7f070078" />. If you have different number then copy it from public.xml to the number in the smali.

8:Save the smali then go to the folder (\SystemUI\smali\com) download this file Attachment and extract to that folder.

9:Now open the file (\SystemUI\res\layout\status_bar.xml) look for the line
Code:
<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="12.0dip" android:layout_height="18.0dip" android:layout_marginBottom="0.33000004dip" android:layout_marginStart="5.0dip" />
Replace with
Code:
<ImageView android:gravity="center" android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingStart="3.0dip" />
10: Compile the SystemUI.apk using apk tool and sign it.

11: Now download this file OG BatteryMod and put it inside your phone (system\app) folder.

12:Now push the SystemUI.apk you just compiled inside (system\priv-app).

(Optional)
Add the BatteryMod in phone settings.
1: Decompile SecSettings.apk
2: Open the file (\SecSettings\res\xml\display_headers.xml)
Under the line
Code:
<header android:icon="@drawable/ic_settings_led" android:id="@id/led_indicator_settings" android:title="@string/led_indicator_settings" android:fragment="com.android.settings.LedIndicatorSettings" />
Add this codes
Code:
<header android:icon="@drawable/ic_settings_battery" android:title="@string/battery_mod" android:summary="@string/battery_mod_desc">
        <intent android:targetPackage="com.ghareeb.battery" android:action="android.intent.action.MAIN" android:targetClass="com.ghareeb.battery.Settings" />
</header>
3: Now go open the file (\SecSettings\res\values\string.xml) and add the line
Code:
<string name="battery_mod">OGBattery Mod</string>
<string name="battery_mod_desc">Change battery icon and charging animation.</string>
4: Compile , Sign and push to your (system\priv-app).

5: Enjoy!!!


Credit to the owner of the OGBatteryMod @OsamaGhareeb Thank him here http://forum.xda-developers.com/show...php?p=38905053


Edit: Step 5 was wrong so i fixed it sorry

PS: Working on S5
Attached Files
File Type: rar ghareeb.rar - [Click for QR Code] (7.6 KB, 720 views)
Last edited by meawww; 25th April 2014 at 04:06 PM.
The Following 24 Users Say Thank You to meawww For This Useful Post: [ View ]
25th April 2014, 01:55 PM   |  #2  
SandeepEmekar's Avatar
Senior Member
Thanks Meter: 157
 
612 posts
Join Date:Joined: Oct 2011
It works now!

Thank you very much!
Last edited by SandeepEmekar; 26th April 2014 at 11:01 AM. Reason: G900H
25th April 2014, 02:09 PM   |  #3  
ksr007's Avatar
Senior Member
Flag Hanoi
Thanks Meter: 4,693
 
1,533 posts
Join Date:Joined: Apr 2011
Donate to Me
Quote:
Originally Posted by SandeepEmekar

I can confirm that it doesn't work with Samsung Galaxy S5.

I have attached the original SystemUI.apk in case someone wants to look into it.

This guide is useful than for S5 : http://forum.xda-developers.com/show....php?t=2628560
The Following User Says Thank You to ksr007 For This Useful Post: [ View ]
25th April 2014, 02:13 PM   |  #4  
SandeepEmekar's Avatar
Senior Member
Thanks Meter: 157
 
612 posts
Join Date:Joined: Oct 2011
Quote:
Originally Posted by ksr007

This guide is useful than for S5 : http://forum.xda-developers.com/show....php?t=2628560

I tried that too but I messed up somewhere in the process as it don't have 0-100% battery.
25th April 2014, 02:15 PM   |  #5  
ksr007's Avatar
Senior Member
Flag Hanoi
Thanks Meter: 4,693
 
1,533 posts
Join Date:Joined: Apr 2011
Donate to Me
Quote:
Originally Posted by SandeepEmekar

I tried that too but I messed up somewhere in the process as it don't have 0-100% battery.

Some dev will coming to S5, so just wait and i think that they will do some mods for S5
25th April 2014, 02:16 PM   |  #6  
SandeepEmekar's Avatar
Senior Member
Thanks Meter: 157
 
612 posts
Join Date:Joined: Oct 2011
Quote:
Originally Posted by ksr007

Some dev will coming to S5, so just wait and i think that they will do some mods for S5

Yep,
I am trying to be patient
25th April 2014, 03:21 PM   |  #7  
saywhatt's Avatar
Recognized Contributor
Flag Land of Ooo
Thanks Meter: 1,539
 
2,876 posts
Join Date:Joined: Apr 2012
Donate to Me
More
Thank you for this guide kababayan @meawww

Sent from my SM-N9005 using XDA Premium 4 mobile app
The Following User Says Thank You to saywhatt For This Useful Post: [ View ]
25th April 2014, 03:43 PM   |  #8  
meawww's Avatar
OP Senior Member
Flag Rome
Thanks Meter: 528
 
408 posts
Join Date:Joined: Dec 2013
Donate to Me
More
Quote:
Originally Posted by saywhatt

Thank you for this guide kababayan @meawww

Sent from my SM-N9005 using XDA Premium 4 mobile app

Yw eehehehe OP Edited working with S5 now too
25th April 2014, 03:58 PM   |  #9  
AldrichDSaints's Avatar
Senior Member
Flag Binan City
Thanks Meter: 26
 
158 posts
Join Date:Joined: Oct 2013
More
Quote:
Originally Posted by saywhatt

Thank you for this guide kababayan @meawww

Sent from my SM-N9005 using XDA Premium 4 mobile app

You're a Filipino too?
25th April 2014, 04:01 PM   |  #10  
meawww's Avatar
OP Senior Member
Flag Rome
Thanks Meter: 528
 
408 posts
Join Date:Joined: Dec 2013
Donate to Me
More
Quote:
Originally Posted by AldrichDSaints

You're a Filipino too?

Half

Post Reply Subscribe to Thread

Tags
battery icon, batterymod, ogbattery
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes