[TUT][MOD] Add A Brightness Bar To Stock 4.4.2 And 4.4.4!

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK

Are you running a stock 4.4.2 or 4.4.4 Xperia rom? Or even a rom based on stock like MoonWalker or Ultimate PureXZ?

Yes?

Would you like to add a brightness bar to your pull-down screen?

Yes?

Then read on and I'll tell you how to do it!

For this mod, you need to decompile your rom's SystemUI.apk. If you don't know how to do that, I suggest finding out before you go any further.
Have a look at Tickle My Android (tinyurl.com/ticklemyandroid) if you want to use one of the best decompiling tools on the planet..

Once you've decompiled SystemUI.apk, edit res\layout\somc_quick_settings_tab.xml..

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <com.sonymobile.systemui.statusbar.tools.LayoutAnimationView android:orientation="vertical" android:id="@id/quick_settings_tab" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layoutDirection="ltr">
        <GridLayout android:id="@id/tools_rows" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/notification_panel_tools_padding_top" android:animateLayoutChanges="true" />
        <View android:id="@id/divider" android:background="@android:drawable/divider_horizontal_dark" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
        <HorizontalScrollView android:scrollbarStyle="insideOverlay" android:id="@id/unused_tools_scroll_view" android:background="@drawable/somc_quick_settings_edit" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height">
            <GridLayout android:id="@id/unused_tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height" android:animateLayoutChanges="true" android:rowCount="1" />
        </HorizontalScrollView>
        <View android:id="@id/divider_bottom" android:background="@drawable/somc_statusbar_edit_close" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
    </com.sonymobile.systemui.statusbar.tools.LayoutAnimationView>
</FrameLayout>
Add this line above the GridLayout:

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <com.sonymobile.systemui.statusbar.tools.LayoutAnimationView android:orientation="vertical" android:id="@id/quick_settings_tab" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layoutDirection="ltr">
[COLOR="Red"][b]        <include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/ticklefish_brightness_dialog" />[/COLOR][/b]
	<GridLayout android:id="@id/tools_rows" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/notification_panel_tools_padding_top" android:animateLayoutChanges="true" />
        <View android:id="@id/divider" android:background="@android:drawable/divider_horizontal_dark" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
        <HorizontalScrollView android:scrollbarStyle="insideOverlay" android:id="@id/unused_tools_scroll_view" android:background="@drawable/somc_quick_settings_edit" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height">
            <GridLayout android:id="@id/unused_tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="@dimen/unused_tools_minimum_height" android:animateLayoutChanges="true" android:rowCount="1" />
        </HorizontalScrollView>
        <View android:id="@id/divider_bottom" android:background="@drawable/somc_statusbar_edit_close" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="1.0dip" />
    </com.sonymobile.systemui.statusbar.tools.LayoutAnimationView>
</FrameLayout>
This will now put a brightness bar above the grid with all the quick settings. However, it doesn't actually do anything. Yet...

Now edit smali\com\android\systemui\statusbar\phone\PhoneStatusBar.smali.

After the last .field line, insert the line in red..

Code:
.field private mUserSetupObserver:Landroid/database/ContentObserver;

[b][COLOR="Red"].field private mBrightnessController:Lcom/android/systemui/settings/BrightnessController;[/COLOR][/b]
Then, under # direct methods, insert this code..

Code:
[B][COLOR="Red"]# direct methods
.method private setUpBrightnessSlider()V
    .locals 4

    .prologue
    .line 196
    iget-object v2, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mNotificationPanel:Lcom/android/systemui/statusbar/phone/NotificationPanelView;

    const v0, [COLOR="DeepSkyBlue"]0x7f08004c[/COLOR]

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

    move-result-object v0

    check-cast v0, Landroid/widget/ImageView;

    const v1, [COLOR="SeaGreen"]0x7f08004d[/COLOR]

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

    move-result-object v1

    check-cast v1, Lcom/android/systemui/settings/ToggleSlider;

    new-instance v2, Lcom/android/systemui/settings/BrightnessController;
	
    iget-object v3, p0, Lcom/android/systemui/SystemUI;->mContext:Landroid/content/Context;
	
    invoke-direct {v2, v3, v0, v1}, Lcom/android/systemui/settings/BrightnessController;-><init>(Landroid/content/Context;Landroid/widget/ImageView;Lcom/android/systemui/settings/ToggleSlider;)V

    .line 199
    iput-object v2, p0, Lcom/android/systemui/settings/BrightnessDialog;->mBrightnessController:Lcom/android/systemui/settings/BrightnessController;
	
    .line 201
    return-void
.end method[/COLOR][/B]
Open up res\values\public.xml, look up the reference for brightness_icon and replace 0x7f08004c in the code above with it.

Then look up the reference for brightness_slider and replace 0x7f08004d with it in the code above.

Finally, find this code in your smali:

Code:
    const-string v0, "com.sonymobile.notes.NEW_SKETCH"

    invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->isAppInstalled(Ljava/lang/String;)Z

    move-result v0

    iput-boolean v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mRightVisible:Z
Directly underneath that code, put this line:

Code:
    const-string v0, "com.sonymobile.notes.NEW_SKETCH"

    invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->isAppInstalled(Ljava/lang/String;)Z

    move-result v0

    iput-boolean v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mRightVisible:Z

    [b][COLOR="Red"]invoke-direct {p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setUpBrightnessSlider()V[/COLOR][/b]
The last thing you need to do is extract the xml from the attached zip file and copy it into your SystemUI.apk\res\layout\ folder.

Save everything, recompile and flash back to your phone, wait for everything to load and...there's your brightness bar!

(Please note, this is meant for stock Xperia 4.4.2 and 4.4.4 roms only. If you have something else, this mod probably won't work for you. And please don't ask me to make it work.)

Credits for this mod entirely go to The Master, @serajr, for his help with the smali. Get well soon, my friend! :good:
 

Attachments

Last edited:

rer3

Senior Member
Aug 17, 2013
214
88
0
Bandung
You just need to edit 'quick_settings_brightness_dialog.xml'.. [emoji1]

--------------------------------
Sent via Tapatalk
---------------------------
It's gone, but whenever I touch brightness' quick setting tile, the systemui crashed.

EDIT:
solved, just create another "quick_settings_brightness_dialog.xml". one for the quick setting tile, and one for the statusbar's brightness slider.
 
Last edited:
  • Like
Reactions: Ticklefish

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
It's gone, but whenever I touch brightness' quick setting tile, the systemui crashed.

EDIT:
solved, just create another "quick_settings_brightness_dialog.xml". one for the quick setting tile, and one for the statusbar's brightness slider.
Hmm..I didn't know that. On my setup I used a different xml for the brightness bar as well. I didn't put that in the OP to keep it simple.
I'll have to update the OP with a separate xml file for those who like to mod it.

Many thanks for bringing it to my attention! ☺

--------------------------------
Sent via Tapatalk
---------------------------
 

rer3

Senior Member
Aug 17, 2013
214
88
0
Bandung
Hmm..I didn't know that. On my setup I used a different xml for the brightness bar as well. I didn't put that in the OP to keep it simple.
I'll have to update the OP with a separate xml file for those who like to mod it.

Many thanks for bringing it to my attention! ☺

--------------------------------
Sent via Tapatalk
---------------------------
No problem mate, I'm still searching for a way to make the slider thinner, to save some place.

Sent from my C6603 using XDA Free mobile app
 

liwenfei

Member
Sep 8, 2014
11
3
0
Ticklefish hello:
Thank you for everything you have done for a very, my phone is z1,4.4.4, attempts to modify SystemUI.apk file according to your approach leads to boot error, I uploaded my cell phone PhoneStatusBar.smali.
File, can you help me to check under it? I need this brightness slider, thank you!
 

Attachments

  • Like
Reactions: Ticklefish

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
Ticklefish hello:
Thank you for everything you have done for a very, my phone is z1,4.4.4, attempts to modify SystemUI.apk file according to your approach leads to boot error, I uploaded my cell phone PhoneStatusBar.smali.
File, can you help me to check under it? I need this brightness slider, thank you!
It would be very helpful if you can share your molded smali and a logcat if possible. That way I can see why your mod didn't work.
Otherwise I might just make the same changes and it'd take longer to fix.. :)

--------------------------------
Sent via Tapatalk
---------------------------
 

liwenfei

Member
Sep 8, 2014
11
3
0
It would be very helpful if you can share your molded smali and a logcat if possible. That way I can see why your mod didn't work.
Otherwise I might just make the same changes and it'd take longer to fix.. :)

--------------------------------
Sent via Tapatalk
---------------------------
Hello, this is my hand to modify the error in the SystemUI.apk file, can you help me to check?
 

Attachments

  • Like
Reactions: Ticklefish

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
Hello, this is my hand to modify the error in the SystemUI.apk file, can you help me to check?
I'm away from my computer today so I can't decompile anything. Especially without a framework-res.ask.
Can you please share your modded smali file and, if possible, a logcat?

--------------------------------
Sent via Tapatalk
---------------------------
 

liwenfei

Member
Sep 8, 2014
11
3
0
I'm away from my computer today so I can't decompile anything. Especially without a framework-res.ask.
Can you please share your modded smali file and, if possible, a logcat?

--------------------------------
Sent via Tapatalk
---------------------------
Hello, I would not use logcat, can not read the error code, here is what I use a software to extract log information, please look at the help is useful.


W/System.err( 3745): java.lang.NoSuchFieldError: com.android.systemui.statusbar.phone.PhoneStatusBar#mToolsMain
W/System.err( 3745): at de.robv.android.xposed.XposedHelpers.findField(XposedHelpers.java:80)
W/System.err( 3745): at de.robv.android.xposed.XposedHelpers.getObjectField(XposedHelpers.java:611)
W/System.err( 3745): at com.serajr.xperia.xposed.kk.hooks.systemui.SystemUI_QuickSettingsButtons$13.afterHookedMethod(SystemUI_QuickSettingsButtons.java:1034)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.makeStatusBarView(Native Method)
W/System.err( 3745): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3745): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 3745): at de.robv.android.xposed.XposedHelpers.callMethod(XposedHelpers.java:947)
W/System.err( 3745): at com.serajr.xperia.xposed.kk.hooks.systemui.SystemUI_FullScreenMode$13.replaceHookedMethod(SystemUI_FullScreenMode.java:516)
W/System.err( 3745): at de.robv.android.xposed.XC_MethodReplacement.beforeHookedMethod(XC_MethodReplacement.java:15)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:611)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.addStatusBarWindow(Native Method)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.createAndAddWindows(PhoneStatusBar.java:3057)
W/System.err( 3745): at com.android.systemui.statusbar.BaseStatusBar.start(BaseStatusBar.java:277)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
W/System.err( 3745): at com.android.systemui.statusbar.BaseStatusBar.start(Native Method)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.start(PhoneStatusBar.java:588)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.start(Native Method)
W/System.err( 3745): at com.android.systemui.statusbar.SystemBars.createStatusBarFromConfig(SystemBars.java:106)
W/System.err( 3745): at com.android.systemui.statusbar.SystemBars.onNoService(SystemBars.java:58)
W/System.err( 3745): at com.android.systemui.statusbar.ServiceMonitor.startService(ServiceMonitor.java:228)
W/System.err( 3745): at com.android.systemui.statusbar.ServiceMonitor.access$000(ServiceMonitor.java:49)
W/System.err( 3745): at com.android.systemui.statusbar.ServiceMonitor$1.handleMessage(ServiceMonitor.java:73)
W/System.err( 3745): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 3745): at android.os.Looper.loop(Looper.java:212)
W/System.err( 3745): at android.app.ActivityThread.main(ActivityThread.java:5135)
W/System.err( 3745): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3745): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 3745): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
W/System.err( 3745): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
W/System.err( 3745): at dalvik.system.NativeStart.main(Native Method)
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
Hello, I would not use logcat, can not read the error code, here is what I use a software to extract log information, please look at the help is useful.


W/System.err( 3745): java.lang.NoSuchFieldError: com.android.systemui.statusbar.phone.PhoneStatusBar#mToolsMain
W/System.err( 3745): at de.robv.android.xposed.XposedHelpers.findField(XposedHelpers.java:80)
W/System.err( 3745): at de.robv.android.xposed.XposedHelpers.getObjectField(XposedHelpers.java:611)
W/System.err( 3745): at com.serajr.xperia.xposed.kk.hooks.systemui.SystemUI_QuickSettingsButtons$13.afterHookedMethod(SystemUI_QuickSettingsButtons.java:1034)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.makeStatusBarView(Native Method)
W/System.err( 3745): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3745): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 3745): at de.robv.android.xposed.XposedHelpers.callMethod(XposedHelpers.java:947)
W/System.err( 3745): at com.serajr.xperia.xposed.kk.hooks.systemui.SystemUI_FullScreenMode$13.replaceHookedMethod(SystemUI_FullScreenMode.java:516)
W/System.err( 3745): at de.robv.android.xposed.XC_MethodReplacement.beforeHookedMethod(XC_MethodReplacement.java:15)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:611)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.addStatusBarWindow(Native Method)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.createAndAddWindows(PhoneStatusBar.java:3057)
W/System.err( 3745): at com.android.systemui.statusbar.BaseStatusBar.start(BaseStatusBar.java:277)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
W/System.err( 3745): at com.android.systemui.statusbar.BaseStatusBar.start(Native Method)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.start(PhoneStatusBar.java:588)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
W/System.err( 3745): at com.android.systemui.statusbar.phone.PhoneStatusBar.start(Native Method)
W/System.err( 3745): at com.android.systemui.statusbar.SystemBars.createStatusBarFromConfig(SystemBars.java:106)
W/System.err( 3745): at com.android.systemui.statusbar.SystemBars.onNoService(SystemBars.java:58)
W/System.err( 3745): at com.android.systemui.statusbar.ServiceMonitor.startService(ServiceMonitor.java:228)
W/System.err( 3745): at com.android.systemui.statusbar.ServiceMonitor.access$000(ServiceMonitor.java:49)
W/System.err( 3745): at com.android.systemui.statusbar.ServiceMonitor$1.handleMessage(ServiceMonitor.java:73)
W/System.err( 3745): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 3745): at android.os.Looper.loop(Looper.java:212)
W/System.err( 3745): at android.app.ActivityThread.main(ActivityThread.java:5135)
W/System.err( 3745): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3745): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 3745): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
W/System.err( 3745): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
W/System.err( 3745): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
W/System.err( 3745): at dalvik.system.NativeStart.main(Native Method)
Are you able to share your modded xml at all?

--------------------------------
Sent via Tapatalk
---------------------------
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
may I ask a question ?
Is it possible to add flashlight button to quicksetting ? If yes, could you made a tutorial about it ?
Yes...but I don't know how to do it just yet.

It's worth having a look at the SystemUI.apk ported from the Z3 by Niaboc. That comes with the flashlight toggle already.

--------------------------------
Sent via Tapatalk
---------------------------
 
  • Like
Reactions: rer3

liwenfei

Member
Sep 8, 2014
11
3
0
Are you able to share your modded xml at all?

--------------------------------
Sent via Tapatalk
---------------------------

modded somc_quick_settings_tab.xml


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quick_settings_tab" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/quick_settings_brightness_dialog" />
<LinearLayout android:eek:rientation="vertical" android:id="@id/tools_rows" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</FrameLayout>
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
modded somc_quick_settings_tab.xml


<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quick_settings_tab" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/quick_settings_brightness_dialog" />
<LinearLayout android:eek:rientation="vertical" android:id="@id/tools_rows" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</FrameLayout>
Damn...sorry about that. I meant to ask for your modded smali...:silly:
 

Ticklefish

Recognized Themer
Oct 27, 2011
6,741
8,526
263
Hampshire, UK
I follow your tutorial to modify smali files.
I've finally had a chance to look at this for you. You didn't mention that you'd already included your modded smali in your original post, that's why I kept asking for it.

I'll be honest, I can't see why your apk won't load. Your code looks fine to me.. :confused:

I know you don't like using logcat but it will give enough information to find out what's going on here.