Merge changes I2b6bfca0,I9a854d43

* changes:
  Add option to retrieve pending intent result
  Fix issue with permission check for shortcuts and pendingIntent
This commit is contained in:
Jorim Jaggi
2018-01-23 17:14:03 +00:00
committed by Android (Google) Code Review
12 changed files with 447 additions and 178 deletions

View File

@@ -867,19 +867,30 @@ public final class PendingIntent implements Parcelable {
@Nullable OnFinished onFinished, @Nullable Handler handler,
@Nullable String requiredPermission, @Nullable Bundle options)
throws CanceledException {
if (sendAndReturnResult(context, code, intent, onFinished, handler, requiredPermission,
options) < 0) {
throw new CanceledException();
}
}
/**
* Like {@link #send}, but returns the result
* @hide
*/
public int sendAndReturnResult(Context context, int code, @Nullable Intent intent,
@Nullable OnFinished onFinished, @Nullable Handler handler,
@Nullable String requiredPermission, @Nullable Bundle options)
throws CanceledException {
try {
String resolvedType = intent != null ?
intent.resolveTypeIfNeeded(context.getContentResolver())
: null;
int res = ActivityManager.getService().sendIntentSender(
return ActivityManager.getService().sendIntentSender(
mTarget, mWhitelistToken, code, intent, resolvedType,
onFinished != null
? new FinishedDispatcher(this, onFinished, handler)
: null,
requiredPermission, options);
if (res < 0) {
throw new CanceledException();
}
} catch (RemoteException e) {
throw new CanceledException(e);
}