Relayout window when rotated landscape <-> seascape

When 180 degree rotation happens there is no real configuration
change, so an application window could miss an update, which
caused visual artifacts.
In this CL layout is forced when rotation changes.

Test: Unit tests in ag/1778638.
Bug: 33607506
Change-Id: Ia1e3375212bade9061d6e1d9679604e67c50da20
This commit is contained in:
Andrii Kulian
2017-01-11 00:36:44 -08:00
parent 8c72ab3ee6
commit b2e3780299
3 changed files with 23 additions and 9 deletions

View File

@@ -1724,6 +1724,7 @@ public final class ViewRootImpl implements ViewParent,
final int surfaceGenerationId = mSurface.getGenerationId(); final int surfaceGenerationId = mSurface.getGenerationId();
final boolean isViewVisible = viewVisibility == View.VISIBLE; final boolean isViewVisible = viewVisibility == View.VISIBLE;
final boolean windowRelayoutWasForced = mForceNextWindowRelayout;
if (mFirst || windowShouldResize || insetsChanged || if (mFirst || windowShouldResize || insetsChanged ||
viewVisibilityChanged || params != null || mForceNextWindowRelayout) { viewVisibilityChanged || params != null || mForceNextWindowRelayout) {
mForceNextWindowRelayout = false; mForceNextWindowRelayout = false;
@@ -1888,7 +1889,7 @@ public final class ViewRootImpl implements ViewParent,
mAttachInfo.mThreadedRenderer.destroy(); mAttachInfo.mThreadedRenderer.destroy();
} }
} else if ((surfaceGenerationId != mSurface.getGenerationId() } else if ((surfaceGenerationId != mSurface.getGenerationId()
|| surfaceSizeChanged) || surfaceSizeChanged || windowRelayoutWasForced)
&& mSurfaceHolder == null && mSurfaceHolder == null
&& mAttachInfo.mThreadedRenderer != null) { && mAttachInfo.mThreadedRenderer != null) {
mFullRedrawNeeded = true; mFullRedrawNeeded = true;

View File

@@ -4465,7 +4465,7 @@ public class WindowManagerService extends IWindowManager.Stub
mRoot.mOrientationChangeComplete = false; mRoot.mOrientationChangeComplete = false;
w.mLastFreezeDuration = 0; w.mLastFreezeDuration = 0;
} }
w.mReportOrientationChanged = true;
}, true /* traverseTopToBottom */); }, true /* traverseTopToBottom */);
if (rotateSeamlessly) { if (rotateSeamlessly) {

View File

@@ -428,6 +428,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
*/ */
int mLastVisibleLayoutRotation = -1; int mLastVisibleLayoutRotation = -1;
/**
* Set when we need to report the orientation change to client to trigger a relayout.
*/
boolean mReportOrientationChanged;
/** /**
* How long we last kept the screen frozen. * How long we last kept the screen frozen.
*/ */
@@ -1093,7 +1098,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|| mFrameSizeChanged || mFrameSizeChanged
|| configChanged || configChanged
|| dragResizingChanged || dragResizingChanged
|| !isResizedWhileNotDragResizingReported()) { || !isResizedWhileNotDragResizingReported()
|| mReportOrientationChanged) {
if (DEBUG_RESIZE || DEBUG_ORIENTATION) { if (DEBUG_RESIZE || DEBUG_ORIENTATION) {
Slog.v(TAG_WM, "Resize reasons for w=" + this + ": " Slog.v(TAG_WM, "Resize reasons for w=" + this + ": "
+ " contentInsetsChanged=" + mContentInsetsChanged + " contentInsetsChanged=" + mContentInsetsChanged
@@ -1108,7 +1114,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
+ " configChanged=" + configChanged + " configChanged=" + configChanged
+ " dragResizingChanged=" + dragResizingChanged + " dragResizingChanged=" + dragResizingChanged
+ " resizedWhileNotDragResizingReported=" + " resizedWhileNotDragResizingReported="
+ isResizedWhileNotDragResizingReported()); + isResizedWhileNotDragResizingReported()
+ " reportOrientationChanged=" + mReportOrientationChanged);
} }
// If it's a dead window left on screen, and the configuration changed, there is nothing // If it's a dead window left on screen, and the configuration changed, there is nothing
@@ -3004,6 +3011,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final Rect stableInsets = mLastStableInsets; final Rect stableInsets = mLastStableInsets;
final Rect outsets = mLastOutsets; final Rect outsets = mLastOutsets;
final boolean reportDraw = mWinAnimator.mDrawState == DRAW_PENDING; final boolean reportDraw = mWinAnimator.mDrawState == DRAW_PENDING;
final boolean reportOrientation = mReportOrientationChanged;
if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
&& mClient instanceof IWindow.Stub) { && mClient instanceof IWindow.Stub) {
// To prevent deadlock simulate one-way call if win.mClient is a local object. // To prevent deadlock simulate one-way call if win.mClient is a local object.
@@ -3012,7 +3020,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
public void run() { public void run() {
try { try {
dispatchResized(frame, overscanInsets, contentInsets, visibleInsets, dispatchResized(frame, overscanInsets, contentInsets, visibleInsets,
stableInsets, outsets, reportDraw, newConfig); stableInsets, outsets, reportDraw, newConfig,
reportOrientation);
} catch (RemoteException e) { } catch (RemoteException e) {
// Not a remote call, RemoteException won't be raised. // Not a remote call, RemoteException won't be raised.
} }
@@ -3020,7 +3029,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}); });
} else { } else {
dispatchResized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets, dispatchResized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets,
outsets, reportDraw, newConfig); outsets, reportDraw, newConfig, reportOrientation);
} }
//TODO (multidisplay): Accessibility supported only for the default display. //TODO (multidisplay): Accessibility supported only for the default display.
@@ -3036,6 +3045,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mFrameSizeChanged = false; mFrameSizeChanged = false;
mResizedWhileNotDragResizingReported = true; mResizedWhileNotDragResizingReported = true;
mWinAnimator.mSurfaceResized = false; mWinAnimator.mSurfaceResized = false;
mReportOrientationChanged = false;
} catch (RemoteException e) { } catch (RemoteException e) {
mOrientationChanging = false; mOrientationChanging = false;
mLastFreezeDuration = (int)(SystemClock.elapsedRealtime() mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
@@ -3076,8 +3086,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
private void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets, private void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw, Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
Configuration newConfig) throws RemoteException { Configuration newConfig, boolean reportOrientation) throws RemoteException {
final boolean forceRelayout = isDragResizeChanged() || mResizedWhileNotDragResizing; final boolean forceRelayout = isDragResizeChanged() || mResizedWhileNotDragResizing
|| reportOrientation;
mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets, outsets, mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets, outsets,
reportDraw, newConfig, getBackdropFrame(frame), reportDraw, newConfig, getBackdropFrame(frame),
@@ -3370,11 +3381,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
pw.print(" mDestroying="); pw.print(mDestroying); pw.print(" mDestroying="); pw.print(mDestroying);
pw.print(" mRemoved="); pw.println(mRemoved); pw.print(" mRemoved="); pw.println(mRemoved);
} }
if (mOrientationChanging || mAppFreezing || mTurnOnScreen) { if (mOrientationChanging || mAppFreezing || mTurnOnScreen
|| mReportOrientationChanged) {
pw.print(prefix); pw.print("mOrientationChanging="); pw.print(prefix); pw.print("mOrientationChanging=");
pw.print(mOrientationChanging); pw.print(mOrientationChanging);
pw.print(" mAppFreezing="); pw.print(mAppFreezing); pw.print(" mAppFreezing="); pw.print(mAppFreezing);
pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen); pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen);
pw.print(" mReportOrientationChanged="); pw.println(mReportOrientationChanged);
} }
if (mLastFreezeDuration != 0) { if (mLastFreezeDuration != 0) {
pw.print(prefix); pw.print("mLastFreezeDuration="); pw.print(prefix); pw.print("mLastFreezeDuration=");