Clear member reference AR#mStartingWindow once starting window death.
Clear the local reference of starting window once the window is death,
so it won't be reuse anywhere else.
Bug: 308334422
Test: launch test app to show splash screen then kill systemui
immediately, verify the starting window reference can be removed right
after receive binderDied.
Change-Id: Ic1b35d9a05d761e9716e3d5f603847df1d7b4d26
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index bdab4d4..b70fa8f 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -2887,7 +2887,6 @@
}
final StartingSurfaceController.StartingSurface surface;
- final WindowState startingWindow = mStartingWindow;
final boolean animate;
if (mStartingData != null) {
if (mStartingData.mWaitForSyncTransactionCommit
@@ -4545,7 +4544,7 @@
mTransitionChangeFlags |= FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
}
// Post cleanup after the visibility and animation are transferred.
- fromActivity.postWindowRemoveStartingWindowCleanup();
+ fromActivity.postWindowRemoveStartingWindowCleanup(tStartingWindow);
fromActivity.mVisibleSetFromTransferredStartingWindow = false;
mWmService.updateFocusedWindowLocked(
@@ -7461,7 +7460,12 @@
}
}
- void postWindowRemoveStartingWindowCleanup() {
+ void postWindowRemoveStartingWindowCleanup(@NonNull WindowState win) {
+ if (mStartingWindow == win) {
+ // This could only happen when the window is removed from hierarchy. So do not keep its
+ // reference anymore.
+ mStartingWindow = null;
+ }
if (mChildren.size() == 0 && mVisibleSetFromTransferredStartingWindow) {
// We set the visible state to true for the token from a transferred starting
// window. We now reset it back to false since the starting window was the last
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a90e08e..6623d02e 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2020,7 +2020,7 @@
}
if (win.mActivityRecord != null) {
- win.mActivityRecord.postWindowRemoveStartingWindowCleanup();
+ win.mActivityRecord.postWindowRemoveStartingWindowCleanup(win);
}
if (win.mAttrs.type == TYPE_WALLPAPER) {