summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-06-30 15:04:49 -0700
committerBrian Carlstrom <bdc@google.com>2011-06-30 15:18:13 -0700
commit7037b73962c34e884467d3d4a871ecdab9797fc3 (patch)
tree28b062a6ffb66bb1d64770cdb15427e68f8081e2 /src
parent5dd41f62ffcc499c853e83b7e582382a072dd374 (diff)
downloadandroid_packages_apps_KeyChain-7037b73962c34e884467d3d4a871ecdab9797fc3.tar.gz
android_packages_apps_KeyChain-7037b73962c34e884467d3d4a871ecdab9797fc3.tar.bz2
android_packages_apps_KeyChain-7037b73962c34e884467d3d4a871ecdab9797fc3.zip
Return non-null for methods with AccountAuthenticatorResponse argument
The AbstractAccountAuthenticator methods that take an AccountAuthenticatorResponse argument expect the receipient either return a non-null value immediately or later on call the AccountAuthenticatorResponse. Returning null for presumably uncalled methods led to surprises when they were invoked from unexpected contexts such as Settings, leading to a hang on "Add Account". Change-Id: I0f7b2667c4fd4632921f2e2bed10266dd6662720
Diffstat (limited to 'src')
-rw-r--r--src/com/android/keychain/KeyChainService.java51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/com/android/keychain/KeyChainService.java b/src/com/android/keychain/KeyChainService.java
index 827f278..43f4e57 100644
--- a/src/com/android/keychain/KeyChainService.java
+++ b/src/com/android/keychain/KeyChainService.java
@@ -213,7 +213,7 @@ public class KeyChainService extends Service {
@Override public Bundle editProperties(AccountAuthenticatorResponse response,
String accountType) {
- return null;
+ return new Bundle();
}
@Override public Bundle addAccount(AccountAuthenticatorResponse response,
@@ -221,13 +221,18 @@ public class KeyChainService extends Service {
String authTokenType,
String[] requiredFeatures,
Bundle options) {
- return null;
+ Bundle result = new Bundle();
+ result.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
+ result.putString(AccountManager.KEY_ACCOUNT_TYPE, KeyChain.ACCOUNT_TYPE);
+ return result;
}
@Override public Bundle confirmCredentials(AccountAuthenticatorResponse response,
Account account,
Bundle options) {
- return null;
+ Bundle result = new Bundle();
+ result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
+ return result;
}
/**
@@ -257,42 +262,44 @@ public class KeyChainService extends Service {
Account account,
String authTokenType,
Bundle options) {
- return null;
+ Bundle bundle = new Bundle();
+ bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
+ bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, KeyChain.ACCOUNT_TYPE);
+ return bundle;
}
@Override public Bundle hasFeatures(AccountAuthenticatorResponse response,
Account account,
String[] features) {
- return null;
+ Bundle result = new Bundle();
+ result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, features.length == 0);
+ return result;
}
};
private final IBinder mAuthenticator = new KeyChainAccountAuthenticator(this).getIBinder();
@Override public IBinder onBind(Intent intent) {
- if (IKeyChainService.class.getName().equals(intent.getAction())) {
-
- // ensure singleton keychain account exists
- synchronized (mAccountLock) {
- Account[] accounts = mAccountManager.getAccountsByType(KeyChain.ACCOUNT_TYPE);
- if (accounts.length == 0) {
- // TODO localize account name
- mAccount = new Account("Android Key Chain", KeyChain.ACCOUNT_TYPE);
- mAccountManager.addAccountExplicitly(mAccount, null, null);
- } else if (accounts.length == 1) {
- mAccount = accounts[0];
- } else {
- throw new IllegalStateException();
- }
+ // ensure singleton keychain account exists for both
+ // IKeyChainService and AbstractAccountAuthenticator
+ synchronized (mAccountLock) {
+ Account[] accounts = mAccountManager.getAccountsByType(KeyChain.ACCOUNT_TYPE);
+ if (accounts.length == 0) {
+ mAccount = new Account(getResources().getString(R.string.app_name),
+ KeyChain.ACCOUNT_TYPE);
+ mAccountManager.addAccountExplicitly(mAccount, null, null);
+ } else if (accounts.length == 1) {
+ mAccount = accounts[0];
+ } else {
+ throw new IllegalStateException();
}
-
+ }
+ if (IKeyChainService.class.getName().equals(intent.getAction())) {
return mIKeyChainService;
}
-
if (AccountManager.ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) {
return mAuthenticator;
}
-
return null;
}
}