From 4f1297a9d336291c6fccdcf7e621989361331814 Mon Sep 17 00:00:00 2001 From: Alison Cichowlas Date: Tue, 30 Jan 2018 11:40:36 -0500 Subject: [PATCH] Grant read/write permissions on share/edit screenshot. Test: Manually tested, being sure to cover receiving apps without auto-granted permissions. Change-Id: I868240449a4ec07715607f82981eee6a5bee210e --- .../com/android/systemui/screenshot/GlobalScreenshot.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 0132fa850f955..bf4a225a00ec8 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -293,6 +293,7 @@ class SaveImageInBackgroundTask extends AsyncTask { sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject); + sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Create a share action for the notification. Note, we proxy the call to // ScreenshotActionReceiver because RemoteViews currently forces an activity options @@ -310,7 +311,9 @@ class SaveImageInBackgroundTask extends AsyncTask { Intent editIntent = new Intent(Intent.ACTION_EDIT); editIntent.setType("image/png"); - editIntent.putExtra(Intent.EXTRA_STREAM, uri); + editIntent.setData(uri); + editIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + editIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // Create a edit action for the notification the same way. PendingIntent editAction = PendingIntent.getBroadcast(context, 1, @@ -902,6 +905,7 @@ class GlobalScreenshot { Intent chooserIntent = Intent.createChooser(sharingIntent, null, chooseAction.getIntentSender()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); + ActivityOptions opts = ActivityOptions.makeBasic(); opts.setDisallowEnterPictureInPictureWhileLaunching(true); context.startActivityAsUser(chooserIntent, opts.toBundle(), UserHandle.CURRENT);