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"));