| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.test.mock; |
| 17 |
|
| 18 |
import android.accounts.Account; |
| 19 |
import android.accounts.AccountManager; |
| 20 |
import android.accounts.AccountManagerCallback; |
| 21 |
import android.accounts.AccountManagerFuture; |
| 22 |
import android.accounts.AuthenticatorException; |
| 23 |
import android.accounts.OnAccountsUpdateListener; |
| 24 |
import android.accounts.OperationCanceledException; |
| 25 |
import android.content.Context; |
| 26 |
import android.os.Handler; |
| 27 |
import java.io.IOException; |
| 28 |
import java.util.concurrent.TimeUnit; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
@Deprecated |
| 41 |
public class MockAccountManager { |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public static AccountManager newMockAccountManager(Context context) { |
| 50 |
return new MockAccountManagerImpl(context); |
| 51 |
} |
| 52 |
|
| 53 |
private MockAccountManager() { |
| 54 |
} |
| 55 |
|
| 56 |
private static class MockAccountManagerImpl extends AccountManager { |
| 57 |
|
| 58 |
MockAccountManagerImpl(Context context) { |
| 59 |
super(context, null , null ); |
| 60 |
} |
| 61 |
|
| 62 |
public void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, |
| 63 |
Handler handler, boolean updateImmediately) { |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
public Account[] getAccounts() { |
| 68 |
return new Account[] {}; |
| 69 |
} |
| 70 |
|
| 71 |
public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures( |
| 72 |
final String type, final String[] features, |
| 73 |
AccountManagerCallback<Account[]> callback, Handler handler) { |
| 74 |
return new MockAccountManagerFuture<Account[]>(new Account[0]); |
| 75 |
} |
| 76 |
|
| 77 |
public String blockingGetAuthToken(Account account, String authTokenType, |
| 78 |
boolean notifyAuthFailure) |
| 79 |
throws OperationCanceledException, IOException, AuthenticatorException { |
| 80 |
return null; |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
private static class MockAccountManagerFuture<T> |
| 89 |
implements AccountManagerFuture<T> { |
| 90 |
|
| 91 |
T mResult; |
| 92 |
|
| 93 |
MockAccountManagerFuture(T result) { |
| 94 |
mResult = result; |
| 95 |
} |
| 96 |
|
| 97 |
public boolean cancel(boolean mayInterruptIfRunning) { |
| 98 |
return false; |
| 99 |
} |
| 100 |
|
| 101 |
public boolean isCancelled() { |
| 102 |
return false; |
| 103 |
} |
| 104 |
|
| 105 |
public boolean isDone() { |
| 106 |
return true; |
| 107 |
} |
| 108 |
|
| 109 |
public T getResult() |
| 110 |
throws OperationCanceledException, IOException, AuthenticatorException { |
| 111 |
return mResult; |
| 112 |
} |
| 113 |
|
| 114 |
public T getResult(long timeout, TimeUnit unit) |
| 115 |
throws OperationCanceledException, IOException, AuthenticatorException { |
| 116 |
return getResult(); |
| 117 |
} |
| 118 |
} |
| 119 |
} |