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

Commit b1dbcb4a authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge "Notify if screenshot fails due to locked device"

parents 9dd354eb c3a65895
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