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

Search This thread

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
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
 
Last edited:

sanjshetty

Member
Oct 5, 2011
27
2
Mangalore,India
By default the user can set as minimum brightness level 30 from the settings, 20 sliding the finger on the status bar.

Files changed:
  • /system/framework/services.jar
  • /system/framework/framework.jar
  • /system/app/Settings.apk

(I used KPU as reference)

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. I use this:
Code:
const/16 v4, [B]0x4[/B]
3) Look for 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]0x4[/B]


framework.jar

1) Decompile framework.jar and open android/os/Power.smali
2) Look for:
Code:
.field public static final BRIGHTNESS_DIM:I = 0x14
This is the brighntess level used when the phone is inactive. I suggest you to set a value lower or equal to the values used above, otherwise the backlight will increase instead of decreasing (I'm not sure of that, I didn't try an higher value).
Code:
.field public static final BRIGHTNESS_DIM:I = [B]0x4[/B]


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]0x4[/B]
line 664: add-int/lit8 v0, p2, [B]0x4[/B]
line 603: add-int/lit8 v3, v3, [B]0x4[/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]0x4[/B]

Here attached there's a CWM flashable zip. It's made for stock KPU.
ATTENTION: I didn't test it, do a nandroid backup!.

If you want to change the auto-brightness levels there's already a tutorial: http://xdaforums.com/showthread.php?t=1235212
Trying it now.
 

.Harshit

Senior Member
Oct 29, 2010
154
31
Thanks for working upon this.

But i would suggest one can use Screenfliter app from Market. Its more elegant solution
 

shriom_manerker

Senior Member
Mar 23, 2011
1,914
804
Margao,Goa
OnePlus 3
OnePlus 5T
Thanks for working upon this.

But i would suggest one can use Screenfliter app from Market. Its more elegant solution

ur screen filter app works only in SUPERAMOLED and AMOLED displays ! i had used it in the past and the screen just looks faded brown with the same brightness level ! with this tweak u can actually lower the real brightness leel ! i myself use this app called ROOTDIM its amazing lets u put shortcuts on the desktop with the brightness levels :) i kept night as 1 ! and its awesome !
 

ivAnash

Senior Member
Aug 15, 2011
465
79
Bangalore
OnePlus 3
OnePlus 3T
Thanks for working upon this.

But i would suggest one can use Screenfliter app from Market. Its more elegant solution

Screenfilter does not reduce the brightness of the screen, it actually creates another darker layer (or something like that) so the screen is running at the same brightness but u see another darker layer on top...

The Dev in this thread is directly reducing the screen brightness itself obviously resulting in better battery life...

Thanks loSconosciuto for working on this..
 
Last edited:

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
  • Like
Reactions: drajax

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
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.
 

ilcorsaronero

Senior Member
Dec 6, 2011
76
25
Mori
Last edited:
  • Like
Reactions: loSconosciuto

loSconosciuto

Senior Member
Nov 21, 2011
765
2,817
Another update. See the OP for the changes (in the guide there's a better explanation).

Confirmed to work on DDKP3. RootDim can achieve lower light level than this, this has got a good balance. Great.

Just wondering... is it possible to merge this fix and that one about phone not vibrating when fully charged? Like they did here for SGS2 http://xdaforums.com/showthread.php?t=1070506 and http://xdaforums.com/showpost.php?p=18900464&postcount=150? It would be the perfect "night pack" for i9003!!!

:)

Are you sure? I can set as minimum level 1 from the settings and sliding the finger on the statusbar (in this case is harder to set the brightness at 1). If you used the first version (the one made for KPU, not avaible anymore), you are allowed to set as minimum brightness 4 (I decided to do so).
Otherwise I think I did something wrong, I can't test all the flashable zips.

Regarding the notification:
I disabled it in a dirty way renaming
Code:
/system/media/audio/ui/TW_Battery_caution.ogg
to
Code:
/system/media/audio/ui/TW_Battery_caution.ogg.bak
You can do the same for Charger_Connection.ogg and TW_Low_Battery.ogg (the names are self explanatory).

Anyway I'll see the guide, thanks.
 
Last edited:

pancit

Senior Member
Oct 11, 2011
67
83
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:
Code:
.method private batteryIsLow()Z
(line 1494) few lines below this you have:
Code:
if-nez v0, :cond_10
(line 1501). Add before this line this:
Code:
goto :cond_10

You mean add this line:
goto :goto_1

And will you please add a date in the title of the post whenever you update the OP...

Thanks man
 
  • Like
Reactions: loSconosciuto

ivAnash

Senior Member
Aug 15, 2011
465
79
Bangalore
OnePlus 3
OnePlus 3T
I'm sorry if u consider this off topic..
There are 2 apps in the market ROOTDIM & SCREENDIM... Are these apps safe to use IN THE LONG RUN and which one's better .. The one using root or the one without...
 

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.