Search in sources :

Example 61 with IIntentSender

use of android.content.IIntentSender in project platform_frameworks_base by android.

the class PendingIntent method getBroadcastAsUser.

/**
     * @hide
     * Note that UserHandle.CURRENT will be interpreted at the time the
     * broadcast is sent, not when the pending intent is created.
     */
public static PendingIntent getBroadcastAsUser(Context context, int requestCode, Intent intent, int flags, UserHandle userHandle) {
    String packageName = context.getPackageName();
    String resolvedType = intent != null ? intent.resolveTypeIfNeeded(context.getContentResolver()) : null;
    try {
        intent.prepareToLeaveProcess(context);
        IIntentSender target = ActivityManagerNative.getDefault().getIntentSender(ActivityManager.INTENT_SENDER_BROADCAST, packageName, null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, flags, null, userHandle.getIdentifier());
        return target != null ? new PendingIntent(target) : null;
    } catch (RemoteException e) {
    }
    return null;
}
Also used : IIntentSender(android.content.IIntentSender) RemoteException(android.os.RemoteException)

Example 62 with IIntentSender

use of android.content.IIntentSender in project cornerstone by Onskreen.

the class ActivityManagerService method startActivityIntentSender.

public int startActivityIntentSender(IApplicationThread caller, IntentSender intent, Intent fillInIntent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle options) {
    enforceNotIsolatedCaller("startActivityIntentSender");
    // Refuse possible leaked file descriptors
    if (fillInIntent != null && fillInIntent.hasFileDescriptors()) {
        throw new IllegalArgumentException("File descriptors passed in Intent");
    }
    IIntentSender sender = intent.getTarget();
    if (!(sender instanceof PendingIntentRecord)) {
        throw new IllegalArgumentException("Bad PendingIntent object");
    }
    PendingIntentRecord pir = (PendingIntentRecord) sender;
    synchronized (this) {
        // effectively saying that app switches are allowed at this point.
        if (mMainStack.mResumedActivity != null && mMainStack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
            mAppSwitchesAllowedTime = 0;
        }
        /**
             * Author: Onskreen
             * Date: 27/01/2011
             *
             * Mirroring the app switching logic in cornerstone. Not clear if this should
             * be mirrored or applied to only the appropriate stack?
             */
        if (mCornerstoneStack.mResumedActivity != null && mCornerstoneStack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
            mAppSwitchesAllowedTime = 0;
        }
    }
    int ret = pir.sendInner(0, fillInIntent, resolvedType, null, null, resultTo, resultWho, requestCode, flagsMask, flagsValues, options);
    return ret;
}
Also used : IIntentSender(android.content.IIntentSender)

Example 63 with IIntentSender

use of android.content.IIntentSender in project platform_frameworks_base by android.

the class ActivityManagerService method startActivityIntentSender.

@Override
public int startActivityIntentSender(IApplicationThread caller, IntentSender intent, Intent fillInIntent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions) throws TransactionTooLargeException {
    enforceNotIsolatedCaller("startActivityIntentSender");
    // Refuse possible leaked file descriptors
    if (fillInIntent != null && fillInIntent.hasFileDescriptors()) {
        throw new IllegalArgumentException("File descriptors passed in Intent");
    }
    IIntentSender sender = intent.getTarget();
    if (!(sender instanceof PendingIntentRecord)) {
        throw new IllegalArgumentException("Bad PendingIntent object");
    }
    PendingIntentRecord pir = (PendingIntentRecord) sender;
    synchronized (this) {
        // If this is coming from the currently resumed activity, it is
        // effectively saying that app switches are allowed at this point.
        final ActivityStack stack = getFocusedStack();
        if (stack.mResumedActivity != null && stack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
            mAppSwitchesAllowedTime = 0;
        }
    }
    int ret = pir.sendInner(0, fillInIntent, resolvedType, null, null, resultTo, resultWho, requestCode, flagsMask, flagsValues, bOptions, null);
    return ret;
}
Also used : IIntentSender(android.content.IIntentSender) Point(android.graphics.Point)

Example 64 with IIntentSender

use of android.content.IIntentSender in project platform_frameworks_base by android.

the class ActiveServices method requestStartTargetPermissionsReviewIfNeededLocked.

private boolean requestStartTargetPermissionsReviewIfNeededLocked(ServiceRecord r, String callingPackage, int callingUid, Intent service, boolean callerFg, final int userId) {
    if (mAm.getPackageManagerInternalLocked().isPermissionsReviewRequired(r.packageName, r.userId)) {
        // Show a permission review UI only for starting from a foreground app
        if (!callerFg) {
            Slog.w(TAG, "u" + r.userId + " Starting a service in package" + r.packageName + " requires a permissions review");
            return false;
        }
        IIntentSender target = mAm.getIntentSenderLocked(ActivityManager.INTENT_SENDER_SERVICE, callingPackage, callingUid, userId, null, null, 0, new Intent[] { service }, new String[] { service.resolveType(mAm.mContext.getContentResolver()) }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
        final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSIONS);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.putExtra(Intent.EXTRA_PACKAGE_NAME, r.packageName);
        intent.putExtra(Intent.EXTRA_INTENT, new IntentSender(target));
        if (DEBUG_PERMISSIONS_REVIEW) {
            Slog.i(TAG, "u" + r.userId + " Launching permission review for package " + r.packageName);
        }
        mAm.mHandler.post(new Runnable() {

            @Override
            public void run() {
                mAm.mContext.startActivityAsUser(intent, new UserHandle(userId));
            }
        });
        return false;
    }
    return true;
}
Also used : IIntentSender(android.content.IIntentSender) UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender)

Example 65 with IIntentSender

use of android.content.IIntentSender in project platform_frameworks_base by android.

the class BroadcastQueue method requestStartTargetPermissionsReviewIfNeededLocked.

private boolean requestStartTargetPermissionsReviewIfNeededLocked(BroadcastRecord receiverRecord, String receivingPackageName, final int receivingUserId) {
    if (!mService.getPackageManagerInternalLocked().isPermissionsReviewRequired(receivingPackageName, receivingUserId)) {
        return true;
    }
    final boolean callerForeground = receiverRecord.callerApp != null ? receiverRecord.callerApp.setSchedGroup != ProcessList.SCHED_GROUP_BACKGROUND : true;
    // Show a permission review UI only for explicit broadcast from a foreground app
    if (callerForeground && receiverRecord.intent.getComponent() != null) {
        IIntentSender target = mService.getIntentSenderLocked(ActivityManager.INTENT_SENDER_BROADCAST, receiverRecord.callerPackage, receiverRecord.callingUid, receiverRecord.userId, null, null, 0, new Intent[] { receiverRecord.intent }, new String[] { receiverRecord.intent.resolveType(mService.mContext.getContentResolver()) }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
        final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSIONS);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        intent.putExtra(Intent.EXTRA_PACKAGE_NAME, receivingPackageName);
        intent.putExtra(Intent.EXTRA_INTENT, new IntentSender(target));
        if (DEBUG_PERMISSIONS_REVIEW) {
            Slog.i(TAG, "u" + receivingUserId + " Launching permission review for package " + receivingPackageName);
        }
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                mService.mContext.startActivityAsUser(intent, new UserHandle(receivingUserId));
            }
        });
    } else {
        Slog.w(TAG, "u" + receivingUserId + " Receiving a broadcast in package" + receivingPackageName + " requires a permissions review");
    }
    return false;
}
Also used : IIntentSender(android.content.IIntentSender) UserHandle(android.os.UserHandle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender)

Aggregations

IIntentSender (android.content.IIntentSender)106 RemoteException (android.os.RemoteException)57 IntentSender (android.content.IntentSender)43 Intent (android.content.Intent)38 PendingIntent (android.app.PendingIntent)33 KeyguardManager (android.app.KeyguardManager)10 ResolveInfo (android.content.pm.ResolveInfo)10 UserInfo (android.content.pm.UserInfo)10 UserHandle (android.os.UserHandle)10 Parcel (android.os.Parcel)9 ComponentName (android.content.ComponentName)8 ActivityInfo (android.content.pm.ActivityInfo)8 HeavyWeightSwitcherActivity (com.android.internal.app.HeavyWeightSwitcherActivity)8 ActivityOptions (android.app.ActivityOptions)5 IActivityContainer (android.app.IActivityContainer)5 UserManager (android.os.UserManager)5 PendingActivityLaunch (com.android.server.am.ActivityStackSupervisor.PendingActivityLaunch)5 Point (android.graphics.Point)4 Message (android.os.Message)4