Ensure screenshot edit action gets permissions for current user

Previously, edit action intent was sent to ActionProxyReceiver with the
SYSTEM user. It had the FLAG_GRANT_READ_URI_PERMISSION flag, but when
the current user wasn't the system user, the system user wouldn't have
permissions to read that URI so it didn't work. This caused Markup to
fail to open the screenshot since it wasn't given permission.

Bug: 148128165
Test: Validate that Markup can read/write/delete screenshot w/ secondary
      user.
Change-Id: Ifa1d8fd195d5f777ab51972183ed6db4e6735ffd
This commit is contained in:
Matt Casey
2020-05-20 14:56:28 -04:00
parent 197709093a
commit c57f0cb7f2

View File

@@ -331,7 +331,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
int requestCode = mContext.getUserId();
// Create a edit action
PendingIntent editAction = PendingIntent.getBroadcastAsUser(context, requestCode,
PendingIntent editAction = PendingIntent.getBroadcast(context, requestCode,
new Intent(context, GlobalScreenshot.ActionProxyReceiver.class)
.putExtra(GlobalScreenshot.EXTRA_ACTION_INTENT, editIntent)
.putExtra(GlobalScreenshot.EXTRA_CANCEL_NOTIFICATION,
@@ -341,7 +341,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
mSmartActionsEnabled)
.setAction(Intent.ACTION_EDIT)
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND),
PendingIntent.FLAG_CANCEL_CURRENT, UserHandle.SYSTEM);
PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Action.Builder editActionBuilder = new Notification.Action.Builder(
Icon.createWithResource(r, R.drawable.ic_screenshot_edit),
r.getString(com.android.internal.R.string.screenshot_edit), editAction);