OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.test.util; | 5 package org.chromium.chrome.test.util; |
6 | 6 |
7 import android.accounts.Account; | 7 import android.accounts.Account; |
8 import android.accounts.AccountManager; | 8 import android.accounts.AccountManager; |
9 import android.accounts.AccountManagerCallback; | 9 import android.accounts.AccountManagerCallback; |
10 import android.accounts.AccountManagerFuture; | 10 import android.accounts.AccountManagerFuture; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 /** | 171 /** |
172 * Helper class for adding Google accounts to OS. | 172 * Helper class for adding Google accounts to OS. |
173 * | 173 * |
174 * Usage: Use this as the callback parameter when using {@link addAccount} i
n | 174 * Usage: Use this as the callback parameter when using {@link addAccount} i
n |
175 * {@link android.accounts.AccountManager}. | 175 * {@link android.accounts.AccountManager}. |
176 */ | 176 */ |
177 private static class AuthenticationCallback implements AccountManagerCallbac
k<Bundle> { | 177 private static class AuthenticationCallback implements AccountManagerCallbac
k<Bundle> { |
178 private final Object mAuthenticationCompletionLock = new Object(); | 178 private final Object mAuthenticationCompletionLock = new Object(); |
179 | 179 |
180 /** Stores the result of account authentication. Null means not finished
. */ | 180 /** Stores the result of account authentication. Null means not finished
. */ |
181 private Bundle mResultBundle = null; | 181 private Bundle mResultBundle; |
182 | 182 |
183 /** | 183 /** |
184 * Block and wait for the authentication callback to complete. | 184 * Block and wait for the authentication callback to complete. |
185 * | 185 * |
186 * @return the {@link Bundle} result from the authentication. | 186 * @return the {@link Bundle} result from the authentication. |
187 */ | 187 */ |
188 public Bundle waitForAuthCompletion() { | 188 public Bundle waitForAuthCompletion() { |
189 synchronized (mAuthenticationCompletionLock) { | 189 synchronized (mAuthenticationCompletionLock) { |
190 while (mResultBundle == null) { | 190 while (mResultBundle == null) { |
191 try { | 191 try { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 */ | 224 */ |
225 private Bundle buildExceptionBundle(Exception e) { | 225 private Bundle buildExceptionBundle(Exception e) { |
226 Bundle bundle = new Bundle(); | 226 Bundle bundle = new Bundle(); |
227 bundle.putInt(AccountManager.KEY_ERROR_CODE, | 227 bundle.putInt(AccountManager.KEY_ERROR_CODE, |
228 AccountManager.ERROR_CODE_INVALID_RESPONSE); | 228 AccountManager.ERROR_CODE_INVALID_RESPONSE); |
229 bundle.putString(AccountManager.KEY_ERROR_MESSAGE, e.toString()); | 229 bundle.putString(AccountManager.KEY_ERROR_MESSAGE, e.toString()); |
230 return bundle; | 230 return bundle; |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
OLD | NEW |