Loading services/core/java/com/android/server/wm/TaskRecord.java +12 −12 Original line number Diff line number Diff line Loading @@ -1278,28 +1278,28 @@ class TaskRecord extends ConfigurationContainer { } /** * Checks if the root activity requires a particular orientation (either by override or * Checks if the top activity requires a particular orientation (either by override or * activityInfo) and returns that. Otherwise, this returns ORIENTATION_UNDEFINED. */ private int getRootActivityRequestedOrientation() { ActivityRecord root = getRootActivity(); private int getTopActivityRequestedOrientation() { ActivityRecord top = getTopActivity(); if (getRequestedOverrideConfiguration().orientation != ORIENTATION_UNDEFINED || root == null) { || top == null) { return getRequestedOverrideConfiguration().orientation; } int rootScreenOrientation = root.getOrientation(); if (rootScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { int screenOrientation = top.getOrientation(); if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { // NOSENSOR means the display's "natural" orientation, so return that. ActivityDisplay display = mStack != null ? mStack.getDisplay() : null; if (display != null && display.mDisplayContent != null) { return mStack.getDisplay().mDisplayContent.getNaturalOrientation(); } } else if (rootScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { } else if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { // LOCKED means the activity's orientation remains unchanged, so return existing value. return root.getConfiguration().orientation; } else if (ActivityInfo.isFixedOrientationLandscape(rootScreenOrientation)) { return top.getConfiguration().orientation; } else if (ActivityInfo.isFixedOrientationLandscape(screenOrientation)) { return ORIENTATION_LANDSCAPE; } else if (ActivityInfo.isFixedOrientationPortrait(rootScreenOrientation)) { } else if (ActivityInfo.isFixedOrientationPortrait(screenOrientation)) { return ORIENTATION_PORTRAIT; } return ORIENTATION_UNDEFINED; Loading Loading @@ -2196,9 +2196,9 @@ class TaskRecord extends ConfigurationContainer { // In FULLSCREEN mode, always start with empty bounds to indicate "fill parent" outOverrideBounds.setEmpty(); // If the task or its root activity require a different orientation, make it fit the // If the task or its top activity requires a different orientation, make it fit the // available bounds by scaling down its bounds. int forcedOrientation = getRootActivityRequestedOrientation(); int forcedOrientation = getTopActivityRequestedOrientation(); if (forcedOrientation != ORIENTATION_UNDEFINED && forcedOrientation != newParentConfig.orientation) { final Rect parentBounds = newParentConfig.windowConfiguration.getBounds(); Loading services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java +19 −8 Original line number Diff line number Diff line Loading @@ -217,12 +217,17 @@ public class TaskRecordTests extends ActivityTestsBase { info.logicalHeight = fullScreenBounds.height(); ActivityDisplay display = addNewActivityDisplayAt(info, POSITION_TOP); assertTrue(mRootActivityContainer.getActivityDisplay(display.mDisplayId) != null); // Override display orientation. Normally this is available via DisplayContent, but DC // is mocked-out. display.getRequestedOverrideConfiguration().orientation = Configuration.ORIENTATION_LANDSCAPE; display.onRequestedOverrideConfigurationChanged( display.getRequestedOverrideConfiguration()); ActivityStack stack = new StackBuilder(mRootActivityContainer) .setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build(); TaskRecord task = stack.getChildAt(0); ActivityRecord root = task.getRootActivity(); ActivityRecord top = new ActivityBuilder(mService).setTask(task).setStack(stack).build(); assertEquals(root, task.getRootActivity()); ActivityRecord root = task.getTopActivity(); assertEquals(root, task.getTopActivity()); assertEquals(fullScreenBounds, task.getBounds()); Loading @@ -233,16 +238,22 @@ public class TaskRecordTests extends ActivityTestsBase { assertTrue(task.getBounds().width() < task.getBounds().height()); assertEquals(fullScreenBounds.height(), task.getBounds().height()); // Setting non-root app has no effect setActivityRequestedOrientation(root, SCREEN_ORIENTATION_LANDSCAPE); assertTrue(task.getBounds().width() < task.getBounds().height()); // Top activity gets used ActivityRecord top = new ActivityBuilder(mService).setTask(task).setStack(stack).build(); assertEquals(top, task.getTopActivity()); setActivityRequestedOrientation(top, SCREEN_ORIENTATION_LANDSCAPE); assertTrue(task.getBounds().width() > task.getBounds().height()); assertEquals(task.getBounds().width(), fullScreenBounds.width()); // Setting app to unspecified restores setActivityRequestedOrientation(root, SCREEN_ORIENTATION_UNSPECIFIED); setActivityRequestedOrientation(top, SCREEN_ORIENTATION_UNSPECIFIED); assertEquals(fullScreenBounds, task.getBounds()); // Setting app to fixed landscape and changing display setActivityRequestedOrientation(root, SCREEN_ORIENTATION_LANDSCAPE); setActivityRequestedOrientation(top, SCREEN_ORIENTATION_LANDSCAPE); // simulate display orientation changing (normally done via DisplayContent) display.getRequestedOverrideConfiguration().orientation = Configuration.ORIENTATION_PORTRAIT; display.setBounds(fullScreenBoundsPort); assertTrue(task.getBounds().width() > task.getBounds().height()); assertEquals(fullScreenBoundsPort.width(), task.getBounds().width()); Loading Loading
services/core/java/com/android/server/wm/TaskRecord.java +12 −12 Original line number Diff line number Diff line Loading @@ -1278,28 +1278,28 @@ class TaskRecord extends ConfigurationContainer { } /** * Checks if the root activity requires a particular orientation (either by override or * Checks if the top activity requires a particular orientation (either by override or * activityInfo) and returns that. Otherwise, this returns ORIENTATION_UNDEFINED. */ private int getRootActivityRequestedOrientation() { ActivityRecord root = getRootActivity(); private int getTopActivityRequestedOrientation() { ActivityRecord top = getTopActivity(); if (getRequestedOverrideConfiguration().orientation != ORIENTATION_UNDEFINED || root == null) { || top == null) { return getRequestedOverrideConfiguration().orientation; } int rootScreenOrientation = root.getOrientation(); if (rootScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { int screenOrientation = top.getOrientation(); if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { // NOSENSOR means the display's "natural" orientation, so return that. ActivityDisplay display = mStack != null ? mStack.getDisplay() : null; if (display != null && display.mDisplayContent != null) { return mStack.getDisplay().mDisplayContent.getNaturalOrientation(); } } else if (rootScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { } else if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { // LOCKED means the activity's orientation remains unchanged, so return existing value. return root.getConfiguration().orientation; } else if (ActivityInfo.isFixedOrientationLandscape(rootScreenOrientation)) { return top.getConfiguration().orientation; } else if (ActivityInfo.isFixedOrientationLandscape(screenOrientation)) { return ORIENTATION_LANDSCAPE; } else if (ActivityInfo.isFixedOrientationPortrait(rootScreenOrientation)) { } else if (ActivityInfo.isFixedOrientationPortrait(screenOrientation)) { return ORIENTATION_PORTRAIT; } return ORIENTATION_UNDEFINED; Loading Loading @@ -2196,9 +2196,9 @@ class TaskRecord extends ConfigurationContainer { // In FULLSCREEN mode, always start with empty bounds to indicate "fill parent" outOverrideBounds.setEmpty(); // If the task or its root activity require a different orientation, make it fit the // If the task or its top activity requires a different orientation, make it fit the // available bounds by scaling down its bounds. int forcedOrientation = getRootActivityRequestedOrientation(); int forcedOrientation = getTopActivityRequestedOrientation(); if (forcedOrientation != ORIENTATION_UNDEFINED && forcedOrientation != newParentConfig.orientation) { final Rect parentBounds = newParentConfig.windowConfiguration.getBounds(); Loading
services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java +19 −8 Original line number Diff line number Diff line Loading @@ -217,12 +217,17 @@ public class TaskRecordTests extends ActivityTestsBase { info.logicalHeight = fullScreenBounds.height(); ActivityDisplay display = addNewActivityDisplayAt(info, POSITION_TOP); assertTrue(mRootActivityContainer.getActivityDisplay(display.mDisplayId) != null); // Override display orientation. Normally this is available via DisplayContent, but DC // is mocked-out. display.getRequestedOverrideConfiguration().orientation = Configuration.ORIENTATION_LANDSCAPE; display.onRequestedOverrideConfigurationChanged( display.getRequestedOverrideConfiguration()); ActivityStack stack = new StackBuilder(mRootActivityContainer) .setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build(); TaskRecord task = stack.getChildAt(0); ActivityRecord root = task.getRootActivity(); ActivityRecord top = new ActivityBuilder(mService).setTask(task).setStack(stack).build(); assertEquals(root, task.getRootActivity()); ActivityRecord root = task.getTopActivity(); assertEquals(root, task.getTopActivity()); assertEquals(fullScreenBounds, task.getBounds()); Loading @@ -233,16 +238,22 @@ public class TaskRecordTests extends ActivityTestsBase { assertTrue(task.getBounds().width() < task.getBounds().height()); assertEquals(fullScreenBounds.height(), task.getBounds().height()); // Setting non-root app has no effect setActivityRequestedOrientation(root, SCREEN_ORIENTATION_LANDSCAPE); assertTrue(task.getBounds().width() < task.getBounds().height()); // Top activity gets used ActivityRecord top = new ActivityBuilder(mService).setTask(task).setStack(stack).build(); assertEquals(top, task.getTopActivity()); setActivityRequestedOrientation(top, SCREEN_ORIENTATION_LANDSCAPE); assertTrue(task.getBounds().width() > task.getBounds().height()); assertEquals(task.getBounds().width(), fullScreenBounds.width()); // Setting app to unspecified restores setActivityRequestedOrientation(root, SCREEN_ORIENTATION_UNSPECIFIED); setActivityRequestedOrientation(top, SCREEN_ORIENTATION_UNSPECIFIED); assertEquals(fullScreenBounds, task.getBounds()); // Setting app to fixed landscape and changing display setActivityRequestedOrientation(root, SCREEN_ORIENTATION_LANDSCAPE); setActivityRequestedOrientation(top, SCREEN_ORIENTATION_LANDSCAPE); // simulate display orientation changing (normally done via DisplayContent) display.getRequestedOverrideConfiguration().orientation = Configuration.ORIENTATION_PORTRAIT; display.setBounds(fullScreenBoundsPort); assertTrue(task.getBounds().width() > task.getBounds().height()); assertEquals(fullScreenBoundsPort.width(), task.getBounds().width()); Loading