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

Commit 72671fbb authored by Jeff Brown's avatar Jeff Brown
Browse files

Require DEVICE_POWER permission for DOZE_WAKE_LOCK.

This wake lock is only intended to be used internally.

Change-Id: I8d109c492605673616cf7f4f31f082a42fb1d912
parent a71f03c4
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -195,6 +195,8 @@ public final class PowerManager {
     * <p>
     * This is used by the dream manager to implement doze mode.  It currently
     * has no effect unless the power manager is in the dozing state.
     * </p><p>
     * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
     * </p>
     *
     * {@hide}
@@ -330,6 +332,12 @@ public final class PowerManager {
     */
    public static final int GO_TO_SLEEP_REASON_HDMI = 5;

    /**
     * Go to sleep flag: Skip dozing state and directly go to full sleep.
     * @hide
     */
    public static final int GO_TO_SLEEP_FLAG_NO_DOZE = 1 << 0;

    /**
     * The value to pass as the 'reason' argument to reboot() to
     * reboot into recovery mode (for applying system updates, doing
@@ -343,12 +351,6 @@ public final class PowerManager {
     */
    public static final String REBOOT_RECOVERY = "recovery";
    
    /**
     * Go to sleep flag: Skip dozing state and directly go to full sleep.
     * @hide
     */
    public static final int GO_TO_SLEEP_FLAG_NO_DOZE = 1 << 0;

    final Context mContext;
    final IPowerManager mService;
    final Handler mHandler;
+4 −0
Original line number Diff line number Diff line
@@ -2774,6 +2774,10 @@ public final class PowerManagerService extends com.android.server.SystemService
            PowerManager.validateWakeLockParameters(flags, tag);

            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WAKE_LOCK, null);
            if ((flags & PowerManager.DOZE_WAKE_LOCK) != 0) {
                mContext.enforceCallingOrSelfPermission(
                        android.Manifest.permission.DEVICE_POWER, null);
            }
            if (ws != null && ws.size() != 0) {
                mContext.enforceCallingOrSelfPermission(
                        android.Manifest.permission.UPDATE_DEVICE_STATS, null);