From 283da3bf5ffb0fe39f69171215a7cd950238bca6 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Tue, 18 Aug 2020 21:08:22 +0800 Subject: [PATCH] Fixes activity didn't receive windowing mode change while exitPip When user dismiss pip, WindowOrganizerController#applyChanges would first try to resize pinned task, this will cause the activity to do ensureActivityConfiguration and which could trigger configuration change or relaunch the client activity. However, the windowing mode was not change yet, so the windowing mode change would be scheduled in another configuration change to client. But since the windowing mode is not public, client will treat there is difference so skip that configuration. To ensure client receive windowing mode change, check it before check configuration difference. And in order to prevent the WindowState#reportResized send before ActivityRelaunchItem send to client, skip resize if we already know that activity is going to relaunch. Bug: 165051679 Test: atest ActivityLifecyclePipTests ActivityLifecycleSplitScreenTests ActivityLifecycleTopResumedStateTests PinnedStackTests SplitScreenTests ActivityLifecycleKeyguardTests Change-Id: I7b96bbcf1a71ff75751e14db44c03261862bc857 --- core/java/android/app/ActivityThread.java | 10 +++++----- .../core/java/com/android/server/wm/WindowState.java | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index f6b0453492199..caca05a9e3b34 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5656,6 +5656,11 @@ public final class ActivityThread extends ClientTransactionHandler { throw new IllegalArgumentException("Activity token not set. Is the activity attached?"); } + // WindowConfiguration differences aren't considered as public, check it separately. + // multi-window / pip mode changes, if any, should be sent before the configuration + // change callback, see also PinnedStackTests#testConfigurationChangeOrderDuringTransition + handleWindowingModeChangeIfNeeded(activity, newConfig); + final boolean movedToDifferentDisplay = isDifferentDisplay(activity, displayId); boolean shouldReportChange = false; if (activity.mCurrentConfig == null) { @@ -5708,11 +5713,6 @@ public final class ActivityThread extends ClientTransactionHandler { } if (shouldReportChange) { - // multi-window / pip mode changes, if any, should be sent before the configuration - // change callback, see also - // PinnedStackTests#testConfigurationChangeOrderDuringTransition - handleWindowingModeChangeIfNeeded(activity, newConfig); - activity.mCalled = false; activity.onConfigurationChanged(configToReport); if (!activity.mCalled) { diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index f262c5ad7b2b9..69d38219284f7 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -3569,6 +3569,13 @@ class WindowState extends WindowContainer implements WindowManagerP } void reportResized() { + // If the activity is scheduled to relaunch, skip sending the resized to ViewRootImpl now + // since it will be destroyed anyway. This also prevents the client from receiving + // windowing mode change before it is destroyed. + if (mActivityRecord != null && mActivityRecord.isRelaunching()) { + return; + } + if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "wm.reportResized_" + getWindowTag()); }