LightBlog

dimanche 2 mai 2021

How to customize Android’s built-in battery saver mode

Android has had a built-in Battery Saver mode for years now. If your phone is about to run out of battery, then you can activate it to keep the device running for a few extra hours. Battery Saver disables quite a few power-hungry features and tweaks a bunch of settings to extend the battery life. While it’s quite useful as is for most people, some people may want to tweak it so it doesn’t turn certain settings off or make it even more aggressive at saving battery. If that describes you, then here’s a tutorial on how to customize Android’s battery saver mode.

Before we begin, we need to explain what Battery Saver mode actually does. According to a Google support page, here’s what Battery Saver limits on a Pixel phone:

What Battery Saver limits

  • Apps refresh their content, like email or news, only when you open the app.
  • Location services stop when your screen is off.
  • Apps don’t run in the background, unless you turn off battery optimization.
  • Your phone doesn’t listen for “Ok Google” and can’t continue a conversation. Instead, each time, tap Google Assistant Assistant.
  • Dark Theme turns on.
  • Your notifications may be delayed.
  • “Always show time and info” turns off.
  • Pixel phones with Active Edge won’t respond to a squeeze.
  • On Pixel 3, Pixel 4, and later Pixel phones, car crash detection turns off.
  • On Pixel 4 phones, Motion Sense turns off.
  • On Pixel 4 and later Pixel phones, smooth display turns off.
  • Pixel phones with 5G fall back to 4G service.

(Exclusive to Google’s Pixel 3 and later is an even more powerful Extreme Battery Saver Mode, but seeing as this is a Pixel-exclusive feature, we won’t be talking about it any further.)

The list shown above is actually incomplete: Battery Saver mode on Android phones actually does more than what Google says on the support page. In fact, Battery Saver also disables things like app launch boost, vibrations, and animations, and it also limits the maximum brightness of the panel. Since Android’s battery saver mode is open source and can be controlled through the command-line interface for the Settings tables, it’s possible to tweak battery saver mode to make it more or less aggressive in what it disables.

Customize Android’s Battery Saver Mode

Method 1 – ADB Shell

  1. Follow this guide to set up ADB on your PC or read this post to learn how to set up a local ADB shell.
  2. Once you have ADB up and running, open a command prompt or terminal window and run the following command in shell:
    settings put global battery_saver_constants "advertise_is_enabled=BOOLEAN,datasaver_disabled=BOOLEAN,enable_night_mode=BOOLEAN,launch_boost_disabled=BOOLEAN,vibration_disabled=BOOLEAN,animation_disabled=BOOLEAN,soundtrigger_disabled=BOOLEAN,fullbackup_deferred=BOOLEAN,keyvaluebackup_deferred=BOOLEAN,firewall_disabled=BOOLEAN,gps_mode=INTEGER,adjust_brightness_disabled=BOOLEAN,adjust_brightness_factor=FLOAT,force_all_apps_standby=BOOLEAN,force_background_check=BOOLEAN,optional_sensors_disabled=BOOLEAN,aod_disabled=BOOLEAN,quick_doze_enabled=BOOLEAN"

    where BOOLEAN is either true or false, INTEGER is a whole number, and FLOAT is a decimal number.

  3. If you want to know what the parameters under battery saver mode are currently set to, you can run the following ADB shell:
    dumpsys power | grep -A 128 "Battery saver policy"

    This will show you the current battery saver policy and all the parameter values. Alternatively, you can check the output of:

    settings get global battery_saver_constants

    …however, this won’t populate until after you’ve made changes to this Settings value at least once.

  4. If you want to revert battery saver mode back to its default parameters, then you can run either:
    settings delete global battery_saver_constants

    or

    settings put global battery_saver_constants "advertise_is_enabled=true,datasaver_disabled=true,enable_night_mode=true,launch_boost_disabled=true,vibration_disabled=true,animation_disabled=false,soundtrigger_disabled=true,fullbackup_deferred=true,keyvaluebackup_deferred=true,firewall_disabled=true,gps_mode=2,adjust_brightness_disabled=true,adjust_brightness_factor=0.5,force_all_apps_standby=true,force_background_check=true,optional_sensors_disabled=true,aod_disabled=true,quick_doze_enabled=true"

Since we last covered how to tweak Android’s built-in battery saver mode through the command line, a developer has come up with an app that provides a GUI to change each of these parameters. If you don’t want to manually run shell commands and/or look through AOSP to find out exactly what each parameter does, then read on.

Method 2 – Buoy app

XDA Recognized Developer tytydraco, the developer of the LADB app we covered the other day, is back with another app called Buoy. It’s described as an “extension to the built in Android Battery Saver”, and what it does is exposes Android’s hidden parameters to customize the behavior of the battery saver mode. The app lets you toggle the following:

  • Advertising to other apps that low power mode is enabled
  • Android’s data saver for metered WiFi or mobile data connections
  • The built-in dark mode
  • Launch boost to accelerate app starts
  • Vibration
  • Showing window and activity animations
  • Allowing apps to use the SoundTrigger HAL
  • Deferring full device backups for later
  • Deferring app setting backups for later
  • Using the built-in web firewall to protect against possibly malicious sites
  • Changing the location access mode restrictions for apps
  • Reducing the max brightness of the panel
  • Forcing all apps into standby mode
  • Forcing all apps to not check data in the background
  • Disabling unnecessary sensors
  • Using the Always-On-Display
  • Putting the device into deep sleep as soon as the screen turns off

It also lets you toggle “sticky” low power mode, a feature added in Android 9 Pie that lets battery saver mode automatically re-enable itself when the device is unplugged from power or rebooted.

Buoy app customize Android battery saver mode presets Buoy app customize Android battery saver mode settings Buoy app customize Android battery saver settings 2 Buoy app customize Android battery saver settings

In order to use Buoy, you’ll need an Android device running Android 8.0 Oreo or later, though the available parameters will differ depending on the Android version. Also, you’ll have to grant the app the WRITE_SECURE_SETTINGS permission or root access for it to change the value of Settings.Global.battery_saver_constants. Once again, I’ll refer you to our article on how to set up ADB or tytydraco’s LADB app so you can do that.

If you install the app and make any changes, be aware that the changes won’t automatically revert when you uninstall the app. You’ll have to either hit the “reset” button in Buoy or send one of the commands mentioned in step 4 from before in order to revert battery saver mode’s parameters back to default.

Buoy — Pimp Your Battery Saver ($0.99, Google Play) →

Buoy costs $0.99 on Google Play in the U.S., but it’s also open source so you can compile it yourself if you’re so inclined. Alternatively, you can just set the battery saver mode parameters manually as I previously mentioned. If you want to make things easier and support the developer, then you can buy the app from the Play Store. If you have any questions or feedback, check out the developer’s thread on the XDA forums linked below.

Buoy – XDA Forum Thread

The post How to customize Android’s built-in battery saver mode appeared first on xda-developers.



from xda-developers https://ift.tt/3xFLfY6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire