@Test public void noLoginIntentProvided() throws NetworkErrorException { Mockito.doAnswer(invocation -> null).when(authCallback).getLoginIntent(); Bundle result = authenticator.addAccount(response, account.type, tokenType, null, null); }
@Override public Bundle addAccount( @NonNull AccountAuthenticatorResponse response, @NonNull String accountType, @Nullable String authTokenType, @Nullable String[] requiredFeatures, @Nullable Bundle options) throws NetworkErrorException { log( "addAccount for %s as %s with features %s and options %s", accountType, authTokenType, Arrays.toString(requiredFeatures), BundleUtil.toString(options)); final Bundle bundle = new Bundle(); final Intent intent = service.getLoginIntent(); if (intent != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); bundle.putParcelable(AccountManager.KEY_INTENT, intent); } return bundle; }
OAuthAuthenticator extends AbstractAccountAuthenticator { @Override public Bundle addAccount( @NonNull AccountAuthenticatorResponse response, @NonNull String accountType, @Nullable String authTokenType, @Nullable String[] requiredFeatures, @Nullable Bundle options) throws NetworkErrorException { log( "addAccount for %s as %s with features %s and options %s", accountType, authTokenType, Arrays.toString(requiredFeatures), BundleUtil.toString(options)); final Bundle bundle = new Bundle(); final Intent intent = service.getLoginIntent(); if (intent != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); bundle.putParcelable(AccountManager.KEY_INTENT, intent); } return bundle; } }
OAuthAuthenticator extends AbstractAccountAuthenticator { @Override public Bundle addAccount( @NonNull AccountAuthenticatorResponse response, @NonNull String accountType, @Nullable String authTokenType, @Nullable String[] requiredFeatures, @Nullable Bundle options) throws NetworkErrorException { log( "addAccount for %s as %s with features %s and options %s", accountType, authTokenType, Arrays.toString(requiredFeatures), BundleUtil.toString(options)); final Bundle bundle = new Bundle(); final Intent intent = service.getLoginIntent(); if (intent != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); bundle.putParcelable(AccountManager.KEY_INTENT, intent); } return bundle; } @Inject  OAuthAuthenticator(Context context, AuthCallback service); }
OAuthAuthenticator extends AbstractAccountAuthenticator { @Override public Bundle addAccount( @NonNull AccountAuthenticatorResponse response, @NonNull String accountType, @Nullable String authTokenType, @Nullable String[] requiredFeatures, @Nullable Bundle options) throws NetworkErrorException { log( "addAccount for %s as %s with features %s and options %s", accountType, authTokenType, Arrays.toString(requiredFeatures), BundleUtil.toString(options)); final Bundle bundle = new Bundle(); final Intent intent = service.getLoginIntent(); if (intent != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); bundle.putParcelable(AccountManager.KEY_INTENT, intent); } return bundle; } @Inject  OAuthAuthenticator(Context context, AuthCallback service); @Override Bundle editProperties(
            @NonNull AccountAuthenticatorResponse response, @NonNull String accountType); @Override Bundle addAccount(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull String accountType,
            @Nullable String authTokenType,
            @Nullable String[] requiredFeatures,
            @Nullable Bundle options); @Override Bundle confirmCredentials(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull Account account,
            @Nullable Bundle options); @Override Bundle getAuthToken(
            @NonNull final AccountAuthenticatorResponse response,
            @NonNull final Account account,
            @NonNull final String authTokenType,
            @Nullable final Bundle options); @Override String getAuthTokenLabel(@NonNull String authTokenType); @Override Bundle updateCredentials(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull Account account,
            @Nullable String authTokenType,
            @Nullable Bundle options); @Override Bundle hasFeatures(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull Account account,
            @NonNull String[] features); boolean isLoggingEnabled(); void setLoggingEnabled(boolean loggingEnabled); }
OAuthAuthenticator extends AbstractAccountAuthenticator { @Override public Bundle addAccount( @NonNull AccountAuthenticatorResponse response, @NonNull String accountType, @Nullable String authTokenType, @Nullable String[] requiredFeatures, @Nullable Bundle options) throws NetworkErrorException { log( "addAccount for %s as %s with features %s and options %s", accountType, authTokenType, Arrays.toString(requiredFeatures), BundleUtil.toString(options)); final Bundle bundle = new Bundle(); final Intent intent = service.getLoginIntent(); if (intent != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); bundle.putParcelable(AccountManager.KEY_INTENT, intent); } return bundle; } @Inject  OAuthAuthenticator(Context context, AuthCallback service); @Override Bundle editProperties(
            @NonNull AccountAuthenticatorResponse response, @NonNull String accountType); @Override Bundle addAccount(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull String accountType,
            @Nullable String authTokenType,
            @Nullable String[] requiredFeatures,
            @Nullable Bundle options); @Override Bundle confirmCredentials(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull Account account,
            @Nullable Bundle options); @Override Bundle getAuthToken(
            @NonNull final AccountAuthenticatorResponse response,
            @NonNull final Account account,
            @NonNull final String authTokenType,
            @Nullable final Bundle options); @Override String getAuthTokenLabel(@NonNull String authTokenType); @Override Bundle updateCredentials(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull Account account,
            @Nullable String authTokenType,
            @Nullable Bundle options); @Override Bundle hasFeatures(
            @NonNull AccountAuthenticatorResponse response,
            @NonNull Account account,
            @NonNull String[] features); boolean isLoggingEnabled(); void setLoggingEnabled(boolean loggingEnabled);  }