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

Commit f8398cd0 authored by Darryl Johnson's avatar Darryl Johnson Committed by Android (Google) Code Review
Browse files

Merge "Protect against assumptions of an existing home stack."

parents 62709b5a 3388bd2a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2679,7 +2679,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // DisplayContent#topRunningActivity().
        final ActivityRecord next = display.topRunningActivity();
        final boolean isLastStackOverEmptyHome =
                next == null && stack.isFocusedStackOnDisplay() && display.getRootHomeTask() != null;
                next == null && stack.isFocusedStackOnDisplay()
                        && display.getOrCreateRootHomeTask() != null;
        if (isLastStackOverEmptyHome) {
            // Don't destroy activity immediately if this is the last activity on the display and
            // the display contains home stack. Although there is no next activity at the moment,
+1 −1
Original line number Diff line number Diff line
@@ -1374,7 +1374,7 @@ class ActivityStarter {
                    break;
                case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY:
                    final ActivityStack homeStack =
                            startedActivityStack.getDisplay().getRootHomeTask();
                            startedActivityStack.getDisplay().getOrCreateRootHomeTask();
                    if (homeStack != null && homeStack.shouldBeVisible(null /* starting */)) {
                        mService.mWindowManager.showRecentApps();
                    }
+16 −5
Original line number Diff line number Diff line
@@ -1937,6 +1937,20 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        return mTaskContainers.getRootHomeTask();
    }

    /**
     * Returns the existing home stack or creates and returns a new one if it should exist for the
     * display.
     */
    @Nullable
    ActivityStack getOrCreateRootHomeTask() {
        ActivityStack homeTask = getRootHomeTask();
        if (homeTask == null && supportsSystemDecorations() && !isUntrustedVirtualDisplay()) {
            homeTask = createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME,
                    false /* onTop */);
        }
        return homeTask;
    }

    /** @return The primary split-screen task, and {@code null} otherwise. */
    ActivityStack getRootSplitScreenPrimaryTask() {
        return mTaskContainers.getRootSplitScreenPrimaryTask();
@@ -4258,9 +4272,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }

        ActivityStack getRootHomeTask() {
            if (mRootHomeTask == null && mDisplayId == DEFAULT_DISPLAY) {
                Slog.e(TAG_WM, "getHomeStack: Returning null from this=" + this);
            }
            return mRootHomeTask;
        }

@@ -6011,7 +6022,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        } finally {
            final ActivityStack topFullscreenStack =
                    getTopStackInWindowingMode(WINDOWING_MODE_FULLSCREEN);
            final ActivityStack homeStack = getRootHomeTask();
            final ActivityStack homeStack = getOrCreateRootHomeTask();
            if (topFullscreenStack != null && homeStack != null && !isTopStack(homeStack)) {
                // Whenever split-screen is dismissed we want the home stack directly behind the
                // current top fullscreen stack so it shows up when the top stack is finished.
@@ -6577,7 +6588,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    }

    void moveHomeStackToFront(String reason) {
        final ActivityStack homeStack = getRootHomeTask();
        final ActivityStack homeStack = getOrCreateRootHomeTask();
        if (homeStack != null) {
            homeStack.moveToFront(reason);
        }
+7 −5
Original line number Diff line number Diff line
@@ -1998,8 +1998,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        removeStacksInWindowingModes(WINDOWING_MODE_PINNED);

        mUserStackInFront.put(mCurrentUser, focusStackId);
        final int restoreStackId =
                mUserStackInFront.get(userId, getDefaultDisplay().getRootHomeTask().getRootTaskId());
        mCurrentUser = userId;

        mStackSupervisor.mStartingUsers.add(uss);
@@ -2011,9 +2009,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            }
        }

        final int restoreStackId = mUserStackInFront.get(userId);
        ActivityStack stack = getStack(restoreStackId);
        if (stack == null) {
            stack = getDefaultDisplay().getRootHomeTask();
            stack = getDefaultDisplay().getOrCreateRootHomeTask();
        }
        final boolean homeInFront = stack.isActivityTypeHome();
        if (stack.isOnHomeDisplay()) {
@@ -2035,8 +2034,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
     */
    void updateUserStack(int userId, ActivityStack stack) {
        if (userId != mCurrentUser) {
            mUserStackInFront.put(userId, stack != null ? stack.getRootTaskId()
                    : getDefaultDisplay().getRootHomeTask().getRootTaskId());
            if (stack == null) {
                stack = getDefaultDisplay().getOrCreateRootHomeTask();
            }

            mUserStackInFront.put(userId, stack.getRootTaskId());
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -1493,7 +1493,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        // Some system windows (e.g. "Power off" dialog) don't have a task, but we would still
        // associate them with some stack to enable dimming.
        final DisplayContent dc = getDisplayContent();
        return mAttrs.type >= FIRST_SYSTEM_WINDOW && dc != null ? dc.getRootHomeTask() : null;
        return mAttrs.type >= FIRST_SYSTEM_WINDOW && dc != null
                ? dc.getOrCreateRootHomeTask() : null;
    }

    /**
Loading