Merge "Allow foreground AppWindowToken to influence orientation." into oc-dr1-dev
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index 63890bf..c4ff455 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -1311,7 +1311,7 @@
// going to the bottom. Allowing closing {@link AppWindowToken} to participate can lead to
// an Activity in another task being started in the wrong orientation during the transition.
if (!(sendingToBottom || mService.mClosingApps.contains(this))
- && (isVisible() || mService.mOpeningApps.contains(this))) {
+ && (isVisible() || mService.mOpeningApps.contains(this) || isOnTop())) {
return mOrientation;
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 55c0612f..4d77d40 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -3308,6 +3308,13 @@
setLayoutNeeded();
}
+
+ @Override
+ boolean isOnTop() {
+ // Considered always on top
+ return true;
+ }
+
@Override
void positionChildAt(int position, TaskStack child, boolean includingParents) {
if (StackId.isAlwaysOnTop(child.mStackId) && position != POSITION_TOP) {
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 600bc5c..3df73d7 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -472,6 +472,13 @@
return false;
}
+ /**
+a * Returns whether this child is on top of the window hierarchy.
+ */
+ boolean isOnTop() {
+ return getParent().getTopChild() == this && getParent().isOnTop();
+ }
+
/** Returns the top child container. */
E getTopChild() {
return mChildren.peekLast();
diff --git a/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java
index 36083bf..b09601e 100644
--- a/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java
@@ -185,6 +185,11 @@
assertEquals(SCREEN_ORIENTATION_UNSET, token.getOrientation());
// Can specify orientation if the current orientation candidate is orientation behind.
assertEquals(SCREEN_ORIENTATION_LANDSCAPE, token.getOrientation(SCREEN_ORIENTATION_BEHIND));
+
+ token.sendingToBottom = false;
+ token.setIsOnTop(true);
+ // Allow for token to provide orientation hidden if on top and not being sent to bottom.
+ assertEquals(SCREEN_ORIENTATION_LANDSCAPE, token.getOrientation());
}
@Test
diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowTestUtils.java b/services/tests/servicestests/src/com/android/server/wm/WindowTestUtils.java
index b83532c..7ff1110 100644
--- a/services/tests/servicestests/src/com/android/server/wm/WindowTestUtils.java
+++ b/services/tests/servicestests/src/com/android/server/wm/WindowTestUtils.java
@@ -89,6 +89,7 @@
/** Used so we can gain access to some protected members of the {@link AppWindowToken} class. */
public static class TestAppWindowToken extends AppWindowToken {
+ boolean mOnTop = false;
TestAppWindowToken(DisplayContent dc) {
super(dc.mService, new IApplicationToken.Stub() {}, false, dc, true /* fillsParent */,
@@ -125,6 +126,15 @@
int positionInParent() {
return getParent().mChildren.indexOf(this);
}
+
+ void setIsOnTop(boolean onTop) {
+ mOnTop = onTop;
+ }
+
+ @Override
+ boolean isOnTop() {
+ return mOnTop;
+ }
}
/* Used so we can gain access to some protected members of the {@link WindowToken} class */