Package org.robolectric.shadows
Class ShadowAccountManager
java.lang.Object
org.robolectric.shadows.ShadowAccountManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void__constructor__(Context context, IAccountManager service) voidaddAccount(Account account) voidaddAccount(Account account, String... visibleToPackages) Adds an account to the AccountManager but whenAccountManager.getAccountsByTypeForPackage(String, String)is called will be included if is in one of the #visibleToPackagesprotected AccountManagerFuture<Bundle>addAccount(String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) protected booleanaddAccountExplicitly(Account account, String password, Bundle userdata) voidaddAuthenticator(AuthenticatorDescription authenticator) voidaddAuthenticator(String type) protected voidaddOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately) protected voidaddOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately, String[] accountTypes) protected StringblockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure) protected AccountManagerFuture<Bundle>finishSession(Bundle sessionBundle, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) Returns sessionBundle as the result of finishSession.protected static AccountManagerprotected Account[]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[]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) Consumes and returns the nextaddAccountOptionspassed toaddAccount(android.accounts.Account).protected StringgetPassword(Account account) protected StringgetPreviousName(Account account) protected StringgetUserData(Account account, String key) protected AccountManagerFuture<Boolean>hasFeatures(Account account, String[] features, AccountManagerCallback<Boolean> callback, Handler handler) protected voidinvalidateAuthToken(String accountType, String authToken) protected StringpeekAuthToken(Account account, String tokenType) Returns the nextaddAccountOptionspassed toaddAccount(android.accounts.Account)without consuming it.protected AccountManagerFuture<Boolean>removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler) The remove operation is posted to the givenhandler, and will be executed according to theScheduler.IdleStateof the correspondingScheduler.protected AccountManagerFuture<Bundle>removeAccount(Account account, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) Removes the account unlesssetRemoveAccountIntent(android.content.Intent)has been set.protected booleanremoveAccountExplicitly(Account account) voidRemoves all accounts that have been added.protected voidstatic voidreset()voidsetAuthenticationErrorOnNextResponse(boolean authenticationErrorOnNextResponse) Sets authenticator exception, which will be thrown bygetAccountsByTypeAndFeatures(java.lang.String, java.lang.String[], android.accounts.AccountManagerCallback<android.accounts.Account[]>, android.os.Handler).protected voidsetAuthToken(Account account, String tokenType, String authToken) voidsetFeatures(Account account, String[] accountFeatures) protected voidsetPassword(Account account, String password) voidsetPreviousAccountName(Account account, String previousName) Sets the previous name for an account, which will be returned byAccountManager.getPreviousName(Account).voidsetRemoveAccountIntent(Intent removeAccountIntent) Sets the intent to include in Bundle result fromremoveAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler)if Activity is given.protected voidsetUserData(Account account, String key, String value) protected AccountManagerFuture<Bundle>startAddAccountSession(String accountType, String authTokenType, String[] requiredFeatures, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) Returns a bundle that contains the account session bundle underAccountManager.KEY_ACCOUNT_SESSION_BUNDLEto later be passed on toAccountManager.finishSession(Bundle,Activity,AccountManagerCallback<Bundle>,Handler).
-
Constructor Details
-
ShadowAccountManager
public ShadowAccountManager()
-
-
Method Details
-
reset
-
__constructor__
-
get
-
getAccounts
-
getAccountsByType
-
setAuthToken
-
peekAuthToken
-
addAccountExplicitly
@Implementation protected boolean addAccountExplicitly(Account account, String password, Bundle userdata) -
blockingGetAuthToken
@Implementation protected String blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure) -
removeAccount
@Implementation protected AccountManagerFuture<Boolean> removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler) The remove operation is posted to the givenhandler, and will be executed according to theScheduler.IdleStateof the correspondingScheduler. -
removeAccount
@Implementation(minSdk=22) protected AccountManagerFuture<Bundle> removeAccount(Account account, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) Removes the account unlesssetRemoveAccountIntent(android.content.Intent)has been set. If set, the future Bundle will include the Intent andAccountManager.KEY_BOOLEAN_RESULTwill be false. -
removeAccountExplicitly
-
removeAllAccounts
public void removeAllAccounts()Removes all accounts that have been added. -
getAuthenticatorTypes
-
addOnAccountsUpdatedListener
@Implementation protected void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately) -
addOnAccountsUpdatedListener
@Implementation(minSdk=26) protected void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately, String[] accountTypes) -
removeOnAccountsUpdatedListener
-
getUserData
-
setUserData
-
setPassword
-
getPassword
-
invalidateAuthToken
-
startAddAccountSession
@Implementation(minSdk=26) protected AccountManagerFuture<Bundle> startAddAccountSession(String accountType, String authTokenType, String[] requiredFeatures, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) Returns a bundle that contains the account session bundle underAccountManager.KEY_ACCOUNT_SESSION_BUNDLEto later be passed on toAccountManager.finishSession(Bundle,Activity,AccountManagerCallback<Bundle>,Handler). The session bundle simply propagates the givenaccountTypeso as not to be empty and is not encrypted as it would be in the real implementation. If an activity isn't provided, resulting bundle will only have a dummyIntentunderAccountManager.KEY_INTENT.- Parameters:
accountType- An authenticator must exist for the accountType, or elseAuthenticatorExceptionis thrown.authTokenType- is ignored.requiredFeatures- is ignored.options- is ignored.activity- if null, onlyAccountManager.KEY_INTENTwill be present in result.callback- if not null, will be called with result bundle.handler- is ignored.- Returns:
- future for bundle containing
AccountManager.KEY_ACCOUNT_SESSION_BUNDLEif activity is provided, orAccountManager.KEY_INTENTotherwise.
-
finishSession
@Implementation(minSdk=26) protected AccountManagerFuture<Bundle> finishSession(Bundle sessionBundle, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) Returns sessionBundle as the result of finishSession.- Parameters:
sessionBundle- is returned as the result bundle.activity- is ignored.callback- if not null, will be called with result bundle.handler- is ignored.
-
addAccount
- Parameters:
account- User account.
-
addAccount
Adds an account to the AccountManager but whenAccountManager.getAccountsByTypeForPackage(String, String)is called will be included if is in one of the #visibleToPackages- Parameters:
account- User account.
-
getNextAddAccountOptions
Consumes and returns the nextaddAccountOptionspassed toaddAccount(android.accounts.Account).- Returns:
- the next
addAccountOptions
-
peekNextAddAccountOptions
Returns the nextaddAccountOptionspassed toaddAccount(android.accounts.Account)without consuming it.- Returns:
- the next
addAccountOptions
-
addAccount
@Implementation protected AccountManagerFuture<Bundle> addAccount(String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) -
setFeatures
-
addAuthenticator
- Parameters:
authenticator- System authenticator.
-
addAuthenticator
-
setPreviousAccountName
Sets the previous name for an account, which will be returned byAccountManager.getPreviousName(Account).- Parameters:
account- User account.previousName- Previous account name.
-
getPreviousName
- See Also:
-
getAuthToken
@Implementation protected AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) -
getAuthToken
@Implementation protected AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options, boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler) -
hasFeatures
@Implementation protected AccountManagerFuture<Boolean> hasFeatures(Account account, String[] features, AccountManagerCallback<Boolean> callback, Handler handler) -
getAccountsByTypeAndFeatures
@Implementation protected AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures(String type, String[] features, AccountManagerCallback<Account[]> callback, Handler handler) -
getAccountsByTypeForPackage
-
setAuthenticationErrorOnNextResponse
public void setAuthenticationErrorOnNextResponse(boolean authenticationErrorOnNextResponse) Sets authenticator exception, which will be thrown bygetAccountsByTypeAndFeatures(java.lang.String, java.lang.String[], android.accounts.AccountManagerCallback<android.accounts.Account[]>, android.os.Handler).- Parameters:
authenticationErrorOnNextResponse- to set flag that exception will be thrown on next response.
-
setRemoveAccountIntent
Sets the intent to include in Bundle result fromremoveAccount(android.accounts.Account, android.accounts.AccountManagerCallback<java.lang.Boolean>, android.os.Handler)if Activity is given.- Parameters:
removeAccountIntent- the intent to surface asAccountManager.KEY_INTENT.
-
getListeners
-