From d9674b589267fa9c9595c6dbea7988d92d43329b Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Wed, 30 Jun 2021 15:53:22 -0400 Subject: [PATCH] Restore non-scrolling UI on long screenshots crash If the long screenshot capture process crashes, or the returned long screenshot is of height zero, just restore the regular UI (without the scroll button) and reset the timeout. Bug: 189331695 Fix: 189331695 Test: manual Change-Id: Icb9bc230a7151726865715722de0b670f8bf6ffb --- .../screenshot/ScreenshotController.java | 7 +++++++ .../systemui/screenshot/ScreenshotView.java | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java index 24cca91ea3f30..a76b2696ad774 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java @@ -662,12 +662,19 @@ public class ScreenshotController { mScrollCaptureController.run(response); future.addListener(() -> { ScrollCaptureController.LongScreenshot longScreenshot; + try { longScreenshot = future.get(); } catch (CancellationException | InterruptedException | ExecutionException e) { Log.e(TAG, "Exception", e); + mScreenshotView.restoreNonScrollingUi(); + return; + } + + if (longScreenshot.getHeight() == 0) { + mScreenshotView.restoreNonScrollingUi(); return; } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index 9fe8c84bc13d1..da50ddd47a47e 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -851,6 +851,23 @@ public class ScreenshotView extends FrameLayout implements anim.start(); } + void restoreNonScrollingUi() { + mScrollChip.setVisibility(View.GONE); + mScrollablePreview.setVisibility(View.GONE); + mScrollingScrim.setVisibility(View.GONE); + + if (mAccessibilityManager.isEnabled()) { + mDismissButton.setVisibility(View.VISIBLE); + } + mActionsContainer.setVisibility(View.VISIBLE); + mBackgroundProtection.setVisibility(View.VISIBLE); + mActionsContainerBackground.setVisibility(View.VISIBLE); + mScreenshotPreviewBorder.setVisibility(View.VISIBLE); + mScreenshotPreview.setVisibility(View.VISIBLE); + // reset the timeout + mCallbacks.onUserInteraction(); + } + boolean isDismissing() { return (mDismissAnimation != null && mDismissAnimation.isRunning()); }