diff options
author | Jim Miller <jaggies@google.com> | 2009-12-18 19:57:07 -0800 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2009-12-22 14:15:20 -0800 |
commit | 18c59475445751e9ed24cacd7cfdbf86a94412fd (patch) | |
tree | 4684a22059a53db4ad1543452a5511341bdeb942 /policy/com | |
parent | 0874372554523a02c3a210fca46107fc4b2c6bef (diff) | |
download | frameworks_base-18c59475445751e9ed24cacd7cfdbf86a94412fd.zip frameworks_base-18c59475445751e9ed24cacd7cfdbf86a94412fd.tar.gz frameworks_base-18c59475445751e9ed24cacd7cfdbf86a94412fd.tar.bz2 |
Fix 2338170: Fix a bug where adding a SAML account would cause the fallback unlock to break.
Adding a SAML account to the system would cause the current test to fail because it expected to have
only one account on the system. Instead, ensure that the device has at lease one non-SAML account.
Fixed update bug where having a single SAML account still showed the "Forgot pattern" button.
Tested:
- Wipe device and add pattern lock
- Add SAML account, verify "forgot pattern" doesn't appear.
- Add GAIA account, verify "forgot pattern" appears.
- Wipe device and add pattern lock
- Add GAIA account, verify "forgot pattern" appears
- Add SAML account, verify "forgot pattern" doesn't go away.
Diffstat (limited to 'policy/com')
-rw-r--r-- | policy/com/android/internal/policy/impl/LockPatternKeyguardView.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java index 00dc929..66c5159 100644 --- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -139,6 +139,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase */ private final LockPatternUtils mLockPatternUtils; + private int mNumAccounts; + /** * @return Whether we are stuck on the lock screen because the sim is * missing. @@ -149,22 +151,22 @@ public class LockPatternKeyguardView extends KeyguardViewBase && (mUpdateMonitor.getSimState() == IccCard.State.ABSENT); } + // Called by AccountManager.getAccountByTypeAndFeatures() below... public void run(AccountManagerFuture<Account[]> future) { - // We err on the side of caution. - // In case of error we assume we have a SAML account. - boolean hasSAMLAccount = true; + int samlAccounts = 0; try { - hasSAMLAccount = future.getResult().length > 0; + samlAccounts = future.getResult().length; } catch (OperationCanceledException e) { } catch (IOException e) { } catch (AuthenticatorException e) { } - mEnableFallback = !hasSAMLAccount; + // At least one of the accounts must be non-SAML to enable the fallback. + mEnableFallback = samlAccounts < mNumAccounts; if (mUnlockScreen == null) { Log.w(TAG, "no unlock screen when receiving AccountManager information"); } else if (mUnlockScreen instanceof UnlockScreen) { - ((UnlockScreen)mUnlockScreen).setEnableFallback(true); + ((UnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback); } } @@ -313,12 +315,19 @@ public class LockPatternKeyguardView extends KeyguardViewBase mUnlockScreen = createUnlockScreenFor(unlockMode); mUnlockScreenMode = unlockMode; + maybeEnableFallback(context); + + addView(mUnlockScreen); + updateScreen(mMode); + } + + private void maybeEnableFallback(Context context) { // Ask the account manager if we have an account that can be used as a // fallback in case the user forgets his pattern. The response comes // back in run() below; don't bother asking until you've called // createUnlockScreenFor(), else the information will go unused. - final boolean hasAccount = AccountManager.get(context).getAccounts().length > 0; - if (hasAccount) { + mNumAccounts = AccountManager.get(context).getAccounts().length; + if (mNumAccounts > 0) { /* If we have a SAML account which requires web login we can not use the fallback screen UI to ask the user for credentials. For now we will disable fallback screen in this case. @@ -328,12 +337,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase AccountManager.get(context).getAccountsByTypeAndFeatures( "com.google", features, this, null); } - - addView(mUnlockScreen); - updateScreen(mMode); } - @Override public void reset() { mIsVerifyUnlockOnly = false; |