summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java4
-rw-r--r--services/core/java/com/android/server/wm/Task.java5
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java77
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java8
4 files changed, 55 insertions, 39 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index fece980065b0..9beac65643a6 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -2011,9 +2011,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
mDisplay.getDisplayInfo(mDisplayInfo);
mDisplay.getMetrics(mDisplayMetrics);
- for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) {
- mTaskStackContainers.getChildAt(i).updateDisplayInfo(null);
- }
+ onDisplayChanged(this);
}
void initializeDisplayBaseInfo() {
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 30eca89a88ec..c9800f85cb22 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -237,7 +237,7 @@ class Task extends WindowContainer<AppWindowToken> {
super.onParentSet();
// Update task bounds if needed.
- updateDisplayInfo(getDisplayContent());
+ adjustBoundsForDisplayChangeIfNeeded(getDisplayContent());
if (getWindowConfiguration().windowsAreScaleable()) {
// We force windows out of SCALING_MODE_FREEZE so that we can continue to animate them
@@ -303,6 +303,7 @@ class Task extends WindowContainer<AppWindowToken> {
@Override
void onDisplayChanged(DisplayContent dc) {
updateSurfaceSize(dc);
+ adjustBoundsForDisplayChangeIfNeeded(dc);
super.onDisplayChanged(dc);
}
@@ -501,7 +502,7 @@ class Task extends WindowContainer<AppWindowToken> {
return mDragResizeMode;
}
- void updateDisplayInfo(final DisplayContent displayContent) {
+ private void adjustBoundsForDisplayChangeIfNeeded(final DisplayContent displayContent) {
if (displayContent == null) {
return;
}
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 4dc2b8ec8858..056ec0e52cc2 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -418,32 +418,6 @@ public class TaskStack extends WindowContainer<Task> implements
getBounds(out);
}
- void updateDisplayInfo(Rect bounds) {
- if (mDisplayContent == null) {
- return;
- }
-
- for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) {
- mChildren.get(taskNdx).updateDisplayInfo(mDisplayContent);
- }
- if (bounds != null) {
- setBounds(bounds);
- return;
- } else if (matchParentBounds()) {
- setBounds(null);
- return;
- }
-
- mTmpRect2.set(getRawBounds());
- final int newRotation = mDisplayContent.getDisplayInfo().rotation;
- final int newDensity = mDisplayContent.getDisplayInfo().logicalDensityDpi;
- if (mRotation == newRotation && mDensity == newDensity) {
- setBounds(mTmpRect2);
- }
-
- // If the rotation or density didn't match, we'll update it in onConfigurationChanged.
- }
-
/**
* Updates the passed-in {@code inOutBounds} based on how it would change when this container's
* override configuration is applied to the specified {@code parentConfig} and
@@ -820,16 +794,24 @@ public class TaskStack extends WindowContainer<Task> implements
@Override
void onDisplayChanged(DisplayContent dc) {
- if (mDisplayContent != null) {
+ if (mDisplayContent != null && mDisplayContent != dc) {
throw new IllegalStateException("onDisplayChanged: Already attached");
}
+ final boolean movedToNewDisplay = mDisplayContent == null;
mDisplayContent = dc;
- updateBoundsForWindowModeChange();
- mAnimationBackgroundSurface = makeChildSurface(null).setColorLayer(true)
- .setName("animation background stackId=" + mStackId)
- .build();
+ if (movedToNewDisplay) {
+ updateBoundsForWindowModeChange();
+ } else {
+ updateBoundsForDisplayChanges();
+ }
+
+ if (mAnimationBackgroundSurface != null) {
+ mAnimationBackgroundSurface = makeChildSurface(null).setColorLayer(true)
+ .setName("animation background stackId=" + mStackId)
+ .build();
+ }
super.onDisplayChanged(dc);
}
@@ -845,10 +827,41 @@ public class TaskStack extends WindowContainer<Task> implements
}, true);
}
- updateDisplayInfo(bounds);
+ setBoundsForWindowModeChange(bounds);
updateSurfaceBounds();
}
+ private void setBoundsForWindowModeChange(Rect bounds) {
+ if (mDisplayContent == null) {
+ return;
+ }
+
+ if (bounds != null) {
+ setBounds(bounds);
+ return;
+ }
+
+ updateBoundsForDisplayChanges();
+ }
+
+ private void updateBoundsForDisplayChanges() {
+ // Avoid setting override bounds to bounds inherited from parent if there was no override
+ // bounds set.
+ if (matchParentBounds()) {
+ setBounds(null);
+ return;
+ }
+
+ mTmpRect2.set(getRawBounds());
+ final int newRotation = mDisplayContent.getDisplayInfo().rotation;
+ final int newDensity = mDisplayContent.getDisplayInfo().logicalDensityDpi;
+ if (mRotation == newRotation && mDensity == newDensity) {
+ setBounds(mTmpRect2);
+ }
+
+ // If the rotation or density didn't match, we'll update it in onConfigurationChanged.
+ }
+
private Rect calculateBoundsForWindowModeChange() {
final boolean inSplitScreenPrimary = inSplitScreenPrimaryWindowingMode();
final TaskStack splitScreenStack =
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index abc382656db3..266006db9987 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -42,8 +42,10 @@ import android.view.MagnificationSpec;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Builder;
import android.view.SurfaceSession;
+
import com.android.internal.util.ToBooleanFunction;
import com.android.server.wm.SurfaceAnimator.Animatable;
+
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.LinkedList;
@@ -501,8 +503,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
/**
- * Notify that the display this container is on has changed.
- * @param dc The new display this container is on.
+ * Notify that the display this container is on has changed. This could be either this container
+ * is moved to a new display, or some configurations on the display it is on changes.
+ *
+ * @param dc The display this container is on after changes.
*/
void onDisplayChanged(DisplayContent dc) {
for (int i = mChildren.size() - 1; i >= 0; --i) {