Search in sources :

Example 91 with IntentSender

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

the class ConfirmDeviceCredentialUtils method checkForPendingIntent.

public static void checkForPendingIntent(Activity activity) {
    // See Change-Id I52c203735fa9b53fd2f7df971824747eeb930f36 for context
    int taskId = activity.getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
    if (taskId != -1) {
        try {
            IActivityManager activityManager = ActivityManager.getService();
            final ActivityOptions options = ActivityOptions.makeBasic();
            activityManager.startActivityFromRecents(taskId, options.toBundle());
            return;
        } catch (RemoteException e) {
        // Do nothing.
        }
    }
    IntentSender intentSender = activity.getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
    if (intentSender != null) {
        try {
            activity.startIntentSenderForResult(intentSender, -1, null, 0, 0, 0);
        } catch (IntentSender.SendIntentException e) {
        /* ignore */
        }
    }
}
Also used : RemoteException(android.os.RemoteException) IntentSender(android.content.IntentSender) IActivityManager(android.app.IActivityManager) ActivityOptions(android.app.ActivityOptions)

Example 92 with IntentSender

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

the class NotificationStation method formatPendingIntent.

private static String formatPendingIntent(PendingIntent pi) {
    final StringBuilder sb = new StringBuilder();
    final IntentSender is = pi.getIntentSender();
    sb.append("Intent(pkg=").append(is.getCreatorPackage());
    try {
        final boolean isActivity = ActivityManager.getService().isIntentSenderAnActivity(is.getTarget());
        if (isActivity)
            sb.append(" (activity)");
    } catch (RemoteException ex) {
    }
    sb.append(")");
    return sb.toString();
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) IntentSender(android.content.IntentSender) RemoteException(android.os.RemoteException)

Example 93 with IntentSender

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

the class AccountSyncSettings method requestAccountAccessIfNeeded.

private boolean requestAccountAccessIfNeeded(String packageName) {
    if (packageName == null) {
        return false;
    }
    final int uid;
    try {
        uid = getContext().getPackageManager().getPackageUidAsUser(packageName, mUserHandle.getIdentifier());
    } catch (PackageManager.NameNotFoundException e) {
        Log.e(TAG, "Invalid sync ", e);
        return false;
    }
    AccountManager accountManager = getContext().getSystemService(AccountManager.class);
    if (!accountManager.hasAccountAccess(mAccount, packageName, mUserHandle)) {
        IntentSender intent = accountManager.createRequestAccountAccessIntentSenderAsUser(mAccount, packageName, mUserHandle);
        if (intent != null) {
            try {
                startIntentSenderForResult(intent, uid, null, 0, 0, 0, null);
                return true;
            } catch (IntentSender.SendIntentException e) {
                Log.e(TAG, "Error requesting account access", e);
            }
        }
    }
    return false;
}
Also used : PackageManager(android.content.pm.PackageManager) AccountManager(android.accounts.AccountManager) IntentSender(android.content.IntentSender)

Example 94 with IntentSender

use of android.content.IntentSender in project VirtualApp by asLody.

the class VPackageInstallerService method uninstall.

@Override
public void uninstall(String packageName, String callerPackageName, int flags, IntentSender statusReceiver, int userId) throws RemoteException {
    boolean success = VAppManagerService.get().uninstallPackage(packageName);
    if (statusReceiver != null) {
        final Intent fillIn = new Intent();
        fillIn.putExtra(PackageInstaller.EXTRA_PACKAGE_NAME, packageName);
        fillIn.putExtra(PackageInstaller.EXTRA_STATUS, success ? PackageInstaller.STATUS_SUCCESS : PackageInstaller.STATUS_FAILURE);
        fillIn.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE, PackageHelper.deleteStatusToString(success));
        fillIn.putExtra("android.content.pm.extra.LEGACY_STATUS", success ? 1 : -1);
        try {
            statusReceiver.sendIntent(mContext, 0, fillIn, null, null);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }
    }
}
Also used : 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