diff options
| author | 2019-12-06 16:27:29 +0000 | |
|---|---|---|
| committer | 2019-12-06 16:27:29 +0000 | |
| commit | 1aba5d25afdcc00cfa30e8026bd652415e4c066d (patch) | |
| tree | 49746a633751237cdb311f8ae97cd95f5276f867 | |
| parent | 5bfa0bf08b657840ffbea1d3026e083a61a93d8d (diff) | |
| parent | 891e56d389dd6d7f37910c02ae44c90decc78c4a (diff) | |
Merge "Move add-to-whitelist APIs."
| -rw-r--r-- | apex/jobscheduler/framework/java/android/os/DeviceIdleManager.java | 18 | ||||
| -rw-r--r-- | apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java | 27 | ||||
| -rw-r--r-- | api/system-current.txt | 2 | ||||
| -rw-r--r-- | api/test-current.txt | 3 |
4 files changed, 31 insertions, 19 deletions
diff --git a/apex/jobscheduler/framework/java/android/os/DeviceIdleManager.java b/apex/jobscheduler/framework/java/android/os/DeviceIdleManager.java index 8019d4fdb870..4c443349ea58 100644 --- a/apex/jobscheduler/framework/java/android/os/DeviceIdleManager.java +++ b/apex/jobscheduler/framework/java/android/os/DeviceIdleManager.java @@ -17,13 +17,10 @@ package android.os; import android.annotation.NonNull; -import android.annotation.RequiresPermission; import android.annotation.SystemService; import android.annotation.TestApi; import android.content.Context; -import java.util.List; - /** * Access to the service that keeps track of device idleness and drives low power mode based on * that. @@ -75,21 +72,6 @@ public class DeviceIdleManager { } /** - * Add the specified packages to the power save whitelist. - * - * @return the number of packages that were successfully added to the whitelist - */ - @RequiresPermission(android.Manifest.permission.DEVICE_POWER) - public int addPowerSaveWhitelistApps(@NonNull List<String> packageNames) { - try { - return mService.addPowerSaveWhitelistApps(packageNames); - } catch (RemoteException e) { - e.rethrowFromSystemServer(); - return 0; - } - } - - /** * Return whether a given package is in the power-save whitelist or not. * @hide */ diff --git a/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java b/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java index 7a3ed92c1556..4ffcf8ab6076 100644 --- a/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java +++ b/apex/jobscheduler/framework/java/android/os/PowerWhitelistManager.java @@ -26,6 +26,8 @@ import android.content.Context; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Collections; +import java.util.List; /** * Interface to access and modify the power save whitelist. @@ -78,6 +80,31 @@ public class PowerWhitelistManager { } /** + * Add the specified package to the power save whitelist. + * + * @return true if the package was successfully added to the whitelist + */ + @RequiresPermission(android.Manifest.permission.DEVICE_POWER) + public boolean addToWhitelist(@NonNull String packageName) { + return addToWhitelist(Collections.singletonList(packageName)) == 1; + } + + /** + * Add the specified packages to the power save whitelist. + * + * @return the number of packages that were successfully added to the whitelist + */ + @RequiresPermission(android.Manifest.permission.DEVICE_POWER) + public int addToWhitelist(@NonNull List<String> packageNames) { + try { + return mService.addPowerSaveWhitelistApps(packageNames); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + return 0; + } + } + + /** * Add an app to the temporary whitelist for a short amount of time. * * @param packageName The package to add to the temp whitelist diff --git a/api/system-current.txt b/api/system-current.txt index fe9c0d1a7ff2..6df0c4da8088 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6379,6 +6379,8 @@ package android.os { } public class PowerWhitelistManager { + method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public boolean addToWhitelist(@NonNull String); + method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public int addToWhitelist(@NonNull java.util.List<java.lang.String>); method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public void whitelistAppTemporarily(@NonNull String, long); method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public long whitelistAppTemporarilyForEvent(@NonNull String, int, @NonNull String); field public static final int EVENT_MMS = 2; // 0x2 diff --git a/api/test-current.txt b/api/test-current.txt index 3ddbbf82d9d7..3ce8c5ead4cb 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1796,7 +1796,6 @@ package android.os { } public class DeviceIdleManager { - method @RequiresPermission("android.permission.DEVICE_POWER") public int addPowerSaveWhitelistApps(@NonNull java.util.List<java.lang.String>); method @NonNull public String[] getSystemPowerWhitelist(); method @NonNull public String[] getSystemPowerWhitelistExceptIdle(); } @@ -2045,6 +2044,8 @@ package android.os { } public class PowerWhitelistManager { + method @RequiresPermission("android.permission.DEVICE_POWER") public boolean addToWhitelist(@NonNull String); + method @RequiresPermission("android.permission.DEVICE_POWER") public int addToWhitelist(@NonNull java.util.List<java.lang.String>); method @RequiresPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") public void whitelistAppTemporarily(@NonNull String, long); method @RequiresPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") public long whitelistAppTemporarilyForEvent(@NonNull String, int, @NonNull String); field public static final int EVENT_MMS = 2; // 0x2 |