Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7a93b53 authored by Robert Horvath's avatar Robert Horvath
Browse files

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
parent 559266a7
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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_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_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_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 ACTION_POWER_SAVE_MODE_CHANGED = "android.os.action.POWER_SAVE_MODE_CHANGED";
    field @Deprecated public static final int FULL_WAKE_LOCK = 26; // 0x1a
    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_ALL_DISABLED_WHEN_SCREEN_OFF = 2; // 0x2
+0 −1
Original line number Original line Diff line number Diff line
@@ -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(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(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);
    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_DYNAMIC = 1; // 0x1
    field public static final int POWER_SAVE_MODE_TRIGGER_PERCENTAGE = 0; // 0x0
    field public static final int POWER_SAVE_MODE_TRIGGER_PERCENTAGE = 0; // 0x0
    field public static final String REBOOT_USERSPACE = "userspace";
    field public static final String REBOOT_USERSPACE = "userspace";
+4 −6
Original line number Original line Diff line number Diff line
@@ -2968,15 +2968,13 @@ public final class PowerManager {
            "android.os.action.LOW_POWER_STANDBY_ENABLED_CHANGED";
            "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.
     * This broadcast is only sent to registered receivers.
     *
     *
     * @see #getLowPowerStandbyPolicy
     * @see #isExemptFromLowPowerStandby()
     * @see #setLowPowerStandbyPolicy
     * @see #isAllowedInLowPowerStandby(int)
     * @hide
     * @see #isAllowedInLowPowerStandby(String)
     */
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_LOW_POWER_STANDBY)
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_LOW_POWER_STANDBY_POLICY_CHANGED =
    public static final String ACTION_LOW_POWER_STANDBY_POLICY_CHANGED =
            "android.os.action.LOW_POWER_STANDBY_POLICY_CHANGED";
            "android.os.action.LOW_POWER_STANDBY_POLICY_CHANGED";
+1 −3
Original line number Original line Diff line number Diff line
@@ -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.LOW_POWER_STANDBY_ALLOWED_REASON_TEMP_POWER_SAVE_ALLOWLIST;
import static android.os.PowerManager.lowPowerStandbyAllowedReasonsToString;
import static android.os.PowerManager.lowPowerStandbyAllowedReasonsToString;


import android.Manifest;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.AlarmManager;
import android.app.AlarmManager;
@@ -692,8 +691,7 @@ public class LowPowerStandbyController {
        final Intent intent = new Intent(
        final Intent intent = new Intent(
                PowerManager.ACTION_LOW_POWER_STANDBY_POLICY_CHANGED);
                PowerManager.ACTION_LOW_POWER_STANDBY_POLICY_CHANGED);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
        mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
        mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
                Manifest.permission.MANAGE_LOW_POWER_STANDBY);
    }
    }


    private void onStandbyTimeoutExpired() {
    private void onStandbyTimeoutExpired() {