From cfb22eae9dc5469746d0c3589fb0ae7a9db8eabd Mon Sep 17 00:00:00 2001 From: Yuncheol Heo Date: Fri, 27 Aug 2021 12:53:23 -0700 Subject: [PATCH] Dispatch taskInfoChanged after the app transition is finished. Bug: 197787343 Test: Follow the reproducible steps in b/197787343 Change-Id: Iff246e84c47bda3219b1a9adef5e9a4c3a888666 --- services/core/java/com/android/server/wm/ActivityRecord.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 67043dbab6a38..944331755e4bd 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4893,6 +4893,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // getting visible so we also wait for them. forAllWindows(mWmService::makeWindowFreezingScreenIfNeededLocked, true); } + // dispatchTaskInfoChangedIfNeeded() right after ActivityRecord#setVisibility() can report + // the stale visible state, because the state will be updated after the app transition. + // So tries to report the actual visible state again where the state is changed. + if (task != null) task.dispatchTaskInfoChangedIfNeeded(false /* force */); ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "commitVisibility: %s: visible=%b mVisibleRequested=%b", this, isVisible(), mVisibleRequested);