From 1b599135738422392cac766024b9f0bc1a156845 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Wed, 24 Nov 2021 15:02:00 -0800 Subject: [PATCH] Resume appSwitchesAllowed after exit PiP Bug: 207601475 Test: manual, see reproduce path in the bug Change-Id: I9c0fa3f0ab65aa3cc5305978d23a385683be747d --- .../core/java/com/android/server/wm/Task.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index d2eea76a29fcf..db0fc6521ada4 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -4581,14 +4581,15 @@ class Task extends TaskFragment { } super.setWindowingMode(windowingMode); - // Try reparent pinned activity back to its original task after onConfigurationChanged - // cascade finishes. This is done on Task level instead of - // {@link ActivityRecord#onConfigurationChanged(Configuration)} since when we exit PiP, - // we set final windowing mode on the ActivityRecord first and then on its Task when - // the exit PiP transition finishes. Meanwhile, the exit transition is always - // performed on its original task, reparent immediately in ActivityRecord breaks it. - if (currentMode == WINDOWING_MODE_PINNED) { - if (topActivity != null && topActivity.getLastParentBeforePip() != null) { + if (currentMode == WINDOWING_MODE_PINNED && topActivity != null) { + // Try reparent pinned activity back to its original task after + // onConfigurationChanged cascade finishes. This is done on Task level instead of + // {@link ActivityRecord#onConfigurationChanged(Configuration)} since when we exit + // PiP, we set final windowing mode on the ActivityRecord first and then on its + // Task when the exit PiP transition finishes. Meanwhile, the exit transition is + // always performed on its original task, reparent immediately in ActivityRecord + // breaks it. + if (topActivity.getLastParentBeforePip() != null) { // Do not reparent if the pinned task is in removal, indicated by the // force hidden flag. if (!isForceHidden()) { @@ -4601,6 +4602,11 @@ class Task extends TaskFragment { } } } + // Resume app-switches-allowed flag when exiting from pinned mode since + // it does not follow the ActivityStarter path. + if (topActivity.shouldBeVisible()) { + mAtmService.resumeAppSwitches(); + } } if (creating) {