[MediaProjection] Handle null DisplayContent when trying to set the session

The VirtualDisplay may have already been removed by the time WindowManager
attempts to handle an incoming recording session. The returned DisplayContent
is then null.

Bug: 280596594
Test: Manual; no NPE when screenshot from Betterbug
Change-Id: Ie956a6b6fea0efd5bd35afa0f73b415a7f6ca346
This commit is contained in:
Naomi Musgrave
2023-05-12 13:59:39 +00:00
parent 5cef355a78
commit 82bcdaf2df
2 changed files with 13 additions and 0 deletions

View File

@@ -2059,6 +2059,12 @@
"group": "WM_DEBUG_CONFIGURATION",
"at": "com\/android\/server\/wm\/ActivityRecord.java"
},
"-233530384": {
"message": "Content Recording: Incoming session on display %d can't be set since it is already null; the corresponding VirtualDisplay must have already been removed.",
"level": "VERBOSE",
"group": "WM_DEBUG_CONTENT_RECORDING",
"at": "com\/android\/server\/wm\/ContentRecordingController.java"
},
"-230587670": {
"message": "SyncGroup %d: Unfinished container: %s",
"level": "VERBOSE",

View File

@@ -98,6 +98,13 @@ final class ContentRecordingController {
mSession == null ? null : mSession.getVirtualDisplayId());
incomingDisplayContent = wmService.mRoot.getDisplayContentOrCreate(
incomingSession.getVirtualDisplayId());
if (incomingDisplayContent == null) {
ProtoLog.v(WM_DEBUG_CONTENT_RECORDING,
"Content Recording: Incoming session on display %d can't be set since it "
+ "is already null; the corresponding VirtualDisplay must have "
+ "already been removed.", incomingSession.getVirtualDisplayId());
return;
}
incomingDisplayContent.setContentRecordingSession(incomingSession);
// TODO(b/270118861): When user grants consent to re-use, explicitly ask ContentRecorder
// to update, since no config/display change arrives. Mark recording as black.