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

Commit 811229a8 authored by lijilou's avatar lijilou
Browse files

ContentRecorder: fix the NPE problem.

In RemoteToken class,window container is weakly referenced and may be recycled if memory is tight, so we need to do a null check, just like other AOSP code uses this method.

Test: OEM monkey test
Flag: EXEMPT bugfix
Bug: 383048157
Change-Id: I8e28303e27ed248fec681936307268a0967494bb
parent abe12c8c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -453,15 +453,17 @@ final class ContentRecorder implements WindowContainerListener {
            case RECORD_CONTENT_TASK:
                // Given the WindowToken of the region to record, retrieve the associated
                // SurfaceControl.
                if (tokenToRecord == null) {
                final WindowContainer wc = tokenToRecord != null
                        ? WindowContainer.fromBinder(tokenToRecord) : null;
                if (wc == null) {
                    handleStartRecordingFailed();
                    ProtoLog.v(WM_DEBUG_CONTENT_RECORDING,
                            "Content Recording: Unable to start recording due to null token for "
                                    + "display %d",
                            "Content Recording: Unable to start recording due to null token or " +
                                    "null window container for " + "display %d",
                            mDisplayContent.getDisplayId());
                    return null;
                }
                Task taskToRecord = WindowContainer.fromBinder(tokenToRecord).asTask();
                final Task taskToRecord = wc.asTask();
                if (taskToRecord == null) {
                    handleStartRecordingFailed();
                    ProtoLog.v(WM_DEBUG_CONTENT_RECORDING,