Loading services/core/java/com/android/server/wm/PresentationController.java +7 −3 Original line number Diff line number Diff line Loading @@ -224,13 +224,17 @@ class PresentationController implements DisplayManager.DisplayListener { void removePresentation(int displayId, @NonNull String reason) { final Presentation presentation = mPresentations.get(displayId); if (ENABLE_PRESENTATION_FOR_CONNECTED_DISPLAYS.isTrue() && presentation != null) { ProtoLog.v(WmProtoLogGroups.WM_DEBUG_PRESENTATION, "Removing Presentation %s for " + "reason %s", mPresentations.get(displayId), reason); final WindowState win = presentation.mWin; win.mWmService.mAtmService.mH.post(() -> { synchronized (win.mWmService.mGlobalLock) { // Invoke removeIfPossible() only if the presentation isn't being removed. if (!win.mAnimatingExit || !win.mRemoveOnExit) { ProtoLog.v(WmProtoLogGroups.WM_DEBUG_PRESENTATION, "Removing Presentation %s for reason %s", mPresentations.get(displayId), reason); win.removeIfPossible(); } } }); } } Loading services/core/java/com/android/server/wm/WindowState.java +6 −0 Original line number Diff line number Diff line Loading @@ -5587,6 +5587,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP void setViewVisibility(int viewVisibility) { mViewVisibility = viewVisibility; if (isPresentation() && (viewVisibility == View.INVISIBLE || viewVisibility == View.GONE)) { mWmService.mPresentationController.removePresentation(getDisplayId(), "setViewVisibility"); } } SurfaceControl getClientViewRootSurface() { Loading services/tests/wmtests/src/com/android/server/wm/PresentationControllerTests.java +27 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,33 @@ public class PresentationControllerTests extends WindowTestsBase { assertAddPresentationWindowFails(uid + 1, presentationDisplay.mDisplayId); } @EnableFlags(FLAG_ENABLE_PRESENTATION_FOR_CONNECTED_DISPLAYS) @Test public void testInvisiblePresentationIsNotAllowed() { final int uid = Binder.getCallingUid(); final Task task = createTask(mDefaultDisplay); task.effectiveUid = uid; final ActivityRecord activity = createActivityRecord(task); assertTrue(activity.isVisible()); // Add a presentation window on a presentation display. final DisplayContent presentationDisplay = createPresentationDisplay(); final WindowState window = addPresentationWindow(uid, presentationDisplay.getDisplayId()); window.setViewVisibility(View.VISIBLE); final Transition addTransition = window.mTransitionController.getCollectingTransition(); completeTransition(addTransition, /*abortSync=*/ true); assertTrue(window.isVisible()); // Making the presentation view invisible automatically removes it. window.setViewVisibility(View.GONE); assertTrue(window.isVisible()); waitHandlerIdle(window.mWmService.mAtmService.mH); final Transition removeTransition = window.mTransitionController.getCollectingTransition(); assertEquals(TRANSIT_CLOSE, removeTransition.mType); completeTransition(removeTransition, /*abortSync=*/ false); assertFalse(window.isVisible()); } @EnableFlags(FLAG_ENABLE_PRESENTATION_FOR_CONNECTED_DISPLAYS) @Test public void testPresentationCannotLaunchOnNonPresentationDisplayWithoutHostHavingGlobalFocus() { Loading Loading
services/core/java/com/android/server/wm/PresentationController.java +7 −3 Original line number Diff line number Diff line Loading @@ -224,13 +224,17 @@ class PresentationController implements DisplayManager.DisplayListener { void removePresentation(int displayId, @NonNull String reason) { final Presentation presentation = mPresentations.get(displayId); if (ENABLE_PRESENTATION_FOR_CONNECTED_DISPLAYS.isTrue() && presentation != null) { ProtoLog.v(WmProtoLogGroups.WM_DEBUG_PRESENTATION, "Removing Presentation %s for " + "reason %s", mPresentations.get(displayId), reason); final WindowState win = presentation.mWin; win.mWmService.mAtmService.mH.post(() -> { synchronized (win.mWmService.mGlobalLock) { // Invoke removeIfPossible() only if the presentation isn't being removed. if (!win.mAnimatingExit || !win.mRemoveOnExit) { ProtoLog.v(WmProtoLogGroups.WM_DEBUG_PRESENTATION, "Removing Presentation %s for reason %s", mPresentations.get(displayId), reason); win.removeIfPossible(); } } }); } } Loading
services/core/java/com/android/server/wm/WindowState.java +6 −0 Original line number Diff line number Diff line Loading @@ -5587,6 +5587,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP void setViewVisibility(int viewVisibility) { mViewVisibility = viewVisibility; if (isPresentation() && (viewVisibility == View.INVISIBLE || viewVisibility == View.GONE)) { mWmService.mPresentationController.removePresentation(getDisplayId(), "setViewVisibility"); } } SurfaceControl getClientViewRootSurface() { Loading
services/tests/wmtests/src/com/android/server/wm/PresentationControllerTests.java +27 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,33 @@ public class PresentationControllerTests extends WindowTestsBase { assertAddPresentationWindowFails(uid + 1, presentationDisplay.mDisplayId); } @EnableFlags(FLAG_ENABLE_PRESENTATION_FOR_CONNECTED_DISPLAYS) @Test public void testInvisiblePresentationIsNotAllowed() { final int uid = Binder.getCallingUid(); final Task task = createTask(mDefaultDisplay); task.effectiveUid = uid; final ActivityRecord activity = createActivityRecord(task); assertTrue(activity.isVisible()); // Add a presentation window on a presentation display. final DisplayContent presentationDisplay = createPresentationDisplay(); final WindowState window = addPresentationWindow(uid, presentationDisplay.getDisplayId()); window.setViewVisibility(View.VISIBLE); final Transition addTransition = window.mTransitionController.getCollectingTransition(); completeTransition(addTransition, /*abortSync=*/ true); assertTrue(window.isVisible()); // Making the presentation view invisible automatically removes it. window.setViewVisibility(View.GONE); assertTrue(window.isVisible()); waitHandlerIdle(window.mWmService.mAtmService.mH); final Transition removeTransition = window.mTransitionController.getCollectingTransition(); assertEquals(TRANSIT_CLOSE, removeTransition.mType); completeTransition(removeTransition, /*abortSync=*/ false); assertFalse(window.isVisible()); } @EnableFlags(FLAG_ENABLE_PRESENTATION_FOR_CONNECTED_DISPLAYS) @Test public void testPresentationCannotLaunchOnNonPresentationDisplayWithoutHostHavingGlobalFocus() { Loading