summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-12-20 23:11:02 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-12-20 23:11:02 +0000
commit280b86b35b0cdc36ef6e3e40c879567aa33f79af (patch)
treec364d0b694b609d048ecb1dc11ed30decc15b5a4
parentb6bbfb5cd18e1fcbf620c9b1043c88a60ad2a427 (diff)
parent966c041b7f7cb5ff386ff7ff7f56fdf28bc84168 (diff)
Merge "Use tasks' orientation in multi-window activities"
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java61
2 files changed, 66 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 150328222772..834e924bca59 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -6308,6 +6308,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
resolveSizeCompatModeConfiguration(newParentConfiguration);
} else {
super.resolveOverrideConfiguration(newParentConfiguration);
+ // We ignore activities' requested orientation in multi-window modes. Task level may
+ // take them into consideration when calculating bounds.
+ if (getParent() != null && getParent().inMultiWindowMode()) {
+ resolvedConfig.orientation = Configuration.ORIENTATION_UNDEFINED;
+ }
applyAspectRatio(resolvedConfig.windowConfiguration.getBounds(),
newParentConfiguration.windowConfiguration.getAppBounds(),
newParentConfiguration.windowConfiguration.getBounds());
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index 89723d14090b..65704c891318 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
+import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.os.Process.NOBODY_UID;
@@ -62,6 +63,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.never;
import android.app.ActivityOptions;
+import android.app.WindowConfiguration;
import android.app.servertransaction.ActivityConfigurationChangeItem;
import android.app.servertransaction.ClientTransaction;
import android.app.servertransaction.PauseActivityItem;
@@ -70,6 +72,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Rect;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.platform.test.annotations.Presubmit;
@@ -376,6 +379,64 @@ public class ActivityRecordTests extends ActivityTestsBase {
}
@Test
+ public void ignoreRequestedOrientationInFreeformWindows() {
+ mStack.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM);
+ final Rect stableRect = new Rect();
+ mStack.getDisplay().mDisplayContent.getStableRect(stableRect);
+ final boolean isScreenPortrait = stableRect.width() <= stableRect.height();
+ final Rect bounds = new Rect(stableRect);
+ if (isScreenPortrait) {
+ // Landscape bounds
+ final int newHeight = stableRect.width() - 10;
+ bounds.top = stableRect.top + (stableRect.height() - newHeight) / 2;
+ bounds.bottom = bounds.top + newHeight;
+ } else {
+ // Portrait bounds
+ final int newWidth = stableRect.height() - 10;
+ bounds.left = stableRect.left + (stableRect.width() - newWidth) / 2;
+ bounds.right = bounds.left + newWidth;
+ }
+ mTask.setBounds(bounds);
+
+ // Requests orientation that's different from its bounds.
+ mActivity.setRequestedOrientation(
+ isScreenPortrait ? SCREEN_ORIENTATION_PORTRAIT : SCREEN_ORIENTATION_LANDSCAPE);
+
+ // Asserts it has orientation derived from bounds.
+ assertEquals(isScreenPortrait ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT,
+ mActivity.getConfiguration().orientation);
+ }
+
+ @Test
+ public void ignoreRequestedOrientationInSplitWindows() {
+ mStack.setWindowingMode(WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+ final Rect stableRect = new Rect();
+ mStack.getDisplay().mDisplayContent.getStableRect(stableRect);
+ final boolean isScreenPortrait = stableRect.width() <= stableRect.height();
+ final Rect bounds = new Rect(stableRect);
+ if (isScreenPortrait) {
+ // Landscape bounds
+ final int newHeight = stableRect.width() - 10;
+ bounds.top = stableRect.top + (stableRect.height() - newHeight) / 2;
+ bounds.bottom = bounds.top + newHeight;
+ } else {
+ // Portrait bounds
+ final int newWidth = stableRect.height() - 10;
+ bounds.left = stableRect.left + (stableRect.width() - newWidth) / 2;
+ bounds.right = bounds.left + newWidth;
+ }
+ mTask.setBounds(bounds);
+
+ // Requests orientation that's different from its bounds.
+ mActivity.setRequestedOrientation(
+ isScreenPortrait ? SCREEN_ORIENTATION_PORTRAIT : SCREEN_ORIENTATION_LANDSCAPE);
+
+ // Asserts it has orientation derived from bounds.
+ assertEquals(isScreenPortrait ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT,
+ mActivity.getConfiguration().orientation);
+ }
+
+ @Test
public void testShouldMakeActive_deferredResume() {
mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");