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

Commit cfc84e2c authored by Louis Chang's avatar Louis Chang
Browse files

Wake up the device if activity can turn screen on

The device was waking up after app process attached when the device
has no lock screen set. In that case, extra unnecessary activity
lifecycle events (resume -> pause -> resume) was detected.

Bug: 388286686
Test: ActivityVisibilityTests
Flag: EXEMPT bugfix
Change-Id: Ic7135d1905821b9f3e59360dbfca00a18c708a80
parent 00b01090
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2538,7 +2538,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {

    void wakeUp(int displayId, String reason) {
        mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_APPLICATION,
                "android.server.am:TURN_ON:" + reason, displayId);
                "android.server.wm:TURN_ON:" + reason, displayId);
    }

    /** Starts a batch of visibility updates. */
+9 −3
Original line number Diff line number Diff line
@@ -5230,10 +5230,16 @@ class Task extends TaskFragment {
            // to ensure any necessary pause logic occurs. In the case where the Activity will be
            // shown regardless of the lock screen, the call to
            // {@link ActivityTaskSupervisor#checkReadyForSleepLocked} is skipped.
            if (shouldSleepActivities()) {
                final ActivityRecord next = topRunningActivity(true /* focusableOnly */);
            if (next == null || !next.canTurnScreenOn()) {
                if (next != null && next.canTurnScreenOn()
                        && !mWmService.mPowerManager.isInteractive()) {
                    mTaskSupervisor.wakeUp(getDisplayId(), "resumeTop-turnScreenOnFlag");
                    next.setCurrentLaunchCanTurnScreenOn(false);
                } else {
                    checkReadyForSleep();
                }
            }
        } finally {
            mInResumeTopActivity = false;
        }