summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-10-02 02:25:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-10-02 02:25:22 +0000
commit75a288bf0793e4694e00ced0393967630ed946be (patch)
tree04be514de72da18b9800a5cd75cfa8cf57092e32
parent407392046c18fab3e94f887f171bf1f28379dac7 (diff)
parent780e5452cd727860290d37cb6922e188713f6489 (diff)
downloadbase-75a288bf0793e4694e00ced0393967630ed946be.tar.gz
Merge "Use normal rotation if orientation is changed by resume-scheduled app" into rvc-qpr-dev
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java9
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java21
2 files changed, 30 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 553aad1a43cd..946d797b8348 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1496,6 +1496,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
// intermediate orientation change, it is more stable to freeze the display.
return false;
}
+ if (r.isState(RESUMED) && !r.getRootTask().mInResumeTopActivity) {
+ // If the activity is executing or has done the lifecycle callback, use normal
+ // rotation animation so the display info can be updated immediately (see
+ // updateDisplayAndOrientation). This prevents a compatibility issue such as
+ // calling setRequestedOrientation in Activity#onCreate and then get display info.
+ // If fixed rotation is applied, the display rotation will still be the old one,
+ // unless the client side gets the rotation again after the adjustments arrive.
+ return false;
+ }
} else if (r != topRunningActivity()) {
// If the transition has not started yet, the activity must be the top.
return false;
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index c7a8bd857674..1948003a7499 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -1276,6 +1276,27 @@ public class DisplayContentTests extends WindowTestsBase {
}
@Test
+ public void testNoFixedRotationOnResumedScheduledApp() {
+ final ActivityRecord app = new ActivityTestsBase.StackBuilder(mWm.mRoot)
+ .setDisplay(mDisplayContent).build().getTopMostActivity();
+ app.setVisible(false);
+ app.setState(ActivityStack.ActivityState.RESUMED, "test");
+ mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN,
+ false /* alwaysKeepCurrent */);
+ mDisplayContent.mOpeningApps.add(app);
+ final int newOrientation = getRotatedOrientation(mDisplayContent);
+ app.setRequestedOrientation(newOrientation);
+
+ // The condition should reject using fixed rotation because the resumed client in real case
+ // might get display info immediately. And the fixed rotation adjustments haven't arrived
+ // client side so the info may be inconsistent with the requested orientation.
+ verify(mDisplayContent).handleTopActivityLaunchingInDifferentOrientation(eq(app),
+ eq(true) /* checkOpening */);
+ assertFalse(app.isFixedRotationTransforming());
+ assertFalse(mDisplayContent.hasTopFixedRotationLaunchingApp());
+ }
+
+ @Test
public void testRecentsNotRotatingWithFixedRotation() {
final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
doCallRealMethod().when(displayRotation).updateRotationUnchecked(anyBoolean());