Loading services/core/java/com/android/server/wm/ContentRecorder.java +10 −5 Original line number Diff line number Diff line Loading @@ -388,8 +388,7 @@ final class ContentRecorder implements WindowContainerListener { * </p> */ private void handleStartRecordingFailed() { final boolean shouldExitTaskRecording = mContentRecordingSession != null && mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK; final boolean shouldExitTaskRecording = isRecordingContentTask(); clearContentRecordingSession(); if (shouldExitTaskRecording) { // Clean up the cached session first to ensure recording doesn't re-start, since Loading Loading @@ -475,9 +474,10 @@ final class ContentRecorder implements WindowContainerListener { ProtoLog.v(WM_DEBUG_CONTENT_RECORDING, "Recorded task is removed, so stop recording on display %d", mDisplayContent.getDisplayId()); Task recordedTask = mRecordedWindowContainer.asTask(); if (recordedTask == null || mContentRecordingSession.getContentToRecord() != RECORD_CONTENT_TASK) { Task recordedTask = mRecordedWindowContainer != null ? mRecordedWindowContainer.asTask() : null; if (recordedTask == null || !isRecordingContentTask()) { return; } recordedTask.unregisterWindowContainerListener(this); Loading @@ -501,4 +501,9 @@ final class ContentRecorder implements WindowContainerListener { @VisibleForTesting interface MediaProjectionManagerWrapper { void stopActiveProjection(); } private boolean isRecordingContentTask() { return mContentRecordingSession != null && mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK; } } services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java +8 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,14 @@ public class ContentRecorderTests extends WindowTestsBase { verify(mMediaProjectionManagerWrapper).stopActiveProjection(); } @Test public void testRemoveTask_stopsRecording_nullSessionShouldNotThrowExceptions() { mContentRecorder.setContentRecordingSession(mTaskSession); mContentRecorder.updateRecording(); mContentRecorder.setContentRecordingSession(null); mTask.removeImmediately(); } @Test public void testUpdateMirroredSurface_capturedAreaResized() { mContentRecorder.setContentRecordingSession(mDisplaySession); Loading Loading
services/core/java/com/android/server/wm/ContentRecorder.java +10 −5 Original line number Diff line number Diff line Loading @@ -388,8 +388,7 @@ final class ContentRecorder implements WindowContainerListener { * </p> */ private void handleStartRecordingFailed() { final boolean shouldExitTaskRecording = mContentRecordingSession != null && mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK; final boolean shouldExitTaskRecording = isRecordingContentTask(); clearContentRecordingSession(); if (shouldExitTaskRecording) { // Clean up the cached session first to ensure recording doesn't re-start, since Loading Loading @@ -475,9 +474,10 @@ final class ContentRecorder implements WindowContainerListener { ProtoLog.v(WM_DEBUG_CONTENT_RECORDING, "Recorded task is removed, so stop recording on display %d", mDisplayContent.getDisplayId()); Task recordedTask = mRecordedWindowContainer.asTask(); if (recordedTask == null || mContentRecordingSession.getContentToRecord() != RECORD_CONTENT_TASK) { Task recordedTask = mRecordedWindowContainer != null ? mRecordedWindowContainer.asTask() : null; if (recordedTask == null || !isRecordingContentTask()) { return; } recordedTask.unregisterWindowContainerListener(this); Loading @@ -501,4 +501,9 @@ final class ContentRecorder implements WindowContainerListener { @VisibleForTesting interface MediaProjectionManagerWrapper { void stopActiveProjection(); } private boolean isRecordingContentTask() { return mContentRecordingSession != null && mContentRecordingSession.getContentToRecord() == RECORD_CONTENT_TASK; } }
services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java +8 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,14 @@ public class ContentRecorderTests extends WindowTestsBase { verify(mMediaProjectionManagerWrapper).stopActiveProjection(); } @Test public void testRemoveTask_stopsRecording_nullSessionShouldNotThrowExceptions() { mContentRecorder.setContentRecordingSession(mTaskSession); mContentRecorder.updateRecording(); mContentRecorder.setContentRecordingSession(null); mTask.removeImmediately(); } @Test public void testUpdateMirroredSurface_capturedAreaResized() { mContentRecorder.setContentRecordingSession(mDisplaySession); Loading