Loading services/core/java/com/android/server/wm/WindowState.java +20 −8 Original line number Diff line number Diff line Loading @@ -2202,18 +2202,30 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } void prepareWindowToDisplayDuringRelayout(MergedConfiguration mergedConfiguration) { void prepareWindowToDisplayDuringRelayout(MergedConfiguration mergedConfiguration, boolean wasVisible) { // We need to turn on screen regardless of visibility. if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) { if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this); mTurnOnScreen = true; } // If we were already visible, skip rest of preparation. if (wasVisible) { if (DEBUG_VISIBILITY) Slog.v(TAG, "Already visible and does not turn on screen, skip preparing: " + this); return; } if ((mAttrs.softInputMode & SOFT_INPUT_MASK_ADJUST) == SOFT_INPUT_ADJUST_RESIZE) { mLayoutNeeded = true; } if (isDrawnLw() && mService.okToDisplay()) { mWinAnimator.applyEnterAnimationLocked(); } if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) { if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this); mTurnOnScreen = true; } if (isConfigChanged()) { final Configuration globalConfig = mService.mRoot.getConfiguration(); final Configuration overrideConfig = getMergedOverrideConfiguration(); Loading Loading @@ -4348,9 +4360,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLastVisibleLayoutRotation = getDisplayContent().getRotation(); mWinAnimator.mEnteringAnimation = true; if (!wasVisible) { prepareWindowToDisplayDuringRelayout(mergedConfiguration); } prepareWindowToDisplayDuringRelayout(mergedConfiguration, wasVisible); if ((attrChanges & FORMAT_CHANGED) != 0) { // If the format can't be changed in place, preserve the old surface until the app draws // on the new one. This prevents blinking when we change elevation of freeform and Loading services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.wm; import android.util.MergedConfiguration; import android.view.WindowManager; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -204,4 +206,20 @@ public class WindowStateTests extends WindowTestsBase { assertEquals(mediaChild, windows.pollFirst()); assertTrue(windows.isEmpty()); } @Test public void testPrepareWindowToDisplayDuringRelayout() throws Exception { testPrepareWindowToDisplayDuringRelayout(false /*wasVisible*/); testPrepareWindowToDisplayDuringRelayout(true /*wasVisible*/); } private void testPrepareWindowToDisplayDuringRelayout(boolean wasVisible) { final WindowState root = createWindow(null, TYPE_APPLICATION, "root"); root.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; root.mTurnOnScreen = false; root.prepareWindowToDisplayDuringRelayout(new MergedConfiguration(), wasVisible /*wasVisible*/); assertTrue(root.mTurnOnScreen); } } Loading
services/core/java/com/android/server/wm/WindowState.java +20 −8 Original line number Diff line number Diff line Loading @@ -2202,18 +2202,30 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } void prepareWindowToDisplayDuringRelayout(MergedConfiguration mergedConfiguration) { void prepareWindowToDisplayDuringRelayout(MergedConfiguration mergedConfiguration, boolean wasVisible) { // We need to turn on screen regardless of visibility. if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) { if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this); mTurnOnScreen = true; } // If we were already visible, skip rest of preparation. if (wasVisible) { if (DEBUG_VISIBILITY) Slog.v(TAG, "Already visible and does not turn on screen, skip preparing: " + this); return; } if ((mAttrs.softInputMode & SOFT_INPUT_MASK_ADJUST) == SOFT_INPUT_ADJUST_RESIZE) { mLayoutNeeded = true; } if (isDrawnLw() && mService.okToDisplay()) { mWinAnimator.applyEnterAnimationLocked(); } if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) { if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this); mTurnOnScreen = true; } if (isConfigChanged()) { final Configuration globalConfig = mService.mRoot.getConfiguration(); final Configuration overrideConfig = getMergedOverrideConfiguration(); Loading Loading @@ -4348,9 +4360,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLastVisibleLayoutRotation = getDisplayContent().getRotation(); mWinAnimator.mEnteringAnimation = true; if (!wasVisible) { prepareWindowToDisplayDuringRelayout(mergedConfiguration); } prepareWindowToDisplayDuringRelayout(mergedConfiguration, wasVisible); if ((attrChanges & FORMAT_CHANGED) != 0) { // If the format can't be changed in place, preserve the old surface until the app draws // on the new one. This prevents blinking when we change elevation of freeform and Loading
services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.wm; import android.util.MergedConfiguration; import android.view.WindowManager; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -204,4 +206,20 @@ public class WindowStateTests extends WindowTestsBase { assertEquals(mediaChild, windows.pollFirst()); assertTrue(windows.isEmpty()); } @Test public void testPrepareWindowToDisplayDuringRelayout() throws Exception { testPrepareWindowToDisplayDuringRelayout(false /*wasVisible*/); testPrepareWindowToDisplayDuringRelayout(true /*wasVisible*/); } private void testPrepareWindowToDisplayDuringRelayout(boolean wasVisible) { final WindowState root = createWindow(null, TYPE_APPLICATION, "root"); root.mAttrs.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; root.mTurnOnScreen = false; root.prepareWindowToDisplayDuringRelayout(new MergedConfiguration(), wasVisible /*wasVisible*/); assertTrue(root.mTurnOnScreen); } }