From 0dc542c8667b4c78abf6bbd95015a18464e64c62 Mon Sep 17 00:00:00 2001 From: Matt Casey Date: Thu, 14 May 2020 20:50:58 -0400 Subject: [PATCH] Hide screenshot UI in setup wizard. Full screenshot UI would expose edit/share actions that are not appropriate for SUW. ThiS CL removes all the UI in this situation and just does a haptic with a toast indicating that the screenshot has been taken. Bug: 151797808 Test: - Verify behavior unchanged w/ normal screenshots. - Verify that tooltip UI is used during setup wizard. - Verify that screenshots taken during SUW are saved. Change-Id: Id9791265088e34f067cea68fd1eaba597e3c97b0 --- .../systemui/screenshot/GlobalScreenshot.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 414828953778d..842ba9d7543f2 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -54,6 +54,7 @@ import android.os.PowerManager; import android.os.RemoteException; import android.os.UserHandle; import android.provider.DeviceConfig; +import android.provider.Settings; import android.util.DisplayMetrics; import android.util.Log; import android.util.MathUtils; @@ -155,6 +156,9 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset static final String EXTRA_CANCEL_NOTIFICATION = "android:screenshot_cancel_notification"; static final String EXTRA_DISALLOW_ENTER_PIP = "android:screenshot_disallow_enter_pip"; + // From WizardManagerHelper.java + private static final String SETTINGS_SECURE_USER_SETUP_COMPLETE = "user_setup_complete"; + private static final String TAG = "GlobalScreenshot"; private static final long SCREENSHOT_FLASH_IN_DURATION_MS = 133; @@ -378,6 +382,13 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset return; } + if (!isUserSetupComplete()) { + // User setup isn't complete, so we don't want to show any UI beyond a toast, as editing + // and sharing shouldn't be exposed to the user. + saveScreenshotAndToast(finisher); + return; + } + // Optimizations mScreenBitmap.setHasAlpha(false); mScreenBitmap.prepareToDraw(); @@ -467,6 +478,41 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset } } + /** + * Save the bitmap but don't show the normal screenshot UI.. just a toast (or notification on + * failure). + */ + private void saveScreenshotAndToast(Consumer finisher) { + // Play the shutter sound to notify that we've taken a screenshot + mScreenshotHandler.post(() -> { + mCameraSound.play(MediaActionSound.SHUTTER_CLICK); + }); + + saveScreenshotInWorkerThread(finisher, new ActionsReadyListener() { + @Override + void onActionsReady(SavedImageData imageData) { + finisher.accept(imageData.uri); + if (imageData.uri == null) { + mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_NOT_SAVED); + mNotificationsController.notifyScreenshotError( + R.string.screenshot_failed_to_capture_text); + } else { + mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_SAVED); + + mScreenshotHandler.post(() -> { + Toast.makeText(mContext, R.string.screenshot_saved_title, + Toast.LENGTH_SHORT).show(); + }); + } + } + }); + } + + private boolean isUserSetupComplete() { + return Settings.Secure.getInt(mContext.getContentResolver(), + SETTINGS_SECURE_USER_SETUP_COMPLETE, 0) == 1; + } + /** * Clears current screenshot */