Open POLICY_CHANGED broadcast up to public API

(Non-privileged) apps can query aspects of the Low Power Standby policy.
They should also be able to react to changes in the policy.

Bug: 234002812
Test: atest LowPowerStandbyTest
Change-Id: Id475e8799611444dda77b00c7a4eec103002cdc8
This commit is contained in:
Robert Horvath
2023-02-14 09:28:00 +01:00
parent 559266a74f
commit a7a93b5304
4 changed files with 6 additions and 10 deletions

View File

@@ -33305,6 +33305,7 @@ package android.os {
field public static final String ACTION_DEVICE_IDLE_MODE_CHANGED = "android.os.action.DEVICE_IDLE_MODE_CHANGED";
field public static final String ACTION_DEVICE_LIGHT_IDLE_MODE_CHANGED = "android.os.action.LIGHT_DEVICE_IDLE_MODE_CHANGED";
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 @Deprecated public static final int FULL_WAKE_LOCK = 26; // 0x1a
field public static final int LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF = 2; // 0x2

View File

@@ -10638,7 +10638,6 @@ package android.os {
method @RequiresPermission(anyOf={android.Manifest.permission.DEVICE_POWER, android.Manifest.permission.POWER_SAVER}) public boolean setPowerSaveModeEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE) public void suppressAmbientDisplay(@NonNull String, boolean);
method @RequiresPermission(anyOf={android.Manifest.permission.DEVICE_POWER, android.Manifest.permission.USER_ACTIVITY}) public void userActivity(long, int, int);
field @RequiresPermission(android.Manifest.permission.MANAGE_LOW_POWER_STANDBY) public static final String ACTION_LOW_POWER_STANDBY_POLICY_CHANGED = "android.os.action.LOW_POWER_STANDBY_POLICY_CHANGED";
field public static final int POWER_SAVE_MODE_TRIGGER_DYNAMIC = 1; // 0x1
field public static final int POWER_SAVE_MODE_TRIGGER_PERCENTAGE = 0; // 0x0
field public static final String REBOOT_USERSPACE = "userspace";

View File

@@ -2968,15 +2968,13 @@ public final class PowerManager {
"android.os.action.LOW_POWER_STANDBY_ENABLED_CHANGED";
/**
* Intent that is broadcast when Low Power Standby is enabled or disabled.
* Intent that is broadcast when Low Power Standby policy is changed.
* This broadcast is only sent to registered receivers.
*
* @see #getLowPowerStandbyPolicy
* @see #setLowPowerStandbyPolicy
* @hide
* @see #isExemptFromLowPowerStandby()
* @see #isAllowedInLowPowerStandby(int)
* @see #isAllowedInLowPowerStandby(String)
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.MANAGE_LOW_POWER_STANDBY)
@SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_LOW_POWER_STANDBY_POLICY_CHANGED =
"android.os.action.LOW_POWER_STANDBY_POLICY_CHANGED";

View File

@@ -19,7 +19,6 @@ package com.android.server.power;
import static android.os.PowerManager.LOW_POWER_STANDBY_ALLOWED_REASON_TEMP_POWER_SAVE_ALLOWLIST;
import static android.os.PowerManager.lowPowerStandbyAllowedReasonsToString;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AlarmManager;
@@ -692,8 +691,7 @@ public class LowPowerStandbyController {
final Intent intent = new Intent(
PowerManager.ACTION_LOW_POWER_STANDBY_POLICY_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
Manifest.permission.MANAGE_LOW_POWER_STANDBY);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
}
private void onStandbyTimeoutExpired() {