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

This commit is contained in:
Louis Chang
2019-03-20 14:45:50 +00:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 2 deletions

View File

@@ -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);

View File

@@ -3053,7 +3053,17 @@ class ActivityStack extends ConfigurationContainer {
ActivityOptions.abort(options);
if (DEBUG_STATES) Slog.d(TAG_STATES,
"resumeTopActivityInNextFocusableStack: " + reason + ", go home");
return mRootActivityContainer.resumeHomeActivity(prev, reason, mDisplayId);
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. */