@Implements(value=android.accounts.AccountManager.class) public class ShadowAccountManager extends Object
Constructor and Description |
---|
ShadowAccountManager() |
@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)
The remove operation is posted to the given 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)
Removes the account unless 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()
Removes all accounts that have been added.
@Implementation protected AuthenticatorDescription[] getAuthenticatorTypes()
@Implementation protected void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately)
@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)
Adds an account to the AccountManager but when AccountManager.getAccountsByTypeForPackage(String, String)
is called will be included if is in one of the #visibileToPackages
account
- User account.public Bundle getNextAddAccountOptions()
Consumes and returns the next addAccountOptions
passed to addAccount(android.accounts.Account)
.
addAccountOptions
public Bundle peekNextAddAccountOptions()
Returns the next 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)
Sets the previous name for an account, which will be returned by 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)
Sets authenticator exception, which will be thrown by 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)
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.
removeAccountIntent
- the intent to surface as AccountManager.KEY_INTENT
.