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:
- Install ADB and USB drivers if necessary.
- Connect the Android device to the PC with USB and wait until the device is detected
- Open a command prompt and type
adb devices
to make sure the ADB detects it.
- Type
adb shell
- 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
- 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.