mercredi 29 janvier 2014

[MOD][HOW-TO]Imaged Battery for 4.4.2 KitKat topic




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 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 for 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 the following things:
APKtool
Notepad++ (or AcroEdit, etc.)
deodexed SystemUI.apk
drawables.zip (attachment)
smali.zip (attachment)


This guide is based on XXUENA6


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

All of the public values is changable values depended on the kind of firmware build
(Don't care about that if you're in XXUENA6)



1. Decompile SystemUI.apk using APKtool


2. Extract drawables.zip


3. Move and overwrite 2 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" />
        <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" />
    </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" />
        <ImageView android:gravity="center" android:id="@id/battery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="0.33dip" />
    </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" />
  ...



change like this


Code:


    <public type="drawable" name="quick_setting_button_divider_bg" id="0x7f020281" />
    <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" />

    <public type="drawable" name="notification_panel_bg" id="0x7f0200a4" />
    <public type="drawable" name="tw_quick_panel_quick_setting_button_bg_normal" id="0x7f020228" />
  ...




Find tw_stat_sys_signal_null


Code:


    <public type="drawable" name="tw_stat_sys_signal_null" id="0x7f02026b" />
    <public type="drawable" name="APKTOOL_DUMMY_0001" id="0x7f020001" />
    <public type="drawable" name="APKTOOL_DUMMY_0002" id="0x7f020002" />
  ...



change like this


Code:


    <public type="drawable" name="tw_stat_sys_signal_null" id="0x7f02026b" />
    <public type="drawable" name="tw_null_icon" id="0x7f020282" />
    <public type="drawable" name="tw_stat_sys_battery_10" id="0x7f020284" />
    <public type="drawable" name="tw_stat_sys_battery_100" id="0x7f020285" />
    <public type="drawable" name="tw_stat_sys_battery_10_red" id="0x7f020286" />
    <public type="drawable" name="tw_stat_sys_battery_20" id="0x7f020287" />
    <public type="drawable" name="tw_stat_sys_battery_20_red" id="0x7f020288" />
    <public type="drawable" name="tw_stat_sys_battery_34" id="0x7f020289" />
    <public type="drawable" name="tw_stat_sys_battery_4" id="0x7f02028a" />
    <public type="drawable" name="tw_stat_sys_battery_49" id="0x7f02028b" />
    <public type="drawable" name="tw_stat_sys_battery_4_red" id="0x7f02028c" />
    <public type="drawable" name="tw_stat_sys_battery_64" id="0x7f02028d" />
    <public type="drawable" name="tw_stat_sys_battery_79" id="0x7f02028e" />
    <public type="drawable" name="tw_stat_sys_battery_94" id="0x7f02028f" />
    <public type="drawable" name="tw_stat_sys_battery_charge_10" id="0x7f020291" />
    <public type="drawable" name="tw_stat_sys_battery_charge_100" id="0x7f020292" />
    <public type="drawable" name="tw_stat_sys_battery_charge_20" id="0x7f020293" />
    <public type="drawable" name="tw_stat_sys_battery_charge_34" id="0x7f020294" />
    <public type="drawable" name="tw_stat_sys_battery_charge_4" id="0x7f020295" />
    <public type="drawable" name="tw_stat_sys_battery_charge_49" id="0x7f020296" />
    <public type="drawable" name="tw_stat_sys_battery_charge_64" id="0x7f020297" />
    <public type="drawable" name="tw_stat_sys_battery_charge_79" id="0x7f020298" />
    <public type="drawable" name="tw_stat_sys_battery_charge_94" id="0x7f020299" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_10" id="0x7f02029b" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_100" id="0x7f02029c" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_20" id="0x7f02029d" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_34" id="0x7f02029e" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_4" id="0x7f02029f" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_49" id="0x7f0202a0" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_64" id="0x7f0202a1" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_79" id="0x7f0202a2" />
    <public type="drawable" name="tw_stat_sys_battery_not_charge_94" id="0x7f0202a3" />

    <public type="drawable" name="APKTOOL_DUMMY_0001" id="0x7f020001" />
    <public type="drawable" name="APKTOOL_DUMMY_0002" id="0x7f020002" />
  ...




6. Extract smali.zip


7. Move and overwrite BatteryController.smali to SystemUI\smali\com\android\systemui\statusbar\poli cy\
(All of the public values in BatteryController.smali is what we added to public.xml just before.)


8. Open SystemUI\smali\com\android\systemui\statusbar\poli cy\BatteryController$BatteryStateChangeCallback.smali in Notepad++



Code:


# virtual methods
.method public abstract onBatteryLevelChanged(IZ)V
.end method



change like this


Code:


# virtual methods
.method public abstract onBatteryLevelChanged(IZI)V
.end method




9. Open SystemUI\smali\com\android\systemui\statusbar\phon e\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 724
    new-instance v25, Lcom/android/systemui/statusbar/policy/SmartBondingController;

    move-object/from16 v0, p0
  ...



change like this


Code:


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

    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, 0x7f070077

    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


    .line 724
    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 728
    move-object/from16 v0, p0

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



change like this


Code:


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

    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


    .line 728
    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 percent batteries as you want!














Attached Files








File Type: zip drawables.zip -
[Click for QR Code]
(24.7 KB)
File Type: zip smali.zip -
[Click for QR Code]
(2.8 KB)









Aucun commentaire:

Enregistrer un commentaire