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

Commit 2ed0a72d authored by Alex Johnston's avatar Alex Johnston Committed by Automerger Merge Worker
Browse files

Merge "Prevent screenshot when admin disable screenshots for all users" into...

Merge "Prevent screenshot when admin disable screenshots for all users" into tm-dev am: 4b568d34 am: 772b6f21 am: 3764441a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17907951



Change-Id: Ice8aab98170687d00b9072c2bf016bcf9f1312cc
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dbd09c7d 3764441a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -213,6 +213,8 @@
    <!-- Notification text displayed when we fail to take a screenshot. [CHAR LIMIT=100] -->
    <string name="screenshot_failed_to_capture_text">Taking screenshots isn\'t allowed by the app or
        your organization</string>
    <!-- Notification text displayed when screenshots are blocked by an IT admin. [CHAR LIMIT=100] -->
    <string name="screenshot_blocked_by_admin">Taking screenshots is blocked by your IT admin</string>
    <!-- Label for UI element which allows editing the screenshot [CHAR LIMIT=30] -->
    <string name="screenshot_edit_label">Edit</string>
    <!-- Content description indicating that tapping the element will allow editing the screenshot [CHAR LIMIT=NONE] -->
+17 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.systemui.screenshot.LogConfig.logTag;

import android.annotation.MainThread;
import android.app.Service;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -42,9 +43,11 @@ import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

import androidx.annotation.NonNull;

@@ -62,9 +65,11 @@ public class TakeScreenshotService extends Service {
    private ScreenshotController mScreenshot;

    private final UserManager mUserManager;
    private final DevicePolicyManager mDevicePolicyManager;
    private final UiEventLogger mUiEventLogger;
    private final ScreenshotNotificationsController mNotificationsController;
    private final Handler mHandler;
    private final Context mContext;

    private final BroadcastReceiver mCloseSystemDialogs = new BroadcastReceiver() {
        @Override
@@ -91,16 +96,18 @@ public class TakeScreenshotService extends Service {

    @Inject
    public TakeScreenshotService(ScreenshotController screenshotController, UserManager userManager,
            UiEventLogger uiEventLogger,
            ScreenshotNotificationsController notificationsController) {
            DevicePolicyManager devicePolicyManager, UiEventLogger uiEventLogger,
            ScreenshotNotificationsController notificationsController, Context context) {
        if (DEBUG_SERVICE) {
            Log.d(TAG, "new " + this);
        }
        mHandler = new Handler(Looper.getMainLooper(), this::handleMessage);
        mScreenshot = screenshotController;
        mUserManager = userManager;
        mDevicePolicyManager = devicePolicyManager;
        mUiEventLogger = uiEventLogger;
        mNotificationsController = notificationsController;
        mContext = context;
    }

    @Override
@@ -182,6 +189,14 @@ public class TakeScreenshotService extends Service {
            requestCallback.reportError();
            return true;
        }
        if(mDevicePolicyManager.getScreenCaptureDisabled(null, UserHandle.USER_ALL)) {
            Log.w(TAG, "Skipping screenshot because an IT admin has disabled "
                    + "screenshots on the device");
            Toast.makeText(mContext, R.string.screenshot_blocked_by_admin,
                    Toast.LENGTH_SHORT).show();
            requestCallback.reportError();
            return true;
        }

        ScreenshotHelper.ScreenshotRequest screenshotRequest =
                (ScreenshotHelper.ScreenshotRequest) msg.obj;