summaryrefslogtreecommitdiffstats
path: root/core/java/android/accounts/AccountManagerService.java
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2009-10-29 18:04:17 -0700
committerMarco Nelissen <marcone@google.com>2009-10-29 18:04:17 -0700
commitc81e43c8ee31d986e34ee892b7d7bfbf70f82da7 (patch)
tree162d3ba3926da135b52d7a64fc4f6b3f910378eb /core/java/android/accounts/AccountManagerService.java
parent758b5b25f04e4f75e7c6c7a419bf333e4ee49718 (diff)
parent31957f1badbb900bbfe211317e1ea992d650a72d (diff)
downloadframeworks_base-c81e43c8ee31d986e34ee892b7d7bfbf70f82da7.zip
frameworks_base-c81e43c8ee31d986e34ee892b7d7bfbf70f82da7.tar.gz
frameworks_base-c81e43c8ee31d986e34ee892b7d7bfbf70f82da7.tar.bz2
resolved conflicts for merge 31957f1b to eclair-mr2
Diffstat (limited to 'core/java/android/accounts/AccountManagerService.java')
-rw-r--r--core/java/android/accounts/AccountManagerService.java119
1 files changed, 102 insertions, 17 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 8af5fa4..0a857af 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -155,6 +155,7 @@ public class AccountManagerService
private static final boolean isDebuggableMonkeyBuild =
SystemProperties.getBoolean("ro.monkey", false)
&& SystemProperties.getBoolean("ro.debuggable", false);
+ private static final Account[] EMPTY_ACCOUNT_ARRAY = new Account[]{};
static {
ACCOUNTS_CHANGED_INTENT = new Intent(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
@@ -267,6 +268,10 @@ public class AccountManagerService
}
private String readPasswordFromDatabase(Account account) {
+ if (account == null) {
+ return null;
+ }
+
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_PASSWORD},
ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
@@ -292,6 +297,10 @@ public class AccountManagerService
}
private String readUserDataFromDatabase(Account account, String key) {
+ if (account == null) {
+ return null;
+ }
+
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_EXTRAS, new String[]{EXTRAS_VALUE},
EXTRAS_ACCOUNTS_ID
@@ -363,6 +372,9 @@ public class AccountManagerService
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
try {
+ if (account == null) {
+ return false;
+ }
boolean noBroadcast = false;
if (account.type.equals(GOOGLE_ACCOUNT_TYPE)) {
// Look for the 'nobroadcast' flag and remove it since we don't want it to persist
@@ -416,6 +428,14 @@ public class AccountManagerService
checkManageAccountsPermission();
long identityToken = clearCallingIdentity();
try {
+ if (account == null) {
+ try {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS, "null account");
+ } catch (RemoteException e) {
+ // it doesn't matter if we are unable to deliver this error
+ }
+ return;
+ }
new RemoveAccountSession(response, account).bind();
} finally {
restoreCallingIdentity(identityToken);
@@ -512,6 +532,9 @@ public class AccountManagerService
}
private boolean saveAuthTokenToDatabase(Account account, String type, String authToken) {
+ if (account == null || type == null) {
+ return false;
+ }
cancelNotification(getSigninRequiredNotificationId(account));
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
@@ -538,6 +561,9 @@ public class AccountManagerService
}
public String readAuthTokenFromDatabase(Account account, String authTokenType) {
+ if (account == null || authTokenType == null) {
+ return null;
+ }
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_AUTHTOKENS, new String[]{AUTHTOKENS_AUTHTOKEN},
AUTHTOKENS_ACCOUNTS_ID + "=(select _id FROM accounts WHERE name=? AND type=?) AND "
@@ -585,6 +611,9 @@ public class AccountManagerService
}
private void setPasswordInDB(Account account, String password) {
+ if (account == null) {
+ return;
+ }
ContentValues values = new ContentValues();
values.put(ACCOUNTS_PASSWORD, password);
mOpenHelper.getWritableDatabase().update(TABLE_ACCOUNTS, values,
@@ -607,23 +636,12 @@ public class AccountManagerService
}
}
- private void sendResult(IAccountManagerResponse response, Bundle bundle) {
- if (response != null) {
- try {
- response.onResult(bundle);
- } catch (RemoteException e) {
- // if the caller is dead then there is no one to care about remote
- // exceptions
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "failure while notifying response", e);
- }
- }
- }
- }
-
public void setUserData(Account account, String key, String value) {
checkAuthenticateAccountsPermission(account);
long identityToken = clearCallingIdentity();
+ if (account == null) {
+ return;
+ }
if (account.type.equals(GOOGLE_ACCOUNT_TYPE) && key.equals("broadcast")) {
sendAccountsChangedBroadcast();
return;
@@ -636,6 +654,9 @@ public class AccountManagerService
}
private void writeUserdataIntoDatabase(Account account, String key, String value) {
+ if (account == null || key == null) {
+ return;
+ }
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
try {
@@ -684,6 +705,22 @@ public class AccountManagerService
long identityToken = clearCallingIdentity();
try {
+ try {
+ if (account == null) {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+ "account is null");
+ return;
+ }
+ if (authTokenType == null) {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+ "authTokenType is null");
+ return;
+ }
+ } catch (RemoteException e) {
+ // it doesn't matter if we can't deliver this error
+ return;
+ }
+
// if the caller has permission, do the peek. otherwise go the more expensive
// route of starting a Session
if (permissionGranted) {
@@ -849,6 +886,16 @@ public class AccountManagerService
checkManageAccountsPermission();
long identityToken = clearCallingIdentity();
try {
+ try {
+ if (authTokenType == null) {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+ "authTokenType is null");
+ return;
+ }
+ } catch (RemoteException e) {
+ // it doesn't matter if we can't deliver this error
+ return;
+ }
new Session(response, accountType, expectActivityLaunch) {
public void run() throws RemoteException {
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
@@ -874,6 +921,16 @@ public class AccountManagerService
checkManageAccountsPermission();
long identityToken = clearCallingIdentity();
try {
+ try {
+ if (account == null) {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+ "account is null");
+ return;
+ }
+ } catch (RemoteException e) {
+ // it doesn't matter if we can't deliver this error
+ return;
+ }
new Session(response, account.type, expectActivityLaunch) {
public void run() throws RemoteException {
mAuthenticator.confirmCredentials(this, account, options);
@@ -894,6 +951,16 @@ public class AccountManagerService
checkManageAccountsPermission();
long identityToken = clearCallingIdentity();
try {
+ try {
+ if (account == null) {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+ "account is null");
+ return;
+ }
+ } catch (RemoteException e) {
+ // it doesn't matter if we can't deliver this error
+ return;
+ }
new Session(response, account.type, expectActivityLaunch) {
public void run() throws RemoteException {
mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions);
@@ -916,6 +983,16 @@ public class AccountManagerService
checkManageAccountsPermission();
long identityToken = clearCallingIdentity();
try {
+ try {
+ if (accountType == null) {
+ response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+ "accountType is null");
+ return;
+ }
+ } catch (RemoteException e) {
+ // it doesn't matter if we can't deliver this error
+ return;
+ }
new Session(response, accountType, expectActivityLaunch) {
public void run() throws RemoteException {
mAuthenticator.editProperties(this, mAccountType);
@@ -1636,9 +1713,11 @@ public class AccountManagerService
}
private boolean permissionIsGranted(Account account, String authTokenType, int callerUid) {
- final boolean fromAuthenticator = hasAuthenticatorUid(account.type, callerUid);
- final boolean hasExplicitGrants = hasExplicitlyGrantedPermission(account, authTokenType);
final boolean inSystemImage = inSystemImage(callerUid);
+ final boolean fromAuthenticator = account != null
+ && hasAuthenticatorUid(account.type, callerUid);
+ final boolean hasExplicitGrants = account != null
+ && hasExplicitlyGrantedPermission(account, authTokenType);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "checkGrantsOrCallingUidAgainstAuthenticator: caller uid "
+ callerUid + ", account " + account
@@ -1682,7 +1761,7 @@ public class AccountManagerService
private void checkCallingUidAgainstAuthenticator(Account account) {
final int uid = Binder.getCallingUid();
- if (!hasAuthenticatorUid(account.type, uid)) {
+ if (account == null || !hasAuthenticatorUid(account.type, uid)) {
String msg = "caller uid " + uid + " is different than the authenticator's uid";
Log.w(TAG, msg);
throw new SecurityException(msg);
@@ -1713,6 +1792,9 @@ public class AccountManagerService
* @hide
*/
public void grantAppPermission(Account account, String authTokenType, int uid) {
+ if (account == null || authTokenType == null) {
+ return;
+ }
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
try {
@@ -1740,6 +1822,9 @@ public class AccountManagerService
* @hide
*/
public void revokeAppPermission(Account account, String authTokenType, int uid) {
+ if (account == null || authTokenType == null) {
+ return;
+ }
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
try {