Merge "Only check canSpecifyOrientation at leaf Task" into sc-dev
This commit is contained in:
@@ -3291,11 +3291,22 @@ class Task extends WindowContainer<WindowContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean handlesOrientationChangeFromDescendant() {
|
boolean handlesOrientationChangeFromDescendant() {
|
||||||
return super.handlesOrientationChangeFromDescendant()
|
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
|
// Display won't rotate for the orientation request if the Task/TaskDisplayArea
|
||||||
// can't specify orientation.
|
// can't specify orientation.
|
||||||
&& canSpecifyOrientation()
|
return canSpecifyOrientation() && getDisplayArea().canSpecifyOrientation();
|
||||||
&& getDisplayArea().canSpecifyOrientation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize(boolean relayout, boolean forced) {
|
void resize(boolean relayout, boolean forced) {
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
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_FREEFORM;
|
||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
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 android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||||
|
|
||||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||||
@@ -257,4 +260,21 @@ public class TaskTests extends WindowTestsBase {
|
|||||||
task.resolveOverrideConfiguration(parentConfig);
|
task.resolveOverrideConfiguration(parentConfig);
|
||||||
assertThat(resolvedOverride.getWindowingMode()).isEqualTo(WINDOWING_MODE_UNDEFINED);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user