How to Customize the Battery Saver Trigger Percent or Enable it when the Screen is Off

How to Customize the Battery Saver Trigger Percent or Enable it when the Screen is Off

Enhancing the battery life of your device is one of the primary reasons why users flock to our forums. At XDA, you can find apps, kernels, ROMs, and guides on how improving your battery life. Rarely, though, will you find a battery life tip that works universally.

A feature that Google introduced in Android 5.0 Lollipop called “Battery Saver” is one example of a battery saving tool that works on almost any Android device. Battery Saver, when enabled, disables background data, location services, vibration, animations, and also reduces CPU performance where necessary. It’s a useful feature to take advantage of when you need to extend your battery life, but by default the service only activates when the battery level is 5, 10, or 15% or when activated manually.

What if you want to change the battery percent that triggers the Battery Saver feature? Or perhaps you want to automatically enable Battery Saver when the screen is off? Sure, you can use a Quick Settings toggle or shortcut to enable Battery Saver, but remembering to do that can be a hassle. In this tutorial, I’ll show you how you can modify Battery Saver’s trigger percentage or even automatically start the feature based on whatever criteria you want.


Custom Battery Saver

Like nearly every setting on Android, the property can be modified so long as you have the proper permission. The Battery Saver parameter is defined in the Settings.Global class, although you won’t find the documentation on that page as the feature is not guaranteed to be present on every device.

However, a cursory glance at AOSP or by listing all of the available settings on your device reveals that the Battery Saver parameter is defined under the “low_power” constant. It holds an integer value of either “0” or “1” for “off” and “on” respectively. The trigger level/percent value for Battery Saver is defined under the “low_power_trigger_level” constant, and this holds an integer value between 1 and 100. By modifying either of these two parameters, we can control Battery Saver ourselves.

Custom Battery Saver Trigger Level

First, we will set a manual battery saver trigger percent/level. There are two solutions to this, the first of which involves modifying the low_power_trigger_level constant itself to let the Android system handle enabling/disabling Battery Saver on its own. To do so, all you need to do is send a simple ADB command. If you already have ADB set up on your machine, then skip the next section. If not, then read on.

Setting up ADB

First, download the ADB binary straight from Google for your particular OS and extract it to a separate directory on your computer. Next, install the proper driver for your particular phone. Then, enable “USB Debugging” in Settings –> Developer Options. If you don’t see Developer Options, then you will need to enable it by going to Settings –> About Phone then tapping on Build number 7 times. Finally, ensure that ADB is working by starting a command prompt in the same directory as the ADB binary (right-click –> “open command prompt here”) and run the following command:

adb devices

If you see your device’s serial number (and it doesn’t say unauthorized), you’re golden. If you see a pop-up on your phone asking you to grant your computer ADB access, then say yes. If you don’t see either happen, then try rebooting your computer/phone and re-plugging it into your computer. Otherwise, try re-installing the driver.

Custom Trigger Level – ADB Method

Once ADB is set-up, it’s time to modify the setting. All you have to do is enter a single command as follows:

adb shell settings put global low_power_trigger_level TRIGGER_LEVEL

where TRIGGER_LEVEL is the battery level (between 1-100%) that you want Android to enable Battery Saver. Once set, be warned that this value automatically resets if you enter the Battery Saver menu in Settings (which you shouldn’t need to do since the only option there is what we’re changing anyways).

In the next section, I’ll show you how to use the popular automation app known as Tasker along with the AutoTools Beta plug-in to set a custom trigger level. The benefit of this method is that you will also be able to enable Battery Saver based on whatever condition you want, which we will discuss below.


Custom Trigger Level – Tasker Method

The screenshot above, if you are familiar with Tasker, shows you what we’re basically doing. On the left, there are two State Contexts, that when are met, Tasker will enable Battery Saver. When these two States are no longer met, then Tasker disables Battery Saver. The first State is the current battery level, and when it is between 1-25% this State becomes active. The second State is active when the phone is off the charger, to ensure that Battery Saver doesn’t activate when charging no matter what.

The two State Contexts above can be implemented without needing anything apart from Tasker, but in order for Tasker to control Battery Saver, we need to make use of the AutoTools plug-in. In particular, the AutoTools Secure Settings function. However, by default AutoTools does not have the proper permission necessary to control Battery Saver, so we need to grant it that permission first.

Granting Secure Settings Permission to AutoTools

Under Android’s permission management system, applications define the permissions they want to be granted in the Manifest file. Users can then grant or deny permissions on installation (pre-Marshmallow) or on demand (Marshmallow+). However, there are certain permissions that applications cannot be granted even if they request it in the Manifest, such as WRITE_SECURE_SETTINGS. This is because granting any application a permission as powerful as this would give that app a ton of control over your device.

But there is one workaround that we can use to grant the WRITE_SECURE_SETTINGS permission to any app we want. By using ADB’s package manager (pm) tool, we can grant almost any permission to any application we want (provided that application requests that permission in the Manifest file).

The first thing you’ll need to do is install the ADB binary onto your computer followed by the right driver for your device. Then, enable USB Debugging in Developer Options (go to Settings –> About Phone and tap on Build number 7 times if you haven’t already) and connect your phone to your computer. Finally, send the following command once you’ve opened up a terminal:

adb shell pm grant com.joaomgcd.autotools android.permission.WRITE_SECURE_SETTINGS

Now AutoTools will have the ability to change any Global, Secure, or System setting on your device. There are various ways you can play around with these settings, and the list of available settings in each category completely depends on your device and software build, but that discussion is for another time. In any case, we’ll move on show you how to use AutoTools to control the lock screen timeout.

Using AutoTools with Tasker to Control Battery Saver

Here’s a step-by-step guide now to have Tasker control Battery Saver at custom battery level/percentages, since we have all the prerequisites out of the way.

Fortunately, unlike with the ADB method, we don’t have to worry about entering any commands. The developer of AutoTools wrote the feature to trigger Battery Saver that sends the shell command wrapped up in a user friendly UI, so the app takes care of the command while all you have to do is pick an option in the app.

  1. Open up Tasker and press the + icon in the bottom right to create a new Profile. Name the profile “Battery Saver – Custom Level” and choose the State context.
  2. Go to Power –> Battery Level. Set the “from” slider to 1 and the “to” slider to the battery level you want Battery Saver to be triggered.
  3. Create a new Task attached to this Profile and name it “Enable Battery Saver.”
  4. Press the + button in the bottom middle to create a new Action. Go to Plugin –> AutoTools –> Secure Settings. Press the pencil button to enter AutoTools configuration.
  5. Choose the Battery Saver option and set it to “Enable.”
  6. Back at the main screen, long-press on the Battery Level State we made earlier so we can add an additional State Context to this Profile. Go to Power –> Power and for the Source pick “Any” and check “Invert.”
  7. Again, back at the main screen, long-press now on the “Enable Battery Saver” Task to add an “Exit” Task to this profile, which triggers when the battery level is > your threshold or when the device is on the charger. Name this Task “Disable Battery Saver.”
  8. For the Action, go to Plugin –> AutoTools –> Secure Settings once again. This time set the Battery Saver option to “Disable.”

Next, we’ll use Tasker to trigger Battery Saver whenever the phone goes to sleep/the display is off.


Enable Battery Saver on Display Off

I’m assuming that you granted AutoTools the necessary permission to access Secure Settings as mentioned above. If not, go back and do that. Once you’re ready, here’s a step-by-step instruction.

  1. Open up Tasker and press the + icon in the bottom right to create a new Profile. Name the profile “Battery Saver – Display Off” and choose the State context.
  2. Go to Power –> Display State. Set it the “off” option.
  3. For the Task, you can select the “Enable Battery Saver” Task you made before. If you didn’t follow those steps, then create a new Task named “Enable Battery Saver.”
    1. Press the + button in the bottom middle to create a new Action. Go to Plugin –> AutoTools –> Secure Settings. Press the pencil button to enter AutoTools configuration.
    2. Choose the Battery Saver option and set it to “Enable.”
  4. Back at the main screen, long-press on the Battery Level State we made earlier so we can add an additional State Context to this Profile. Go to Power –> Power and for the Source pick “Any” and check “Invert.”
  5. Again, back at the main screen, long-press now on the “Enable Battery Saver” Task to add an “Exit” Task to this profile, which triggers when the display turns on or when the device is on the charger. Add the Task “Disable Battery Saver” from before, or follow the next step to add it now.
    1. For the Action, go to Plugin –> AutoTools –> Secure Settings once again. This time set the Battery Saver option to “Disable.”

That’s it! Tasker should now automatically enable Battery Saver whenever the screen is off and the device is off the charger, and disable Battery Saver when the screen turns back on or the device is on the charger.


Try these tips out and let us know how they work for you, or give us your own suggestions on how to improve this trick!

Discuss This Story

You might also like