From 4ebd859bc4b89b6ac34d3a10b7630618edd02779 Mon Sep 17 00:00:00 2001 From: Zak Cohen Date: Fri, 8 May 2020 17:16:15 -0700 Subject: [PATCH] Overview Actions - shows a message if action is blocked by policy. Device policy or app secure surface policy mean that snapshot based actions shouldn't work. This is encoded in whether the snapshot is "real", the fake snapshot is generated when policy doesn't allow captures. Test: tested with Test DPC fake device policy app Change-Id: Ib34e5a90ab58fb401d4516c531866d1c13569256 --- .../android/quickstep/TaskOverlayFactory.java | 24 ++++++++++++++++--- quickstep/res/values/strings.xml | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java index b44d6df26e..042c542d87 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java @@ -22,6 +22,7 @@ import android.content.Context; import android.graphics.Insets; import android.graphics.Matrix; import android.graphics.Rect; +import android.widget.Toast; import com.android.launcher3.BaseActivity; import com.android.launcher3.BaseDraggingActivity; @@ -109,16 +110,26 @@ public class TaskOverlayFactory implements ResourceBasedOverride { public void initOverlay(Task task, ThumbnailData thumbnail, Matrix matrix) { ImageActionsApi imageApi = new ImageActionsApi( mApplicationContext, mThumbnailView::getThumbnail); + final boolean isAllowedByPolicy = thumbnail.isRealSnapshot; + getActionsView().setCallbacks(new OverlayUICallbacks() { @Override public void onShare() { - imageApi.startShareActivity(); + if (isAllowedByPolicy) { + imageApi.startShareActivity(); + } else { + showBlockedByPolicyMessage(); + } } @Override public void onScreenshot() { - imageApi.saveScreenshot(mThumbnailView.getThumbnail(), - getTaskSnapshotBounds(), getTaskSnapshotInsets(), task.key.id); + if (isAllowedByPolicy) { + imageApi.saveScreenshot(mThumbnailView.getThumbnail(), + getTaskSnapshotBounds(), getTaskSnapshotInsets(), task.key.id); + } else { + showBlockedByPolicyMessage(); + } } }); } @@ -152,6 +163,13 @@ public class TaskOverlayFactory implements ResourceBasedOverride { // TODO: return the real insets return Insets.of(0, 0, 0, 0); } + + private void showBlockedByPolicyMessage() { + Toast.makeText( + mThumbnailView.getContext(), + R.string.blocked_by_policy, + Toast.LENGTH_LONG).show(); + } } /** diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml index b474a329d8..8368817196 100644 --- a/quickstep/res/values/strings.xml +++ b/quickstep/res/values/strings.xml @@ -141,4 +141,6 @@ Share Screenshot + + This action isn\'t allowed by the app or your organization \ No newline at end of file