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

Commit 8824a8a4 authored by wilsonshih's avatar wilsonshih
Browse files

Fix black screen when finish FallbackHome

The reason for the short black screen is that FallbackHome will be destroyed
directly when the it finish, and there will be no home activity until the
NexusLauncher resumed.
In order to fix this problem, we can check if the display also contains the
home stack, because in this case there must have a home activity on that display.

- Also add a unit test to verify the home stack shouldn't be destroy
immediately.

Fix: 119392020
Test: atest ActivityStackTests ActivityDisplayTests

Change-Id: Ic0035f784a6b29c212ebc33d8addfcb3f3bf38c6
parent a50d69cc
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -4111,9 +4111,16 @@ class ActivityStack extends ConfigurationContainer {
        if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to FINISHING: " + r);

        r.setState(FINISHING, "finishCurrentActivityLocked");

        // Don't destroy activity immediately if the display contains home stack, although there is
        // no next activity at the moment but another home activity should be started later. Keep
        // this activity alive until next home activity is resumed then user won't see a temporary
        // black screen.
        final boolean noRunningStack = next == null && display.topRunningActivity() == null
                && display.getHomeStack() == null;
        final boolean noFocusedStack = r.getActivityStack() != display.getFocusedStack();
        final boolean finishingInNonFocusedStackOrNoRunning = mode == FINISH_AFTER_VISIBLE
                && prevState == PAUSED && (r.getActivityStack() != display.getFocusedStack()
                        || (next == null && display.topRunningActivity() == null));
                && prevState == PAUSED && (noFocusedStack || noRunningStack);

        if (mode == FINISH_IMMEDIATELY
                || (prevState == PAUSED
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityStack.ActivityState.DESTROYING;
import static com.android.server.wm.ActivityStack.ActivityState.FINISHING;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSED;
import static com.android.server.wm.ActivityStack.ActivityState.PAUSING;
import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
@@ -928,6 +929,16 @@ public class ActivityStackTests extends ActivityTestsBase {
        assertThat(mStack.getAllTasks()).isEmpty();
    }

    @Test
    public void testWontFinishHomeStackImmediately() {
        final ActivityStack homeStack = createStackForShouldBeVisibleTest(mDefaultDisplay,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, true /* onTop */);

        // Home stack should not be destroyed immediately.
        final ActivityRecord activity1 = finishCurrentActivity(homeStack);
        assertEquals(FINISHING, activity1.getState());
    }

    @Test
    public void testFinishCurrentActivity() {
        // Create 2 activities on a new display.