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

Commit 418c46ce authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Stop mirroring display if display surface is migrated

SystemUI uses RootDisplayAreaOrganizer to organize display surface,
so if SystemUI is died, it will also refresh the surfaces.
Then the original mirroring target may be outdated.

Bug: 361414017
Flag: EXEMPT bugfix
Test: Force crash sysui when mirroring.
      Enable "Developer options > Simulate secondary displays"
      adb shell am crash com.android.systemui
      The mirroring display can still show the latest content.

Change-Id: I3b910b1455f4caaa813c3bbc8ba2fa3d01ab5198
parent f7af0707
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -243,6 +243,19 @@ final class ContentRecorder implements WindowContainerListener {
        }
    }

    /** Called when the surface of display is changed to a different instance. */
    void resetRecordingDisplay(int displayId) {
        if (!isCurrentlyRecording()
                || mContentRecordingSession.getDisplayToRecord() != displayId) {
            return;
        }
        ProtoLog.v(WM_DEBUG_CONTENT_RECORDING,
                "Content Recording: Display %d changed surface so stop recording", displayId);
        mDisplayContent.mWmService.mTransactionFactory.get().remove(mRecordedSurface).apply();
        mRecordedSurface = null;
        // Do not un-set the token, in case new surface is ready and recording should begin again.
    }

    /**
     * Pauses recording on this display content. Note the session does not need to be updated,
     * since recording can be resumed still.
+7 −1
Original line number Diff line number Diff line
@@ -1264,7 +1264,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    @Override
    void migrateToNewSurfaceControl(Transaction t) {
        t.remove(mSurfaceControl);

        // Reset the recording displays which were mirroring this display.
        for (int i = mRootWindowContainer.getChildCount() - 1; i >= 0; i--) {
            final ContentRecorder recorder = mRootWindowContainer.getChildAt(i).mContentRecorder;
            if (recorder != null) {
                recorder.resetRecordingDisplay(mDisplayId);
            }
        }
        mLastSurfacePosition.set(0, 0);
        mLastDeltaRotation = Surface.ROTATION_0;