summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2024-04-30 19:58:04 +0800
committer Riddle Hsu <riddlehsu@google.com> 2024-04-30 20:05:07 +0800
commitdaf8921dbdbaa960583974501b774dc34469fbc0 (patch)
tree6951dddd90127f0214e0f79ec4cba109f99f8a22
parentb94064952b8993562945e292fe52570b76780f49 (diff)
Make default orientation of window container unset
The UNSPECIFIED is also a kind of provided orientation. If a window container doesn't provide orientation, it should return UNSET instead. As the implementation getOrientation of various container, e.g. ActivityRecord, TaskFragment, DisplayArea, which return UNSET if it can not decide the orientation. And the UNSET will be reported as UNSPECIFIED in DisplayContent. This could speed up a bit when traversing WindowContainer# getOrientation that skips UNSET directly. Bug: 163976519 Test: testGetOrientation_childSpecified Change-Id: Iec067673e48dab559f5976f15d3e6524e0657b44
-rw-r--r--services/core/java/com/android/server/wm/Task.java3
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java33
4 files changed, 10 insertions, 33 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index f23a440eb0ed..94a59d4c21c2 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -43,7 +43,6 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
-import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -640,8 +639,6 @@ class Task extends TaskFragment {
mLastTaskSnapshotData = _lastSnapshotData != null
? _lastSnapshotData
: new PersistedTaskSnapshotData();
- // Tasks have no set orientation value (including SCREEN_ORIENTATION_UNSPECIFIED).
- setOrientation(SCREEN_ORIENTATION_UNSET);
affinityIntent = _affinityIntent;
affinity = _affinity;
rootAffinity = _rootAffinity;
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 90ac57613cff..4768bd5af423 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -186,7 +186,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// The specified orientation for this window container.
// Shouldn't be accessed directly since subclasses can override getOverrideOrientation.
@ScreenOrientation
- private int mOverrideOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
+ private int mOverrideOrientation = SCREEN_ORIENTATION_UNSET;
/**
* The window container which decides its orientation since the last time
@@ -1683,8 +1683,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
for (int i = mChildren.size() - 1; i >= 0; --i) {
final WindowContainer wc = mChildren.get(i);
- // TODO: Maybe mOverrideOrientation should default to SCREEN_ORIENTATION_UNSET vs.
- // SCREEN_ORIENTATION_UNSPECIFIED?
final int orientation = wc.getOrientation(candidate == SCREEN_ORIENTATION_BEHIND
? SCREEN_ORIENTATION_BEHIND : SCREEN_ORIENTATION_UNSET);
if (orientation == SCREEN_ORIENTATION_BEHIND) {
@@ -1700,7 +1698,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
continue;
}
- if (wc.providesOrientation() || orientation != SCREEN_ORIENTATION_UNSPECIFIED) {
+ if (orientation != SCREEN_ORIENTATION_UNSPECIFIED || wc.providesOrientation()) {
// Use the orientation if the container can provide or requested an explicit
// orientation that isn't SCREEN_ORIENTATION_UNSPECIFIED.
ProtoLog.v(WM_DEBUG_ORIENTATION, "%s is requesting orientation %d (%s)",
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 7356b4376e8a..48dedd32eb3c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -1071,6 +1071,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testAllowsTopmostFullscreenOrientation() {
final DisplayContent dc = createNewDisplay();
+ assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, dc.getOrientation());
dc.getDisplayRotation().setFixedToUserRotation(
IWindowManager.FIXED_TO_USER_ROTATION_DISABLED);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index 48fc2dc4bada..9f85acb98817 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -565,36 +565,17 @@ public class WindowContainerTests extends WindowTestsBase {
@Test
public void testGetOrientation_childSpecified() {
- testGetOrientation_childSpecifiedConfig(false, SCREEN_ORIENTATION_LANDSCAPE,
- SCREEN_ORIENTATION_LANDSCAPE);
- testGetOrientation_childSpecifiedConfig(false, SCREEN_ORIENTATION_UNSET,
- SCREEN_ORIENTATION_UNSPECIFIED);
- }
-
- private void testGetOrientation_childSpecifiedConfig(boolean childVisible, int childOrientation,
- int expectedOrientation) {
final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(mWm);
- final TestWindowContainer root = builder.setLayer(0).build();
+ final TestWindowContainer root = builder.build();
root.setFillsParent(true);
+ assertEquals(SCREEN_ORIENTATION_UNSET, root.getOrientation());
- builder.setIsVisible(childVisible);
-
- if (childOrientation != SCREEN_ORIENTATION_UNSET) {
- builder.setOrientation(childOrientation);
- }
-
- final TestWindowContainer child1 = root.addChildWindow(builder);
- child1.setFillsParent(true);
-
- assertEquals(expectedOrientation, root.getOrientation());
- }
+ final TestWindowContainer child = root.addChildWindow();
+ child.setFillsParent(true);
+ assertEquals(SCREEN_ORIENTATION_UNSET, root.getOrientation());
- @Test
- public void testGetOrientation_Unset() {
- final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(mWm);
- final TestWindowContainer root = builder.setLayer(0).setIsVisible(true).build();
- // Unspecified well because we didn't specify anything...
- assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, root.getOrientation());
+ child.setOverrideOrientation(SCREEN_ORIENTATION_LANDSCAPE);
+ assertEquals(SCREEN_ORIENTATION_LANDSCAPE, root.getOrientation());
}
@Test