synchronized(owner) {
if (!canceled) {
sent = true;
if ((key.flags&PendingIntent.FLAG_ONE_SHOT) != 0) {
owner.cancelIntentSenderLocked(this, true);
canceled = true;
}
Intent finalIntent = key.requestIntent != null
? new Intent(key.requestIntent) : new Intent();
if (intent != null) {
int changes = finalIntent.fillIn(intent, key.flags);
if ((changes&Intent.FILL_IN_DATA) == 0) {
resolvedType = key.requestResolvedType;
}
} else {
resolvedType = key.requestResolvedType;
}
final long origId = Binder.clearCallingIdentity();
boolean sendFinish = finishedReceiver != null;
switch (key.type) {
case IActivityManager.INTENT_SENDER_ACTIVITY:
try {
owner.startActivityInPackage(uid,
finalIntent, resolvedType,
null, null, 0, false);
} catch (RuntimeException e) {
Log.w(ActivityManagerService.TAG,
"Unable to send startActivity intent", e);
}
break;
case IActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
owner.sendActivityResultLocked(-1, key.activity,
key.who, key.requestCode, code, finalIntent);
break;
case IActivityManager.INTENT_SENDER_BROADCAST:
try {
// If a completion callback has been requested, require
// that the broadcast be delivered synchronously
owner.broadcastIntentInPackage(key.packageName, uid,
finalIntent, resolvedType,
finishedReceiver, code, null, null, null,
(finishedReceiver != null), false);
sendFinish = false;
} catch (RuntimeException e) {
Log.w(ActivityManagerService.TAG,
"Unable to send startActivity intent", e);
}
break;
case IActivityManager.INTENT_SENDER_SERVICE:
try {
owner.startServiceInPackage(uid,
finalIntent, resolvedType);
} catch (RuntimeException e) {
Log.w(ActivityManagerService.TAG,
"Unable to send startService intent", e);
}
break;
}
if (sendFinish) {
try {
finishedReceiver.performReceive(new Intent(finalIntent), 0,
null, null, false);
} catch (RemoteException e) {
}
}
Binder.restoreCallingIdentity(origId);
return 0;
}
}
return -1;