Loading services/core/java/com/android/server/wm/AppWindowToken.java +4 −0 Original line number Diff line number Diff line Loading @@ -394,6 +394,10 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree startingWindow.mPolicyVisibility = false; startingWindow.mPolicyVisibilityAfterAnim = false; } // We are becoming visible, so better freeze the screen with the windows that are // getting visible so we also wait for them. forAllWindows(mService::makeWindowFreezingScreenIfNeededLocked, true); } if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this Loading services/core/java/com/android/server/wm/TaskSnapshotSurface.java +17 −2 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ class TaskSnapshotSurface implements StartingSurface { private final Paint mBackgroundPaint = new Paint(); private final int mStatusBarColor; @VisibleForTesting final SystemBarBackgroundPainter mSystemBarBackgroundPainter; private final int mOrientationOnCreation; static TaskSnapshotSurface create(WindowManagerService service, AppWindowToken token, TaskSnapshot snapshot) { Loading @@ -146,6 +147,7 @@ class TaskSnapshotSurface implements StartingSurface { final int sysUiVis; final int windowFlags; final int windowPrivateFlags; final int currentOrientation; synchronized (service.mWindowMap) { final WindowState mainWindow = token.findMainWindow(); if (mainWindow == null) { Loading Loading @@ -183,6 +185,7 @@ class TaskSnapshotSurface implements StartingSurface { } else { taskBounds = null; } currentOrientation = mainWindow.getConfiguration().orientation; } try { final int res = session.addToDisplay(window, window.mSeq, layoutParams, Loading @@ -197,7 +200,8 @@ class TaskSnapshotSurface implements StartingSurface { } final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window, surface, snapshot, layoutParams.getTitle(), backgroundColor, statusBarColor, navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds); navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds, currentOrientation); window.setOuter(snapshotSurface); try { session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, tmpFrame, Loading @@ -215,7 +219,7 @@ class TaskSnapshotSurface implements StartingSurface { TaskSnapshotSurface(WindowManagerService service, Window window, Surface surface, TaskSnapshot snapshot, CharSequence title, int backgroundColor, int statusBarColor, int navigationBarColor, int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds) { Rect taskBounds, int currentOrientation) { mService = service; mHandler = new Handler(mService.mH.getLooper()); mSession = WindowManagerGlobal.getWindowSession(); Loading @@ -228,6 +232,7 @@ class TaskSnapshotSurface implements StartingSurface { mSystemBarBackgroundPainter = new SystemBarBackgroundPainter(windowFlags, windowPrivateFlags, sysUiVis, statusBarColor, navigationBarColor); mStatusBarColor = statusBarColor; mOrientationOnCreation = currentOrientation; } @Override Loading Loading @@ -394,6 +399,7 @@ class TaskSnapshotSurface implements StartingSurface { static class Window extends BaseIWindow { private TaskSnapshotSurface mOuter; public void setOuter(TaskSnapshotSurface outer) { mOuter = outer; } Loading @@ -403,6 +409,15 @@ class TaskSnapshotSurface implements StartingSurface { Rect stableInsets, Rect outsets, boolean reportDraw, MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout, boolean alwaysConsumeNavBar, int displayId) { if (mergedConfiguration != null && mOuter != null && mOuter.mOrientationOnCreation != mergedConfiguration.getMergedConfiguration().orientation) { // The orientation of the screen is changing. We better remove the snapshot ASAP as // we are going to wait on the new window in any case to unfreeze the screen, and // the starting window is not needed anymore. sHandler.post(mOuter::remove); } if (reportDraw) { sHandler.obtainMessage(MSG_REPORT_DRAW, mOuter).sendToTarget(); } Loading services/core/java/com/android/server/wm/WindowStateAnimator.java +21 −19 Original line number Diff line number Diff line Loading @@ -1524,7 +1524,10 @@ class WindowStateAnimator { void prepareSurfaceLocked(final boolean recoveringMemory) { final WindowState w = mWin; if (!hasSurface()) { if (w.mOrientationChanging) { // There is no need to wait for an animation change if our window is gone for layout // already as we'll never be visible. if (w.mOrientationChanging && w.isGoneForLayoutLw()) { if (DEBUG_ORIENTATION) { Slog.v(TAG, "Orientation change skips hidden " + w); } Loading Loading @@ -1557,13 +1560,11 @@ class WindowStateAnimator { hide("prepareSurfaceLocked"); mWallpaperControllerLocked.hideWallpapers(w); // If we are waiting for this window to handle an // orientation change, well, it is hidden, so // doesn't really matter. Note that this does // introduce a potential glitch if the window // becomes unhidden before it has drawn for the // new orientation. if (w.mOrientationChanging) { // If we are waiting for this window to handle an orientation change. If this window is // really hidden (gone for layout), there is no point in still waiting for it. // Note that this does introduce a potential glitch if the window becomes unhidden // before it has drawn for the new orientation. if (w.mOrientationChanging && w.isGoneForLayoutLw()) { w.mOrientationChanging = false; if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change skips hidden " + w); Loading Loading @@ -1630,7 +1631,6 @@ class WindowStateAnimator { displayed = true; } if (displayed) { if (w.mOrientationChanging) { if (!w.isDrawnLw()) { mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE; Loading @@ -1642,6 +1642,8 @@ class WindowStateAnimator { if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w); } } if (displayed) { w.mToken.hasVisible = true; } } Loading services/tests/servicestests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase { final TaskSnapshot snapshot = new TaskSnapshot(buffer, ORIENTATION_PORTRAIT, contentInsets, false, 1.0f); mSurface = new TaskSnapshotSurface(sWm, new Window(), new Surface(), snapshot, "Test", Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds); Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds, ORIENTATION_PORTRAIT); } private void setupSurface(int width, int height) { Loading Loading
services/core/java/com/android/server/wm/AppWindowToken.java +4 −0 Original line number Diff line number Diff line Loading @@ -394,6 +394,10 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree startingWindow.mPolicyVisibility = false; startingWindow.mPolicyVisibilityAfterAnim = false; } // We are becoming visible, so better freeze the screen with the windows that are // getting visible so we also wait for them. forAllWindows(mService::makeWindowFreezingScreenIfNeededLocked, true); } if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this Loading
services/core/java/com/android/server/wm/TaskSnapshotSurface.java +17 −2 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ class TaskSnapshotSurface implements StartingSurface { private final Paint mBackgroundPaint = new Paint(); private final int mStatusBarColor; @VisibleForTesting final SystemBarBackgroundPainter mSystemBarBackgroundPainter; private final int mOrientationOnCreation; static TaskSnapshotSurface create(WindowManagerService service, AppWindowToken token, TaskSnapshot snapshot) { Loading @@ -146,6 +147,7 @@ class TaskSnapshotSurface implements StartingSurface { final int sysUiVis; final int windowFlags; final int windowPrivateFlags; final int currentOrientation; synchronized (service.mWindowMap) { final WindowState mainWindow = token.findMainWindow(); if (mainWindow == null) { Loading Loading @@ -183,6 +185,7 @@ class TaskSnapshotSurface implements StartingSurface { } else { taskBounds = null; } currentOrientation = mainWindow.getConfiguration().orientation; } try { final int res = session.addToDisplay(window, window.mSeq, layoutParams, Loading @@ -197,7 +200,8 @@ class TaskSnapshotSurface implements StartingSurface { } final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window, surface, snapshot, layoutParams.getTitle(), backgroundColor, statusBarColor, navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds); navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds, currentOrientation); window.setOuter(snapshotSurface); try { session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, tmpFrame, Loading @@ -215,7 +219,7 @@ class TaskSnapshotSurface implements StartingSurface { TaskSnapshotSurface(WindowManagerService service, Window window, Surface surface, TaskSnapshot snapshot, CharSequence title, int backgroundColor, int statusBarColor, int navigationBarColor, int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds) { Rect taskBounds, int currentOrientation) { mService = service; mHandler = new Handler(mService.mH.getLooper()); mSession = WindowManagerGlobal.getWindowSession(); Loading @@ -228,6 +232,7 @@ class TaskSnapshotSurface implements StartingSurface { mSystemBarBackgroundPainter = new SystemBarBackgroundPainter(windowFlags, windowPrivateFlags, sysUiVis, statusBarColor, navigationBarColor); mStatusBarColor = statusBarColor; mOrientationOnCreation = currentOrientation; } @Override Loading Loading @@ -394,6 +399,7 @@ class TaskSnapshotSurface implements StartingSurface { static class Window extends BaseIWindow { private TaskSnapshotSurface mOuter; public void setOuter(TaskSnapshotSurface outer) { mOuter = outer; } Loading @@ -403,6 +409,15 @@ class TaskSnapshotSurface implements StartingSurface { Rect stableInsets, Rect outsets, boolean reportDraw, MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout, boolean alwaysConsumeNavBar, int displayId) { if (mergedConfiguration != null && mOuter != null && mOuter.mOrientationOnCreation != mergedConfiguration.getMergedConfiguration().orientation) { // The orientation of the screen is changing. We better remove the snapshot ASAP as // we are going to wait on the new window in any case to unfreeze the screen, and // the starting window is not needed anymore. sHandler.post(mOuter::remove); } if (reportDraw) { sHandler.obtainMessage(MSG_REPORT_DRAW, mOuter).sendToTarget(); } Loading
services/core/java/com/android/server/wm/WindowStateAnimator.java +21 −19 Original line number Diff line number Diff line Loading @@ -1524,7 +1524,10 @@ class WindowStateAnimator { void prepareSurfaceLocked(final boolean recoveringMemory) { final WindowState w = mWin; if (!hasSurface()) { if (w.mOrientationChanging) { // There is no need to wait for an animation change if our window is gone for layout // already as we'll never be visible. if (w.mOrientationChanging && w.isGoneForLayoutLw()) { if (DEBUG_ORIENTATION) { Slog.v(TAG, "Orientation change skips hidden " + w); } Loading Loading @@ -1557,13 +1560,11 @@ class WindowStateAnimator { hide("prepareSurfaceLocked"); mWallpaperControllerLocked.hideWallpapers(w); // If we are waiting for this window to handle an // orientation change, well, it is hidden, so // doesn't really matter. Note that this does // introduce a potential glitch if the window // becomes unhidden before it has drawn for the // new orientation. if (w.mOrientationChanging) { // If we are waiting for this window to handle an orientation change. If this window is // really hidden (gone for layout), there is no point in still waiting for it. // Note that this does introduce a potential glitch if the window becomes unhidden // before it has drawn for the new orientation. if (w.mOrientationChanging && w.isGoneForLayoutLw()) { w.mOrientationChanging = false; if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change skips hidden " + w); Loading Loading @@ -1630,7 +1631,6 @@ class WindowStateAnimator { displayed = true; } if (displayed) { if (w.mOrientationChanging) { if (!w.isDrawnLw()) { mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE; Loading @@ -1642,6 +1642,8 @@ class WindowStateAnimator { if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w); } } if (displayed) { w.mToken.hasVisible = true; } } Loading
services/tests/servicestests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase { final TaskSnapshot snapshot = new TaskSnapshot(buffer, ORIENTATION_PORTRAIT, contentInsets, false, 1.0f); mSurface = new TaskSnapshotSurface(sWm, new Window(), new Surface(), snapshot, "Test", Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds); Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds, ORIENTATION_PORTRAIT); } private void setupSurface(int width, int height) { Loading