Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97934746 authored by Naomi Musgrave's avatar Naomi Musgrave Committed by Android (Google) Code Review
Browse files

Merge "Trigger hidden/visible callback when start display recording."

parents ed94e357 0a5a6923
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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
+13 −1
Original line number Diff line number Diff line
@@ -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.