Search in sources :

Example 81 with IntentSender

use of android.content.IntentSender in project robolectric by robolectric.

the class ShadowPackageInstallerTest method sessionCommitSession_streamProperlyClosed.

@Test
public void sessionCommitSession_streamProperlyClosed() throws Exception {
    int sessionId = packageInstaller.createSession(createSessionParams("packageName"));
    PackageInstaller.Session session = packageInstaller.openSession(sessionId);
    OutputStream outputStream = session.openWrite("filename", 0, 0);
    outputStream.close();
    session.commit(new IntentSender(ReflectionHelpers.createNullProxy(IIntentSender.class)));
}
Also used : OutputStream(java.io.OutputStream) PackageInstaller(android.content.pm.PackageInstaller) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender) Test(org.junit.Test)

Example 82 with IntentSender

use of android.content.IntentSender in project robolectric by robolectric.

the class ShadowPackageInstallerTest method sessionCommitSession_streamStillOpen.

@Test(expected = SecurityException.class)
public void sessionCommitSession_streamStillOpen() throws Exception {
    int sessionId = packageInstaller.createSession(createSessionParams("packageName"));
    PackageInstaller.Session session = packageInstaller.openSession(sessionId);
    session.openWrite("filename", 0, 0);
    session.commit(new IntentSender(ReflectionHelpers.createNullProxy(IIntentSender.class)));
}
Also used : PackageInstaller(android.content.pm.PackageInstaller) IIntentSender(android.content.IIntentSender) IntentSender(android.content.IntentSender) Test(org.junit.Test)

Example 83 with IntentSender

use of android.content.IntentSender in project robolectric by robolectric.

the class ShadowCompanionDeviceManagerTest method testAssociate.

@Test
public void testAssociate() {
    AssociationRequest request = new AssociationRequest.Builder().build();
    CompanionDeviceManager.Callback callback = new CompanionDeviceManager.Callback() {

        @Override
        public void onDeviceFound(IntentSender chooserLauncher) {
        }

        @Override
        public void onFailure(CharSequence error) {
        }
    };
    companionDeviceManager.associate(request, callback, null);
    assertThat(shadowCompanionDeviceManager.getLastAssociationRequest()).isSameInstanceAs(request);
    assertThat(shadowCompanionDeviceManager.getLastAssociationCallback()).isSameInstanceAs(callback);
}
Also used : CompanionDeviceManager(android.companion.CompanionDeviceManager) AssociationRequest(android.companion.AssociationRequest) IntentSender(android.content.IntentSender) Test(org.junit.Test)

Example 84 with IntentSender

use of android.content.IntentSender in project android_packages_apps_Settings by SudaMod.

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

use of android.content.IntentSender in project android_packages_apps_Settings by SudaMod.

the class ConfirmDeviceCredentialBaseFragment method checkForPendingIntent.

protected void checkForPendingIntent() {
    int taskId = getActivity().getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
    if (taskId != -1) {
        try {
            IActivityManager activityManager = ActivityManager.getService();
            final ActivityOptions options = ActivityOptions.makeBasic();
            options.setLaunchStackId(ActivityManager.StackId.INVALID_STACK_ID);
            activityManager.startActivityFromRecents(taskId, options.toBundle());
            return;
        } catch (RemoteException e) {
        // Do nothing.
        }
    }
    IntentSender intentSender = getActivity().getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
    if (intentSender != null) {
        try {
            getActivity().startIntentSenderForResult(intentSender, -1, null, 0, 0, 0);
        } catch (IntentSender.SendIntentException e) {
        /* ignore */
        }
    }
}
Also used : RemoteException(android.os.RemoteException) IntentSender(android.content.IntentSender) Point(android.graphics.Point) IActivityManager(android.app.IActivityManager) ActivityOptions(android.app.ActivityOptions)

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