• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.sync.signin;
6 
7 import android.accounts.Account;
8 import android.accounts.AccountManagerCallback;
9 import android.accounts.AccountManagerFuture;
10 import android.accounts.AuthenticatorDescription;
11 import android.accounts.AuthenticatorException;
12 import android.accounts.OperationCanceledException;
13 import android.app.Activity;
14 import android.os.Bundle;
15 import android.os.Handler;
16 
17 import java.io.IOException;
18 
19 /**
20  * Wrapper around the Android account manager, to facilitate dependency injection during testing.
21  */
22 public interface AccountManagerDelegate {
getAccountsByType(String type)23     Account[] getAccountsByType(String type);
24 
getAuthToken(Account account, String authTokenType, boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler)25     AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType,
26             boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler);
27 
getAuthToken(Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)28     AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options,
29             Activity activity, AccountManagerCallback<Bundle> callback, Handler handler);
30 
invalidateAuthToken(String accountType, String authToken)31     void invalidateAuthToken(String accountType, String authToken);
32 
blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure)33     String blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure)
34             throws OperationCanceledException, IOException, AuthenticatorException;
35 
getAccounts()36     Account[] getAccounts();
37 
addAccountExplicitly(Account account, String password, Bundle userdata)38     boolean addAccountExplicitly(Account account, String password, Bundle userdata);
39 
removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler)40     AccountManagerFuture<Boolean> removeAccount(Account account,
41             AccountManagerCallback<Boolean> callback, Handler handler);
42 
getPassword(Account account)43     String getPassword(Account account);
44 
setPassword(Account account, String password)45     void setPassword(Account account, String password);
46 
clearPassword(Account account)47     void clearPassword(Account account);
48 
confirmCredentials(Account account, Bundle bundle, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)49     AccountManagerFuture<Bundle> confirmCredentials(Account account, Bundle bundle,
50             Activity activity, AccountManagerCallback<Bundle> callback, Handler handler);
51 
peekAuthToken(Account account, String authTokenType)52     String peekAuthToken(Account account, String authTokenType);
53 
getAuthenticatorTypes()54     AuthenticatorDescription[] getAuthenticatorTypes();
55 }
56