Add new POWER_SAVER permission & update api

This CL adds a new privileged permission called POWER_SAVER that
will allow whitelisted packages to toggle battery saver on the
device. This can be done via PowerManager, where the API for
setting battery saver has been updated to accept calls from apps
with either DEVICE_POWER or the POWER_SAVER permission.
Additionally, we whitelist Turbo for the permission.

Test: Framework builds, Turbo can toggle EBS
Bug: 115524274
Change-Id: I49d9747b2d42f792a2f3ba90a15aa23c47e489b3
This commit is contained in:
Salvador Martinez
2018-09-24 10:36:11 -07:00
parent 960165c0d7
commit a80bbab54c
6 changed files with 24 additions and 5 deletions

View File

@@ -1154,10 +1154,15 @@ public final class PowerManager {
*
* @return True if the set was allowed.
*
* @see #isPowerSaveMode()
*
* @hide
* @see #isPowerSaveMode()
*/
@SystemApi
@TestApi
@RequiresPermission(anyOf = {
android.Manifest.permission.DEVICE_POWER,
android.Manifest.permission.POWER_SAVER
})
public boolean setPowerSaveMode(boolean mode) {
try {
return mService.setPowerSaveMode(mode);