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
This commit is contained in:
Fred Quintana
2009-04-08 19:14:54 -07:00
committed by The Android Open Source Project
parent 76c65a6688
commit f29d580185
2 changed files with 11 additions and 18 deletions

View File

@@ -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;
}
}
}

View File

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