Search in sources :

Example 71 with IIntentSender

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

the class ActivityStarter method showConfirmDeviceCredential.

void showConfirmDeviceCredential(int userId) {
    // First, retrieve the stack that we want to resume after credential is confirmed.
    ActivityStack targetStack;
    ActivityStack fullscreenStack = mSupervisor.getStack(FULLSCREEN_WORKSPACE_STACK_ID);
    ActivityStack freeformStack = mSupervisor.getStack(FREEFORM_WORKSPACE_STACK_ID);
    if (fullscreenStack != null && fullscreenStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) {
        // Single window case and the case that the docked stack is shown with fullscreen stack.
        targetStack = fullscreenStack;
    } else if (freeformStack != null && freeformStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) {
        targetStack = freeformStack;
    } else {
        // The case that the docked stack is shown with recent.
        targetStack = mSupervisor.getStack(HOME_STACK_ID);
    }
    if (targetStack == null) {
        return;
    }
    final KeyguardManager km = (KeyguardManager) mService.mContext.getSystemService(Context.KEYGUARD_SERVICE);
    final Intent credential = km.createConfirmDeviceCredentialIntent(null, null, userId);
    // For safety, check null here in case users changed the setting after the checking.
    if (credential == null) {
        return;
    }
    final ActivityRecord activityRecord = targetStack.topRunningActivityLocked();
    if (activityRecord != null) {
        final IIntentSender target = mService.getIntentSenderLocked(ActivityManager.INTENT_SENDER_ACTIVITY, activityRecord.launchedFromPackage, activityRecord.launchedFromUid, activityRecord.userId, null, null, 0, new Intent[] { activityRecord.intent }, new String[] { activityRecord.resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE, null);
        credential.putExtra(Intent.EXTRA_INTENT, new IntentSender(target));
        // Show confirm credentials activity.
        startConfirmCredentialIntent(credential);
    }
}
Also used : IIntentSender(android.content.IIntentSender) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSender(android.content.IntentSender) IIntentSender(android.content.IIntentSender) KeyguardManager(android.app.KeyguardManager)

Example 72 with IIntentSender

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

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

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

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

use of android.content.IIntentSender in project XobotOS by xamarin.

the class PendingIntent method getActivities.

/**
     * Like {@link #getActivity(Context, int, Intent, int)}, but allows an
     * array of Intents to be supplied.  The first Intent in the array is
     * taken as the primary key for the PendingIntent, like the single Intent
     * given to {@link #getActivity(Context, int, Intent, int)}.  Upon sending
     * the resulting PendingIntent, all of the Intents are started in the same
     * way as they would be by passing them to {@link Context#startActivities(Intent[])}.
     *
     * <p class="note">
     * The <em>first</em> intent in the array will be started outside of the context of an
     * existing activity, so you must use the {@link Intent#FLAG_ACTIVITY_NEW_TASK
     * Intent.FLAG_ACTIVITY_NEW_TASK} launch flag in the Intent.  (Activities after
     * the first in the array are started in the context of the previous activity
     * in the array, so FLAG_ACTIVITY_NEW_TASK is not needed nor desired for them.)
     * </p>
     *
     * <p class="note">
     * The <em>last</em> intent in the array represents the key for the
     * PendingIntent.  In other words, it is the significant element for matching
     * (as done with the single intent given to {@link #getActivity(Context, int, Intent, int)},
     * its content will be the subject of replacement by
     * {@link #send(Context, int, Intent)} and {@link #FLAG_UPDATE_CURRENT}, etc.
     * This is because it is the most specific of the supplied intents, and the
     * UI the user actually sees when the intents are started.
     * </p>
     *
     * @param context The Context in which this PendingIntent should start
     * the activity.
     * @param requestCode Private request code for the sender (currently
     * not used).
     * @param intents Array of Intents of the activities to be launched.
     * @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
     * {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
     * or any of the flags as supported by
     * {@link Intent#fillIn Intent.fillIn()} to control which unspecified parts
     * of the intent that can be supplied when the actual send happens.
     *
     * @return Returns an existing or new PendingIntent matching the given
     * parameters.  May return null only if {@link #FLAG_NO_CREATE} has been
     * supplied.
     */
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags) {
    String packageName = context.getPackageName();
    String[] resolvedTypes = new String[intents.length];
    for (int i = 0; i < intents.length; i++) {
        intents[i].setAllowFds(false);
        resolvedTypes[i] = intents[i].resolveTypeIfNeeded(context.getContentResolver());
    }
    try {
        IIntentSender target = ActivityManagerNative.getDefault().getIntentSender(IActivityManager.INTENT_SENDER_ACTIVITY, packageName, null, null, requestCode, intents, resolvedTypes, flags);
        return target != null ? new PendingIntent(target) : null;
    } catch (RemoteException e) {
    }
    return null;
}
Also used : IIntentSender(android.content.IIntentSender) RemoteException(android.os.RemoteException)

Example 75 with IIntentSender

use of android.content.IIntentSender in project XobotOS by xamarin.

the class PendingIntent method getService.

/**
     * Retrieve a PendingIntent that will start a service, like calling
     * {@link Context#startService Context.startService()}.  The start
     * arguments given to the service will come from the extras of the Intent.
     *
     * @param context The Context in which this PendingIntent should start
     * the service.
     * @param requestCode Private request code for the sender (currently
     * not used).
     * @param intent An Intent describing the service to be started.
     * @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
     * {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
     * or any of the flags as supported by
     * {@link Intent#fillIn Intent.fillIn()} to control which unspecified parts
     * of the intent that can be supplied when the actual send happens.
     *
     * @return Returns an existing or new PendingIntent matching the given
     * parameters.  May return null only if {@link #FLAG_NO_CREATE} has been
     * supplied.
     */
public static PendingIntent getService(Context context, int requestCode, Intent intent, int flags) {
    String packageName = context.getPackageName();
    String resolvedType = intent != null ? intent.resolveTypeIfNeeded(context.getContentResolver()) : null;
    try {
        intent.setAllowFds(false);
        IIntentSender target = ActivityManagerNative.getDefault().getIntentSender(IActivityManager.INTENT_SENDER_SERVICE, packageName, null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, flags);
        return target != null ? new PendingIntent(target) : null;
    } catch (RemoteException e) {
    }
    return null;
}
Also used : IIntentSender(android.content.IIntentSender) RemoteException(android.os.RemoteException)

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