diff options
6 files changed, 32 insertions, 29 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java index e58960072454..3920d585734e 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java @@ -255,11 +255,11 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler Assert.isMainThread(); mCurrentRequestCallback = requestCallback; + Rect bounds = screenshot.getOriginalScreenBounds(); if (screenshot.getType() == WindowManager.TAKE_SCREENSHOT_FULLSCREEN && screenshot.getBitmap() == null) { - Rect bounds = getFullScreenRect(); + bounds = getFullScreenRect(); screenshot.setBitmap(mImageCapture.captureDisplay(mDisplay.getDisplayId(), bounds)); - screenshot.setScreenBounds(bounds); } if (screenshot.getBitmap() == null) { @@ -325,22 +325,22 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler boolean showFlash; if (screenshot.getType() == WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE) { - if (screenshot.getScreenBounds() != null - && aspectRatiosMatch(screenshot.getBitmap(), screenshot.getInsets(), - screenshot.getScreenBounds())) { + if (bounds != null + && aspectRatiosMatch(screenshot.getBitmap(), screenshot.getOriginalInsets(), + bounds)) { showFlash = false; } else { showFlash = true; - screenshot.setInsets(Insets.NONE); - screenshot.setScreenBounds(new Rect(0, 0, screenshot.getBitmap().getWidth(), - screenshot.getBitmap().getHeight())); + bounds = new Rect(0, 0, screenshot.getBitmap().getWidth(), + screenshot.getBitmap().getHeight()); } } else { showFlash = true; } + final Rect animationBounds = bounds; mViewProxy.prepareEntranceAnimation( - () -> startAnimation(screenshot.getScreenBounds(), showFlash, + () -> startAnimation(animationBounds, showFlash, () -> mMessageContainerController.onScreenshotTaken(screenshot))); mViewProxy.setScreenshot(screenshot); diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.kt index 0806be8d6bb2..2a63564b1d55 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.kt @@ -174,7 +174,6 @@ internal constructor( if (screenshot.type == TAKE_SCREENSHOT_FULLSCREEN && screenshot.bitmap == null) { val bounds = fullScreenRect screenshot.bitmap = imageCapture.captureDisplay(display.displayId, bounds) - screenshot.screenBounds = bounds } val currentBitmap = screenshot.bitmap @@ -235,23 +234,27 @@ internal constructor( window.attachWindow() + var bounds = + screenshot.originalScreenBounds ?: Rect(0, 0, currentBitmap.width, currentBitmap.height) + val showFlash: Boolean if (screenshot.type == TAKE_SCREENSHOT_PROVIDED_IMAGE) { - if (aspectRatiosMatch(currentBitmap, screenshot.insets, screenshot.screenBounds)) { + if ( + aspectRatiosMatch( + currentBitmap, + screenshot.originalInsets, + screenshot.originalScreenBounds, + ) + ) { showFlash = false } else { showFlash = true - screenshot.insets = Insets.NONE - screenshot.screenBounds = Rect(0, 0, currentBitmap.width, currentBitmap.height) + bounds = Rect(0, 0, currentBitmap.width, currentBitmap.height) } } else { showFlash = true } - // screenshot.screenBounds is expected to be non-null in all cases at this point - val bounds = - screenshot.screenBounds ?: Rect(0, 0, currentBitmap.width, currentBitmap.height) - viewProxy.prepareEntranceAnimation { startAnimation(bounds, showFlash) { messageContainerController.onScreenshotTaken(screenshot) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotData.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotData.kt index 2df1e8aa2e68..c390e71d3701 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotData.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotData.kt @@ -21,9 +21,9 @@ data class ScreenshotData( val userHandle: UserHandle, /** ComponentName of the top-most app in the screenshot. */ val topComponent: ComponentName?, - var screenBounds: Rect?, val taskId: Int, - var insets: Insets, + val originalScreenBounds: Rect?, + val originalInsets: Insets, var bitmap: Bitmap?, val displayId: Int, ) { @@ -42,9 +42,9 @@ data class ScreenshotData( source = request.source, userHandle = UserHandle.of(request.userId), topComponent = request.topComponent, - screenBounds = request.boundsInScreen, + originalScreenBounds = request.boundsInScreen, taskId = request.taskId, - insets = request.insets, + originalInsets = request.insets, bitmap = request.bitmap, displayId = displayId, ) @@ -61,9 +61,9 @@ data class ScreenshotData( source = source, userHandle = userHandle, topComponent = topComponent, - screenBounds = null, + originalScreenBounds = null, taskId = 0, - insets = Insets.NONE, + originalInsets = Insets.NONE, bitmap = bitmap, displayId = Display.DEFAULT_DISPLAY, ) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/policy/PolicyRequestProcessor.kt b/packages/SystemUI/src/com/android/systemui/screenshot/policy/PolicyRequestProcessor.kt index b67ad8a2b947..a94393b774a1 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/policy/PolicyRequestProcessor.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/policy/PolicyRequestProcessor.kt @@ -141,7 +141,7 @@ class PolicyRequestProcessor( userHandle = owner, taskId = taskId, topComponent = componentName, - screenBounds = taskBounds, + originalScreenBounds = taskBounds, ) } @@ -159,7 +159,7 @@ class PolicyRequestProcessor( bitmap = screenshot, userHandle = owner, topComponent = componentName, - screenBounds = Rect(0, 0, screenshot?.width ?: 0, screenshot?.height ?: 0), + originalScreenBounds = Rect(0, 0, screenshot?.width ?: 0, screenshot?.height ?: 0), taskId = taskId ?: -1, ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt index 1d74e8b3002c..4ede90ec4466 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotDataTest.kt @@ -53,8 +53,8 @@ class ScreenshotDataTest { assertThat(data.source).isEqualTo(source) assertThat(data.type).isEqualTo(type) - assertThat(data.screenBounds).isEqualTo(bounds) - assertThat(data.insets).isEqualTo(insets) + assertThat(data.originalScreenBounds).isEqualTo(bounds) + assertThat(data.originalInsets).isEqualTo(insets) assertThat(data.taskId).isEqualTo(taskId) assertThat(data.userHandle).isEqualTo(UserHandle.of(userId)) assertThat(data.topComponent).isEqualTo(component) diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/policy/PolicyRequestProcessorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/policy/PolicyRequestProcessorTest.kt index 2fcacb9880dd..e4329a513772 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/policy/PolicyRequestProcessorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/policy/PolicyRequestProcessorTest.kt @@ -60,9 +60,9 @@ class PolicyRequestProcessorTest { SCREENSHOT_KEY_CHORD, UserHandle.CURRENT, topComponent = null, - screenBounds = Rect(0, 0, 1, 1), + originalScreenBounds = Rect(0, 0, 1, 1), taskId = -1, - insets = Insets.NONE, + originalInsets = Insets.NONE, bitmap = null, displayId = DEFAULT_DISPLAY, ) |