summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Oleg Blinnikov <olb@google.com> 2022-09-28 09:52:37 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-09-28 09:52:37 +0000
commit6bf944b758fdc8728c3ee2aee83a2379aa72cb2d (patch)
tree6433dcd6173dfe57909c90c7ea03d07000c35c46
parent8504f8c84328df46a4eb454bab9521cb879c8d1b (diff)
parent419f9ed5ddfc92db48e8f29c587a6a743286e086 (diff)
Merge "Fix NullPointerException in ContentRecorder" into tm-qpr-dev
-rw-r--r--services/core/java/com/android/server/wm/ContentRecorder.java15
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java8
2 files changed, 18 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java
index 35a744f70d27..f304b4a009b5 100644
--- a/services/core/java/com/android/server/wm/ContentRecorder.java
+++ b/services/core/java/com/android/server/wm/ContentRecorder.java
@@ -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
@@ -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);
@@ -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;
+ }
}
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 7fbf6bb683bf..f6d53852f9a1 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ContentRecorderTests.java
@@ -289,6 +289,14 @@ public class ContentRecorderTests extends WindowTestsBase {
}
@Test
+ public void testRemoveTask_stopsRecording_nullSessionShouldNotThrowExceptions() {
+ mContentRecorder.setContentRecordingSession(mTaskSession);
+ mContentRecorder.updateRecording();
+ mContentRecorder.setContentRecordingSession(null);
+ mTask.removeImmediately();
+ }
+
+ @Test
public void testUpdateMirroredSurface_capturedAreaResized() {
mContentRecorder.setContentRecordingSession(mDisplaySession);
mContentRecorder.updateRecording();