Ensure activity display with an empty stack can be released
The activities in home stack was destroyed/removed and resulted in an empty home stack. Activity display was leaked due to it had an empty home stack left which prevented it from being released. Making sure activity display with an empty home stack can also be released. Also fixed an issue that home activity was not being resumed due to early return in recursively resuming top activities. Bug: 126747441 Test: atest ActivityManagerMultiDisplayTests Change-Id: I243fab507268f81df0a8067883157d63f0f79c22
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user