summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorFred Quintana <fredq@google.com>2010-03-25 14:50:20 -0700
committerFred Quintana <fredq@google.com>2010-03-25 14:50:20 -0700
commitcd8aed8c503ee37fa36b7d14744c9d0271faf12d (patch)
tree5b3ab45de2896a564d06d6d0351a93c36df8e366 /policy
parent00f4d986c6eb4bc16f2d2661ead2cdae33e82ff3 (diff)
downloadframeworks_base-cd8aed8c503ee37fa36b7d14744c9d0271faf12d.zip
frameworks_base-cd8aed8c503ee37fa36b7d14744c9d0271faf12d.tar.gz
frameworks_base-cd8aed8c503ee37fa36b7d14744c9d0271faf12d.tar.bz2
change the account unlock enabling logic use async calls rather than
blocking calls limit the account unlocks to google accounts Change-Id: If412a7557716503f7d122ec3ff31375f47b624b9 http://b/issue?id=2544496
Diffstat (limited to 'policy')
-rw-r--r--policy/com/android/internal/policy/impl/AccountUnlockScreen.java2
-rw-r--r--policy/com/android/internal/policy/impl/LockPatternKeyguardView.java86
2 files changed, 52 insertions, 36 deletions
diff --git a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java b/policy/com/android/internal/policy/impl/AccountUnlockScreen.java
index 53793de..9921069 100644
--- a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java
+++ b/policy/com/android/internal/policy/impl/AccountUnlockScreen.java
@@ -223,7 +223,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
* find a single best match.
*/
private Account findIntendedAccount(String username) {
- Account[] accounts = AccountManager.get(mContext).getAccounts();
+ Account[] accounts = AccountManager.get(mContext).getAccountsByType("com.google");
// Try to figure out which account they meant if they
// typed only the username (and not the domain), or got
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 169368c..4005ae6 100644
--- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -61,7 +61,7 @@ import java.io.IOException;
public class LockPatternKeyguardView extends KeyguardViewBase {
static final boolean DEBUG_CONFIGURATION = false;
-
+
// time after launching EmergencyDialer before the screen goes blank.
private static final int EMERGENCY_CALL_TIMEOUT = 10000;
@@ -331,46 +331,62 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
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.
- 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;
+ private class AccountAnalyzer implements AccountManagerCallback<Bundle> {
+ private final AccountManager mAccountManager;
+ private final Account[] mAccounts;
+ private int mAccountIndex;
- } catch (OperationCanceledException e) {
- Log.w(TAG, "couldn't talk to AccountManager", e);
+ private AccountAnalyzer(AccountManager accountManager) {
+ mAccountManager = accountManager;
+ mAccounts = accountManager.getAccountsByType("com.google");
+ }
- } 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);
+ private void next() {
+ // if we are ready to enable the fallback or if we depleted the list of accounts
+ // then finish and get out
+ if (mEnableFallback || mAccountIndex >= mAccounts.length) {
+ if (mUnlockScreen == null) {
+ Log.w(TAG, "no unlock screen when trying to enable fallback");
+ } else if (mUnlockScreen instanceof PatternUnlockScreen) {
+ ((PatternUnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback);
}
+ return;
+ }
+
+ // lookup the confirmCredentials intent for the current account
+ mAccountManager.confirmCredentials(mAccounts[mAccountIndex], null, null, this, null);
+ }
+
+ public void start() {
+ mEnableFallback = false;
+ mAccountIndex = 0;
+ next();
+ }
+ public void run(AccountManagerFuture<Bundle> future) {
+ try {
+ Bundle result = future.getResult();
+ if (result.getParcelable(AccountManager.KEY_INTENT) != null) {
+ mEnableFallback = true;
+ }
+ } catch (OperationCanceledException e) {
+ // just skip the account if we are unable to query it
} catch (IOException e) {
- Log.w(TAG, "couldn't talk to AccountManager", e);
+ // just skip the account if we are unable to query it
+ } catch (AuthenticatorException e) {
+ // just skip the account if we are unable to query it
+ } finally {
+ mAccountIndex++;
+ next();
}
}
+ }
- if (mUnlockScreen == null) {
- Log.w(TAG, "no unlock screen when trying to enable fallback");
- } else if (mUnlockScreen instanceof PatternUnlockScreen) {
- ((PatternUnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback);
- }
+ 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.
+ AccountAnalyzer accountAnalyzer = new AccountAnalyzer(AccountManager.get(context));
+ accountAnalyzer.start();
}
@@ -509,7 +525,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
if (DEBUG_CONFIGURATION) Log.v(TAG, "**** UPDATE SCREEN: mode=" + mode
+ " last mode=" + mMode, new RuntimeException());
-
+
mMode = mode;
// Re-create the unlock screen if necessary. This is primarily required to properly handle
@@ -529,7 +545,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
Log.v(TAG, "Gone=" + goneScreen);
Log.v(TAG, "Visible=" + visibleScreen);
}
-
+
if (mScreenOn) {
if (goneScreen.getVisibility() == View.VISIBLE) {
((KeyguardScreen) goneScreen).onPause();