From 7c88cf83035e331bb4c4ccb519c8200f2e9d083f Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 5 Jun 2019 15:18:37 +0200 Subject: [PATCH] Prevent dismissing starting window when reopening app We reset the draw state in case the app was hidden before. This ensures that the starting window doesn't get dismissed immediately, in case there is some weirdness going on when restarting an activity, like a surface view that hasn't drawn yet. However, we don't reset draw state for starting windows as the snapshot doesn't redraw ever. Test: Open Chrome, swipe up, reopen Chrome, ensure no holes Test: Same for camera Test: go/wm-smoke Fixes: 134561008 Change-Id: I02742cef93a6b58f2096c98514371119fa606d16 --- .../core/java/com/android/server/wm/AppWindowToken.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index cae7612e0fcc2..912d5c4a66a55 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -539,6 +539,14 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree // If the app was already visible, don't reset the waitingToShow state. if (isHidden()) { waitingToShow = true; + + // Let's reset the draw state in order to prevent the starting window to be + // immediately dismissed when the app still has the surface. + forAllWindows(w -> { + if (w.mAttrs.type != TYPE_APPLICATION_STARTING) { + w.mWinAnimator.resetDrawState(); + } + }, true /* traverseTopToBottom */); } }