Search in sources :

Example 21 with TransactionTooLargeException

use of android.os.TransactionTooLargeException in project android_frameworks_base by ResurrectionRemix.

the class PendingIntentRecord method sendInner.

int sendInner(int code, Intent intent, String resolvedType, IIntentReceiver finishedReceiver, String requiredPermission, IBinder resultTo, String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle options, IActivityContainer container) {
    if (intent != null)
        intent.setDefusable(true);
    if (options != null)
        options.setDefusable(true);
    if (whitelistDuration > 0 && !canceled) {
        // Must call before acquiring the lock. It's possible the method return before sending
        // the intent due to some validations inside the lock, in which case the UID shouldn't
        // be whitelisted, but since the whitelist is temporary, that would be ok.
        owner.tempWhitelistAppForPowerSave(Binder.getCallingPid(), Binder.getCallingUid(), uid, whitelistDuration);
    }
    synchronized (owner) {
        final ActivityContainer activityContainer = (ActivityContainer) container;
        if (activityContainer != null && activityContainer.mParentActivity != null && activityContainer.mParentActivity.state != ActivityStack.ActivityState.RESUMED) {
            // Cannot start a child activity if the parent is not resumed.
            return ActivityManager.START_CANCELED;
        }
        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();
            final boolean immutable = (key.flags & PendingIntent.FLAG_IMMUTABLE) != 0;
            if (!immutable) {
                if (intent != null) {
                    int changes = finalIntent.fillIn(intent, key.flags);
                    if ((changes & Intent.FILL_IN_DATA) == 0) {
                        resolvedType = key.requestResolvedType;
                    }
                } else {
                    resolvedType = key.requestResolvedType;
                }
                flagsMask &= ~Intent.IMMUTABLE_FLAGS;
                flagsValues &= flagsMask;
                finalIntent.setFlags((finalIntent.getFlags() & ~flagsMask) | flagsValues);
            } else {
                resolvedType = key.requestResolvedType;
            }
            final long origId = Binder.clearCallingIdentity();
            boolean sendFinish = finishedReceiver != null;
            int userId = key.userId;
            if (userId == UserHandle.USER_CURRENT) {
                userId = owner.mUserController.getCurrentOrTargetUserIdLocked();
            }
            int res = 0;
            switch(key.type) {
                case ActivityManager.INTENT_SENDER_ACTIVITY:
                    if (options == null) {
                        options = key.options;
                    } else if (key.options != null) {
                        Bundle opts = new Bundle(key.options);
                        opts.putAll(options);
                        options = opts;
                    }
                    try {
                        if (key.allIntents != null && key.allIntents.length > 1) {
                            Intent[] allIntents = new Intent[key.allIntents.length];
                            String[] allResolvedTypes = new String[key.allIntents.length];
                            System.arraycopy(key.allIntents, 0, allIntents, 0, key.allIntents.length);
                            if (key.allResolvedTypes != null) {
                                System.arraycopy(key.allResolvedTypes, 0, allResolvedTypes, 0, key.allResolvedTypes.length);
                            }
                            allIntents[allIntents.length - 1] = finalIntent;
                            allResolvedTypes[allResolvedTypes.length - 1] = resolvedType;
                            owner.startActivitiesInPackage(uid, key.packageName, allIntents, allResolvedTypes, resultTo, options, userId);
                        } else {
                            owner.startActivityInPackage(uid, key.packageName, finalIntent, resolvedType, resultTo, resultWho, requestCode, 0, options, userId, container, null);
                        }
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startActivity intent", e);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
                    if (key.activity.task.stack != null) {
                        key.activity.task.stack.sendActivityResultLocked(-1, key.activity, key.who, key.requestCode, code, finalIntent);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_BROADCAST:
                    try {
                        // If a completion callback has been requested, require
                        // that the broadcast be delivered synchronously
                        int sent = owner.broadcastIntentInPackage(key.packageName, uid, finalIntent, resolvedType, finishedReceiver, code, null, null, requiredPermission, options, (finishedReceiver != null), false, userId);
                        if (sent == ActivityManager.BROADCAST_SUCCESS) {
                            sendFinish = false;
                        }
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startActivity intent", e);
                    }
                    break;
                case ActivityManager.INTENT_SENDER_SERVICE:
                    try {
                        owner.startServiceInPackage(uid, finalIntent, resolvedType, key.packageName, userId);
                    } catch (RuntimeException e) {
                        Slog.w(TAG, "Unable to send startService intent", e);
                    } catch (TransactionTooLargeException e) {
                        res = ActivityManager.START_CANCELED;
                    }
                    break;
            }
            if (sendFinish && res != ActivityManager.START_CANCELED) {
                try {
                    finishedReceiver.performReceive(new Intent(finalIntent), 0, null, null, false, false, key.userId);
                } catch (RemoteException e) {
                }
            }
            Binder.restoreCallingIdentity(origId);
            return res;
        }
    }
    return ActivityManager.START_CANCELED;
}
Also used : Bundle(android.os.Bundle) ActivityContainer(com.android.server.am.ActivityStackSupervisor.ActivityContainer) IActivityContainer(android.app.IActivityContainer) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TransactionTooLargeException(android.os.TransactionTooLargeException) RemoteException(android.os.RemoteException)

Aggregations

TransactionTooLargeException (android.os.TransactionTooLargeException)21 RemoteException (android.os.RemoteException)15 PendingIntent (android.app.PendingIntent)10 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 DeadObjectException (android.os.DeadObjectException)10 IOException (java.io.IOException)10 IActivityContainer (android.app.IActivityContainer)5 IBinder (android.os.IBinder)5 Parcel (android.os.Parcel)5 RemoteCallback (android.os.RemoteCallback)5 UserHandle (android.os.UserHandle)5 ServiceState (com.android.internal.app.procstats.ServiceState)5 ActivityContainer (com.android.server.am.ActivityStackSupervisor.ActivityContainer)5 SuppressLint (android.annotation.SuppressLint)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 FileNotFoundException (java.io.FileNotFoundException)1 RuntimeException (java.lang.RuntimeException)1 StackOverflowError (java.lang.StackOverflowError)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1