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

Commit 329c60d4 authored by Louis Chang's avatar Louis Chang
Browse files

Skip resuming activities on sleeping display

Bubble activity was resumed while the ActivityView was hidden after
device unlocked.

Also reduce always resuming activities from RWC since already looping
through all displays when applying sleep tokens.

Bug: 160338354
Test: atest RootActivityContainerTests
Change-Id: I7f08e09fb9273a3ae7855728ed6f4eb1b7fdb206
parent 0d9def8f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2269,6 +2269,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>

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

            final boolean curResult = result;
            boolean resumedOnDisplay = display.reduceOnAllTaskDisplayAreas(
                    (taskDisplayArea, resumed) -> {
@@ -2360,7 +2364,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
@@ -894,6 +894,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.