1 // Copyright (c) 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.
5 package org.chromium.sync.signin;
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;
17 import java.io.IOException;
20 * Wrapper around the Android account manager, to facilitate dependency injection during testing.
22 public interface AccountManagerDelegate {
23 Account[] getAccountsByType(String type);
25 AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType,
26 boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler);
28 AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options,
29 Activity activity, AccountManagerCallback<Bundle> callback, Handler handler);
31 void invalidateAuthToken(String accountType, String authToken);
33 String blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure)
34 throws OperationCanceledException, IOException, AuthenticatorException;
36 Account[] getAccounts();
38 boolean addAccountExplicitly(Account account, String password, Bundle userdata);
40 AccountManagerFuture<Boolean> removeAccount(Account account,
41 AccountManagerCallback<Boolean> callback, Handler handler);
43 String getPassword(Account account);
45 void setPassword(Account account, String password);
47 void clearPassword(Account account);
49 AccountManagerFuture<Bundle> confirmCredentials(Account account, Bundle bundle,
50 Activity activity, AccountManagerCallback<Bundle> callback, Handler handler);
52 String peekAuthToken(Account account, String authTokenType);
54 AuthenticatorDescription[] getAuthenticatorTypes();