More docs for LowPowerStandbyPolicy, rename FEATURE_WAKE_ON_LAN
Rename LOW_POWER_STANDBY_FEATURE_WAKE_ON_LAN to
FEATURE_WAKE_ON_LAN_IN_LOW_POWER_STANDBY and better document how it is
used in LowPowerStandbyPolicy.
Bug: 269254783
Test: m
Change-Id: I40c547e78c5f123eb6bcc9f365b46dcb994cae6b
diff --git a/core/api/current.txt b/core/api/current.txt
index 3eb543d..8891a43 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -33458,6 +33458,7 @@
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
@@ -33467,7 +33468,6 @@
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 1a634f5..7fdfba4 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -3048,7 +3048,7 @@
*
* @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 @@
@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 8a29f75..d3c0e35 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 @@
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 @@
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