Search in sources :

Example 66 with IIntentSender

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

the class ActivityStartInterceptor method interceptWithConfirmCredentialsIfNeeded.

/**
     * Creates an intent to intercept the current activity start with Confirm Credentials if needed.
     *
     * @return The intercepting intent if needed.
     */
private Intent interceptWithConfirmCredentialsIfNeeded(Intent intent, String resolvedType, ActivityInfo aInfo, String callingPackage, int userId) {
    if (!mService.mUserController.shouldConfirmCredentials(userId)) {
        return null;
    }
    // Allow direct boot aware activity to be displayed before the user is unlocked.
    if (aInfo.directBootAware && mService.mUserController.isUserRunningLocked(userId, ActivityManager.FLAG_AND_LOCKED)) {
        return null;
    }
    final IIntentSender target = mService.getIntentSenderLocked(INTENT_SENDER_ACTIVITY, callingPackage, Binder.getCallingUid(), userId, null, null, 0, new Intent[] { intent }, new String[] { resolvedType }, FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT | FLAG_IMMUTABLE, null);
    final KeyguardManager km = (KeyguardManager) mService.mContext.getSystemService(KEYGUARD_SERVICE);
    final Intent newIntent = km.createConfirmDeviceCredentialIntent(null, null, userId);
    if (newIntent == null) {
        return null;
    }
    newIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | FLAG_ACTIVITY_TASK_ON_HOME);
    newIntent.putExtra(EXTRA_PACKAGE_NAME, aInfo.packageName);
    newIntent.putExtra(EXTRA_INTENT, new IntentSender(target));
    return newIntent;
}
Also used : IIntentSender(android.content.IIntentSender) Intent(android.content.Intent) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender) KeyguardManager(android.app.KeyguardManager)

Example 67 with IIntentSender

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

the class ActivityStartInterceptor method interceptQuietProfileIfNeeded.

private boolean interceptQuietProfileIfNeeded() {
    // Do not intercept if the user has not turned off the profile
    if (!mUserManager.isQuietModeEnabled(UserHandle.of(mUserId))) {
        return false;
    }
    IIntentSender target = mService.getIntentSenderLocked(INTENT_SENDER_ACTIVITY, mCallingPackage, mCallingUid, mUserId, null, null, 0, new Intent[] { mIntent }, new String[] { mResolvedType }, FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT, null);
    mIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(mUserId, new IntentSender(target));
    mCallingPid = mRealCallingPid;
    mCallingUid = mRealCallingUid;
    mResolvedType = null;
    final UserInfo parent = mUserManager.getProfileParent(mUserId);
    mRInfo = mSupervisor.resolveIntent(mIntent, mResolvedType, parent.id);
    mAInfo = mSupervisor.resolveActivity(mIntent, mRInfo, mStartFlags, null);
    return true;
}
Also used : IIntentSender(android.content.IIntentSender) UserInfo(android.content.pm.UserInfo) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender)

Example 68 with IIntentSender

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

the class ActivityStarter method buildEphemeralInstallerIntent.

/**
     * Builds and returns an intent to launch the ephemeral installer.
     */
private Intent buildEphemeralInstallerIntent(Intent launchIntent, Intent origIntent, String ephemeralPackage, String callingPackage, String resolvedType, int userId) {
    final Intent nonEphemeralIntent = new Intent(origIntent);
    nonEphemeralIntent.setFlags(nonEphemeralIntent.getFlags() | Intent.FLAG_IGNORE_EPHEMERAL);
    // Intent that is launched if the ephemeral package couldn't be installed
    // for any reason.
    final IIntentSender failureIntentTarget = mService.getIntentSenderLocked(ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, Binder.getCallingUid(), userId, null, /*token*/
    null, /*resultWho*/
    1, new Intent[] { nonEphemeralIntent }, new String[] { resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
    final Intent ephemeralIntent;
    if (USE_DEFAULT_EPHEMERAL_LAUNCHER) {
        // Force the intent to be directed to the ephemeral package
        ephemeralIntent = new Intent(origIntent);
        ephemeralIntent.setPackage(ephemeralPackage);
    } else {
        // Success intent goes back to the installer
        ephemeralIntent = new Intent(launchIntent);
    }
    // Intent that is eventually launched if the ephemeral package was
    // installed successfully. This will actually be launched by a platform
    // broadcast receiver.
    final IIntentSender successIntentTarget = mService.getIntentSenderLocked(ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, Binder.getCallingUid(), userId, null, /*token*/
    null, /*resultWho*/
    0, new Intent[] { ephemeralIntent }, new String[] { resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
    // Finally build the actual intent to launch the ephemeral installer
    int flags = launchIntent.getFlags();
    final Intent intent = new Intent();
    intent.setFlags(flags | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    intent.putExtra(Intent.EXTRA_PACKAGE_NAME, ephemeralPackage);
    intent.putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, new IntentSender(failureIntentTarget));
    intent.putExtra(Intent.EXTRA_EPHEMERAL_SUCCESS, new IntentSender(successIntentTarget));
    // TODO: Remove when the platform has fully implemented ephemeral apps
    intent.setData(origIntent.getData().buildUpon().clearQuery().build());
    return intent;
}
Also used : IIntentSender(android.content.IIntentSender) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSender(android.content.IntentSender) IIntentSender(android.content.IIntentSender)

Example 69 with IIntentSender

use of android.content.IIntentSender in project android_frameworks_base by DirtyUnicorns.

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 70 with IIntentSender

use of android.content.IIntentSender in project android_frameworks_base by DirtyUnicorns.

the class ActivityStarter method buildEphemeralInstallerIntent.

/**
     * Builds and returns an intent to launch the ephemeral installer.
     */
private Intent buildEphemeralInstallerIntent(Intent launchIntent, Intent origIntent, String ephemeralPackage, String callingPackage, String resolvedType, int userId) {
    final Intent nonEphemeralIntent = new Intent(origIntent);
    nonEphemeralIntent.setFlags(nonEphemeralIntent.getFlags() | Intent.FLAG_IGNORE_EPHEMERAL);
    // Intent that is launched if the ephemeral package couldn't be installed
    // for any reason.
    final IIntentSender failureIntentTarget = mService.getIntentSenderLocked(ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, Binder.getCallingUid(), userId, null, /*token*/
    null, /*resultWho*/
    1, new Intent[] { nonEphemeralIntent }, new String[] { resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
    final Intent ephemeralIntent;
    if (USE_DEFAULT_EPHEMERAL_LAUNCHER) {
        // Force the intent to be directed to the ephemeral package
        ephemeralIntent = new Intent(origIntent);
        ephemeralIntent.setPackage(ephemeralPackage);
    } else {
        // Success intent goes back to the installer
        ephemeralIntent = new Intent(launchIntent);
    }
    // Intent that is eventually launched if the ephemeral package was
    // installed successfully. This will actually be launched by a platform
    // broadcast receiver.
    final IIntentSender successIntentTarget = mService.getIntentSenderLocked(ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, Binder.getCallingUid(), userId, null, /*token*/
    null, /*resultWho*/
    0, new Intent[] { ephemeralIntent }, new String[] { resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
    // Finally build the actual intent to launch the ephemeral installer
    int flags = launchIntent.getFlags();
    final Intent intent = new Intent();
    intent.setFlags(flags | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    intent.putExtra(Intent.EXTRA_PACKAGE_NAME, ephemeralPackage);
    intent.putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, new IntentSender(failureIntentTarget));
    intent.putExtra(Intent.EXTRA_EPHEMERAL_SUCCESS, new IntentSender(successIntentTarget));
    // TODO: Remove when the platform has fully implemented ephemeral apps
    intent.setData(origIntent.getData().buildUpon().clearQuery().build());
    return intent;
}
Also used : IIntentSender(android.content.IIntentSender) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSender(android.content.IntentSender) IIntentSender(android.content.IIntentSender)

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