From 00d586d8f0bcd6233fd21970582ec27621fbceed Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Fri, 28 Jul 2017 20:48:43 -0700 Subject: [PATCH] Allow foreground AppWindowToken to influence orientation. It is possible for an activity to request an orientation after finish has been called, causing the system orientation to be re-evaluated. Since the activity is closing, it will no longer be eligible to influence orientation. If another stack/task is brought to the foreground, it will as well won't be able to participate since it is not considered an opening app and won't be visible. As a result, we set the orientation to unspecified, leading to the foreground activity to be resumed in the wrong orientation. This changelist addresses the issue by allowing an AppWindowToken to participate in orientation calculations if it is not closing and is on top of the wm hierarchy, regardless of its visibility. Change-Id: I0f316d6d824398d084c7648cf2dc2c2d07b4410d Fixes: 63982461 Fixes: 63513655 Test: bit FrameworksServicesTests:com.android.server.wm.AppWindowTokenTests#testGetOrientation Test: go/wm-smoke --- .../java/com/android/server/wm/AppWindowToken.java | 2 +- .../java/com/android/server/wm/DisplayContent.java | 7 +++++++ .../java/com/android/server/wm/WindowContainer.java | 7 +++++++ .../src/com/android/server/wm/AppWindowTokenTests.java | 5 +++++ .../src/com/android/server/wm/WindowTestUtils.java | 10 ++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 63890bf346efc..c4ff455fa3d3c 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -1311,7 +1311,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree // going to the bottom. Allowing closing {@link AppWindowToken} to participate can lead to // an Activity in another task being started in the wrong orientation during the transition. if (!(sendingToBottom || mService.mClosingApps.contains(this)) - && (isVisible() || mService.mOpeningApps.contains(this))) { + && (isVisible() || mService.mOpeningApps.contains(this) || isOnTop())) { return mOrientation; } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 55c0612ff7644..4d77d40584c18 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3308,6 +3308,13 @@ class DisplayContent extends WindowContainer implements Comparable