Merge "Fix punch hole wrong position during rotation" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a62d58a7cb
@@ -159,6 +159,8 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected DisplayDecorationSupport mHwcScreenDecorationSupport;
|
protected DisplayDecorationSupport mHwcScreenDecorationSupport;
|
||||||
private Display.Mode mDisplayMode;
|
private Display.Mode mDisplayMode;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected DisplayInfo mDisplayInfo = new DisplayInfo();
|
||||||
|
|
||||||
private CameraAvailabilityListener.CameraTransitionCallback mCameraTransitionCallback =
|
private CameraAvailabilityListener.CameraTransitionCallback mCameraTransitionCallback =
|
||||||
new CameraAvailabilityListener.CameraTransitionCallback() {
|
new CameraAvailabilityListener.CameraTransitionCallback() {
|
||||||
@@ -325,9 +327,10 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
private void startOnScreenDecorationsThread() {
|
private void startOnScreenDecorationsThread() {
|
||||||
mWindowManager = mContext.getSystemService(WindowManager.class);
|
mWindowManager = mContext.getSystemService(WindowManager.class);
|
||||||
mDisplayManager = mContext.getSystemService(DisplayManager.class);
|
mDisplayManager = mContext.getSystemService(DisplayManager.class);
|
||||||
mRotation = mContext.getDisplay().getRotation();
|
mContext.getDisplay().getDisplayInfo(mDisplayInfo);
|
||||||
mDisplayMode = mContext.getDisplay().getMode();
|
mRotation = mDisplayInfo.rotation;
|
||||||
mDisplayUniqueId = mContext.getDisplay().getUniqueId();
|
mDisplayMode = mDisplayInfo.getMode();
|
||||||
|
mDisplayUniqueId = mDisplayInfo.uniqueId;
|
||||||
mRoundedCornerResDelegate = new RoundedCornerResDelegate(mContext.getResources(),
|
mRoundedCornerResDelegate = new RoundedCornerResDelegate(mContext.getResources(),
|
||||||
mDisplayUniqueId);
|
mDisplayUniqueId);
|
||||||
mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
|
mRoundedCornerResDelegate.setPhysicalPixelDisplaySizeRatio(
|
||||||
@@ -351,8 +354,9 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisplayChanged(int displayId) {
|
public void onDisplayChanged(int displayId) {
|
||||||
final int newRotation = mContext.getDisplay().getRotation();
|
mContext.getDisplay().getDisplayInfo(mDisplayInfo);
|
||||||
final Display.Mode newDisplayMode = mContext.getDisplay().getMode();
|
final int newRotation = mDisplayInfo.rotation;
|
||||||
|
final Display.Mode newDisplayMode = mDisplayInfo.getMode();
|
||||||
if ((mOverlays != null || mScreenDecorHwcWindow != null)
|
if ((mOverlays != null || mScreenDecorHwcWindow != null)
|
||||||
&& (mRotation != newRotation
|
&& (mRotation != newRotation
|
||||||
|| displayModeChanged(mDisplayMode, newDisplayMode))) {
|
|| displayModeChanged(mDisplayMode, newDisplayMode))) {
|
||||||
@@ -398,7 +402,7 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String newUniqueId = mContext.getDisplay().getUniqueId();
|
final String newUniqueId = mDisplayInfo.uniqueId;
|
||||||
if (!Objects.equals(newUniqueId, mDisplayUniqueId)) {
|
if (!Objects.equals(newUniqueId, mDisplayUniqueId)) {
|
||||||
mDisplayUniqueId = newUniqueId;
|
mDisplayUniqueId = newUniqueId;
|
||||||
final DisplayDecorationSupport newScreenDecorationSupport =
|
final DisplayDecorationSupport newScreenDecorationSupport =
|
||||||
@@ -923,11 +927,10 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
float getPhysicalPixelDisplaySizeRatio() {
|
float getPhysicalPixelDisplaySizeRatio() {
|
||||||
final Point stableDisplaySize = mDisplayManager.getStableDisplaySize();
|
final Point stableDisplaySize = mDisplayManager.getStableDisplaySize();
|
||||||
final DisplayInfo displayInfo = new DisplayInfo();
|
mContext.getDisplay().getDisplayInfo(mDisplayInfo);
|
||||||
mContext.getDisplay().getDisplayInfo(displayInfo);
|
|
||||||
return DisplayUtils.getPhysicalPixelDisplaySizeRatio(
|
return DisplayUtils.getPhysicalPixelDisplaySizeRatio(
|
||||||
stableDisplaySize.x, stableDisplaySize.y, displayInfo.getNaturalWidth(),
|
stableDisplaySize.x, stableDisplaySize.y, mDisplayInfo.getNaturalWidth(),
|
||||||
displayInfo.getNaturalHeight());
|
mDisplayInfo.getNaturalHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1004,11 +1007,12 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
"must call on " + mHandler.getLooper().getThread()
|
"must call on " + mHandler.getLooper().getThread()
|
||||||
+ ", but was " + Thread.currentThread());
|
+ ", but was " + Thread.currentThread());
|
||||||
|
|
||||||
int newRotation = mContext.getDisplay().getRotation();
|
mContext.getDisplay().getDisplayInfo(mDisplayInfo);
|
||||||
|
final int newRotation = mDisplayInfo.rotation;
|
||||||
if (mRotation != newRotation) {
|
if (mRotation != newRotation) {
|
||||||
mDotViewController.setNewRotation(newRotation);
|
mDotViewController.setNewRotation(newRotation);
|
||||||
}
|
}
|
||||||
final Display.Mode newMod = mContext.getDisplay().getMode();
|
final Display.Mode newMod = mDisplayInfo.getMode();
|
||||||
|
|
||||||
if (!mPendingConfigChange
|
if (!mPendingConfigChange
|
||||||
&& (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
|
&& (newRotation != mRotation || displayModeChanged(mDisplayMode, newMod))) {
|
||||||
@@ -1220,7 +1224,7 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
@Override
|
@Override
|
||||||
public void updateRotation(int rotation) {
|
public void updateRotation(int rotation) {
|
||||||
mRotation = rotation;
|
mRotation = rotation;
|
||||||
updateCutout();
|
super.updateRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
|
@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
|
||||||
@@ -1431,9 +1435,10 @@ public class ScreenDecorations extends CoreStartable implements Tunable , Dumpab
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreDraw() {
|
public boolean onPreDraw() {
|
||||||
final int displayRotation = mContext.getDisplay().getRotation();
|
mContext.getDisplay().getDisplayInfo(mDisplayInfo);
|
||||||
final Display.Mode displayMode = mContext.getDisplay().getMode();
|
final int displayRotation = mDisplayInfo.rotation;
|
||||||
if (displayRotation != mRotation && displayModeChanged(mDisplayMode, displayMode)
|
final Display.Mode displayMode = mDisplayInfo.getMode();
|
||||||
|
if ((displayRotation != mRotation || displayModeChanged(mDisplayMode, displayMode))
|
||||||
&& !mPendingConfigChange) {
|
&& !mPendingConfigChange) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
if (displayRotation != mRotation) {
|
if (displayRotation != mRotation) {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ import android.util.RotationUtils;
|
|||||||
import android.util.Size;
|
import android.util.Size;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.DisplayCutout;
|
import android.view.DisplayCutout;
|
||||||
|
import android.view.DisplayInfo;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -136,6 +137,8 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
private CornerDecorProvider mPrivacyDotBottomRightDecorProvider;
|
private CornerDecorProvider mPrivacyDotBottomRightDecorProvider;
|
||||||
@Mock
|
@Mock
|
||||||
private Display.Mode mDisplayMode;
|
private Display.Mode mDisplayMode;
|
||||||
|
@Mock
|
||||||
|
private DisplayInfo mDisplayInfo;
|
||||||
private PrivacyDotViewController.ShowingListener mPrivacyDotShowingListener;
|
private PrivacyDotViewController.ShowingListener mPrivacyDotShowingListener;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -159,7 +162,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
when(mContext.getDisplay()).thenReturn(mDisplay);
|
when(mContext.getDisplay()).thenReturn(mDisplay);
|
||||||
// Not support hwc layer by default
|
// Not support hwc layer by default
|
||||||
doReturn(null).when(mDisplay).getDisplayDecorationSupport();
|
doReturn(null).when(mDisplay).getDisplayDecorationSupport();
|
||||||
doReturn(mDisplayMode).when(mDisplay).getMode();
|
doReturn(mDisplayMode).when(mDisplayInfo).getMode();
|
||||||
|
|
||||||
when(mMockTypedArray.length()).thenReturn(0);
|
when(mMockTypedArray.length()).thenReturn(0);
|
||||||
mPrivacyDotTopLeftDecorProvider = spy(new PrivacyDotCornerDecorProviderImpl(
|
mPrivacyDotTopLeftDecorProvider = spy(new PrivacyDotCornerDecorProviderImpl(
|
||||||
@@ -214,6 +217,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
mExecutor.runAllReady();
|
mExecutor.runAllReady();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mScreenDecorations.mDisplayInfo = mDisplayInfo;
|
||||||
doReturn(1f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
|
doReturn(1f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
|
||||||
reset(mTunerService);
|
reset(mTunerService);
|
||||||
|
|
||||||
@@ -977,7 +981,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
getTestsDrawable(com.android.systemui.tests.R.drawable.rounded4px)
|
getTestsDrawable(com.android.systemui.tests.R.drawable.rounded4px)
|
||||||
/* roundedBottomDrawable */,
|
/* roundedBottomDrawable */,
|
||||||
0 /* roundedPadding */, false /* fillCutout */, true /* privacyDot */);
|
0 /* roundedPadding */, false /* fillCutout */, true /* privacyDot */);
|
||||||
doReturn(Surface.ROTATION_0).when(mDisplay).getRotation();
|
mDisplayInfo.rotation = Surface.ROTATION_0;
|
||||||
|
|
||||||
mScreenDecorations.start();
|
mScreenDecorations.start();
|
||||||
|
|
||||||
@@ -991,7 +995,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
getTestsDrawable(com.android.systemui.tests.R.drawable.rounded5px)
|
getTestsDrawable(com.android.systemui.tests.R.drawable.rounded5px)
|
||||||
/* roundedBottomDrawable */,
|
/* roundedBottomDrawable */,
|
||||||
0 /* roundedPadding */, false /* fillCutout */, true /* privacyDot */);
|
0 /* roundedPadding */, false /* fillCutout */, true /* privacyDot */);
|
||||||
doReturn(Surface.ROTATION_270).when(mDisplay).getRotation();
|
mDisplayInfo.rotation = Surface.ROTATION_270;
|
||||||
|
|
||||||
mScreenDecorations.onConfigurationChanged(null);
|
mScreenDecorations.onConfigurationChanged(null);
|
||||||
|
|
||||||
@@ -1274,7 +1278,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
final ScreenDecorHwcLayer hwcLayer = mScreenDecorations.mScreenDecorHwcLayer;
|
final ScreenDecorHwcLayer hwcLayer = mScreenDecorations.mScreenDecorHwcLayer;
|
||||||
spyOn(hwcLayer);
|
spyOn(hwcLayer);
|
||||||
doReturn(mDisplay).when(hwcLayer).getDisplay();
|
doReturn(mDisplay).when(hwcLayer).getDisplay();
|
||||||
doReturn(mDisplayMode).when(mDisplay).getMode();
|
|
||||||
|
|
||||||
mScreenDecorations.mDisplayListener.onDisplayChanged(1);
|
mScreenDecorations.mDisplayListener.onDisplayChanged(1);
|
||||||
|
|
||||||
@@ -1298,7 +1301,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
mScreenDecorations.mCutoutViews[BOUNDS_POSITION_TOP];
|
mScreenDecorations.mCutoutViews[BOUNDS_POSITION_TOP];
|
||||||
spyOn(cutoutView);
|
spyOn(cutoutView);
|
||||||
doReturn(mDisplay).when(cutoutView).getDisplay();
|
doReturn(mDisplay).when(cutoutView).getDisplay();
|
||||||
doReturn(mDisplayMode).when(mDisplay).getMode();
|
|
||||||
|
|
||||||
mScreenDecorations.mDisplayListener.onDisplayChanged(1);
|
mScreenDecorations.mDisplayListener.onDisplayChanged(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user