From f29d580185e68bc23750d528511d2717d0de99aa Mon Sep 17 00:00:00 2001 From: Fred Quintana <> Date: Wed, 8 Apr 2009 19:14:54 -0700 Subject: [PATCH] AI 145177: phase two of the AccountManager - added an AccountManagerActivity, a base Activity that can be used by activities that are launched by AccountAuthenticator intents. This makes it easy for an Activity to send a result using an AccountAuthenticatorResponse - added debug strings to the AccountAuthenticatorCache - improved the API for the AccountAuthenticatorResponse and made it Parcelable so that it can be passed to an Activity via an Intent - changed the AccountManager to use Futures for the asynchronous calls and to notify the user via a callback when the request is complete - changed the AccountManager to convert any errors that are returned into Exceptions - added constants for the error codes that are passed across the IAccountManagerResponse and IAccountAuthenticatorResponse interfaces - added a dump() method to the AccountManagerService so that it can display the list of active sessions and registered authenticators - added an way to interrogate the AccountManagerService for the list of registered authenticators - removed more methods from the GoogleLoginServiceHelper and GoogleLoginServiceBlockingHelper and changed the callers to use the AccountManager Automated import of CL 145177 --- .../policy/impl/AccountUnlockScreen.java | 25 ++++++++----------- .../policy/impl/LockPatternKeyguardView.java | 4 +-- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java b/policy/com/android/internal/policy/impl/AccountUnlockScreen.java index aae1c7fe4082c..098a65118445f 100644 --- a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java +++ b/policy/com/android/internal/policy/impl/AccountUnlockScreen.java @@ -53,7 +53,6 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree private final KeyguardScreenCallback mCallback; private final LockPatternUtils mLockPatternUtils; - private AccountManager mAccountManager; private TextView mTopHeader; private TextView mInstructions; @@ -93,12 +92,6 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree mEmergencyCall.setOnClickListener(this); } - void ensureAccountManager() { - if (mAccountManager == null) { - mAccountManager = (AccountManager)mContext.getSystemService(Context.ACCOUNT_SERVICE); - } - } - public void afterTextChanged(Editable s) { } @@ -193,11 +186,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree * find a single best match. */ private Account findIntendedAccount(String username) { - ensureAccountManager(); - Account[] accounts = mAccountManager.blockingGetAccounts(); - if (accounts == null) { - return null; - } + Account[] accounts = AccountManager.get(mContext).blockingGetAccounts(); // Try to figure out which account they meant if they // typed only the username (and not the domain), or got @@ -239,8 +228,14 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree if (account == null) { return false; } - // change this to asynchronously issue the request and wait for the response - ensureAccountManager(); - return mAccountManager.authenticateAccount(account, password); + // TODO(fredq) change this to asynchronously issue the request and wait for the response (by + // supplying a callback rather than calling get() immediately) + try { + return AccountManager.get(mContext).confirmPassword( + account, password, null /* callback */, null /* handler */).getResult(); + } catch (android.accounts.OperationCanceledException e) { + // the request was canceled + return false; + } } } diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java index 12e735a89a3d2..486f364ebc711 100644 --- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -149,9 +149,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase { KeyguardWindowController controller) { super(context); - AccountManager accountManager = - (AccountManager)context.getSystemService(Context.ACCOUNT_SERVICE); - mHasAccount = accountManager.blockingGetAccounts().length > 0; + mHasAccount = AccountManager.get(context).blockingGetAccounts().length > 0; mRequiresSim = TextUtils.isEmpty(SystemProperties.get("keyguard.no_require_sim"));