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

Commit 247d83d5 authored by Fiona Campbell's avatar Fiona Campbell Committed by Android (Google) Code Review
Browse files

Merge "Introducing PARTIAL_SLEEP_WAKE_LOCK" into main

parents f81b1561 68a916bf
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -206,6 +206,16 @@ public final class PowerManager {
    public static final int SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK =
            OsProtoEnums.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK; // 0x00000100

    /**
     * Wake lock level: Keep the device asleep - for the user, but ensure that the CPU
     * remains awake.
     * This level supersedes all other wakelocks - others will be ignored if this is held,
     * and the device is asleep.
     * @hide
     */
    public static final int PARTIAL_SLEEP_WAKE_LOCK =
            OsProtoEnums.PARTIAL_SLEEP_WAKE_LOCK; // 0x00000200

    /**
     * Mask for the wake lock level component of a combined wake lock level and flags integer.
     *
@@ -1499,6 +1509,12 @@ public final class PowerManager {
            case DRAW_WAKE_LOCK:
            case SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK:
                break;
            case PARTIAL_SLEEP_WAKE_LOCK:
                if (com.android.server.power.feature.flags.Flags.partialSleepWakelocks()) {
                    break;
                }
                throw new IllegalArgumentException(
                        "Partial sleep wake lock flag not rolled out yet");
            default:
                throw new IllegalArgumentException("Must specify a valid wake lock level.");
        }
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public abstract class PowerManagerInternal {
            case PowerManager.DRAW_WAKE_LOCK -> "DRAW_WAKE_LOCK";
            case PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK ->
                    "SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK";
            case PowerManager.PARTIAL_SLEEP_WAKE_LOCK -> "PARTIAL_SLEEP_WAKE_LOCK";
            default -> "???";
        };
    }
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ message PowerManagerServiceDumpProto {
        optional bool is_stay_awake = 6;
        optional bool is_doze = 7;
        optional bool is_draw = 8;
        optional bool is_partial_sleep = 9;
    }
    message UserActivityProto {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+3 −0
Original line number Diff line number Diff line
@@ -504,6 +504,7 @@ public class Notifier {
    private int getBatteryStatsWakeLockMonitorType(int flags) {
        switch (flags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
            case PowerManager.PARTIAL_WAKE_LOCK:
            case PowerManager.PARTIAL_SLEEP_WAKE_LOCK:
                return BatteryStats.WAKE_TYPE_PARTIAL;

            case PowerManager.FULL_WAKE_LOCK:
@@ -546,6 +547,8 @@ public class Notifier {
                return PowerManager.PARTIAL_WAKE_LOCK;
            case PowerManager.PARTIAL_WAKE_LOCK:
                return PowerManager.PARTIAL_WAKE_LOCK;
            case PowerManager.PARTIAL_SLEEP_WAKE_LOCK:
                return PowerManager.PARTIAL_SLEEP_WAKE_LOCK;
            case PowerManager.DOZE_WAKE_LOCK:
                // Doze wake locks are an internal implementation detail of the
                // communication between dream manager service and power manager
+8 −0
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@ public final class PowerManagerService extends SystemService
    static final int WAKE_LOCK_DOZE = 1 << 6;
    static final int WAKE_LOCK_DRAW = 1 << 7;
    static final int WAKE_LOCK_SCREEN_TIMEOUT_OVERRIDE = 1 << 8;
    static final int WAKE_LOCK_PARTIAL_SLEEP = 1 << 9;

    // Summarizes the user activity state.
    static final int USER_ACTIVITY_SCREEN_BRIGHT = 1 << 0;
@@ -2098,6 +2099,8 @@ public final class PowerManagerService extends SystemService
                case PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK:
                    return mSystemReady && mFeatureFlags.isEarlyScreenTimeoutDetectorEnabled()
                            && mScreenTimeoutOverridePolicy != null;
                case PowerManager.PARTIAL_SLEEP_WAKE_LOCK:
                    return mFeatureFlags.isPartialSleepWakelocksFeatureEnabled();
                default:
                    return false;
            }
@@ -2975,6 +2978,8 @@ public final class PowerManagerService extends SystemService
                return WAKE_LOCK_DRAW;
            case PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK:
                return WAKE_LOCK_SCREEN_TIMEOUT_OVERRIDE;
            case PowerManager.PARTIAL_SLEEP_WAKE_LOCK:
                return WAKE_LOCK_PARTIAL_SLEEP;
        }
        return 0;
    }
@@ -5178,6 +5183,9 @@ public final class PowerManagerService extends SystemService
            proto.write(
                    PowerManagerServiceDumpProto.ActiveWakeLocksProto.IS_DRAW,
                    (mWakeLockSummary & WAKE_LOCK_DRAW) != 0);
            proto.write(
                    PowerManagerServiceDumpProto.ActiveWakeLocksProto.IS_PARTIAL_SLEEP,
                    (mWakeLockSummary & WAKE_LOCK_PARTIAL_SLEEP) != 0);
            proto.end(activeWakeLocksToken);

            proto.write(PowerManagerServiceDumpProto.NOTIFY_LONG_SCHEDULED_MS, mNotifyLongScheduled);
Loading