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

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

Reducing unnecessary activity pause if activity can turn on screen

The activity lifecycle is RESUMED->PAUSED->RESUMED while starting
a turn-screen-on activity on a multiple display scenario because
the activity on the secondary display cannot be resumed while
the display is off and therefore put other tasks to sleep.

Bug: 298598671
Test: atest ActivityVisibilityTests
Change-Id: I98c9fce1aa4a4cdf58e15de40c2d4808d09fe976
parent a2d5f0eb
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4453,6 +4453,12 @@
      "group": "WM_DEBUG_BACK_PREVIEW",
      "at": "com\/android\/server\/wm\/BackNavigationController.java"
    },
    "1946983717": {
      "message": "Waiting for screen on due to %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/TaskFragment.java"
    },
    "1947239194": {
      "message": "Deferring rotation, still finishing previous rotation",
      "level": "VERBOSE",
+8 −4
Original line number Diff line number Diff line
@@ -926,10 +926,14 @@ class TaskFragment extends WindowContainer<WindowContainer> {
    boolean sleepIfPossible(boolean shuttingDown) {
        boolean shouldSleep = true;
        if (mResumedActivity != null) {
            if (!shuttingDown && mResumedActivity.canTurnScreenOn()) {
                ProtoLog.v(WM_DEBUG_STATES, "Waiting for screen on due to %s", mResumedActivity);
            } else {
                // Still have something resumed; can't sleep until it is paused.
                ProtoLog.v(WM_DEBUG_STATES, "Sleep needs to pause %s", mResumedActivity);
                startPausing(false /* userLeaving */, true /* uiSleeping */, null /* resuming */,
                        "sleep");
            }
            shouldSleep = false;
        } else if (mPausingActivity != null) {
            // Still waiting for something to pause; can't sleep yet.