Fix ActivityRecord leak if starting window was transferred.
Some windows would stuck in animating status because we didn't get the correct top activity which contains the starting window, after apply animation on this main window it would stuck in animating. Test: atest AmStartOptionsTests#testDashW_FinishingTop, then check there is no WindowState leak after test finish. Bug: 184830058 Change-Id: I8f838427168c157732a50fadfccfc9500a3faccc
This commit is contained in:
@@ -61,6 +61,7 @@ import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
import static android.view.SurfaceControl.METADATA_TASK_ID;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||
import static android.view.WindowManager.TRANSIT_CHANGE;
|
||||
import static android.view.WindowManager.TRANSIT_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
|
||||
@@ -1670,6 +1671,14 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
return isUidPresent;
|
||||
}
|
||||
|
||||
ActivityRecord topActivityContainsStartingWindow() {
|
||||
if (getParent() == null) {
|
||||
return null;
|
||||
}
|
||||
return getActivity((r) -> r.getWindow(window ->
|
||||
window.getBaseType() == TYPE_APPLICATION_STARTING) != null);
|
||||
}
|
||||
|
||||
ActivityRecord topActivityWithStartingWindow() {
|
||||
if (getParent() == null) {
|
||||
return null;
|
||||
|
||||
@@ -38,7 +38,6 @@ import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Slog;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.SurfaceControl;
|
||||
@@ -76,9 +75,6 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
||||
private static final int REPORT_CONFIGS = CONTROLLABLE_CONFIGS;
|
||||
private static final int REPORT_WINDOW_CONFIGS = CONTROLLABLE_WINDOW_CONFIGS;
|
||||
|
||||
private static final boolean DEBUG_ENABLE_REVEAL_ANIMATION =
|
||||
SystemProperties.getBoolean("persist.debug.enable_reveal_animation", false);
|
||||
|
||||
// The set of modes that are currently supports
|
||||
// TODO: Remove once the task organizer can support all modes
|
||||
@VisibleForTesting
|
||||
@@ -187,8 +183,8 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
||||
SurfaceControl windowAnimationLeash = null;
|
||||
Rect mainFrame = null;
|
||||
final boolean playShiftUpAnimation = !task.inMultiWindowMode();
|
||||
if (prepareAnimation && playShiftUpAnimation && DEBUG_ENABLE_REVEAL_ANIMATION) {
|
||||
final ActivityRecord topActivity = task.topActivityWithStartingWindow();
|
||||
if (prepareAnimation && playShiftUpAnimation) {
|
||||
final ActivityRecord topActivity = task.topActivityContainsStartingWindow();
|
||||
if (topActivity != null) {
|
||||
final WindowState mainWindow =
|
||||
topActivity.findMainWindow(false/* includeStartingApp */);
|
||||
|
||||
@@ -2412,14 +2412,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
if (startingWindow && StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) {
|
||||
// cancel the remove starting window animation on shell
|
||||
// Cancel the remove starting window animation on shell. The main window might changed
|
||||
// during animating, checking for all windows would be safer.
|
||||
if (mActivityRecord != null) {
|
||||
final WindowState mainWindow =
|
||||
mActivityRecord.findMainWindow(false/* includeStartingApp */);
|
||||
if (mainWindow != null && mainWindow.isSelfAnimating(0 /* flags */,
|
||||
ANIMATION_TYPE_STARTING_REVEAL)) {
|
||||
mainWindow.cancelAnimation();
|
||||
}
|
||||
mActivityRecord.forAllWindows(w -> {
|
||||
if (w.isSelfAnimating(0, ANIMATION_TYPE_STARTING_REVEAL)) {
|
||||
w.cancelAnimation();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user