@Implements(android.accounts.AccountManager.class) public class ShadowAccountManager extends Object
Constructor | Description |
---|---|
ShadowAccountManager() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
__constructor__(Context context,
IAccountManager service) |
|
void |
addAccount(Account account) |
|
void |
addAccount(Account account,
String... visibileToPackages) |
Adds an account to the AccountManager but when
AccountManager.getAccountsByTypeForPackage(String, String)
is called will be included if is in one of the #visibileToPackages |
protected AccountManagerFuture<Bundle> |
addAccount(String accountType,
String authTokenType,
String[] requiredFeatures,
Bundle addAccountOptions,
Activity activity,
AccountManagerCallback<Bundle> callback,
Handler handler) |
|
protected boolean |
addAccountExplicitly(Account account,
String password,
Bundle userdata) |
|
void |
addAuthenticator(AuthenticatorDescription authenticator) |
|
void |
addAuthenticator(String type) |
|
protected void |
addOnAccountsUpdatedListener(OnAccountsUpdateListener listener,
Handler handler,
boolean updateImmediately) |
|
protected void |
addOnAccountsUpdatedListener(OnAccountsUpdateListener listener,
Handler handler,
boolean updateImmediately,
String[] accountTypes) |
|
protected String |
blockingGetAuthToken(Account account,
String authTokenType,
boolean notifyAuthFailure) |
|
protected static AccountManager |
get(Context context) |
Deprecated.
This method will be removed in Robolectric 3.4 Use
AccountManager.get(Context) instead. |
protected Account[] |
getAccounts() |
|
protected Account[] |
getAccountsByType(String type) |
|
protected AccountManagerFuture<Account[]> |
getAccountsByTypeAndFeatures(String type,
String[] features,
AccountManagerCallback<Account[]> callback,
Handler handler) |
|
protected Account[] |
getAccountsByTypeForPackage(String type,
String packageName) |
|
protected AuthenticatorDescription[] |
getAuthenticatorTypes() |
|
protected AccountManagerFuture<Bundle> |
getAuthToken(Account account,
String authTokenType,
Bundle options,
boolean notifyAuthFailure,
AccountManagerCallback<Bundle> callback,
Handler handler) |
|
protected AccountManagerFuture<Bundle> |
getAuthToken(Account account,
String authTokenType,
Bundle options,
Activity activity,
AccountManagerCallback<Bundle> callback,
Handler handler) |
|
Map<OnAccountsUpdateListener,Set<String>> |
getListeners() |
|
Bundle |
getNextAddAccountOptions() |
Consumes and returns the next
addAccountOptions passed to addAccount(android.accounts.Account) . |
protected String |
getPassword(Account account) |
|
protected String |
getPreviousName(Account account) |
|
protected String |
getUserData(Account account,
String key) |
|
protected AccountManagerFuture<Boolean> |
hasFeatures(Account account,
String[] features,
AccountManagerCallback<Boolean> callback,
Handler handler) |
|
protected void |
invalidateAuthToken(String accountType,
String authToken) |
|
protected String |
peekAuthToken(Account account,
String tokenType) |
|
Bundle |
peekNextAddAccountOptions() |
Returns the next
addAccountOptions passed to addAccount(android.accounts.Account) without consuming it. |
protected AccountManagerFuture<Boolean> |
removeAccount(Account account,
AccountManagerCallback<Boolean> callback,
Handler handler) |
The remove operation is posted to the given
handler , and will be executed according to
the Scheduler.IdleState of the corresponding Scheduler . |
protected AccountManagerFuture<Bundle> |
removeAccount(Account account,
Activity activity,
AccountManagerCallback<Bundle> callback,
Handler handler) |
Removes the account unless
setRemoveAccountIntent(android.content.Intent) has been set. |
protected boolean |
removeAccountExplicitly(Account account) |
|
void |
removeAllAccounts() |
Removes all accounts that have been added.
|
protected void |
removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) |
|
void |
setAuthenticationErrorOnNextResponse(boolean authenticationErrorOnNextResponse) |
Sets authenticator exception, which will be thrown by
getAccountsByTypeAndFeatures(java.lang.String, java.lang.String[], android.accounts.AccountManagerCallback<android.accounts.Account[]>, android.os.Handler) . |
protected void |
setAuthToken(Account account,
String tokenType,
String authToken) |
|
void |
setFeatures(Account account,
String[] accountFeatures) |
|
protected void |
setPassword(Account account,
String password) |
|
void |
setPreviousAccountName(Account account,
String previousName) |
Sets the previous name for an account, which will be returned by
AccountManager.getPreviousName(Account) . |
void |
setRemoveAccountIntent(Intent removeAccountIntent) |
Sets the intent to include in Bundle result from
removeAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler) if Activity is given. |
protected void |
setUserData(Account account,
String key,
String value) |
@Implementation protected void __constructor__(Context context, IAccountManager service)
@Deprecated @Implementation protected static AccountManager get(Context context)
AccountManager.get(Context)
instead.@Implementation protected Account[] getAccounts()
@Implementation protected Account[] getAccountsByType(String type)
@Implementation protected void setAuthToken(Account account, String tokenType, String authToken)
@Implementation protected String peekAuthToken(Account account, String tokenType)
@Implementation protected boolean addAccountExplicitly(Account account, String password, Bundle userdata)
@Implementation protected String blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure)
@Implementation protected AccountManagerFuture<Boolean> removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler)
handler
, and will be executed according to
the Scheduler.IdleState
of the corresponding Scheduler
.@Implementation(minSdk=22) protected AccountManagerFuture<Bundle> removeAccount(Account account, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
setRemoveAccountIntent(android.content.Intent)
has been set. If set, the future
Bundle will include the Intent and AccountManager.KEY_BOOLEAN_RESULT
will be false.@Implementation(minSdk=22) protected boolean removeAccountExplicitly(Account account)
public void removeAllAccounts()
@Implementation protected AuthenticatorDescription[] getAuthenticatorTypes()
@Implementation protected void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately)
@Implementation(minSdk=26) protected void addOnAccountsUpdatedListener(@Nullable OnAccountsUpdateListener listener, @Nullable Handler handler, boolean updateImmediately, @Nullable String[] accountTypes)
@Implementation protected void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener)
@Implementation protected String getUserData(Account account, String key)
@Implementation protected void setUserData(Account account, String key, String value)
@Implementation protected void setPassword(Account account, String password)
@Implementation protected String getPassword(Account account)
@Implementation protected void invalidateAuthToken(String accountType, String authToken)
public void addAccount(Account account)
account
- User account.public void addAccount(Account account, String... visibileToPackages)
AccountManager.getAccountsByTypeForPackage(String, String)
is called will be included if is in one of the #visibileToPackagesaccount
- User account.public Bundle getNextAddAccountOptions()
addAccountOptions
passed to addAccount(android.accounts.Account)
.addAccountOptions
public Bundle peekNextAddAccountOptions()
addAccountOptions
passed to addAccount(android.accounts.Account)
without consuming it.addAccountOptions
@Implementation protected AccountManagerFuture<Bundle> addAccount(String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
public void addAuthenticator(AuthenticatorDescription authenticator)
authenticator
- System authenticator.public void addAuthenticator(String type)
public void setPreviousAccountName(Account account, String previousName)
AccountManager.getPreviousName(Account)
.account
- User account.previousName
- Previous account name.@Implementation(minSdk=21) protected String getPreviousName(Account account)
setPreviousAccountName(Account, String)
@Implementation protected AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
@Implementation protected AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options, boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler)
@Implementation protected AccountManagerFuture<Boolean> hasFeatures(Account account, String[] features, AccountManagerCallback<Boolean> callback, Handler handler)
@Implementation protected AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures(String type, String[] features, AccountManagerCallback<Account[]> callback, Handler handler)
@Implementation(minSdk=18) protected Account[] getAccountsByTypeForPackage(String type, String packageName)
public void setAuthenticationErrorOnNextResponse(boolean authenticationErrorOnNextResponse)
getAccountsByTypeAndFeatures(java.lang.String, java.lang.String[], android.accounts.AccountManagerCallback<android.accounts.Account[]>, android.os.Handler)
.authenticationErrorOnNextResponse
- to set flag that exception will be thrown on next
response.public void setRemoveAccountIntent(Intent removeAccountIntent)
removeAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler)
if Activity is given.removeAccountIntent
- the intent to surface as AccountManager.KEY_INTENT
.public Map<OnAccountsUpdateListener,Set<String>> getListeners()