diff options
| -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; |