diff options
author | 2023-02-20 12:44:47 +0000 | |
---|---|---|
committer | 2023-02-20 12:44:47 +0000 | |
commit | b62d832a2072feed18f812b50e56a28f2b75c2c7 (patch) | |
tree | 1db1960ed14f76e8bd69d042b674c83059478f1a | |
parent | cf16a02e27d2f0a89d95dcf17ad088fca6be2300 (diff) | |
parent | 7906bd93da30618e6b8c3bb8b90a0292bdc4b294 (diff) |
Merge "More docs for LowPowerStandbyPolicy, rename FEATURE_WAKE_ON_LAN" into udc-dev
-rw-r--r-- | core/api/current.txt | 2 | ||||
-rw-r--r-- | core/java/android/os/PowerManager.java | 19 | ||||
-rw-r--r-- | services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java | 10 |
3 files changed, 23 insertions, 8 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 170a98548a19..a7f69374ff00 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -33461,6 +33461,7 @@ package android.os { field public static final String ACTION_LOW_POWER_STANDBY_ENABLED_CHANGED = "android.os.action.LOW_POWER_STANDBY_ENABLED_CHANGED"; field public static final String ACTION_LOW_POWER_STANDBY_POLICY_CHANGED = "android.os.action.LOW_POWER_STANDBY_POLICY_CHANGED"; field public static final String ACTION_POWER_SAVE_MODE_CHANGED = "android.os.action.POWER_SAVE_MODE_CHANGED"; + field public static final String FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY = "com.android.lowpowerstandby.WAKE_ON_LAN"; field @Deprecated public static final int FULL_WAKE_LOCK = 26; // 0x1a field public static final int LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF = 2; // 0x2 field public static final int LOCATION_MODE_FOREGROUND_ONLY = 3; // 0x3 @@ -33470,7 +33471,6 @@ package android.os { field public static final int LOW_POWER_STANDBY_ALLOWED_REASON_ONGOING_CALL = 4; // 0x4 field public static final int LOW_POWER_STANDBY_ALLOWED_REASON_TEMP_POWER_SAVE_ALLOWLIST = 2; // 0x2 field public static final int LOW_POWER_STANDBY_ALLOWED_REASON_VOICE_INTERACTION = 1; // 0x1 - field public static final String LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN = "com.android.lowpowerstandby.WAKE_ON_LAN"; field public static final int ON_AFTER_RELEASE = 536870912; // 0x20000000 field public static final int PARTIAL_WAKE_LOCK = 1; // 0x1 field public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32; // 0x20 diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 1a634f5ee33e..7fdfba47986d 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -3048,7 +3048,7 @@ public final class PowerManager { * * @see #isAllowedInLowPowerStandby(String) */ - public static final String LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN = + public static final String FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY = "com.android.lowpowerstandby.WAKE_ON_LAN"; /** @@ -3130,10 +3130,25 @@ public final class PowerManager { @LowPowerStandbyAllowedReason private final int mAllowedReasons; - /** Features that are allowed to be used in Low Power Standby. */ + /** + * Features that are allowed to be used in Low Power Standby. + * + * @see #FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY + */ @NonNull private final Set<String> mAllowedFeatures; + /** + * Create a policy that defines the restrictions enforced by Low Power Standby. + * + * @param identifier Name of the policy, used for debugging & metrics. + * @param exemptPackages Packages that are exempt from Low Power Standby restrictions. + * @param allowedReasons Reasons that this policy allows apps to be automatically exempted + * from Low Power Standby restrictions for. + * @param allowedFeatures Features that are allowed to be used in Low Power Standby. + * Features are declared as strings, see + * {@link #FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY} as an example. + */ public LowPowerStandbyPolicy(@NonNull String identifier, @NonNull Set<String> exemptPackages, @LowPowerStandbyAllowedReason int allowedReasons, diff --git a/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java b/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java index 8a29f75994bd..d3c0e354838b 100644 --- a/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/power/LowPowerStandbyControllerTest.java @@ -16,10 +16,10 @@ package com.android.server.power; +import static android.os.PowerManager.FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY; import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_ONGOING_CALL; import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_TEMP_POWER_SAVE_ALLOWLIST; import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_VOICE_INTERACTION; -import static android.os.PowerManager.LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN; import static android.os.PowerManager.LowPowerStandbyPortDescription.MATCH_PORT_LOCAL; import static android.os.PowerManager.LowPowerStandbyPortDescription.PROTOCOL_TCP; import static android.os.PowerManager.LowPowerStandbyPortDescription.PROTOCOL_UDP; @@ -571,17 +571,17 @@ public class LowPowerStandbyControllerTest { mController.setEnabled(false); mTestLooper.dispatchAll(); - assertTrue(mController.isAllowed(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + assertTrue(mController.isAllowed(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); } @Test public void testSetAllowedFeatures_isAllowedWhenEnabled() throws Exception { mController.systemReady(); mController.setEnabled(true); - mController.setPolicy(policyWithAllowedFeatures(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + mController.setPolicy(policyWithAllowedFeatures(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); mTestLooper.dispatchAll(); - assertTrue(mController.isAllowed(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + assertTrue(mController.isAllowed(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); } @Test @@ -590,7 +590,7 @@ public class LowPowerStandbyControllerTest { mController.setEnabled(true); mTestLooper.dispatchAll(); - assertFalse(mController.isAllowed(LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN)); + assertFalse(mController.isAllowed(FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY)); } @Test |