From 73a1fa7f2cb27e615945a6d4e530fe9bfc7b35cc Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 21 Sep 2016 13:42:52 -0700 Subject: [PATCH] Avoid entering display freeze mode when using seamless rotation. If we enter seamless rotation through the Activity#setRequestedOrientation->updateOrientationFromAppTokens(conf, ibinder) codepath, it will helpfully try to freeze the display for us after updating the orientation. Normally only updateRotationUncheckedLocked does this and so the seamless rotation logic there would prevent it...however in this path we fail to prevent it and strange strange things happen. Bug: 30642017 Change-Id: I12e94905781975f59384d609d12fa54b9fa4fba0 --- .../java/com/android/server/wm/WindowManagerService.java | 6 +++++- .../java/com/android/server/wm/WindowSurfacePlacer.java | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 707b13780c460..2991e825e99ea 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3790,7 +3790,11 @@ public class WindowManagerService extends IWindowManager.Stub Configuration config = null; if (updateOrientationFromAppTokensLocked(false)) { - if (freezeThisOneIfNeeded != null) { + // If we changed the orientation but mOrientationChangeComplete is + // already true, we used seamless rotation, and we don't need + // to freeze the screen. + if (freezeThisOneIfNeeded != null && + !mWindowPlacerLocked.mOrientationChangeComplete) { AppWindowToken atoken = findAppWindowToken(freezeThisOneIfNeeded); if (atoken != null) { startAppFreezingScreenLocked(atoken); diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java index 5a79da938c605..1f3c52cbf1f9b 100644 --- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java +++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java @@ -101,6 +101,10 @@ class WindowSurfacePlacer { static final int SET_WALLPAPER_ACTION_PENDING = 1 << 5; boolean mWallpaperMayChange = false; + // During an orientation change, we track whether all windows have rendered + // at the new orientation, and this will be false from changing orientation until that occurs. + // For seamless rotation cases this always stays true, as the windows complete their orientation + // changes 1 by 1 without disturbing global state. boolean mOrientationChangeComplete = true; boolean mWallpaperActionPending = false;