Loading services/core/java/com/android/server/wm/WindowContainer.java +1 −10 Original line number Original line Diff line number Diff line Loading @@ -41,7 +41,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.logWithStack; import static com.android.server.wm.WindowManagerService.logWithStack; import static com.android.server.wm.WindowStateAnimator.DRAW_PENDING; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import android.annotation.CallSuper; import android.annotation.CallSuper; Loading Loading @@ -70,7 +69,6 @@ import android.view.animation.Animation; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ToBooleanFunction; import com.android.internal.util.ToBooleanFunction; import com.android.server.policy.WindowManagerPolicy; import com.android.server.protolog.common.ProtoLog; import com.android.server.protolog.common.ProtoLog; import com.android.server.wm.SurfaceAnimator.Animatable; import com.android.server.wm.SurfaceAnimator.Animatable; Loading Loading @@ -2165,15 +2163,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } } void waitForAllWindowsDrawn() { void waitForAllWindowsDrawn() { final WindowManagerPolicy policy = mWmService.mPolicy; forAllWindows(w -> { forAllWindows(w -> { final boolean keyguard = policy.isKeyguardHostWindow(w.mAttrs); w.requestDrawIfNeeded(mWaitingForDrawn); if (w.isVisibleLw() && (w.mActivityRecord != null || keyguard)) { w.mWinAnimator.mDrawState = DRAW_PENDING; // Force add to mResizingWindows. w.resetLastContentInsets(); mWaitingForDrawn.add(w); } }, true /* traverseTopToBottom */); }, true /* traverseTopToBottom */); } } Loading services/core/java/com/android/server/wm/WindowState.java +33 −0 Original line number Original line Diff line number Diff line Loading @@ -1726,6 +1726,39 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP && isDrawnLw() && !isAnimating(TRANSITION | PARENTS); && isDrawnLw() && !isAnimating(TRANSITION | PARENTS); } } /** @see WindowManagerInternal#waitForAllWindowsDrawn */ void requestDrawIfNeeded(List<WindowState> outWaitingForDrawn) { if (!isVisible()) { return; } if (mActivityRecord != null) { if (mActivityRecord.allDrawn) { // The allDrawn of activity is reset when the visibility is changed to visible, so // the content should be ready if allDrawn is set. return; } if (mAttrs.type == TYPE_APPLICATION_STARTING) { if (isDrawnLw()) { // Unnecessary to redraw a drawn starting window. return; } } else if (mActivityRecord.startingWindow != null) { // If the activity has an active starting window, there is no need to wait for the // main window. return; } } else if (!mPolicy.isKeyguardHostWindow(mAttrs)) { return; // Always invalidate keyguard host window to make sure it shows the latest content // because its visibility may not be changed. } mWinAnimator.mDrawState = DRAW_PENDING; // Force add to {@link WindowManagerService#mResizingWindows}. resetLastContentInsets(); outWaitingForDrawn.add(this); } @Override @Override void onMovedByResize() { void onMovedByResize() { ProtoLog.d(WM_DEBUG_RESIZE, "onMovedByResize: Moving %s", this); ProtoLog.d(WM_DEBUG_RESIZE, "onMovedByResize: Moving %s", this); Loading services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +29 −0 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,9 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; Loading Loading @@ -82,7 +84,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import java.util.Arrays; import java.util.LinkedList; import java.util.LinkedList; import java.util.List; /** /** * Tests for the {@link WindowState} class. * Tests for the {@link WindowState} class. Loading Loading @@ -531,6 +535,31 @@ public class WindowStateTests extends WindowTestsBase { assertTrue(window.isVisibleByPolicy()); assertTrue(window.isVisibleByPolicy()); } } @Test public void testRequestDrawIfNeeded() { final WindowState startingApp = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "startingApp"); final WindowState startingWindow = createWindow(null /* parent */, TYPE_APPLICATION_STARTING, startingApp.mToken, "starting"); startingApp.mActivityRecord.startingWindow = startingWindow; final WindowState keyguardHostWindow = mStatusBarWindow; final WindowState allDrawnApp = mAppWindow; allDrawnApp.mActivityRecord.allDrawn = true; // The waiting list is used to ensure the content is ready when turning on screen. final List<WindowState> outWaitingForDrawn = mDisplayContent.mWaitingForDrawn; final List<WindowState> visibleWindows = Arrays.asList(mChildAppWindowAbove, keyguardHostWindow, allDrawnApp, startingApp, startingWindow); visibleWindows.forEach(w -> { w.mHasSurface = true; w.requestDrawIfNeeded(outWaitingForDrawn); }); // Keyguard host window should be always contained. The drawn app or app with starting // window are unnecessary to draw. assertEquals(Arrays.asList(keyguardHostWindow, startingWindow), outWaitingForDrawn); } @Test @Test public void testGetTransformationMatrix() { public void testGetTransformationMatrix() { final int PARENT_WINDOW_OFFSET = 1; final int PARENT_WINDOW_OFFSET = 1; Loading Loading
services/core/java/com/android/server/wm/WindowContainer.java +1 −10 Original line number Original line Diff line number Diff line Loading @@ -41,7 +41,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.logWithStack; import static com.android.server.wm.WindowManagerService.logWithStack; import static com.android.server.wm.WindowStateAnimator.DRAW_PENDING; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; import android.annotation.CallSuper; import android.annotation.CallSuper; Loading Loading @@ -70,7 +69,6 @@ import android.view.animation.Animation; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ToBooleanFunction; import com.android.internal.util.ToBooleanFunction; import com.android.server.policy.WindowManagerPolicy; import com.android.server.protolog.common.ProtoLog; import com.android.server.protolog.common.ProtoLog; import com.android.server.wm.SurfaceAnimator.Animatable; import com.android.server.wm.SurfaceAnimator.Animatable; Loading Loading @@ -2165,15 +2163,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } } void waitForAllWindowsDrawn() { void waitForAllWindowsDrawn() { final WindowManagerPolicy policy = mWmService.mPolicy; forAllWindows(w -> { forAllWindows(w -> { final boolean keyguard = policy.isKeyguardHostWindow(w.mAttrs); w.requestDrawIfNeeded(mWaitingForDrawn); if (w.isVisibleLw() && (w.mActivityRecord != null || keyguard)) { w.mWinAnimator.mDrawState = DRAW_PENDING; // Force add to mResizingWindows. w.resetLastContentInsets(); mWaitingForDrawn.add(w); } }, true /* traverseTopToBottom */); }, true /* traverseTopToBottom */); } } Loading
services/core/java/com/android/server/wm/WindowState.java +33 −0 Original line number Original line Diff line number Diff line Loading @@ -1726,6 +1726,39 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP && isDrawnLw() && !isAnimating(TRANSITION | PARENTS); && isDrawnLw() && !isAnimating(TRANSITION | PARENTS); } } /** @see WindowManagerInternal#waitForAllWindowsDrawn */ void requestDrawIfNeeded(List<WindowState> outWaitingForDrawn) { if (!isVisible()) { return; } if (mActivityRecord != null) { if (mActivityRecord.allDrawn) { // The allDrawn of activity is reset when the visibility is changed to visible, so // the content should be ready if allDrawn is set. return; } if (mAttrs.type == TYPE_APPLICATION_STARTING) { if (isDrawnLw()) { // Unnecessary to redraw a drawn starting window. return; } } else if (mActivityRecord.startingWindow != null) { // If the activity has an active starting window, there is no need to wait for the // main window. return; } } else if (!mPolicy.isKeyguardHostWindow(mAttrs)) { return; // Always invalidate keyguard host window to make sure it shows the latest content // because its visibility may not be changed. } mWinAnimator.mDrawState = DRAW_PENDING; // Force add to {@link WindowManagerService#mResizingWindows}. resetLastContentInsets(); outWaitingForDrawn.add(this); } @Override @Override void onMovedByResize() { void onMovedByResize() { ProtoLog.d(WM_DEBUG_RESIZE, "onMovedByResize: Moving %s", this); ProtoLog.d(WM_DEBUG_RESIZE, "onMovedByResize: Moving %s", this); Loading
services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +29 −0 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,9 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; Loading Loading @@ -82,7 +84,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import java.util.Arrays; import java.util.LinkedList; import java.util.LinkedList; import java.util.List; /** /** * Tests for the {@link WindowState} class. * Tests for the {@link WindowState} class. Loading Loading @@ -531,6 +535,31 @@ public class WindowStateTests extends WindowTestsBase { assertTrue(window.isVisibleByPolicy()); assertTrue(window.isVisibleByPolicy()); } } @Test public void testRequestDrawIfNeeded() { final WindowState startingApp = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "startingApp"); final WindowState startingWindow = createWindow(null /* parent */, TYPE_APPLICATION_STARTING, startingApp.mToken, "starting"); startingApp.mActivityRecord.startingWindow = startingWindow; final WindowState keyguardHostWindow = mStatusBarWindow; final WindowState allDrawnApp = mAppWindow; allDrawnApp.mActivityRecord.allDrawn = true; // The waiting list is used to ensure the content is ready when turning on screen. final List<WindowState> outWaitingForDrawn = mDisplayContent.mWaitingForDrawn; final List<WindowState> visibleWindows = Arrays.asList(mChildAppWindowAbove, keyguardHostWindow, allDrawnApp, startingApp, startingWindow); visibleWindows.forEach(w -> { w.mHasSurface = true; w.requestDrawIfNeeded(outWaitingForDrawn); }); // Keyguard host window should be always contained. The drawn app or app with starting // window are unnecessary to draw. assertEquals(Arrays.asList(keyguardHostWindow, startingWindow), outWaitingForDrawn); } @Test @Test public void testGetTransformationMatrix() { public void testGetTransformationMatrix() { final int PARENT_WINDOW_OFFSET = 1; final int PARENT_WINDOW_OFFSET = 1; Loading