Attemp to fix an NPE while transferStartingWindow.

The NPE scenario may happen when:
Start Task with activity(A), then start anoterh task with activity(B),
so there should be an app transition happen to Open B and Close A,
which will start the exit animation on A.
When Activity(A) receive onAnimationFinished, it will remove all
windows with onExitAnimationDone, thus remove the starting window on A.
So if there is another activity(C) below A and it will set to visible,
there will try to transfer the starting window to C.
We shouldn't allow that from happen because window is in the middle of
remove process.

Bug: 201019560
Test: presubmit
Change-Id: I5880896252ea3207d67753552aefa3f1c9f354b3
This commit is contained in:
wilsonshih
2021-12-14 16:33:30 +08:00
parent dfabfc6106
commit eadfad4307

View File

@@ -4003,6 +4003,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
private boolean transferStartingWindow(@NonNull ActivityRecord fromActivity) {
final WindowState tStartingWindow = fromActivity.mStartingWindow;
if (tStartingWindow != null && fromActivity.mStartingSurface != null) {
if (tStartingWindow.getParent() == null) {
// The window has been detached from the parent, so the window cannot be transfer
// to another activity because it may be in the remove process.
// Don't need to remove the starting window at this point because that will happen
// at #postWindowRemoveCleanupLocked
return false;
}
// In this case, the starting icon has already been displayed, so start
// letting windows get shown immediately without any more transitions.
if (fromActivity.mVisible) {