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

Commit 79a5c2bf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Skip resuming activities on sleeping display" into rvc-qpr-dev am: 98273565

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12122880

Change-Id: Ib193b7cbf8199f4c563ebe1a59bdb3aae297c29a
parents f269e673 98273565
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2300,8 +2300,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        }

        for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {
            boolean resumedOnDisplay = false;
            final DisplayContent display = getChildAt(displayNdx);
            if (display.shouldSleep()) {
                continue;
            }

            boolean resumedOnDisplay = false;
            for (int tdaNdx = display.getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) {
                final TaskDisplayArea taskDisplayArea = display.getTaskDisplayAreaAt(tdaNdx);
                for (int sNdx = taskDisplayArea.getStackCount() - 1; sNdx >= 0; --sNdx) {
@@ -2390,7 +2394,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                            // process the keyguard going away, which can happen before the sleep
                            // token is released. As a result, it is important we resume the
                            // activity here.
                            resumeFocusedStacksTopActivities();
                            stack.resumeTopActivityUncheckedLocked(null, null);
                        }
                        // The visibility update must not be called before resuming the top, so the
                        // display orientation can be updated first if needed. Otherwise there may
+18 −0
Original line number Diff line number Diff line
@@ -896,6 +896,24 @@ public class RootActivityContainerTests extends ActivityTestsBase {
        assertEquals(taskDisplayArea.getTopStack(), taskDisplayArea.getRootHomeTask());
    }

    @Test
    public void testResumeFocusedStackOnSleepingDisplay() {
        // Create an activity on secondary display.
        final TestDisplayContent secondDisplay = addNewDisplayContentAt(
                DisplayContent.POSITION_TOP);
        final ActivityStack stack = secondDisplay.getDefaultTaskDisplayArea()
                .createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
        final ActivityRecord activity = new ActivityBuilder(mService).setStack(stack).build();
        spyOn(activity);
        spyOn(stack);

        // Cannot resumed activities on secondary display if the display should sleep.
        doReturn(true).when(secondDisplay).shouldSleep();
        mRootWindowContainer.resumeFocusedStacksTopActivities();
        verify(stack, never()).resumeTopActivityUncheckedLocked(any(), any());
        verify(activity, never()).makeActiveIfNeeded(any());
    }

    /**
     * Mock {@link RootWindowContainer#resolveHomeActivity} for returning consistent activity
     * info for test cases.