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
This commit is contained in:
Robert Horvath
2023-02-17 17:17:11 +01:00
parent 1553046709
commit 7906bd93da
3 changed files with 23 additions and 8 deletions

View File

@@ -33458,6 +33458,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
@@ -33467,7 +33468,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

View File

@@ -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,

View File

@@ -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