Update PowerExemptionManager APIs.
Expose #getAllowListedAppIds. Rename #removeFromAllowList to #removeFromPremanentAllowList. Make arguments for #addToTemporaryAllowList and its variant consistent. Fixes: 183052977 Test: m Change-Id: Ifa11c1a870fd0f426c6b8c953bc115a95eae0eba
This commit is contained in:
@@ -40,9 +40,9 @@ import java.util.List;
|
||||
/**
|
||||
* Interface to access and modify the permanent and temporary power save allow list. The two lists
|
||||
* are kept separately. Apps placed on the permanent allow list are only removed via an explicit
|
||||
* {@link #removeFromAllowList(String)} call. Apps allow-listed by default by the system cannot be
|
||||
* removed. Apps placed on the temporary allow list are removed from that allow list after a
|
||||
* predetermined amount of time.
|
||||
* {@link #removeFromPermanentAllowList(String)} call. Apps allow-listed by default by the system
|
||||
* cannot be removed. Apps placed on the temporary allow list are removed from that allow list after
|
||||
* a predetermined amount of time.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@@ -402,9 +402,9 @@ public class PowerExemptionManager {
|
||||
*
|
||||
* @param includingIdle Set to true if the app should be allow-listed from device idle as well
|
||||
* as other power save restrictions
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
|
||||
public int[] getAllowListedAppIds(boolean includingIdle) {
|
||||
try {
|
||||
if (includingIdle) {
|
||||
@@ -445,7 +445,7 @@ public class PowerExemptionManager {
|
||||
* @param packageName The app to remove from the allow list
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
|
||||
public void removeFromAllowList(@NonNull String packageName) {
|
||||
public void removeFromPermanentAllowList(@NonNull String packageName) {
|
||||
try {
|
||||
mService.removePowerSaveWhitelistApp(packageName);
|
||||
} catch (RemoteException e) {
|
||||
@@ -463,8 +463,8 @@ public class PowerExemptionManager {
|
||||
*/
|
||||
@UserHandleAware
|
||||
@RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
|
||||
public void addToTemporaryAllowList(@NonNull String packageName, long durationMs,
|
||||
@ReasonCode int reasonCode, @Nullable String reason) {
|
||||
public void addToTemporaryAllowList(@NonNull String packageName, @ReasonCode int reasonCode,
|
||||
@Nullable String reason, long durationMs) {
|
||||
try {
|
||||
mService.addPowerSaveTempWhitelistApp(packageName, durationMs, mContext.getUserId(),
|
||||
reasonCode, reason);
|
||||
@@ -488,7 +488,7 @@ public class PowerExemptionManager {
|
||||
@UserHandleAware
|
||||
@RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
|
||||
public long addToTemporaryAllowListForEvent(@NonNull String packageName,
|
||||
@AllowListEvent int event, @ReasonCode int reasonCode, @Nullable String reason) {
|
||||
@ReasonCode int reasonCode, @Nullable String reason, @AllowListEvent int event) {
|
||||
try {
|
||||
switch (event) {
|
||||
case EVENT_MMS:
|
||||
|
||||
@@ -439,12 +439,12 @@ public class PowerWhitelistManager {
|
||||
* whitelisted by default by the system cannot be removed.
|
||||
*
|
||||
* @param packageName The app to remove from the whitelist
|
||||
* @deprecated Use {@link PowerExemptionManager#removeFromAllowList(String)} instead
|
||||
* @deprecated Use {@link PowerExemptionManager#removeFromPermanentAllowList(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
|
||||
public void removeFromWhitelist(@NonNull String packageName) {
|
||||
mPowerExemptionManager.removeFromAllowList(packageName);
|
||||
mPowerExemptionManager.removeFromPermanentAllowList(packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,13 +455,13 @@ public class PowerWhitelistManager {
|
||||
* @param reasonCode one of {@link ReasonCode}, use {@link #REASON_UNKNOWN} if not sure.
|
||||
* @param reason a optional human readable reason string, could be null or empty string.
|
||||
* @deprecated Use {@link PowerExemptionManager#addToTemporaryAllowList(
|
||||
* String, long, int, String)} instead
|
||||
* String, int, String, long)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
|
||||
public void whitelistAppTemporarily(@NonNull String packageName, long durationMs,
|
||||
@ReasonCode int reasonCode, @Nullable String reason) {
|
||||
mPowerExemptionManager.addToTemporaryAllowList(packageName, durationMs, reasonCode, reason);
|
||||
mPowerExemptionManager.addToTemporaryAllowList(packageName, reasonCode, reason, durationMs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,13 +470,13 @@ public class PowerWhitelistManager {
|
||||
* @param packageName The package to add to the temp whitelist
|
||||
* @param durationMs How long to keep the app on the temp whitelist for (in milliseconds)
|
||||
* @deprecated Use {@link PowerExemptionManager#addToTemporaryAllowList(
|
||||
* String, long, int, String)} instead
|
||||
* String, int, String, long)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
|
||||
public void whitelistAppTemporarily(@NonNull String packageName, long durationMs) {
|
||||
mPowerExemptionManager.addToTemporaryAllowList(
|
||||
packageName, durationMs, REASON_UNKNOWN, packageName);
|
||||
packageName, REASON_UNKNOWN, packageName, durationMs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,14 +490,14 @@ public class PowerWhitelistManager {
|
||||
* used for logging purposes. Could be null or empty string.
|
||||
* @return The duration (in milliseconds) that the app is whitelisted for
|
||||
* @deprecated Use {@link PowerExemptionManager#addToTemporaryAllowListForEvent(
|
||||
* String, int, int, String)} instead
|
||||
* String, int, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
|
||||
public long whitelistAppTemporarilyForEvent(@NonNull String packageName,
|
||||
@WhitelistEvent int event, @Nullable String reason) {
|
||||
return mPowerExemptionManager.addToTemporaryAllowListForEvent(
|
||||
packageName, event, REASON_UNKNOWN, reason);
|
||||
packageName, REASON_UNKNOWN, reason, event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -512,14 +512,14 @@ public class PowerWhitelistManager {
|
||||
* used for logging purposes. Could be null or empty string.
|
||||
* @return The duration (in milliseconds) that the app is whitelisted for
|
||||
* @deprecated Use {@link PowerExemptionManager#addToTemporaryAllowListForEvent(
|
||||
* String, int, int, String)} instead
|
||||
* String, int, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
|
||||
public long whitelistAppTemporarilyForEvent(@NonNull String packageName,
|
||||
@WhitelistEvent int event, @ReasonCode int reasonCode, @Nullable String reason) {
|
||||
return mPowerExemptionManager.addToTemporaryAllowListForEvent(
|
||||
packageName, event, reasonCode, reason);
|
||||
packageName, reasonCode, reason, event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8254,9 +8254,10 @@ package android.os {
|
||||
public class PowerExemptionManager {
|
||||
method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public void addToPermanentAllowList(@NonNull String);
|
||||
method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public void addToPermanentAllowList(@NonNull java.util.List<java.lang.String>);
|
||||
method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public void addToTemporaryAllowList(@NonNull String, long, int, @Nullable String);
|
||||
method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public long addToTemporaryAllowListForEvent(@NonNull String, int, int, @Nullable String);
|
||||
method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public void removeFromAllowList(@NonNull String);
|
||||
method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public void addToTemporaryAllowList(@NonNull String, int, @Nullable String, long);
|
||||
method @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST) public long addToTemporaryAllowListForEvent(@NonNull String, int, @Nullable String, int);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public int[] getAllowListedAppIds(boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public void removeFromPermanentAllowList(@NonNull String);
|
||||
field public static final int EVENT_MMS = 2; // 0x2
|
||||
field public static final int EVENT_SMS = 1; // 0x1
|
||||
field public static final int EVENT_UNSPECIFIED = 0; // 0x0
|
||||
|
||||
@@ -563,8 +563,8 @@ public class MediaSessionService extends SystemService implements Monitor {
|
||||
final PowerExemptionManager powerExemptionManager = userContext.getSystemService(
|
||||
PowerExemptionManager.class);
|
||||
powerExemptionManager.addToTemporaryAllowList(targetPackage,
|
||||
FGS_STARTS_TEMP_ALLOWLIST_DURATION_MS,
|
||||
PowerExemptionManager.REASON_MEDIA_SESSION_CALLBACK, reason);
|
||||
PowerExemptionManager.REASON_MEDIA_SESSION_CALLBACK, reason,
|
||||
FGS_STARTS_TEMP_ALLOWLIST_DURATION_MS);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
|
||||
Reference in New Issue
Block a user