diff options
| author | 2024-12-17 01:56:19 -0800 | |
|---|---|---|
| committer | 2024-12-17 01:56:19 -0800 | |
| commit | 736901f07de22c75f6bdcdb728ed31b0cb41721f (patch) | |
| tree | f15f3074cab03c9baf4a70590046f723634d5384 | |
| parent | 6087effc2761a7dd6de53d2426bd9317f6e37548 (diff) | |
| parent | 978dbf9c725423eae43bbcbe6c8a1f5993c2a4ce (diff) | |
Merge "ContentRecorder: fix NPE problem to avoid crash when start recording." into main am: 978dbf9c72
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3418419
Change-Id: I55a8df33d5d913c8f06ac1a77dadd9a026cdf08c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | services/core/java/com/android/server/wm/ContentRecorder.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java index 0aca51184565..1b4898665ebf 100644 --- a/services/core/java/com/android/server/wm/ContentRecorder.java +++ b/services/core/java/com/android/server/wm/ContentRecorder.java @@ -350,6 +350,15 @@ final class ContentRecorder implements WindowContainerListener { return; } + final SurfaceControl sourceSurface = mRecordedWindowContainer.getSurfaceControl(); + if (sourceSurface == null || !sourceSurface.isValid()) { + ProtoLog.v(WM_DEBUG_CONTENT_RECORDING, + "Content Recording: Unable to start recording for display %d since the " + + "surface is null or have been released.", + mDisplayContent.getDisplayId()); + return; + } + final int contentToRecord = mContentRecordingSession.getContentToRecord(); // TODO(b/297514518) Do not start capture if the app is in PIP, the bounds are inaccurate. @@ -377,8 +386,7 @@ final class ContentRecorder implements WindowContainerListener { mDisplayContent.getDisplayId(), mDisplayContent.getDisplayInfo().state); // Create a mirrored hierarchy for the SurfaceControl of the DisplayArea to capture. - mRecordedSurface = SurfaceControl.mirrorSurface( - mRecordedWindowContainer.getSurfaceControl()); + mRecordedSurface = SurfaceControl.mirrorSurface(sourceSurface); SurfaceControl.Transaction transaction = mDisplayContent.mWmService.mTransactionFactory.get() // Set the mMirroredSurface's parent to the root SurfaceControl for this |