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

Commit fef90a09 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Fix launcher failing tests.

- Check for null before accessing top-display-focus stack.
- Create home stack if it doesn't exist.

Fixes: 144030618
Test: atest NexusLauncherOutOfProcTests
Test:
1) Clear Recents
2) adb shell am force-stop com.google.android.apps.nexuslauncher
3) Press home button
Change-Id: Ibb5e5dfafcabdc4af35d6544cdc1d5bf7e2c8eee
parent 1a661232
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.os.FactoryTest.FACTORY_TEST_LOW_LEVEL;

import static com.android.server.wm.ActivityStackSupervisor.ON_TOP;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;

@@ -178,6 +179,13 @@ public class ActivityStartController {
            options.setLaunchActivityType(ACTIVITY_TYPE_HOME);
        }
        options.setLaunchDisplayId(displayId);

        final ActivityDisplay display =
                mService.mRootActivityContainer.getActivityDisplay(displayId);
        // Make sure home stack exist on display.
        final ActivityStack homeStack =
                display.getOrCreateStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);

        mLastHomeActivityStartResult = obtainStarter(intent, "startHomeActivity: " + reason)
                .setOutActivity(tmpOutRecord)
                .setCallingUid(0)
@@ -185,10 +193,7 @@ public class ActivityStartController {
                .setActivityOptions(options.toBundle())
                .execute();
        mLastHomeActivityStartRecord = tmpOutRecord[0];
        final ActivityDisplay display =
                mService.mRootActivityContainer.getActivityDisplay(displayId);
        final ActivityStack homeStack = display != null ? display.getHomeStack() : null;
        if (homeStack != null && homeStack.mInResumeTopActivity) {
        if (homeStack.mInResumeTopActivity) {
            // If we are in resume section already, home activity will be initialized, but not
            // resumed (to avoid recursive resume) and will stay that way until something pokes it
            // again. We need to schedule another resume.
+2 −1
Original line number Diff line number Diff line
@@ -358,7 +358,8 @@ class RootActivityContainer extends ConfigurationContainer
            boolean fromHomeKey) {
        // Fallback to top focused display if the displayId is invalid.
        if (displayId == INVALID_DISPLAY) {
            displayId = getTopDisplayFocusedStack().mDisplayId;
            final ActivityStack stack = getTopDisplayFocusedStack();
            displayId = stack != null ? stack.mDisplayId : DEFAULT_DISPLAY;
        }

        Intent homeIntent = null;