[Galaxy S6 General] asc1977:
How to show/hide stock battery (Choose between stock or 3Minit battery)

So i buided my first mod because users of my rom want to choose between stock battery or 3MinitBattery

First download 3MinitBattery apk here

Second download Smali files and MinitBatteryResources.apk here

Push MinitBatteryRessourches.apk and 3MinitBattery.apk into seperate folders in system/priv-app and reboot phone

decompile SystemUI.apk

push smalis to smali/com/android/systemui/statusbar/policy

open system_icons.xml with notepad++

find

<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/status_bar_battery_width" android:layout_height="@dimen/status_bar_battery_height" android:layout_marginBottom="@dimen/battery_margin_bottom" />

add below this line blue one

<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/status_bar_battery_width" android:layout_height="@dimen/status_bar_battery_height" android:layout_marginBottom="@dimen/battery_margin_bottom" />
[COLOR="Blue"]<com.android.systemui.statusbar.policy.MinitBattery android:layout_width="wrap_content" android:layout_height="wrap_content" />[/COLOR]

open smali/com/android/systemui/statusbar/phonePhoneStatusBar smali in notepad++

find and add in blue

invoke-virtual {v4, v5}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$BatteryTextObserver;->onChange(Z)V

move-object/from16 v0, p0

[COLOR="blue"]invoke-virtual {v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setStockBattery()V[/COLOR]

at end of smali add followed method and replace ID´s with yours

.method setStockBattery()V
.locals 7

iget-object v1, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;

invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v1

const-string v2, "StockBattery"

const/4 v3, 0x1

invoke-static {v1, v2, v3}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v1

if-nez v1, :cond_0

const v3, 0x8

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

const v6, 0x7f0e0334 [COLOR="Purple"]#<public type="id" name="battery" id="0x7f0e0334" />[/COLOR]

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

move-result-object v4

check-cast v4, Lcom/android/systemui/BatteryMeterView;

invoke-virtual {v4, v3}, Lcom/android/systemui/statusbar/SignalClusterView;->setVisibility(I)V

goto/16 :goto_0

:cond_0
const v3, 0x3

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

const v6, 0x7f0e0334 [COLOR="purple"]#<public type="id" name="battery" id="0x7f0e0334" />[/COLOR]

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

move-result-object v4

check-cast v4, Lcom/android/systemui/BatteryMeterView;

invoke-virtual {v4, v3}, Lcom/android/systemui/statusbar/SignalClusterView;->setVisibility(I)V

:goto_0
return-void
.end method

recompile and push to phone

for the switch in RomControlApk add followed lines in xml

<PreferenceCategory android:title="Stock Battery">
<SwitchPreference android:title="Stock Battery" android:key="StockBattery" android:summaryOn="show" android:summaryOff="hide" />
</PreferenceCategory>

this mod works with UI restart

if you want on the fly add followed to PhoneStatusBar$SettingsObserver.smali

find and add blue one

# virtual methods
.method observe()V
.locals 3

const/4 v2, 0x0

iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$SettingsObserver;->this$0:Lcom/android/systemui/statusbar/phone/PhoneStatusBar;

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

invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

[COLOR="blue"] const-string v1, "StockBattery"

invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

move-result-object v1

invoke-virtual {v0, v1, v2, p0}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V[/COLOR]

find and add blue one

.method public onChange(Z)V
.locals 1

iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$SettingsObserver;->this$0:Lcom/android/systemui/statusbar/phone/PhoneStatusBar;

invoke-virtual {v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setStockBattery()V

only problem on this guide is:

if you have 3MinitBattery on and StockBattery is of on lockscreen statusbar it shows both batterys. you can solve that problem if you hide system_icons layout on keyguard_status_bar.xml like here

open res/layout/keyguard_status_bar.xml

find

<FrameLayout android:layout_gravity="center_vertical" android:id="@id/system_icons_container" android:layout_width="wrap_content" android:layout_height="@dimen/status_bar_height">
<include layout="@layout/system_icons" />
</FrameLayout>

and change to blue one

<FrameLayout android:layout_gravity="center_vertical" android:id="@id/system_icons_container" [COLOR="blue"]android:layout_width="0.0dip" android:layout_height="0.0dip"[/COLOR]>
<include layout="@layout/system_icons" />
</FrameLayout>