2

I leave my phone (Samsung Galaxy 4 GT-I9506, Android 5.0.1 lollipop) charging on my table when going to sleep. It reaches full after some hours often. It is so annoying when the display becomes bright after battery reaching full, awakening me.

I know the thread How to prevent brightness from going to full when the battery low popup appears? about the prevention of bright display when the battery goes low. The rooted device seems to be the only choice to change the default behavior. I have unsuccessfully installed CyanogenMod in the device a few times. I am open about other ways to root this device and change its default behavior.

Settings > Display does not have any features by which you can alter the brightness mode. It would be great to customize the brightness in different modes, etc when the battery is low. In the link, the user did not want to consume extra battery with display when the battery was extremely low.

I installed Firelord proposed, Tasker, where I am working the automation. I probably need to root my phone for sufficient change.


How can you prevent brightness when battery reaches full in Android?

  • 1
    I can't say whether it would work but in Tasker, you can setup a profile to decrease the brightness the moment battery charges to full. Profile: Event -> Power -> Battery Full -> Highest. Action: Display -> Display Brightness. Use this in context of time so that this happens only when you sleep. This can be achieved using MacroDroid also. – Firelord Jan 4 '16 at 23:59
4

You may come close but cannot prevent that behavior unless there is a setting unbeknownst to you or the device is rooted. No matter what app you use, the brightness would be set to maximum whenever the battery level reaches 100% and in a matter of few milliseconds, it would revert to whatsoever you want it to be. My solution takes care of that problem. Originally posted here.

The file named max_brightness, a file under /sys, hence a part of Linux kernel and directly managed by it, appears to be the key to the solution. I found that setting the brightness limit in that file is one of the best ways to tackle the issue.

I noticed that once your custom maximum brightness is set, neither Android nor an app was able to set brightness beyond that custom level unless they changed the content of that file, which often an app has no reason to and none of them changed either. Besides, the file is owned by root and is part of group root, so any app or even system_server would require root privilege to make changes into that file.

Finding that file is bit tricky. In my MTK device with Android 4.2, that file appears to be under /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/.

In my Qualcomm device with Android 5.0.2 and above, the file appeared to be in /sys/devices/mdp.0/qcom,mdss_fb_primary.168/leds/lcd-backlight/.

I assume that the best way to find that file is to run a search query (setup for that), such as:

(Requires busybox)

adb shell su -c 'find /sys/ -type f -iname "max_brightness"'

In my Qualcomm device, the output it gives is:

/sys/devices/f9924000.i2c/i2c-2/2-0068/leds/red/max_brightness
/sys/devices/f9924000.i2c/i2c-2/2-0068/leds/blue/max_brightness
/sys/devices/f9924000.i2c/i2c-2/2-0068/leds/green/max_brightness
/sys/devices/mdp.0/qcom,mdss_fb_primary.168/leds/lcd-backlight/max_brightness
/sys/devices/qcom,camera-led-flash.81/leds/torch-light/max_brightness
/sys/devices/msm_sdcc.1/leds/mmc0::/max_brightness
/sys/devices/msm_sdcc.2/leds/mmc1::/max_brightness
/sys/devices/01-qcom,leds-d300/leds/led:flash_torch/max_brightness
/sys/devices/01-qcom,leds-d300/leds/led:flash_0/max_brightness
/sys/devices/01-qcom,leds-d300/leds/led:flash_1/max_brightness
/sys/devices/01-qcom,leds-e200/leds/kpdbl-lut-2/max_brightness
/sys/devices/01-qcom,leds-e200/leds/kpdbl-pwm-3/max_brightness
/sys/devices/01-qcom,leds-e200/leds/kpdbl-pwm-4/max_brightness
/sys/devices/01-qcom,leds-e200/leds/button-backlight/max_brightness

The location where lcd-backlight is mentioned was the only one that made sense to me and this is how I found the file in my device. Don't you worry asking about others. I attempted changing the brightness of the screen and looked for the changes in the file named brightness (also located under those said locations). None of them reflected the correct output other than the one at /sys/devices/mdp.0/qcom,mdss_fb_primary.168/leds/lcd-backlight.

Only for demonstration, try setting a limit in max_brightness

adb shell su -c 'echo LIMIT > PATH_TO_MAX_BRIGHTNESS'   # in my case PATH_TO_MAX_BRIGHTNESS is /sys/devices/mdp.0/qcom,mdss_fb_primary.168/leds/lcd-backlight/ and set LIMIT to a value less than 30 (not limited to). 

Now try maxing the brightness by using brightness slider or a third party app and you would notice that the brightness of your screen doesn't exceed beyond a certain point even when slider or the app's configuration appears to be at maximum. The brightness for that "certain point" would certainly be less than the default one you are used to.

Note that the maximum value in max_brightness is often found to be 255 and the brightness ranges from 0-255. Often, not always true, that is. And fear not from setting the limit to 0. It would cause the screen not to lit until you revert the changes or restart the device.

Find a limit which would not disturb you in your sleep.


Automation

For , use any automation app that can run a command with root privilege and when the context of your preferred trigger is met. I recommend a time based trigger.

Some working examples:

  • In Tasker, setup a profile with your preferred context, create a task and use the action: Code → Run Shell:

    • Command: echo LIMIT > PATH_TO_MAX_BRIGHTNESS
    • check Use Root
  • In MacroDroid, setup your preferred trigger and for action install Secure Settings, choose it → Actions → Run Command:

    • Command: echo LIMIT > PATH_TO_MAX_BRIGHTNESS
    • check Use Root
  • In Automate, as part of your flow, when setting up an action for your trigger, select Shell command superuser under Apps and do:

    • Command Line: echo LIMIT > PATH_TO_MAX_BRIGHTNESS


    Make sure to install all the permissions the flow require.

  • In DroidAutomation, setup your trigger and under task, select Root → Execute a command line and type: echo LIMIT > PATH_TO_MAX_BRIGHTNESS

As you would've guessed, you would have to setup two profiles for every app. One to setup a limit and the other to set the maximum brightness to the default you're used to.


I would like you to keep this under consideration (even though you got a hint at the beginning) that using a 100% battery trigger would defeat the purpose of this answer, which is to override the changes Android want to make. As an example, if you setup LIMIT to 0 whenever the battery reaches 100%, what would happen is your Android would lit the screen to maximum as usual and in few milliseconds (you read correctly) your automation app would run and set the limit. Your sleep may get interrupted in those milliseconds.

The workaround is to set up the battery level to 99 or less for full battery charge.

That said, I wouldn't be surprised if you avoid rooting considering that that the biggest compromise you would be making in using an answer with non-root approach is of not accounting those pesky but only milliseconds.

2

As suggested by @Firelord, you could try with tasker or use MacroDroid

Automation is the preferred option, or rather only option in this case. Many apps are available. I prefer using MacroDroid , since it is free (upto 5 macros) and easy to learn. To understand how MacroDroid works and the settings required for your Android version, see my answer

Note This is not tested on Lollipop as I am on KitKat but should work. Ensure appropriate settings for lollipop are made

Your macro would look like this

Trigger:

Battery Levelincreases to → (choose percentage preferred by you on sliding scale or 100 %)

Actions:

  • Brightness0 (Choose On sliding scale- doesn't require root)
  • Wait before next action → set to 10 seconds (recommended to separate previous and next actions ensuring both happen)
  • Dim ScreenDimmer On → 10% (Choose On sliding scale- doesn't require root, if the earlier action is not good enough for you - this is akin to "screen filter" apps like Darker)

Constraints:

Time of DayStart Time 2200 →End Time 0600 (assuming that's your sleep time)

  • Have you been able to test out please? – beeshyams Jan 6 '16 at 11:51
  • There is brightness for a few milliseconds when using this approach. Firelord's approach ensures no such brightness. – Léo Léopold Hertz 준영 Jan 6 '16 at 11:53
  • Actually, I am testing to find such a feature by CyanogenMod 12.1 by its default settings. It is much more customizable but I have not yet succeeded. I will let you know if I succeed. – Léo Léopold Hertz 준영 Jan 6 '16 at 12:04
  • I have posted anyway..May appeal to some – beeshyams Jan 6 '16 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.