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

Commit 35ee1aa3 authored by Oleg Blinnikov's avatar Oleg Blinnikov Committed by Automerger Merge Worker
Browse files

Merge "Fix NullPointerException in ContentRecorder" into tm-qpr-dev am: 6bf944b7 am: 892cdd7a

parents 872ee1fe 892cdd7a
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -391,8 +391,7 @@ final class ContentRecorder implements WindowContainerListener {
     * </p>
     * </p>
     */
     */
    private void handleStartRecordingFailed() {
    private void handleStartRecordingFailed() {
        final boolean shouldExitTaskRecording = mContentRecordingSession != null
        final boolean shouldExitTaskRecording = isRecordingContentTask();
                && mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK;
        clearContentRecordingSession();
        clearContentRecordingSession();
        if (shouldExitTaskRecording) {
        if (shouldExitTaskRecording) {
            // Clean up the cached session first to ensure recording doesn't re-start, since
            // Clean up the cached session first to ensure recording doesn't re-start, since
@@ -478,9 +477,10 @@ final class ContentRecorder implements WindowContainerListener {
        ProtoLog.v(WM_DEBUG_CONTENT_RECORDING,
        ProtoLog.v(WM_DEBUG_CONTENT_RECORDING,
                "Recorded task is removed, so stop recording on display %d",
                "Recorded task is removed, so stop recording on display %d",
                mDisplayContent.getDisplayId());
                mDisplayContent.getDisplayId());
        Task recordedTask = mRecordedWindowContainer.asTask();

        if (recordedTask == null
        Task recordedTask = mRecordedWindowContainer != null
                || mContentRecordingSession.getContentToRecord() != RECORD_CONTENT_TASK) {
                ? mRecordedWindowContainer.asTask() : null;
        if (recordedTask == null || !isRecordingContentTask()) {
            return;
            return;
        }
        }
        recordedTask.unregisterWindowContainerListener(this);
        recordedTask.unregisterWindowContainerListener(this);
@@ -504,4 +504,9 @@ final class ContentRecorder implements WindowContainerListener {
    @VisibleForTesting interface MediaProjectionManagerWrapper {
    @VisibleForTesting interface MediaProjectionManagerWrapper {
        void stopActiveProjection();
        void stopActiveProjection();
    }
    }

    private boolean isRecordingContentTask() {
        return mContentRecordingSession != null
                && mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK;
    }
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -295,6 +295,14 @@ public class ContentRecorderTests extends WindowTestsBase {
        verify(mMediaProjectionManagerWrapper).stopActiveProjection();
        verify(mMediaProjectionManagerWrapper).stopActiveProjection();
    }
    }


    @Test
    public void testRemoveTask_stopsRecording_nullSessionShouldNotThrowExceptions() {
        mContentRecorder.setContentRecordingSession(mTaskSession);
        mContentRecorder.updateRecording();
        mContentRecorder.setContentRecordingSession(null);
        mTask.removeImmediately();
    }

    @Test
    @Test
    public void testUpdateMirroredSurface_capturedAreaResized() {
    public void testUpdateMirroredSurface_capturedAreaResized() {
        mContentRecorder.setContentRecordingSession(mDisplaySession);
        mContentRecorder.setContentRecordingSession(mDisplaySession);