From 0a5a69237ccc5a42a7d80cec7c431fd6c7caebbb Mon Sep 17 00:00:00 2001 From: Naomi Musgrave Date: Mon, 9 Jan 2023 18:23:48 +0000 Subject: [PATCH] Trigger hidden/visible callback when start display recording. Bug: 264893742 Test: atest WmTests:ContentRecorderTests Change-Id: I6f311fbe4ee8121633b1c91c0e7fb851404e6d18 --- .../com/android/server/wm/ContentRecorder.java | 6 ++++++ .../android/server/wm/ContentRecorderTests.java | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java index af135b7d7710a..9e258cbc2ec6d 100644 --- a/services/core/java/com/android/server/wm/ContentRecorder.java +++ b/services/core/java/com/android/server/wm/ContentRecorder.java @@ -20,6 +20,7 @@ import static android.content.Context.MEDIA_PROJECTION_SERVICE; import static android.content.res.Configuration.ORIENTATION_UNDEFINED; import static android.view.ContentRecordingSession.RECORD_CONTENT_DISPLAY; import static android.view.ContentRecordingSession.RECORD_CONTENT_TASK; +import static android.view.ViewProtoEnums.DISPLAY_STATE_OFF; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONTENT_RECORDING; @@ -317,6 +318,11 @@ final class ContentRecorder implements WindowContainerListener { if (mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK) { mMediaProjectionManager.notifyActiveProjectionCapturedContentVisibilityChanged( mRecordedWindowContainer.asTask().isVisibleRequested()); + } else { + int currentDisplayState = + mRecordedWindowContainer.asDisplayContent().getDisplay().getState(); + mMediaProjectionManager.notifyActiveProjectionCapturedContentVisibilityChanged( + currentDisplayState != DISPLAY_STATE_OFF); } // No need to clean up. In SurfaceFlinger, parents hold references to their children. The diff --git a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java index 4ad851669c8d4..8cc362c1820c4 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java @@ -280,7 +280,7 @@ public class ContentRecorderTests extends WindowTestsBase { } @Test - public void testStartRecording_notifiesCallback() { + public void testStartRecording_notifiesCallback_taskSession() { // WHEN a recording is ongoing. mContentRecorder.setContentRecordingSession(mTaskSession); mContentRecorder.updateRecording(); @@ -291,6 +291,18 @@ public class ContentRecorderTests extends WindowTestsBase { .notifyActiveProjectionCapturedContentVisibilityChanged(true); } + @Test + public void testStartRecording_notifiesCallback_displaySession() { + // WHEN a recording is ongoing. + mContentRecorder.setContentRecordingSession(mDisplaySession); + mContentRecorder.updateRecording(); + assertThat(mContentRecorder.isCurrentlyRecording()).isTrue(); + + // THEN the visibility change callback is notified. + verify(mMediaProjectionManagerWrapper) + .notifyActiveProjectionCapturedContentVisibilityChanged(true); + } + @Test public void testOnVisibleRequestedChanged_notifiesCallback() { // WHEN a recording is ongoing.