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

Commit ec3d9ca9 authored by phweiss's avatar phweiss
Browse files

Show policy transparency dialog after failed screenshot

If an admin disables screen capture, and a screenshot is attempted,
a notification is displayed. Now, tapping it brings you to the policy
transparency dialog.

Bug: 27365337
Test: manual
Change-Id: I93db6e7f508a3d9bbd4483bbf5a7b84eb8beb0af
parent bae3d708
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.admin.DevicePolicyManager;
import android.app.Notification;
import android.app.Notification.BigPictureStyle;
import android.app.NotificationManager;
@@ -46,6 +47,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Process;
import android.os.UserHandle;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.view.Display;
@@ -866,6 +868,16 @@ class GlobalScreenshot {
            .setAutoCancel(true)
            .setColor(context.getColor(
                        com.android.internal.R.color.system_notification_accent_color));
        final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
                Context.DEVICE_POLICY_SERVICE);
        final Intent intent = dpm.createAdminSupportIntent(
                DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE);
        if (intent != null) {
            final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(
                    context, 0, intent, 0, null, UserHandle.CURRENT);
            b.setContentIntent(pendingIntent);
        }

        SystemUI.overrideNotificationAppName(context, b);

        Notification n = new Notification.BigTextStyle(b)