Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3a65895 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Notify if screenshot fails due to locked device

Currently, if the user tries to take a screenshot while the device
is locked, we fail silently. This change adds an error notification
to tell the user what happened.

Bug: 173815237
Fix: 173815237
Test: manual (tried with user locked and unlocked; only change is
additional notification when locked)

Change-Id: I630d2d948b5e19e6b7e6e93bb965ef153baf13c9
parent 47d0450d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -226,6 +226,8 @@
    <string name="screenshot_saved_text">Tap to view your screenshot</string>
    <!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] -->
    <string name="screenshot_failed_title">Couldn\'t save screenshot</string>
    <!-- Notification text displayed when we fail to save a screenshot due to locked storage. [CHAR LIMIT=100] -->
    <string name="screenshot_failed_to_save_user_locked_text">Device must be unlocked before screenshot can be saved</string>
    <!-- Notification text displayed when we fail to save a screenshot for unknown reasons. [CHAR LIMIT=100] -->
    <string name="screenshot_failed_to_save_unknown_text">Try taking screenshot again</string>
    <!-- Notification text displayed when we fail to save a screenshot. [CHAR LIMIT=100] -->
+10 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.view.WindowManager;

import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.ScreenshotHelper;
import com.android.systemui.R;
import com.android.systemui.shared.recents.utilities.BitmapUtil;

import java.util.function.Consumer;
@@ -55,6 +56,7 @@ public class TakeScreenshotService extends Service {
    private final ScreenshotController mScreenshot;
    private final UserManager mUserManager;
    private final UiEventLogger mUiEventLogger;
    private final ScreenshotNotificationsController mNotificationsController;

    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {

@@ -90,6 +92,8 @@ public class TakeScreenshotService extends Service {
            // animation and error notification.
            if (!mUserManager.isUserUnlocked()) {
                Log.w(TAG, "Skipping screenshot because storage is locked!");
                mNotificationsController.notifyScreenshotError(
                        R.string.screenshot_failed_to_save_user_locked_text);
                post(() -> uriConsumer.accept(null));
                post(onComplete);
                return;
@@ -125,11 +129,15 @@ public class TakeScreenshotService extends Service {
    };

    @Inject
    public TakeScreenshotService(ScreenshotController screenshotController, UserManager userManager,
            UiEventLogger uiEventLogger) {
    public TakeScreenshotService(
            ScreenshotController screenshotController,
            UserManager userManager,
            UiEventLogger uiEventLogger,
            ScreenshotNotificationsController notificationsController) {
        mScreenshot = screenshotController;
        mUserManager = userManager;
        mUiEventLogger = uiEventLogger;
        mNotificationsController = notificationsController;
    }

    @Override