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
5package org.chromium.sync.signin;
6
7import android.accounts.Account;
8import android.accounts.AccountManagerCallback;
9import android.accounts.AccountManagerFuture;
10import android.accounts.AuthenticatorDescription;
11import android.accounts.AuthenticatorException;
12import android.accounts.OperationCanceledException;
13import android.app.Activity;
14import android.os.Bundle;
15import android.os.Handler;
16
17import java.io.IOException;
18
19/**
20 * Wrapper around the Android account manager, to facilitate dependency injection during testing.
21 */
22public interface AccountManagerDelegate {
23    Account[] getAccountsByType(String type);
24
25    AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType,
26            boolean notifyAuthFailure, AccountManagerCallback<Bundle> callback, Handler handler);
27
28    AccountManagerFuture<Bundle> getAuthToken(Account account, String authTokenType, Bundle options,
29            Activity activity, AccountManagerCallback<Bundle> callback, Handler handler);
30
31    void invalidateAuthToken(String accountType, String authToken);
32
33    String blockingGetAuthToken(Account account, String authTokenType, boolean notifyAuthFailure)
34            throws OperationCanceledException, IOException, AuthenticatorException;
35
36    Account[] getAccounts();
37
38    boolean addAccountExplicitly(Account account, String password, Bundle userdata);
39
40    AccountManagerFuture<Boolean> removeAccount(Account account,
41            AccountManagerCallback<Boolean> callback, Handler handler);
42
43    String getPassword(Account account);
44
45    void setPassword(Account account, String password);
46
47    void clearPassword(Account account);
48
49    AccountManagerFuture<Bundle> confirmCredentials(Account account, Bundle bundle,
50            Activity activity, AccountManagerCallback<Bundle> callback, Handler handler);
51
52    String peekAuthToken(Account account, String authTokenType);
53
54    AuthenticatorDescription[] getAuthenticatorTypes();
55}
56