From f01601f5860a64c6453de2cafccf3efde2fe15ec Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Thu, 4 Jun 2020 17:12:35 -0400 Subject: [PATCH] Start screenshot timeout even if saving fails Currently we only start the timeout if the saving task completes successfully. This means that if it fails, the preview hangs around indefinitely (though it's still dismissable via the x button). This change moves the timeout code so that the timer is started when we get a response from the saving task, regardless of whether it succeeded or failed. Bug: 158225178 Fix: 158225178 Test: manual Change-Id: Ica15a12e3f9abf49d8d7d12d3947d2bfb8d61252 --- .../systemui/screenshot/GlobalScreenshot.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 9b1734d406748..a624479fa63c3 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -643,6 +643,18 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset */ private void showUiOnActionsReady(SavedImageData imageData) { logSuccessOnActionsReady(imageData); + + AccessibilityManager accessibilityManager = (AccessibilityManager) + mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); + long timeoutMs = accessibilityManager.getRecommendedTimeoutMillis( + SCREENSHOT_CORNER_DEFAULT_TIMEOUT_MILLIS, + AccessibilityManager.FLAG_CONTENT_CONTROLS); + + mScreenshotHandler.removeMessages(MESSAGE_CORNER_TIMEOUT); + mScreenshotHandler.sendMessageDelayed( + mScreenshotHandler.obtainMessage(MESSAGE_CORNER_TIMEOUT), + timeoutMs); + if (imageData.uri != null) { mScreenshotHandler.post(() -> { if (mScreenshotAnimation != null && mScreenshotAnimation.isRunning()) { @@ -656,17 +668,6 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset } else { createScreenshotActionsShadeAnimation(imageData).start(); } - - AccessibilityManager accessibilityManager = (AccessibilityManager) - mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); - long timeoutMs = accessibilityManager.getRecommendedTimeoutMillis( - SCREENSHOT_CORNER_DEFAULT_TIMEOUT_MILLIS, - AccessibilityManager.FLAG_CONTENT_CONTROLS); - - mScreenshotHandler.removeMessages(MESSAGE_CORNER_TIMEOUT); - mScreenshotHandler.sendMessageDelayed( - mScreenshotHandler.obtainMessage(MESSAGE_CORNER_TIMEOUT), - timeoutMs); }); } }