diff options
author | Dirk Balfanz <balfanz@google.com> | 2010-03-17 21:07:56 -0700 |
---|---|---|
committer | Dirk Balfanz <balfanz@google.com> | 2010-03-19 11:31:33 -0700 |
commit | cf59a0b72d3fa6bfe21b3c4cab317ef06496961e (patch) | |
tree | a1f7b1a78f99672c8bcc752fd24f692c58f846d6 /policy | |
parent | 75787398fa5db9add16f3d3bc298198ed2c6671f (diff) | |
download | frameworks_base-cf59a0b72d3fa6bfe21b3c4cab317ef06496961e.zip frameworks_base-cf59a0b72d3fa6bfe21b3c4cab317ef06496961e.tar.gz frameworks_base-cf59a0b72d3fa6bfe21b3c4cab317ef06496961e.tar.bz2 |
Instead of asking whether accounts are SAML accounts to figure out whether they can be used for screen unlocking, we ask directly whether they support confirmCredentials().
Change-Id: Ib83c89133b67661e2eb0827baecc32910b386f63
Diffstat (limited to 'policy')
-rw-r--r-- | policy/com/android/internal/policy/impl/LockPatternKeyguardView.java | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java index da51ad0..169368c 100644 --- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -35,6 +35,7 @@ import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.PixelFormat; import android.graphics.drawable.Drawable; +import android.os.Bundle; import android.os.SystemClock; import android.os.SystemProperties; import android.telephony.TelephonyManager; @@ -57,8 +58,7 @@ import java.io.IOException; * {@link com.android.internal.policy.impl.KeyguardViewManager} * via its {@link com.android.internal.policy.impl.KeyguardViewCallback}, as appropriate. */ -public class LockPatternKeyguardView extends KeyguardViewBase - implements AccountManagerCallback<Account[]> { +public class LockPatternKeyguardView extends KeyguardViewBase { static final boolean DEBUG_CONFIGURATION = false; @@ -155,8 +155,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase */ private final LockPatternUtils mLockPatternUtils; - private int mNumAccounts; - private UnlockMode mCurrentUnlockMode = UnlockMode.Unknown; /** @@ -174,25 +172,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase && (mUpdateMonitor.getSimState() == IccCard.State.ABSENT); } - // Called by AccountManager.getAccountByTypeAndFeatures() below... - public void run(AccountManagerFuture<Account[]> future) { - int samlAccounts = 0; - try { - samlAccounts = future.getResult().length; - } catch (OperationCanceledException e) { - } catch (IOException e) { - } catch (AuthenticatorException e) { - } - // 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 PatternUnlockScreen) { - ((PatternUnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback); - } - } - /** * @param context Used to inflate, and create views. * @param updateMonitor Knows the state of the world, and passed along to each @@ -357,16 +336,40 @@ public class LockPatternKeyguardView extends KeyguardViewBase // 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. - 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. - Ultimately we could consider bringing up a web login from GLS - but need to make sure that it will work in the "locked screen" mode. */ - String[] features = new String[] {"saml"}; - AccountManager.get(context).getAccountsByTypeAndFeatures( - "com.google", features, this, null); + Account[] accounts = AccountManager.get(context).getAccounts(); + mEnableFallback = false; + + for (Account account : accounts) { + // See whether this account can be used to unlock the screen. + try { + // Passing null for action makes sure the confirmCredentials intent is not actually + // executed - we're just checking whether it's supported. + AccountManager.get(context) + .confirmCredentials(account, null, null, null, null) + .getResult(); + mEnableFallback = true; + break; + + } catch (OperationCanceledException e) { + Log.w(TAG, "couldn't talk to AccountManager", e); + + } catch (AuthenticatorException e) { + if (e.getCause() instanceof UnsupportedOperationException) { + // This is expected for accounts that don't support confirmCredentials + continue; + } else { + Log.w(TAG, "couldn't talk to AccountManager", e); + } + + } catch (IOException e) { + Log.w(TAG, "couldn't talk to AccountManager", e); + } + } + + if (mUnlockScreen == null) { + Log.w(TAG, "no unlock screen when trying to enable fallback"); + } else if (mUnlockScreen instanceof PatternUnlockScreen) { + ((PatternUnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback); } } |