Loading services/core/java/com/android/server/wm/WindowContainer.java +8 −1 Original line number Diff line number Diff line Loading @@ -1257,7 +1257,14 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< mOrientation = orientation; final WindowContainer parent = getParent(); if (parent != null) { if (getConfiguration().orientation != getRequestedConfigurationOrientation()) { if (getConfiguration().orientation != getRequestedConfigurationOrientation() // Update configuration directly only if the change won't be dispatched from // ancestor. This prevents from computing intermediate configuration when the // parent also needs to be updated from the ancestor. E.g. the app requests // portrait but the task is still in landscape. While updating from display, // the task can be updated to portrait first so the configuration can be // computed in a consistent environment. && (inMultiWindowMode() || !handlesOrientationChangeFromDescendant())) { // Resolve the requested orientation. onConfigurationChanged(parent.getConfiguration()); } Loading services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +17 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; Loading Loading @@ -633,6 +634,22 @@ public class WindowContainerTests extends WindowTestsBase { assertEquals(SCREEN_ORIENTATION_PORTRAIT, root.getOrientation()); } @Test public void testSetOrientation() { final TestWindowContainer root = spy(new TestWindowContainerBuilder(mWm).build()); final TestWindowContainer child = spy(root.addChildWindow()); doReturn(true).when(root).handlesOrientationChangeFromDescendant(); child.getWindowConfiguration().setWindowingMode(WINDOWING_MODE_FULLSCREEN); child.setOrientation(SCREEN_ORIENTATION_PORTRAIT); // The ancestor should decide whether to dispatch the configuration change. verify(child, never()).onConfigurationChanged(any()); doReturn(false).when(root).handlesOrientationChangeFromDescendant(); child.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); // The ancestor doesn't handle the request so the descendant applies the change directly. verify(child).onConfigurationChanged(any()); } @Test public void testCompareTo() { final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(mWm); Loading Loading
services/core/java/com/android/server/wm/WindowContainer.java +8 −1 Original line number Diff line number Diff line Loading @@ -1257,7 +1257,14 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< mOrientation = orientation; final WindowContainer parent = getParent(); if (parent != null) { if (getConfiguration().orientation != getRequestedConfigurationOrientation()) { if (getConfiguration().orientation != getRequestedConfigurationOrientation() // Update configuration directly only if the change won't be dispatched from // ancestor. This prevents from computing intermediate configuration when the // parent also needs to be updated from the ancestor. E.g. the app requests // portrait but the task is still in landscape. While updating from display, // the task can be updated to portrait first so the configuration can be // computed in a consistent environment. && (inMultiWindowMode() || !handlesOrientationChangeFromDescendant())) { // Resolve the requested orientation. onConfigurationChanged(parent.getConfiguration()); } Loading
services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +17 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; Loading Loading @@ -633,6 +634,22 @@ public class WindowContainerTests extends WindowTestsBase { assertEquals(SCREEN_ORIENTATION_PORTRAIT, root.getOrientation()); } @Test public void testSetOrientation() { final TestWindowContainer root = spy(new TestWindowContainerBuilder(mWm).build()); final TestWindowContainer child = spy(root.addChildWindow()); doReturn(true).when(root).handlesOrientationChangeFromDescendant(); child.getWindowConfiguration().setWindowingMode(WINDOWING_MODE_FULLSCREEN); child.setOrientation(SCREEN_ORIENTATION_PORTRAIT); // The ancestor should decide whether to dispatch the configuration change. verify(child, never()).onConfigurationChanged(any()); doReturn(false).when(root).handlesOrientationChangeFromDescendant(); child.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); // The ancestor doesn't handle the request so the descendant applies the change directly. verify(child).onConfigurationChanged(any()); } @Test public void testCompareTo() { final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(mWm); Loading