Merge "Calculate wallpaper offset with associated display info" into rvc-dev
diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java
index 29a2e18..e43f4b4 100644
--- a/services/core/java/com/android/server/wm/WallpaperController.java
+++ b/services/core/java/com/android/server/wm/WallpaperController.java
@@ -304,7 +304,11 @@
}
}
- boolean updateWallpaperOffset(WindowState wallpaperWin, int dw, int dh, boolean sync) {
+ boolean updateWallpaperOffset(WindowState wallpaperWin, boolean sync) {
+ final DisplayInfo displayInfo = wallpaperWin.getDisplayInfo();
+ final int dw = displayInfo.logicalWidth;
+ final int dh = displayInfo.logicalHeight;
+
int xOffset = 0;
int yOffset = 0;
boolean rawChanged = false;
@@ -444,10 +448,6 @@
}
private void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
- final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
- final int dw = displayInfo.logicalWidth;
- final int dh = displayInfo.logicalHeight;
-
WindowState target = mWallpaperTarget;
if (target != null) {
if (target.mWallpaperX >= 0) {
@@ -484,7 +484,7 @@
}
for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
- mWallpaperTokens.get(curTokenNdx).updateWallpaperOffset(dw, dh, sync);
+ mWallpaperTokens.get(curTokenNdx).updateWallpaperOffset(sync);
}
}
diff --git a/services/core/java/com/android/server/wm/WallpaperWindowToken.java b/services/core/java/com/android/server/wm/WallpaperWindowToken.java
index e29580b..203ca25 100644
--- a/services/core/java/com/android/server/wm/WallpaperWindowToken.java
+++ b/services/core/java/com/android/server/wm/WallpaperWindowToken.java
@@ -73,11 +73,11 @@
}
}
- void updateWallpaperOffset(int dw, int dh, boolean sync) {
+ void updateWallpaperOffset(boolean sync) {
final WallpaperController wallpaperController = mDisplayContent.mWallpaperController;
for (int wallpaperNdx = mChildren.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
final WindowState wallpaper = mChildren.get(wallpaperNdx);
- if (wallpaperController.updateWallpaperOffset(wallpaper, dw, dh, sync)) {
+ if (wallpaperController.updateWallpaperOffset(wallpaper, sync)) {
// We only want to be synchronous with one wallpaper.
sync = false;
}
@@ -85,10 +85,6 @@
}
void updateWallpaperVisibility(boolean visible) {
- final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
- final int dw = displayInfo.logicalWidth;
- final int dh = displayInfo.logicalHeight;
-
if (isVisible() != visible) {
// Need to do a layout to ensure the wallpaper now has the correct size.
mDisplayContent.setLayoutNeeded();
@@ -98,7 +94,7 @@
for (int wallpaperNdx = mChildren.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
final WindowState wallpaper = mChildren.get(wallpaperNdx);
if (visible) {
- wallpaperController.updateWallpaperOffset(wallpaper, dw, dh, false);
+ wallpaperController.updateWallpaperOffset(wallpaper, false /* sync */);
}
wallpaper.dispatchWallpaperVisibility(visible);
@@ -145,19 +141,11 @@
}
}
- DisplayInfo displayInfo = getFixedRotationTransformDisplayInfo();
- if (displayInfo == null) {
- displayInfo = mDisplayContent.getDisplayInfo();
- }
-
- final int dw = displayInfo.logicalWidth;
- final int dh = displayInfo.logicalHeight;
-
for (int wallpaperNdx = mChildren.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
final WindowState wallpaper = mChildren.get(wallpaperNdx);
if (visible) {
- wallpaperController.updateWallpaperOffset(wallpaper, dw, dh, false);
+ wallpaperController.updateWallpaperOffset(wallpaper, false /* sync */);
}
// First, make sure the client has the current visibility state.
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 8e45752..ae668f1 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2332,9 +2332,7 @@
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
if (toBeDisplayed && win.mIsWallpaper) {
- DisplayInfo displayInfo = displayContent.getDisplayInfo();
- displayContent.mWallpaperController.updateWallpaperOffset(
- win, displayInfo.logicalWidth, displayInfo.logicalHeight, false);
+ displayContent.mWallpaperController.updateWallpaperOffset(win, false /* sync */);
}
if (win.mActivityRecord != null) {
win.mActivityRecord.updateReportedVisibilityLocked();
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 7dcf375..b87d181 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1101,7 +1101,6 @@
}
}
- final ActivityStack stack = getRootTask();
layoutDisplayFrame = new Rect(windowFrames.mDisplayFrame);
windowFrames.mDisplayFrame.set(windowFrames.mContainingFrame);
layoutXDiff = mInsetFrame.left - windowFrames.mContainingFrame.left;
@@ -1205,8 +1204,7 @@
if (mIsWallpaper && (fw != windowFrames.mFrame.width()
|| fh != windowFrames.mFrame.height())) {
- dc.mWallpaperController.updateWallpaperOffset(this,
- displayInfo.logicalWidth, displayInfo.logicalHeight, false /* sync */);
+ dc.mWallpaperController.updateWallpaperOffset(this, false /* sync */);
}
// Calculate relative frame
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 9cfee34..38b3d76 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -1039,6 +1039,13 @@
assertEquals(config90.orientation, app.getConfiguration().orientation);
assertEquals(config90.windowConfiguration.getBounds(), app.getBounds());
+ // Force the negative offset to verify it can be updated.
+ mWallpaperWindow.mWinAnimator.mXOffset = mWallpaperWindow.mWinAnimator.mYOffset = -1;
+ assertTrue(mDisplayContent.mWallpaperController.updateWallpaperOffset(mWallpaperWindow,
+ false /* sync */));
+ assertThat(mWallpaperWindow.mWinAnimator.mXOffset).isGreaterThan(-1);
+ assertThat(mWallpaperWindow.mWinAnimator.mYOffset).isGreaterThan(-1);
+
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);
// The animation in old rotation should be cancelled.