summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Li <lihongyu@google.com> 2021-03-03 20:34:09 -0800
committer Chris Li <lihongyu@google.com> 2021-03-04 10:55:25 -0800
commit9a793b07b793615530ad44b2f9752abc235a0fa8 (patch)
tree2b0a0644a907e07b2f21895256535ae54c2cc4cf
parent8232386d0bb15c02cb7ff209567a0b0093ea2324 (diff)
Only check canSpecifyOrientation at leaf Task
Before, we check if the task can specify orientation to determine if the task should be letterboxed for orientatoin request, with which we are using the activity type of the top leaf Task for its sibling Task. Now, we only check for leaf Task, so that we won't letterbox HOME task even if it is not the top most. Bug: 179362640 Test: atest WmTests:TaskTests Test: manually with split screen Change-Id: I92e1c1e8c33bf6877ff3aeec94dc8ab1a3ba0c3e
-rw-r--r--services/core/java/com/android/server/wm/Task.java21
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskTests.java20
2 files changed, 36 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 80173b5942e6..3f6f55723e22 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -3297,11 +3297,22 @@ class Task extends WindowContainer<WindowContainer> {
@Override
boolean handlesOrientationChangeFromDescendant() {
- return super.handlesOrientationChangeFromDescendant()
- // Display won't rotate for the orientation request if the Task/TaskDisplayArea
- // can't specify orientation.
- && canSpecifyOrientation()
- && getDisplayArea().canSpecifyOrientation();
+ if (!super.handlesOrientationChangeFromDescendant()) {
+ return false;
+ }
+
+ // At task level, we want to check canSpecifyOrientation() based on the top activity type.
+ // Do this only on leaf Task, so that the result is not affecting by the sibling leaf Task.
+ // Otherwise, root Task will use the result from the top leaf Task, and all its child
+ // leaf Tasks will rely on that from super.handlesOrientationChangeFromDescendant().
+ if (!isLeafTask()) {
+ return true;
+ }
+
+ // Check for leaf Task.
+ // Display won't rotate for the orientation request if the Task/TaskDisplayArea
+ // can't specify orientation.
+ return canSpecifyOrientation() && getDisplayArea().canSpecifyOrientation();
}
void resize(boolean relayout, boolean forced) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index c3eb5c49cea0..ecb8b607a106 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -16,8 +16,11 @@
package com.android.server.wm;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
@@ -257,4 +260,21 @@ public class TaskTests extends WindowTestsBase {
task.resolveOverrideConfiguration(parentConfig);
assertThat(resolvedOverride.getWindowingMode()).isEqualTo(WINDOWING_MODE_UNDEFINED);
}
+
+ @Test
+ public void testHandlesOrientationChangeFromDescendant() {
+ final Task rootTask = createTaskStackOnDisplay(WINDOWING_MODE_MULTI_WINDOW,
+ ACTIVITY_TYPE_STANDARD, mDisplayContent);
+ final Task leafTask1 = createTaskInStack(rootTask, 0 /* userId */);
+ final Task leafTask2 = createTaskInStack(rootTask, 0 /* userId */);
+ leafTask1.getWindowConfiguration().setActivityType(ACTIVITY_TYPE_HOME);
+ leafTask2.getWindowConfiguration().setActivityType(ACTIVITY_TYPE_STANDARD);
+
+ assertEquals(leafTask2, rootTask.getTopChild());
+ assertTrue(rootTask.handlesOrientationChangeFromDescendant());
+ // Treat orientation request from home as handled.
+ assertTrue(leafTask1.handlesOrientationChangeFromDescendant());
+ // Orientation request from standard activity in multi window will not be handled.
+ assertFalse(leafTask2.handlesOrientationChangeFromDescendant());
+ }
}