Package org.robolectric.shadows
Class ShadowAccountManager
- java.lang.Object
- 
- org.robolectric.shadows.ShadowAccountManager
 
- 
 @Implements(android.accounts.AccountManager.class) public class ShadowAccountManager extends Object 
- 
- 
Constructor SummaryConstructors Constructor Description ShadowAccountManager()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected 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 AccountManagerget(Context context)Deprecated.This method will be removed in Robolectric 3.4 UseAccountManager.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()BundlegetNextAddAccountOptions()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)BundlepeekNextAddAccountOptions()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)voidremoveAllAccounts()Removes all accounts that have been added.protected voidremoveOnAccountsUpdatedListener(OnAccountsUpdateListener listener)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.,Handler) 
 
- 
- 
- 
Method Detail- 
__constructor__@Implementation protected void __constructor__(Context context, IAccountManager service) 
 - 
get@Deprecated @Implementation protected static AccountManager get(Context context) Deprecated.This method will be removed in Robolectric 3.4 UseAccountManager.get(Context)instead.
 - 
getAccounts@Implementation protected Account[] getAccounts() 
 - 
getAccountsByType@Implementation protected Account[] getAccountsByType(String type) 
 - 
setAuthToken@Implementation protected void setAuthToken(Account account, String tokenType, String authToken) 
 - 
peekAuthToken@Implementation protected String peekAuthToken(Account account, String tokenType) 
 - 
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@Implementation(minSdk=22) protected boolean removeAccountExplicitly(Account account) 
 - 
removeAllAccountspublic void removeAllAccounts() Removes all accounts that have been added.
 - 
getAuthenticatorTypes@Implementation protected AuthenticatorDescription[] getAuthenticatorTypes() 
 - 
addOnAccountsUpdatedListener@Implementation protected void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately) 
 - 
addOnAccountsUpdatedListener@Implementation(minSdk=26) protected void addOnAccountsUpdatedListener(@Nullable OnAccountsUpdateListener listener, @Nullable Handler handler, boolean updateImmediately, @Nullable String[] accountTypes) 
 - 
removeOnAccountsUpdatedListener@Implementation protected void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) 
 - 
getUserData@Implementation protected String getUserData(Account account, String key) 
 - 
setUserData@Implementation protected void setUserData(Account account, String key, String value) 
 - 
setPassword@Implementation protected void setPassword(Account account, String password) 
 - 
getPassword@Implementation protected String getPassword(Account account) 
 - 
invalidateAuthToken@Implementation protected void invalidateAuthToken(String accountType, String authToken) 
 - 
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. The session bundle simply propagates the given,Handler) accountTypeso 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 else- AuthenticatorExceptionis thrown.
- authTokenType- is ignored.
- requiredFeatures- is ignored.
- options- is ignored.
- activity- if null, only- AccountManager.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.
 
 - 
addAccountpublic void addAccount(Account account) - Parameters:
- account- User account.
 
 - 
addAccountpublic void addAccount(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 #visibleToPackages- Parameters:
- account- User account.
 
 - 
getNextAddAccountOptionspublic Bundle getNextAddAccountOptions() Consumes and returns the nextaddAccountOptionspassed toaddAccount(android.accounts.Account).- Returns:
- the next addAccountOptions
 
 - 
peekNextAddAccountOptionspublic Bundle 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) 
 - 
addAuthenticatorpublic void addAuthenticator(AuthenticatorDescription authenticator) - Parameters:
- authenticator- System authenticator.
 
 - 
addAuthenticatorpublic void addAuthenticator(String type) 
 - 
setPreviousAccountNamepublic void setPreviousAccountName(Account account, String previousName) Sets the previous name for an account, which will be returned byAccountManager.getPreviousName(Account).- Parameters:
- account- User account.
- previousName- Previous account name.
 
 - 
getPreviousName@Implementation(minSdk=21) protected String getPreviousName(Account account) - See Also:
- setPreviousAccountName(Account, String)
 
 - 
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@Implementation(minSdk=18) protected Account[] getAccountsByTypeForPackage(String type, String packageName) 
 - 
setAuthenticationErrorOnNextResponsepublic 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.
 
 - 
setRemoveAccountIntentpublic void setRemoveAccountIntent(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.- Parameters:
- removeAccountIntent- the intent to surface as- AccountManager.KEY_INTENT.
 
 - 
getListenerspublic Map<OnAccountsUpdateListener,Set<String>> getListeners() 
 
- 
 
-