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

Commit c19f6c52 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Ensure activity display with an empty stack can be released"

parents 9e69b64c cc56871d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -1173,7 +1173,17 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
    }

    private void releaseSelfIfNeeded() {
        if (mStacks.isEmpty() && mRemoved) {
        if (!mRemoved || mDisplayContent == null) {
            return;
        }

        final ActivityStack stack = mStacks.size() == 1 ? mStacks.get(0) : null;
        if (stack != null && stack.isActivityTypeHome() && stack.getAllTasks().isEmpty()) {
            // Release this display if an empty home stack is the only thing left.
            // Since it is the last stack, this display will be released along with the stack
            // removal.
            stack.remove();
        } else if (mStacks.isEmpty()) {
            mDisplayContent.removeIfPossible();
            mDisplayContent = null;
            mRootActivityContainer.removeChild(this);
+11 −1
Original line number Diff line number Diff line
@@ -3053,8 +3053,18 @@ class ActivityStack extends ConfigurationContainer {
        ActivityOptions.abort(options);
        if (DEBUG_STATES) Slog.d(TAG_STATES,
                "resumeTopActivityInNextFocusableStack: " + reason + ", go home");
        if (isActivityTypeHome()) {
            // resumeTopActivityUncheckedLocked has been prevented to run recursively. Post a
            // runnable to resume home since we are currently in the process of resuming top
            // activity in home stack.
            // See {@link #mInResumeTopActivity}.
            mService.mH.post(
                    () -> mRootActivityContainer.resumeHomeActivity(prev, reason, mDisplayId));
            return true;
        } else {
            return mRootActivityContainer.resumeHomeActivity(prev, reason, mDisplayId);
        }
    }

    /** Returns the position the input task should be placed in this stack. */
    int getAdjustedPositionForTask(TaskRecord task, int suggestedPosition,