diff options
| author | 2021-05-03 14:51:24 +0800 | |
|---|---|---|
| committer | 2021-05-03 21:54:13 +0800 | |
| commit | 0cadae1c718e5e448f70b459cbafb0aa5a63504a (patch) | |
| tree | 815c5ffd685e67cc14b49683b81314b493973a33 | |
| parent | 285e3754084cfa88abb9629a6f4f07c8cc3bb809 (diff) | |
Avoid intermediate orientation change
The onDescendantOrientationChanged in Task was used for reporting
requested orientation takes affect after display windowing mode
is changed. But when calling WMS#setWindowingMode, it will call
DC#reconfigureDisplayLocked that also updates orientation from
display so the task orientation can still propagate to display.
So just remove the invocation of onDescendantOrientationChanged
from task's config change. That prevents from reporting
intermediate orientation change when re-parenting multiple tasks
from multi-window to fullscreen.
Bug: 186657559
Test: TaskTests#testTaskOrientationOnDisplayWindowingModeChange
Change-Id: Ie722a4384829c2dab4ee4c35de6ffbbb4a0e4655
| -rw-r--r-- | services/core/java/com/android/server/wm/Task.java | 6 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/TaskTests.java | 15 |
2 files changed, 8 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 9fad7daa7212..7ffc65ab342b 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -2240,7 +2240,6 @@ class Task extends WindowContainer<WindowContainer> { mTmpPrevBounds.set(getBounds()); final boolean wasInMultiWindowMode = inMultiWindowMode(); final boolean wasInPictureInPicture = inPinnedWindowingMode(); - final int oldOrientation = getOrientation(); super.onConfigurationChanged(newParentConfig); // Only need to update surface size here since the super method will handle updating // surface position. @@ -2283,11 +2282,6 @@ class Task extends WindowContainer<WindowContainer> { mForceNotOrganized = false; } - // Report orientation change such as changing from freeform to fullscreen. - if (oldOrientation != getOrientation()) { - onDescendantOrientationChanged(this); - } - saveLaunchingStateIfNeeded(); final boolean taskOrgChanged = updateTaskOrganizerState(false /* forceUpdate */); if (taskOrgChanged) { 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 2389d2d6e8d6..f2767470c651 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -62,7 +62,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.same; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; import android.app.ActivityManager; import android.app.TaskInfo; @@ -1322,20 +1321,22 @@ public class TaskTests extends WindowTestsBase { } @Test - public void testNotifyOrientationChangeCausedByConfigurationChange() { + public void testTaskOrientationOnDisplayWindowingModeChange() { + // Skip unnecessary operations to speed up the test. + mAtm.deferWindowLayout(); final Task task = getTestTask(); final ActivityRecord activity = task.getTopMostActivity(); final DisplayContent display = task.getDisplayContent(); - display.setWindowingMode(WINDOWING_MODE_FREEFORM); + mWm.setWindowingMode(display.mDisplayId, WINDOWING_MODE_FREEFORM); activity.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); assertEquals(SCREEN_ORIENTATION_UNSET, task.getOrientation()); - verify(display).onDescendantOrientationChanged(same(task)); - reset(display); + assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, display.getLastOrientation()); - display.setWindowingMode(WINDOWING_MODE_FULLSCREEN); + mWm.setWindowingMode(display.mDisplayId, WINDOWING_MODE_FULLSCREEN); assertEquals(SCREEN_ORIENTATION_LANDSCAPE, task.getOrientation()); - verify(display).onDescendantOrientationChanged(same(task)); + assertEquals(SCREEN_ORIENTATION_LANDSCAPE, display.getLastOrientation()); + assertEquals(Configuration.ORIENTATION_LANDSCAPE, display.getConfiguration().orientation); } private Task getTestTask() { |