• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[MOD][HOW-TO] Imaged Battery for 4.4.2 KitKat NA6/NA7/NB3

Search This thread

parkhyb

Member
Jan 28, 2014
17
61
This guide is not for a noob in editing.
Tried yourself, first you need to understand relation between public values in smali and xml.

Modified SystemUI for N9005XXUENA6/NA7/NB3 is at post #2 (Flashable)


As we already know, the battery signal of statusbar on Sammy KitKat Firmware is not images but coded one.
That is one of Google's operations in Android 4.4, but make difficulties with theming or customising.
So I modified it back to images to be possible for the methods that you have used on Android 4.3


This guide requires following things:
• APKtool
• Notepad++ (or AcroEdit, etc.)
• deodexed SystemUI.apk
• drawables.zip (attachment)
• smali.zip (attachment)


This guide is based on XXUENB3
All the public value is changable things depended on the kind of firmware build.
(Don't care about that if you're on XXUENB3)

Red text is to be removed
Blue text is to be added


1. Decompile SystemUI.apk using APKtool


2. Extract two folders in drawables.zip


3. Move and overwrite two folders(drawable, drawable-xxhdpi) to SystemUI\res\


4. Open SystemUI\res\layout\status_bar.xml in Notepad++

Find @id/battery
Code:
    <LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
        <include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
        <TextView android:textSize="@dimen/status_bar_battery_text_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" android:layout_marginStart="@dimen/status_bar_battery_text_marginStart" />
        [COLOR="Red"]<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" />[/COLOR]
    </LinearLayout>
  ...

change like this
Code:
    <LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
        <include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
        <TextView android:textSize="@dimen/status_bar_battery_text_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" android:layout_marginStart="@dimen/status_bar_battery_text_marginStart" />
        [COLOR="Blue"]<ImageView android:gravity="center" android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="1.0dip" android:layout_marginStart="2.0dip" />[/COLOR]
    </LinearLayout>
  ...


5. Open SystemUI\res\values\public.xml in Notepad++

Find quick_setting_button_divider_bg
Code:
    <public type="drawable" name="quick_setting_button_divider_bg" id="0x7f020281" />
    <public type="drawable" name="notification_panel_bg" id="0x7f0200a4" />
    <public type="drawable" name="tw_quick_panel_quick_setting_button_bg_normal" id="0x7f020228" />
  ...

add like this
Code:
    <public type="drawable" name="quick_setting_button_divider_bg" id="0x7f020281" />
[COLOR="blue"]    <public type="drawable" name="tw_stat_sys_battery" id="0x7f020283" />
    <public type="drawable" name="tw_stat_sys_battery_charge" id="0x7f020290" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge" id="0x7f02029a" />
    <public type="drawable" name="tw_stat_sys_battery_red" id="0x7f0202a4" />
    <public type="drawable" name="tw_stat_sys_battery_usb_not_charge" id="0x7f0202a5" />[/COLOR]
    <public type="drawable" name="notification_panel_bg" id="0x7f0200a4" />
    <public type="drawable" name="tw_quick_panel_quick_setting_button_bg_normal" id="0x7f020228" />
  ...


6. Extract BatteryController.smali in smali.zip


7. Move and overwrite BatteryController.smali to SystemUI\smali\com\android\systemui\statusbar\policy\
(All the public value in BatteryController.smali is matched with values in default public.xml or what we added to public.xml just before.)


8. Open SystemUI\smali\com\android\systemui\statusbar\policy\BatteryController$BatteryStateChangeCallback.smali in Notepad++
Code:
# virtual methods
[COLOR="Red"].method public abstract onBatteryLevelChanged(IZ)V[/COLOR]
.end method

change like this
Code:
# virtual methods
[COLOR="Blue"].method public abstract onBatteryLevelChanged(IZI)V[/COLOR]
.end method


9. Open SystemUI\smali\com\android\systemui\statusbar\phone\PhoneStatusBar.smali in Notepad++

Find Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController
Code:
    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

    .line 727
    new-instance v25, Lcom/android/systemui/statusbar/policy/SmartBondingController;

    move-object/from16 v0, p0
  ...

add like this
Code:
    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

[COLOR="blue"]    move-object/from16 v0, p0

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

    move-object/from16 v26, 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 v25, v0

    const v27, [B]0x7f070077[/B]

    move-object/from16 v0, v25

    move/from16 v1, v27

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

    move-result-object v25

    check-cast v25, Landroid/widget/ImageView;

    move-object/from16 v0, v26

    move-object/from16 v1, v25

    invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/policy/BatteryController;->addIconView(Landroid/widget/ImageView;)V[/COLOR]

    .line 727
    new-instance v25, Lcom/android/systemui/statusbar/policy/SmartBondingController;

    move-object/from16 v0, p0
  ...
0x7f070077 is a public id value of "battery"
<public type="id" name="battery" id="0x7f070077" />


Find iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText
Code:
    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

    .line 731
    move-object/from16 v0, p0

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

add like this
Code:
    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;

[COLOR="blue"]    move-object/from16 v0, p0

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

    move-object/from16 v25, v0

    move-object/from16 v0, p0

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

    move-object/from16 v26, v0

    invoke-virtual/range {v25 .. v26}, Lcom/android/systemui/statusbar/policy/BatteryController;->addLabelView(Landroid/widget/TextView;)V[/COLOR]

    .line 731
    move-object/from16 v0, p0

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


Editing's all done.
Recompile and put in your Note.

Now we have the battery of JB 4.3 ;)

This means you can change battery images,
and make all of 1% batteries as you want!
 

Attachments

  • drawables.zip
    24.7 KB · Views: 2,611
  • smali.zip
    2.8 KB · Views: 1,946
  • 20-05-23.png
    20-05-23.png
    21.4 KB · Views: 10,032
Last edited:

dr.ketan

Recognized Developer / Recognized Contributor
:confused:

Hello, sorry I'm a newbie but how to use the "Imaged Battery Mod for N9005XXUENA6" file after you install it?

thank you in advance
You have nothing to do, once you install your battery will be same like on 4.3 (if @parkhyb have attached mod is same mod as per said in guide). Basically this guide is more useful to ROM maker and Theme maker rather than end users except you just want to have same battery like on 4.3
You will get extra benefit that after imaged battery mod some Xposed module should work which not supporting battery mod on 4.4
 

tkari4

Senior Member
Jan 24, 2010
2,231
6,982
1% Battery for KitKat

I made for me the 1% step battery and I'll share it. :D

Animated charge included.

Battery under 5%: RED
Battery under 15%: YELLOW
Battery over 15%: GREEN

Battery.gif
Charge.gif


Attachment includes: Green 100% Icon for the left side; Green-Orange Data traffic arrows.

;)

Isn't flashable zip and can be used only with the mod in the OP.
 

Le [email protected]

Senior Member
May 12, 2012
119
101
Bayonne
www.le-chaland.fr
@ parkhyb

Thank you for the mod, work as expected here on stock 4.4.2.


@ tkari4

:good:

Just as info.

On 360 Dpi I must keep the margin.

without: android:layout_marginStart="5.0dip"

Screenshot_2014-01-29-21-11-48.jpg


With margin:
Screenshot_2014-01-29-22-02-49.jpg

Hi tkari4,

As i don't have a deodexed SystemUI.apk, can you share the version where you made the margin correction.
I was unable to decompile the SystemUI.apk in the flashable zip from the OP to edit it, got a lot of errors. :(

Thanks in advance.
 

tkari4

Senior Member
Jan 24, 2010
2,231
6,982
@ parkhyb

Thank you for the mod, work as expected here on stock 4.4.2.


@ tkari4



Hi tkari4,

As i don't have a deodexed SystemUI.apk, can you share the version where you made the margin correction.
I was unable to decompile the SystemUI.apk in the flashable zip from the OP to edit it, got a lot of errors. :(

Thanks in advance.

Of course..

But mine is modified.

I don't use tw_ in the resource names, so the battery can be changed with older Xposed modules.
But you can't change battery with 4.3 Xposed modul. (only 4.3 includes tw_ in the resource names)

;)
 

Attachments

  • SystemUI_N9005XXUENA7.rar
    2.1 MB · Views: 52
  • SystemUI_N9005XXUENA6.rar
    2.1 MB · Views: 28
Last edited:

parkhyb

Member
Jan 28, 2014
17
61
I didn't know that NA7 has been released
actually I don't have note3
Now I'm downloading the latest firmware and will update the mod and guide asap.
Including marginStart, revising marginBottom(I think 1.0dip is better.)

Personally I recommend tkari4's mod:thumbup:

Sent from my SHV-E300S using Tapatalk
 

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    This guide is not for a noob in editing.
    Tried yourself, first you need to understand relation between public values in smali and xml.

    Modified SystemUI for N9005XXUENA6/NA7/NB3 is at post #2 (Flashable)


    As we already know, the battery signal of statusbar on Sammy KitKat Firmware is not images but coded one.
    That is one of Google's operations in Android 4.4, but make difficulties with theming or customising.
    So I modified it back to images to be possible for the methods that you have used on Android 4.3


    This guide requires following things:
    • APKtool
    • Notepad++ (or AcroEdit, etc.)
    • deodexed SystemUI.apk
    • drawables.zip (attachment)
    • smali.zip (attachment)


    This guide is based on XXUENB3
    All the public value is changable things depended on the kind of firmware build.
    (Don't care about that if you're on XXUENB3)

    Red text is to be removed
    Blue text is to be added


    1. Decompile SystemUI.apk using APKtool


    2. Extract two folders in drawables.zip


    3. Move and overwrite two folders(drawable, drawable-xxhdpi) to SystemUI\res\


    4. Open SystemUI\res\layout\status_bar.xml in Notepad++

    Find @id/battery
    Code:
        <LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
            <include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
            <TextView android:textSize="@dimen/status_bar_battery_text_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" android:layout_marginStart="@dimen/status_bar_battery_text_marginStart" />
            [COLOR="Red"]<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" />[/COLOR]
        </LinearLayout>
      ...

    change like this
    Code:
        <LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/signal_battery_cluster" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="2.0dip">
            <include android:id="@id/signal_cluster" android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/signal_cluster_view" />
            <TextView android:textSize="@dimen/status_bar_battery_text_size" android:textColor="#ffffffff" android:layout_gravity="center" android:id="@id/battery_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/status_bar_network_name_separator" android:layout_marginStart="@dimen/status_bar_battery_text_marginStart" />
            [COLOR="Blue"]<ImageView android:gravity="center" android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="1.0dip" android:layout_marginStart="2.0dip" />[/COLOR]
        </LinearLayout>
      ...


    5. Open SystemUI\res\values\public.xml in Notepad++

    Find quick_setting_button_divider_bg
    Code:
        <public type="drawable" name="quick_setting_button_divider_bg" id="0x7f020281" />
        <public type="drawable" name="notification_panel_bg" id="0x7f0200a4" />
        <public type="drawable" name="tw_quick_panel_quick_setting_button_bg_normal" id="0x7f020228" />
      ...

    add like this
    Code:
        <public type="drawable" name="quick_setting_button_divider_bg" id="0x7f020281" />
    [COLOR="blue"]    <public type="drawable" name="tw_stat_sys_battery" id="0x7f020283" />
        <public type="drawable" name="tw_stat_sys_battery_charge" id="0x7f020290" />
        <public type="drawable" name="tw_stat_sys_battery_not_charge" id="0x7f02029a" />
        <public type="drawable" name="tw_stat_sys_battery_red" id="0x7f0202a4" />
        <public type="drawable" name="tw_stat_sys_battery_usb_not_charge" id="0x7f0202a5" />[/COLOR]
        <public type="drawable" name="notification_panel_bg" id="0x7f0200a4" />
        <public type="drawable" name="tw_quick_panel_quick_setting_button_bg_normal" id="0x7f020228" />
      ...


    6. Extract BatteryController.smali in smali.zip


    7. Move and overwrite BatteryController.smali to SystemUI\smali\com\android\systemui\statusbar\policy\
    (All the public value in BatteryController.smali is matched with values in default public.xml or what we added to public.xml just before.)


    8. Open SystemUI\smali\com\android\systemui\statusbar\policy\BatteryController$BatteryStateChangeCallback.smali in Notepad++
    Code:
    # virtual methods
    [COLOR="Red"].method public abstract onBatteryLevelChanged(IZ)V[/COLOR]
    .end method

    change like this
    Code:
    # virtual methods
    [COLOR="Blue"].method public abstract onBatteryLevelChanged(IZI)V[/COLOR]
    .end method


    9. Open SystemUI\smali\com\android\systemui\statusbar\phone\PhoneStatusBar.smali in Notepad++

    Find Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController
    Code:
        iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    
        .line 727
        new-instance v25, Lcom/android/systemui/statusbar/policy/SmartBondingController;
    
        move-object/from16 v0, p0
      ...

    add like this
    Code:
        iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    
    [COLOR="blue"]    move-object/from16 v0, p0
    
        iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    
        move-object/from16 v26, 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 v25, v0
    
        const v27, [B]0x7f070077[/B]
    
        move-object/from16 v0, v25
    
        move/from16 v1, v27
    
        invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->findViewById(I)Landroid/view/View;
    
        move-result-object v25
    
        check-cast v25, Landroid/widget/ImageView;
    
        move-object/from16 v0, v26
    
        move-object/from16 v1, v25
    
        invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/policy/BatteryController;->addIconView(Landroid/widget/ImageView;)V[/COLOR]
    
        .line 727
        new-instance v25, Lcom/android/systemui/statusbar/policy/SmartBondingController;
    
        move-object/from16 v0, p0
      ...
    0x7f070077 is a public id value of "battery"
    <public type="id" name="battery" id="0x7f070077" />


    Find iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText
    Code:
        iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;
    
        .line 731
        move-object/from16 v0, p0
    
        iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;
      ...

    add like this
    Code:
        iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;
    
    [COLOR="blue"]    move-object/from16 v0, p0
    
        iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;
    
        move-object/from16 v25, v0
    
        move-object/from16 v0, p0
    
        iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBatteryText:Landroid/widget/TextView;
    
        move-object/from16 v26, v0
    
        invoke-virtual/range {v25 .. v26}, Lcom/android/systemui/statusbar/policy/BatteryController;->addLabelView(Landroid/widget/TextView;)V[/COLOR]
    
        .line 731
        move-object/from16 v0, p0
    
        iget-object v0, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;
      ...


    Editing's all done.
    Recompile and put in your Note.

    Now we have the battery of JB 4.3 ;)

    This means you can change battery images,
    and make all of 1% batteries as you want!
    9
    Imaged Battery Mod for N9005XXUENA6/NA7/NB3

    (Updated 15-02-2014)
    5
    Thask for guider
    It good for me

    uploadfromtaptalk1391000313932.jpg

    Gửi từ SM-N900 của tôi bằng cách sử dụng Tapatalk
    4
    1% Battery for KitKat

    I made for me the 1% step battery and I'll share it. :D

    Animated charge included.

    Battery under 5%: RED
    Battery under 15%: YELLOW
    Battery over 15%: GREEN

    Battery.gif
    Charge.gif


    Attachment includes: Green 100% Icon for the left side; Green-Orange Data traffic arrows.

    ;)

    Isn't flashable zip and can be used only with the mod in the OP.
    3
    :confused:

    Hello, sorry I'm a newbie but how to use the "Imaged Battery Mod for N9005XXUENA6" file after you install it?

    thank you in advance
    You have nothing to do, once you install your battery will be same like on 4.3 (if @parkhyb have attached mod is same mod as per said in guide). Basically this guide is more useful to ROM maker and Theme maker rather than end users except you just want to have same battery like on 4.3
    You will get extra benefit that after imaged battery mod some Xposed module should work which not supporting battery mod on 4.4