From 6732df291a2c45d7b0bd09b925003941a1a8a0bf Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Mon, 17 Oct 2022 22:33:16 -0700 Subject: [PATCH] ViewRootImpl: Fix display install orientation query for transform hint Apps did not get the correct transform hint when moving between displays because the display install orientation was not updated correctly. Fix by always querying the install orientation instead of relying on the cached value. Bug: 251360251 Test: move app between displays, rotate, check final buffer transforms Change-Id: Icd463de9407b3f22cbea510d65c8d8c1b1c986d6 --- core/java/android/service/wallpaper/WallpaperService.java | 4 +--- core/java/android/view/ViewRootImpl.java | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index e4c26e031738d..2befa15c5689b 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -283,7 +283,6 @@ public abstract class WallpaperService extends Service { private Display mDisplay; private Context mDisplayContext; private int mDisplayState; - private @Surface.Rotation int mDisplayInstallOrientation; private float mWallpaperDimAmount = 0.05f; private float mPreviousWallpaperDimAmount = mWallpaperDimAmount; private float mDefaultDimAmount = mWallpaperDimAmount; @@ -1158,7 +1157,7 @@ public abstract class WallpaperService extends Service { mSurfaceControl, mInsetsState, mTempControls, mSyncSeqIdBundle); final int transformHint = SurfaceControl.rotationToBufferTransform( - (mDisplayInstallOrientation + mDisplay.getRotation()) % 4); + (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4); mSurfaceControl.setTransformHint(transformHint); WindowLayout.computeSurfaceSize(mLayout, maxBounds, mWidth, mHeight, mWinFrames.frame, false /* dragResizing */, mSurfaceSize); @@ -1419,7 +1418,6 @@ public abstract class WallpaperService extends Service { mWallpaperDimAmount = mDefaultDimAmount; mPreviousWallpaperDimAmount = mWallpaperDimAmount; mDisplayState = mDisplay.getState(); - mDisplayInstallOrientation = mDisplay.getInstallOrientation(); if (DEBUG) Log.v(TAG, "onCreate(): " + this); onCreate(mSurfaceHolder); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 1e2b241fbb512..64588d105d7c7 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -428,8 +428,6 @@ public final class ViewRootImpl implements ViewParent, final DisplayManager mDisplayManager; final String mBasePackageName; - private @Surface.Rotation int mDisplayInstallOrientation; - final int[] mTmpLocation = new int[2]; final TypedValue mTmpValue = new TypedValue(); @@ -1134,7 +1132,6 @@ public final class ViewRootImpl implements ViewParent, if (mView == null) { mView = view; - mDisplayInstallOrientation = mDisplay.getInstallOrientation(); mViewLayoutDirectionInitial = mView.getRawLayoutDirection(); mFallbackEventHandler.setView(view); mWindowAttributes.copyFrom(attrs); @@ -1905,7 +1902,6 @@ public final class ViewRootImpl implements ViewParent, updateInternalDisplay(displayId, mView.getResources()); mImeFocusController.onMovedToDisplay(); mAttachInfo.mDisplayState = mDisplay.getState(); - mDisplayInstallOrientation = mDisplay.getInstallOrientation(); // Internal state updated, now notify the view hierarchy. mView.dispatchMovedToDisplay(mDisplay, config); } @@ -8231,7 +8227,7 @@ public final class ViewRootImpl implements ViewParent, } final int transformHint = SurfaceControl.rotationToBufferTransform( - (mDisplayInstallOrientation + mDisplay.getRotation()) % 4); + (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4); WindowLayout.computeSurfaceSize(mWindowAttributes, winConfig.getMaxBounds(), requestedWidth, requestedHeight, mWinFrameInScreen, mPendingDragResizing, mSurfaceSize); @@ -8256,7 +8252,7 @@ public final class ViewRootImpl implements ViewParent, } mLastTransformHint = transformHint; - + mSurfaceControl.setTransformHint(transformHint); if (mAttachInfo.mContentCaptureManager != null) {