[HOW TO][MOD] Lower Brightness levels [04/05/12]

Search This thread

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
UPDATE 4:
If the current brightness is higher than 20/255, when inactive, the screen brighntess is set to 20 instead of 1.

I did not test it that much, if you note something strange, let me know.
 

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
I had already answered to that.

You can set 1/255 with this mod too, the difference is that you don't need and external app, no background services and you can set 1/255 directly from the statusbar (faster and more confortable in my opinion). Also, there are no brightness increases if you lock the screen with a brightness level < 10/255 and then unlock it (I think it's possible to avoid this with rootdim too if you use "lock brightness" option or something like that).

It's also useful if you lowered the autobrightness levels, because when the phone is inactive or your battery level is lower than 10, there are no brightness increases (if you current brightness is lower than 10/255).
 

cuaryos

Member
Aug 22, 2013
14
0
jowo, ID
confuse code lacation

i was trying apply code at i8160 jb 4.1.2 but too much same code found at there, it could bootloop or something when wrong line changed.
much better when know under script (e.g) "find const/16 v4, 0x14 under Lcom/android/server/PowerManagerService;bla bla bla..........."

just IMO:D
 

kithmal11

Senior Member
Jul 12, 2012
198
313
Colombo
i was trying apply code at i8160 jb 4.1.2 but too much same code found at there, it could bootloop or something when wrong line changed.
much better when know under script (e.g) "find const/16 v4, 0x14 under Lcom/android/server/PowerManagerService;bla bla bla..........."

just IMO:D

This MOD is for stock 2.3 ROMS mate. Wouldn't work for CM builds. :)

Regards
 

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
i was trying apply code at i8160 jb 4.1.2 but too much same code found at there, it could bootloop or something when wrong line changed.
much better when know under script (e.g) "find const/16 v4, 0x14 under Lcom/android/server/PowerManagerService;bla bla bla..........."

just IMO:D

This guide is for Gingerbread and most importantly, it's for the Galaxy SL and probably not for the latest official firmwares. JB is a lot different and if you are using a stock ROM, things are even more different.

Anyway, starting from JB I think, you can just change a integer value somewhere in some xml to allow lower brightness level, maybe "config_screenBrightnessDim". However, Samsung usually does some changes here and there, so it maybe doesn't work.

I can't help you more than this.
 

cuaryos

Member
Aug 22, 2013
14
0
jowo, ID
This guide is for Gingerbread and most importantly, it's for the Galaxy SL and probably not for the latest official firmwares. JB is a lot different and if you are using a stock ROM, things are even more different.

Anyway, starting from JB I think, you can just change a integer value somewhere in some xml to allow lower brightness level, maybe "config_screenBrightnessDim". However, Samsung usually does some changes here and there, so it maybe doesn't work.

I can't help you more than this.

This MOD is for stock 2.3 ROMS mate. Wouldn't work for CM builds. :)

Regards

sorry
my bad, still waiting another tweak works on jb rom .
 

MrinmoyJK

Member
Feb 7, 2013
47
3
Asus Zenfone Max Pro M2
4) Look for:
UPDATE 4: (if current brightness is higher than 20/255, use the default dim value):
Code:
.restart local [COLOR="Red"]v10[/COLOR]       #nominalCurrentValue:I
(aound line 5859) and remember the "red" part (aka the register. It could be something different). Now look for:
Code:
const/16 v5, 0x14

Thank you very much for this awesome tutorial. I am using android 2.3.5 and it worked on my phone except the above step. The screen become more bright after the timeout as you said.

There am confused about the ".restart local v10" line. There is ".restart local v8" at line 5865. But there is no "const/16 v5, 0x14" line. Please let me know, what should I do here.

PackageManagerService.smali
 

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
Thank you very much for this awesome tutorial. I am using android 2.3.5 and it worked on my phone except the above step. The screen become more bright after the timeout as you said.

There am confused about the ".restart local v10" line. There is ".restart local v8" at line 5865. But there is no "const/16 v5, 0x14" line. Please let me know, what should I do here.

PackageManagerService.smali

Since this guide was intended for the Galaxy SL, I didn't bother to make it "universal" and it could be really hard to follow when trying to use it for another device. Some differences are expected, especially the line numbers and the name of the registers.

Almost two years have passed since I wrote it, so I don't remember everything, but I think that in my tutorial "v10" is be the current brightness and it's compared with "v5", which is be the value at which the backlight is set when the device is in idle.
You have to figure out what's the name of the register with the current brightness (try look for "#nominalCurrentValue:I" in the code) and adjust the code.

Anyway, I'm quite sure that the file you posted has nothing to do with this mod.
 
  • Like
Reactions: MrinmoyJK

Top Liked Posts

  • There are no posts matching your filters.
  • 15
    Go to the end of the post for the flashable zips.

    ===================================

    By default the user can set as minimum brightness level 30 (over 255) from the settings, 20 sliding the finger on the status bar.

    Files changed:
    • /system/framework/services.jar
    • /system/app/Settings.apk
    • /system/app/SystemUI.apk (UPDATE 5. I completely forgot to add this in the guide)

    (I used KPU as reference)

    How to mod services.jar:
    You need java installed and smali.jar/baksmali.jar. There are probably tools that can help you or you can look for a better explanation on how to do it. (this tutorial is not about smali/baksmali).
    Here what I usually do:
    1) Extract classes.dex from it (jar files are simply zip files, use any file archiver to do that)
    2) Decompile classes.dex with this command (from cmd/shell etc):
    Code:
    java -jar baksmali.jar classes.dex -o classout
    This will create a directory (classout) with all the .smali files in it. Make all the changes you need to do.
    3) Recompile classes.dex with this command:
    Code:
    java -Xmx512M -jar smali.jar classout -o new-classes.dex
    This command will recreate the .dex file (named new-classes.dex).
    4) Rename new-classes.dex to classes.dex and put it back inside services.jar (overwrite the existing one).


    services.jar

    1) Decompile services.jar and open com/android/server/PowerManagerService.smali
    2) Look for:
    Code:
    const/16 v4, 0x14
    (line 10727). 0x14 is the hexadecimal of 20. This is the minimum brightness level achievable. You should use something greater than or equal to 1.
    Code:
    const/16 v4, [B]0x1[/B]

    If you want, you can test some values. You simply need to run:
    Code:
    echo 1 > /sys/class/backlight/omap_bl/brightness
    where 1 is the backlight value (1/255):

    3) Look for:
    Code:
    const/16 v2, 0x14
    (line 2189).
    If you don't change this value you'll be able to decrease your backlight below 20, but if you turn the screen off and then on, it is automatically set to this value. Use the same value above.
    Code:
    const/16 v2, [B]0x1[/B]

    UPDATE 1:
    When the phone is inactive, before the screen is switched off, the backlight value is automatically set to 20. The problem is that if you can go lower to that value, when inactive, instead of decreasing, the brightness increase. To avoid this
    4) Look for:
    UPDATE 4: (if current brightness is higher than 20/255, use the default dim value):
    Code:
    .restart local [COLOR="Red"]v10[/COLOR]       #nominalCurrentValue:I
    (aound line 5859) and remember the "red" part (aka the register. It could be something different). Now look for:
    Code:
    const/16 v5, 0x14
    and change it with
    Code:
        const/16 v5, 0x14
        if-lt [COLOR="Red"]v10[/COLOR],v5,:low_dim
    
        goto/16 :goto_a0
    
        :low_dim
        const/16 v5, 0x1
    (line 5964). Make sure the red part is like the one above.
    Pseudocode:
    Code:
    if your current brightness < 0x14 (20/255) => dim = 0x1 (1/255)
    if your current brightness > 0x14 (20/255) => dim = 0x14 (20/255)
    This value should be less than or equal to the values used above.

    UPDATE 3:
    When the battery is below 10, the brightness goes to the minimum value achievable. That could be a problem if you set a very low value, because everytime you turn off and then on the screen, you'll always need to increase the brightness, because the minimum value is good only in very dark places. To disable this feature:
    5) Look for (line 1494):
    Code:
    .method private batteryIsLow()Z
    Replace this: (UPDATE 3b)
    Code:
    .method private batteryIsLow()Z
        .registers 3
    
        .prologue
        .line 1812
        iget-boolean v0, p0, Lcom/android/server/PowerManagerService;->mIsPowered:Z

    with this:
    Code:
    .method private batteryIsLow()Z
        .registers 3
    
        .prologue
        .line 1812
        const/4 v0, 0x0
        return v0
    
        iget-boolean v0, p0, Lcom/android/server/PowerManagerService;->mIsPowered:Z

    Settings.apk

    1) Decompile Settings.apk and open smali/com/android/settings/BrightnessPreference.smali
    2) Look for 0x1e (3 occurences, lines: 318, 603 and 664) and change with 0x4 (the value used above)

    Code:
    line 318: const/16 v3, 0x1e
    line 664: add-int/lit8 v0, p2, 0x1e
    line 603: add-int/lit8 v3, v3, 0x1e

    Code:
    line 318: const/16 v3, [B]0x1[/B]
    line 664: add-int/lit8 v0, p2, [B]0x1[/B]
    line 603: add-int/lit8 v3, v3, [B]0x1[/B]

    3) open smali/com/android/settings/BrightnessPreference$BrightnessObserver.smali
    Look for 0x1e (line 98) and change it with 0x4
    Code:
    const/16 v3, 0x1e
    Code:
    const/16 v3, [B]0x1[/B]


    UPDATE 5:
    SystemUI.apk

    1) Decompile SystemUI.apk and open smali/com/android/systemui/statusbar/StatusBarService.smali
    2) Look for
    Code:
        .local v0, checkBrightNess:I
        const/16 v1, 0x1e
    (around line 404) and change it with
    Code:
        .local v0, checkBrightNess:I
        const/16 v1, 0x1
    This will let you achieve the minimum brightness level through the status bar.


    AUTO BRIGHTNESS
    If you want to change the auto brightness levels there's already a tutorial: Link
    Probably you'll find this helpful.
    Note that if you set a level below 20, if you don't mod services.jar when your phone is inactive, the brightness will go to 20.

    Are you looking for a "night pack"? Read here

    ===================================
    Flashable zips for DEODEXED only.
    Do a nandroid backup!

    SystemUI.apk is not included in these zips, sorry. You can't go below "30" from the status bar.
    UPDATE 4:
    If the current brightness is higher than 20/255, when inactive, the screen brighntess is set to 20 instead of 1.
    XXKPU

    If you don't like this mod, you can always restore the original files using these flashable zip:
    DDKP3 stock
    XXKPQ stock
    XXKPU stock
    or restore a nandroid backup of course.

    UPDATE 3:
    Brigthness won't change when battery goes below 10.
    DDKP3
    XXKPQ
    XXKPU

    UPDATE 2:
    This time I used as minimum level 1 instead of 4, as shown in the guide. Even if they are close, the difference is significant. In order to avoid brightness increases, the brighntess is set to 1 when inactive.
    DDKP3
    XXKPQ
    XXKPU

    UPDATE 1:
    This is for who downloaded the first version. It simply contains the stock framework.jar, because the change I made is not needed. This will not remove the mod. See the files below for that.
    XXKPU framework.jar
    2
    I made the flashable zips for XXKPQ and DDKP3. See the OP.
    This time I used as minimum level 1 instead of 4, as shown in the guide. Even if they are close, the difference is significant and to avoid brightness increases, the brightness is set to 1 when inactive.

    If you think it's too low, I could use again 4 as value or ignore the minimum value achievable and use a higher value for inactive status.
    1
    thanks a lot! I'll try this for shure. Is it going to work only on KPU? I have stock gingerbread. DDKP3.

    It's better to mod Settings.apk and services.jar again.
    Can some kind Soul make a CWM for KPQ & DK3 & post it? :thumbup: :beer:


    ☞★sent from drajax's Galaxy SL!!! *♂ツ Hit thanz if I helped! ;) :p

    I can do it when I have some spare time.
    1
    Clarification

    UPDATE:
    Backlight value when inactive:
    4) Look for:
    Code:
    const/16 v2, 0x14
    and change it with
    Code:
    const/16 v2, [B]0x4[/B]
    (line 5964).
    This value should be less than or equal to the values used above.

    I think line 5964 reads const/16 v5, 0x14 and not const/16 v2, 0x14 as stated.
    1
    Oh thanks, I forgot to change this.

    OP updated.