Merge "Make ActionProxyReceiver use PendingIntent." into rvc-dev am: a97dfd239e am: 66563da34e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11935080 Change-Id: I56b60a2298e7d0e6a8152879feefca27b44f3f65
This commit is contained in:
@@ -1105,14 +1105,19 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent actionIntent = intent.getParcelableExtra(EXTRA_ACTION_INTENT);
|
PendingIntent actionIntent = intent.getParcelableExtra(EXTRA_ACTION_INTENT);
|
||||||
if (intent.getBooleanExtra(EXTRA_CANCEL_NOTIFICATION, false)) {
|
if (intent.getBooleanExtra(EXTRA_CANCEL_NOTIFICATION, false)) {
|
||||||
ScreenshotNotificationsController.cancelScreenshotNotification(context);
|
ScreenshotNotificationsController.cancelScreenshotNotification(context);
|
||||||
}
|
}
|
||||||
ActivityOptions opts = ActivityOptions.makeBasic();
|
ActivityOptions opts = ActivityOptions.makeBasic();
|
||||||
opts.setDisallowEnterPictureInPictureWhileLaunching(
|
opts.setDisallowEnterPictureInPictureWhileLaunching(
|
||||||
intent.getBooleanExtra(EXTRA_DISALLOW_ENTER_PIP, false));
|
intent.getBooleanExtra(EXTRA_DISALLOW_ENTER_PIP, false));
|
||||||
context.startActivityAsUser(actionIntent, opts.toBundle(), UserHandle.CURRENT);
|
try {
|
||||||
|
actionIntent.send(context, 0, null, null, null, null, opts.toBundle());
|
||||||
|
} catch (PendingIntent.CanceledException e) {
|
||||||
|
Log.e(TAG, "Pending intent canceled", e);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mStatusBar != null) {
|
if (mStatusBar != null) {
|
||||||
|
|||||||
@@ -281,11 +281,13 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
|||||||
Intent.createChooser(sharingIntent, null, chooserAction.getIntentSender())
|
Intent.createChooser(sharingIntent, null, chooserAction.getIntentSender())
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivityAsUser(context, requestCode,
|
||||||
|
sharingChooserIntent, 0, null, UserHandle.CURRENT);
|
||||||
|
|
||||||
// Create a share action for the notification
|
// Create a share action for the notification
|
||||||
PendingIntent shareAction = PendingIntent.getBroadcastAsUser(context, requestCode,
|
PendingIntent shareAction = PendingIntent.getBroadcastAsUser(context, requestCode,
|
||||||
new Intent(context, GlobalScreenshot.ActionProxyReceiver.class)
|
new Intent(context, GlobalScreenshot.ActionProxyReceiver.class)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_ACTION_INTENT, sharingChooserIntent)
|
.putExtra(GlobalScreenshot.EXTRA_ACTION_INTENT, pendingIntent)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_DISALLOW_ENTER_PIP, true)
|
.putExtra(GlobalScreenshot.EXTRA_DISALLOW_ENTER_PIP, true)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_ID, mScreenshotId)
|
.putExtra(GlobalScreenshot.EXTRA_ID, mScreenshotId)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_SMART_ACTIONS_ENABLED,
|
.putExtra(GlobalScreenshot.EXTRA_SMART_ACTIONS_ENABLED,
|
||||||
@@ -320,14 +322,17 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
|||||||
editIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
editIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
editIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
editIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivityAsUser(context, 0,
|
||||||
|
editIntent, 0, null, UserHandle.CURRENT);
|
||||||
|
|
||||||
// Make sure pending intents for the system user are still unique across users
|
// Make sure pending intents for the system user are still unique across users
|
||||||
// by setting the (otherwise unused) request code to the current user id.
|
// by setting the (otherwise unused) request code to the current user id.
|
||||||
int requestCode = mContext.getUserId();
|
int requestCode = mContext.getUserId();
|
||||||
|
|
||||||
// Create a edit action
|
// Create a edit action
|
||||||
PendingIntent editAction = PendingIntent.getBroadcast(context, requestCode,
|
PendingIntent editAction = PendingIntent.getBroadcastAsUser(context, requestCode,
|
||||||
new Intent(context, GlobalScreenshot.ActionProxyReceiver.class)
|
new Intent(context, GlobalScreenshot.ActionProxyReceiver.class)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_ACTION_INTENT, editIntent)
|
.putExtra(GlobalScreenshot.EXTRA_ACTION_INTENT, pendingIntent)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_CANCEL_NOTIFICATION,
|
.putExtra(GlobalScreenshot.EXTRA_CANCEL_NOTIFICATION,
|
||||||
editIntent.getComponent() != null)
|
editIntent.getComponent() != null)
|
||||||
.putExtra(GlobalScreenshot.EXTRA_ID, mScreenshotId)
|
.putExtra(GlobalScreenshot.EXTRA_ID, mScreenshotId)
|
||||||
@@ -335,7 +340,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
|
|||||||
mSmartActionsEnabled)
|
mSmartActionsEnabled)
|
||||||
.setAction(Intent.ACTION_EDIT)
|
.setAction(Intent.ACTION_EDIT)
|
||||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND),
|
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND),
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent.FLAG_CANCEL_CURRENT, UserHandle.SYSTEM);
|
||||||
Notification.Action.Builder editActionBuilder = new Notification.Action.Builder(
|
Notification.Action.Builder editActionBuilder = new Notification.Action.Builder(
|
||||||
Icon.createWithResource(r, R.drawable.ic_screenshot_edit),
|
Icon.createWithResource(r, R.drawable.ic_screenshot_edit),
|
||||||
r.getString(com.android.internal.R.string.screenshot_edit), editAction);
|
r.getString(com.android.internal.R.string.screenshot_edit), editAction);
|
||||||
|
|||||||
Reference in New Issue
Block a user