Enable vibration and location services while on battery saver


Question

I like using battery saver on my Android phone as it greatly extends the battery. However, there is one app that I use that I would like to exempt from two of the things that batter saver disables - vibration and location services.



I'm ok with the battery usage for these on this one app only but want to restrict all other apps from using the battery.



How can I accomplish this?


Answer

Vibration and GPS are considered as system services, not apps. Thus, it cannot be exempted on the usual setting when Battery Saver is enabled. However, since Android 8.0 Oreo, it is possible to tweak some settings for Battery Saver.



This is related to the BATTERY_SAVER_CONSTANTS global settings that can be modified through ADB.



/**
* Battery Saver specific settings
* This is encoded as a key=value list, separated by commas. Ex:
*
* "vibration_disabled=true,adjust_brightness_factor=0.5"
*
* The following keys are supported:
*
* <pre>
* 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 (int)
* 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)
* </pre>
* @hide
* @see com.android.server.power.batterysaver.BatterySaverPolicy
*/
@UnsupportedAppUsage
@TestApi
public static final String BATTERY_SAVER_CONSTANTS = "battery_saver_constants";


For the possible integer values of gps_mode:



/**
* Either the location providers shouldn't be affected by battery saver,
* or battery saver is off.
*/
public static final int LOCATION_MODE_NO_CHANGE = 0;

/**
* In this mode, the GPS based location provider should be disabled when battery saver is on and
* the device is non-interactive.
*/
public static final int LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF = 1;

/**
* All location providers should be disabled when battery saver is on and
* the device is non-interactive.
*/
public static final int LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF = 2;

/**
* In this mode, all the location providers will be kept available, but location fixes
* should only be provided to foreground apps.
*/
public static final int LOCATION_MODE_FOREGROUND_ONLY = 3;

/**
* In this mode, location will not be turned off, but LocationManager will throttle all
* requests to providers when the device is non-interactive.
*/
public static final int LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF = 4;


As stated on XDA Developers, How to Customize Battery Saver Mode in Android 8.0 Oreo:




  1. Install ADB and USB drivers if necessary.

  2. Connect the Android device to the PC with USB and wait until the device is detected

  3. Open a command prompt and type adb devices to make sure the ADB detects it.

  4. Type adb shell

  5. Decide which values wanted to be changed. Inputting multiple keys are supported with comma separation. For this specific question: vibration_disabled=false,gps_mode=0

  6. Type settings put global battery_saver_constants <new_value>. Note that the change is permanent, so to undo, the user needs to manually input the opposite values instead.



On rooted devices, it is also possible to run the settings command directly from the device using terminal apps like Termux.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes