Search in sources :

Example 51 with IntentSender

use of android.content.IntentSender in project android_frameworks_base by AOSPA.

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 52 with IntentSender

use of android.content.IntentSender in project android_frameworks_base by AOSPA.

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 53 with IntentSender

use of android.content.IntentSender in project android_frameworks_base by AOSPA.

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 54 with IntentSender

use of android.content.IntentSender in project android_frameworks_base by ResurrectionRemix.

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 55 with IntentSender

use of android.content.IntentSender in project android_frameworks_base by ResurrectionRemix.

the class UserState method print.

@SuppressWarnings("deprecation")
public Bundle print(@NonNull String printJobName, @NonNull IPrintDocumentAdapter adapter, @Nullable PrintAttributes attributes, @NonNull String packageName, int appId) {
    // Create print job place holder.
    final PrintJobInfo printJob = new PrintJobInfo();
    printJob.setId(new PrintJobId());
    printJob.setAppId(appId);
    printJob.setLabel(printJobName);
    printJob.setAttributes(attributes);
    printJob.setState(PrintJobInfo.STATE_CREATED);
    printJob.setCopies(1);
    printJob.setCreationTime(System.currentTimeMillis());
    // Track this job so we can forget it when the creator dies.
    if (!mPrintJobForAppCache.onPrintJobCreated(adapter.asBinder(), appId, printJob)) {
        // Not adding a print job means the client is dead - done.
        return null;
    }
    // Spin the spooler to add the job and show the config UI.
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            mSpooler.createPrintJob(printJob);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
    final long identity = Binder.clearCallingIdentity();
    try {
        Intent intent = new Intent(PrintManager.ACTION_PRINT_DIALOG);
        intent.setData(Uri.fromParts("printjob", printJob.getId().flattenToString(), null));
        intent.putExtra(PrintManager.EXTRA_PRINT_DOCUMENT_ADAPTER, adapter.asBinder());
        intent.putExtra(PrintManager.EXTRA_PRINT_JOB, printJob);
        intent.putExtra(DocumentsContract.EXTRA_PACKAGE_NAME, packageName);
        IntentSender intentSender = PendingIntent.getActivityAsUser(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, null, new UserHandle(mUserId)).getIntentSender();
        Bundle result = new Bundle();
        result.putParcelable(PrintManager.EXTRA_PRINT_JOB, printJob);
        result.putParcelable(PrintManager.EXTRA_PRINT_DIALOG_INTENT, intentSender);
        return result;
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : PrintJobId(android.print.PrintJobId) Bundle(android.os.Bundle) PrintJobInfo(android.print.PrintJobInfo) UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSender(android.content.IntentSender)

Aggregations

IntentSender (android.content.IntentSender)94 Intent (android.content.Intent)48 IIntentSender (android.content.IIntentSender)46 PendingIntent (android.app.PendingIntent)40 RemoteException (android.os.RemoteException)30 UserHandle (android.os.UserHandle)14 ActivityOptions (android.app.ActivityOptions)13 KeyguardManager (android.app.KeyguardManager)10 UserInfo (android.content.pm.UserInfo)10 Bundle (android.os.Bundle)10 IActivityManager (android.app.IActivityManager)8 ComponentName (android.content.ComponentName)8 ActivityInfo (android.content.pm.ActivityInfo)8 ResolveInfo (android.content.pm.ResolveInfo)8 HeavyWeightSwitcherActivity (com.android.internal.app.HeavyWeightSwitcherActivity)8 AccountManager (android.accounts.AccountManager)7 Activity (android.app.Activity)7 PackageManager (android.content.pm.PackageManager)7 Point (android.graphics.Point)7 SpannableStringBuilder (android.text.SpannableStringBuilder)7