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

Commit 891ce789 authored by Robert Horvath's avatar Robert Horvath Committed by Automerger Merge Worker
Browse files

Merge "Don't poke user activity when dream ends" into tm-dev am: 3f31afd1

parents 77b39093 3f31afd1
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -566,7 +566,8 @@ public final class PowerManager {
            WAKE_REASON_HDMI,
            WAKE_REASON_DISPLAY_GROUP_ADDED,
            WAKE_REASON_DISPLAY_GROUP_TURNED_ON,
            WAKE_REASON_UNFOLD_DEVICE
            WAKE_REASON_UNFOLD_DEVICE,
            WAKE_REASON_DREAM_FINISHED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface WakeReason{}
@@ -672,6 +673,12 @@ public final class PowerManager {
     */
    public static final int WAKE_REASON_UNFOLD_DEVICE = 12;

    /**
     * Wake up reason code: Waking the device due to the dream finishing.
     * @hide
     */
    public static final int WAKE_REASON_DREAM_FINISHED = 13;

    /**
     * Convert the wake reason to a string for debugging purposes.
     * @hide
@@ -691,6 +698,7 @@ public final class PowerManager {
            case WAKE_REASON_DISPLAY_GROUP_ADDED: return "WAKE_REASON_DISPLAY_GROUP_ADDED";
            case WAKE_REASON_DISPLAY_GROUP_TURNED_ON: return "WAKE_REASON_DISPLAY_GROUP_TURNED_ON";
            case WAKE_REASON_UNFOLD_DEVICE: return "WAKE_REASON_UNFOLD_DEVICE";
            case WAKE_REASON_DREAM_FINISHED: return "WAKE_REASON_DREAM_FINISHED";
            default: return Integer.toString(wakeReason);
        }
    }
+6 −2
Original line number Diff line number Diff line
@@ -669,8 +669,12 @@ public final class PowerManagerService extends SystemService
                int reason, int uid, int opUid, String opPackageName, String details) {
            if (wakefulness == WAKEFULNESS_AWAKE) {
                // Kick user activity to prevent newly awake group from timing out instantly.
                // The dream may end without user activity if the dream app crashes / is updated,
                // don't poke the user activity timer for these wakes.
                int flags = reason == PowerManager.WAKE_REASON_DREAM_FINISHED
                        ? PowerManager.USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS : 0;
                userActivityNoUpdateLocked(mPowerGroups.get(groupId), eventTime,
                        PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, uid);
                        PowerManager.USER_ACTIVITY_EVENT_OTHER, flags, uid);
            }
            mDirty |= DIRTY_DISPLAY_GROUP_WAKEFULNESS;
            updateGlobalWakefulnessLocked(eventTime, reason, uid, opUid, opPackageName, details);
@@ -3275,7 +3279,7 @@ public final class PowerManagerService extends SystemService
                    }
                } else {
                    wakePowerGroupLocked(powerGroup, now,
                            PowerManager.WAKE_REASON_UNKNOWN,
                            PowerManager.WAKE_REASON_DREAM_FINISHED,
                            "android.server.power:DREAM_FINISHED", Process.SYSTEM_UID,
                            mContext.getOpPackageName(), Process.SYSTEM_UID);
                }
+21 −0
Original line number Diff line number Diff line
@@ -930,6 +930,27 @@ public class PowerManagerServiceTest {
                PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE);
    }

    @Test
    public void testInattentiveSleep_dreamEnds_goesToSleepAfterTimeout() {
        setMinimumScreenOffTimeoutConfig(5);
        setAttentiveTimeout(30000);
        createService();
        startSystem();

        advanceTime(10000);
        forceDream();
        advanceTime(10000);
        final String pkg = mContextSpy.getOpPackageName();
        mService.getBinderServiceInstance().wakeUp(mClock.now(),
                PowerManager.WAKE_REASON_DREAM_FINISHED, "PowerManagerServiceTest:DREAM_FINISHED",
                pkg);
        advanceTime(10001);

        assertThat(mService.getGlobalWakefulnessLocked()).isEqualTo(WAKEFULNESS_ASLEEP);
        assertThat(mService.getBinderServiceInstance().getLastSleepReason()).isEqualTo(
                PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE);
    }

    @Test
    public void testScreenOffTimeout_goesToSleepAfterTimeout() {
        final DisplayInfo info = new DisplayInfo();