FileDocCategorySizeDatePackage
PendingIntentRecord.javaAPI DocAndroid 1.5 API10711Wed May 06 22:42:00 BST 2009com.android.server.am

PendingIntentRecord

public class PendingIntentRecord extends IIntentSender.Stub

Fields Summary
final ActivityManagerService
owner
final Key
key
final int
uid
final WeakReference
ref
boolean
sent
boolean
canceled
Constructors Summary
PendingIntentRecord(ActivityManagerService _owner, Key _k, int _u)

        owner = _owner;
        key = _k;
        uid = _u;
        ref = new WeakReference<PendingIntentRecord>(this);
    
Methods Summary
voiddump(java.io.PrintWriter pw, java.lang.String prefix)

        pw.println(prefix + "packageName=" + key.packageName
                + " type=" + key.typeName()
                + " flags=0x" + Integer.toHexString(key.flags));
        pw.println(prefix + "activity=" + key.activity + " who=" + key.who);
        pw.println(prefix + "requestCode=" + key.requestCode
                + " requestResolvedType=" + key.requestResolvedType);
        pw.println(prefix + "requestIntent=" + key.requestIntent);
        pw.println(prefix + "sent=" + sent + " canceled=" + canceled);
    
protected voidfinalize()

        if (!canceled) {
            synchronized(owner) {
                WeakReference<PendingIntentRecord> current =
                        owner.mIntentSenderRecords.get(key);
                if (current == ref) {
                    owner.mIntentSenderRecords.remove(key);
                }
            }
        }
    
public intsend(int code, android.content.Intent intent, java.lang.String resolvedType, android.app.IIntentReceiver finishedReceiver)

        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;
    
public java.lang.StringtoString()

        return "IntentSenderRecord{"
            + Integer.toHexString(System.identityHashCode(this))
            + " " + key.packageName + " " + key.typeName() + "}";