diff options
| author | 2024-11-28 12:21:28 +0000 | |
|---|---|---|
| committer | 2024-12-05 02:40:51 +0000 | |
| commit | 418c46ce6ee2b7d5adf20f3fa510f9ad72a67ba3 (patch) | |
| tree | 8dc36b63c6ae184911ce83c3cbcdda93ec443dfc | |
| parent | f7af0707034f763305b2a1dc37bde5f2a9e08e6c (diff) | |
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
| -rw-r--r-- | services/core/java/com/android/server/wm/ContentRecorder.java | 13 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayContent.java | 8 |
2 files changed, 20 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java index 93ccd74c6b23..6ccceb9cf564 100644 --- a/services/core/java/com/android/server/wm/ContentRecorder.java +++ b/services/core/java/com/android/server/wm/ContentRecorder.java @@ -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. diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index fc08a91278b8..00e53de88ceb 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -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; |