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
diff --git a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java b/policy/com/android/internal/policy/impl/AccountUnlockScreen.java
index aae1c7f..098a651 100644
--- a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java
+++ b/policy/com/android/internal/policy/impl/AccountUnlockScreen.java
@@ -53,7 +53,6 @@
 
     private final KeyguardScreenCallback mCallback;
     private final LockPatternUtils mLockPatternUtils;
-    private AccountManager mAccountManager;
 
     private TextView mTopHeader;
     private TextView mInstructions;
@@ -93,12 +92,6 @@
         mEmergencyCall.setOnClickListener(this);
     }
 
-    void ensureAccountManager() {
-        if (mAccountManager == null) {
-            mAccountManager = (AccountManager)mContext.getSystemService(Context.ACCOUNT_SERVICE);
-        }
-    }
-
     public void afterTextChanged(Editable s) {
     }
 
@@ -193,11 +186,7 @@
      * 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 @@
         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 12e735a..486f364 100644
--- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -149,9 +149,7 @@
             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"));