diff options
author | Marco Nelissen <marcone@google.com> | 2009-10-29 18:04:17 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2009-10-29 18:04:17 -0700 |
commit | c81e43c8ee31d986e34ee892b7d7bfbf70f82da7 (patch) | |
tree | 162d3ba3926da135b52d7a64fc4f6b3f910378eb /core | |
parent | 758b5b25f04e4f75e7c6c7a419bf333e4ee49718 (diff) | |
parent | 31957f1badbb900bbfe211317e1ea992d650a72d (diff) | |
download | frameworks_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')
4 files changed, 176 insertions, 107 deletions
diff --git a/core/java/android/accounts/AbstractAccountAuthenticator.java b/core/java/android/accounts/AbstractAccountAuthenticator.java index ee6d748..0efeb1d 100644 --- a/core/java/android/accounts/AbstractAccountAuthenticator.java +++ b/core/java/android/accounts/AbstractAccountAuthenticator.java @@ -87,6 +87,9 @@ import android.Manifest; * the {@link AccountAuthenticatorResponse} as {@link AccountManager#KEY_ACCOUNT_MANAGER_RESPONSE}. * The activity must then call {@link AccountAuthenticatorResponse#onResult} or * {@link AccountAuthenticatorResponse#onError} when it is complete. + * <li> If the authenticator cannot synchronously process the request and return a result then it + * may choose to return null and then use the {@link AccountManagerResponse} to send the result + * when it has completed the request. * </ul> * <p> * The following descriptions of each of the abstract authenticator methods will not describe the @@ -111,44 +114,35 @@ public abstract class AbstractAccountAuthenticator { String authTokenType, String[] requiredFeatures, Bundle options) throws RemoteException { checkBinderPermission(); - final Bundle result; try { - result = AbstractAccountAuthenticator.this.addAccount( + final Bundle result = AbstractAccountAuthenticator.this.addAccount( new AccountAuthenticatorResponse(response), accountType, authTokenType, requiredFeatures, options); + if (result != null) { + response.onResult(result); + } } catch (NetworkErrorException e) { response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage()); - return; } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, "addAccount not supported"); - return; - } - if (result != null) { - response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } public void confirmCredentials(IAccountAuthenticatorResponse response, Account account, Bundle options) throws RemoteException { checkBinderPermission(); - final Bundle result; try { - result = AbstractAccountAuthenticator.this.confirmCredentials( + final Bundle result = AbstractAccountAuthenticator.this.confirmCredentials( new AccountAuthenticatorResponse(response), account, options); + if (result != null) { + response.onResult(result); + } + } catch (NetworkErrorException e) { + response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage()); } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, "confirmCredentials not supported"); - return; - } - if (result != null) { - response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } @@ -180,9 +174,6 @@ public abstract class AbstractAccountAuthenticator { authTokenType, loginOptions); if (result != null) { response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, @@ -195,64 +186,50 @@ public abstract class AbstractAccountAuthenticator { public void updateCredentials(IAccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) throws RemoteException { checkBinderPermission(); - final Bundle result; try { - result = AbstractAccountAuthenticator.this.updateCredentials( + final Bundle result = AbstractAccountAuthenticator.this.updateCredentials( new AccountAuthenticatorResponse(response), account, authTokenType, loginOptions); + if (result != null) { + response.onResult(result); + } + } catch (NetworkErrorException e) { + response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage()); } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, "updateCredentials not supported"); - return; - } - if (result != null) { - response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } public void editProperties(IAccountAuthenticatorResponse response, String accountType) throws RemoteException { checkBinderPermission(); - final Bundle result; try { - result = AbstractAccountAuthenticator.this.editProperties( + final Bundle result = AbstractAccountAuthenticator.this.editProperties( new AccountAuthenticatorResponse(response), accountType); + if (result != null) { + response.onResult(result); + } } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, "editProperties not supported"); - return; - } - if (result != null) { - response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } public void hasFeatures(IAccountAuthenticatorResponse response, Account account, String[] features) throws RemoteException { checkBinderPermission(); - final Bundle result; try { - result = AbstractAccountAuthenticator.this.hasFeatures( + final Bundle result = AbstractAccountAuthenticator.this.hasFeatures( new AccountAuthenticatorResponse(response), account, features); + if (result != null) { + response.onResult(result); + } } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, "hasFeatures not supported"); - return; } catch (NetworkErrorException e) { response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage()); - return; - } - if (result != null) { - response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } @@ -264,9 +241,6 @@ public abstract class AbstractAccountAuthenticator { new AccountAuthenticatorResponse(response), account); if (result != null) { response.onResult(result); - } else { - response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, - "no response from the authenticator"); } } catch (UnsupportedOperationException e) { response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION, @@ -347,16 +321,18 @@ public abstract class AbstractAccountAuthenticator { * <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to * indicate an error * </ul> + * @throws NetworkErrorException if the authenticator could not honor the request due to a + * network error */ public abstract Bundle confirmCredentials(AccountAuthenticatorResponse response, - Account account, Bundle options); - + Account account, Bundle options) + throws NetworkErrorException; /** * Gets the authtoken for an account. * @param response to send the result back to the AccountManager, will never be null * @param account the account whose credentials are to be retrieved, will never be null * @param authTokenType the type of auth token to retrieve, will never be null - * @param loginOptions a Bundle of authenticator-specific options, may be null + * @param options a Bundle of authenticator-specific options, may be null * @return a Bundle result or null if the result is to be returned via the response. The result * will contain either: * <ul> @@ -370,7 +346,7 @@ public abstract class AbstractAccountAuthenticator { * network error */ public abstract Bundle getAuthToken(AccountAuthenticatorResponse response, - Account account, String authTokenType, Bundle loginOptions) + Account account, String authTokenType, Bundle options) throws NetworkErrorException; /** @@ -386,7 +362,7 @@ public abstract class AbstractAccountAuthenticator { * @param account the account whose credentials are to be updated, will never be null * @param authTokenType the type of auth token to retrieve after updating the credentials, * may be null - * @param loginOptions a Bundle of authenticator-specific options, may be null + * @param options a Bundle of authenticator-specific options, may be null * @return a Bundle result or null if the result is to be returned via the response. The result * will contain either: * <ul> @@ -397,9 +373,11 @@ public abstract class AbstractAccountAuthenticator { * <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to * indicate an error * </ul> + * @throws NetworkErrorException if the authenticator could not honor the request due to a + * network error */ public abstract Bundle updateCredentials(AccountAuthenticatorResponse response, - Account account, String authTokenType, Bundle loginOptions); + Account account, String authTokenType, Bundle options) throws NetworkErrorException; /** * Checks if the account supports all the specified authenticator specific features. diff --git a/core/java/android/accounts/AccountAuthenticatorActivity.java b/core/java/android/accounts/AccountAuthenticatorActivity.java index 3d7be48..5cce6da 100644 --- a/core/java/android/accounts/AccountAuthenticatorActivity.java +++ b/core/java/android/accounts/AccountAuthenticatorActivity.java @@ -56,14 +56,8 @@ public class AccountAuthenticatorActivity extends Activity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); - if (icicle == null) { - Intent intent = getIntent(); - mAccountAuthenticatorResponse = - intent.getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); - } else { - mAccountAuthenticatorResponse = - icicle.getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); - } + mAccountAuthenticatorResponse = + getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); if (mAccountAuthenticatorResponse != null) { mAccountAuthenticatorResponse.onRequestContinued(); @@ -71,16 +65,6 @@ public class AccountAuthenticatorActivity extends Activity { } /** - * Saves the AccountAuthenticatorResponse in the instance state. - * @param outState where to store any instance data - */ - protected void onSaveInstanceState(Bundle outState) { - outState.putParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, - mAccountAuthenticatorResponse); - super.onSaveInstanceState(outState); - } - - /** * Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present. */ public void finish() { @@ -89,7 +73,8 @@ public class AccountAuthenticatorActivity extends Activity { if (mResultBundle != null) { mAccountAuthenticatorResponse.onResult(mResultBundle); } else { - mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled"); + mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, + "canceled"); } mAccountAuthenticatorResponse = null; } diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index 153d95f..46dc895 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -237,13 +237,13 @@ public class AccountManager { * with the same UID as the Authenticator for the account. * @param account The account to add * @param password The password to associate with the account. May be null. - * @param extras A bundle of key/value pairs to set as the account's userdata. May be null. + * @param userdata A bundle of key/value pairs to set as the account's userdata. May be null. * @return true if the account was sucessfully added, false otherwise, for example, * if the account already exists or if the account is null */ - public boolean addAccountExplicitly(Account account, String password, Bundle extras) { + public boolean addAccountExplicitly(Account account, String password, Bundle userdata) { try { - return mService.addAccount(account, password, extras); + return mService.addAccount(account, password, userdata); } catch (RemoteException e) { // won't ever happen throw new RuntimeException(e); @@ -320,6 +320,12 @@ public class AccountManager { * AccountManager, null otherwise. */ public String peekAuthToken(final Account account, final String authTokenType) { + if (account == null) { + throw new IllegalArgumentException("the account must not be null"); + } + if (authTokenType == null) { + return null; + } try { return mService.peekAuthToken(account, authTokenType); } catch (RemoteException e) { @@ -339,6 +345,9 @@ public class AccountManager { * @param password the password to set for the account. May be null. */ public void setPassword(final Account account, final String password) { + if (account == null) { + throw new IllegalArgumentException("the account must not be null"); + } try { mService.setPassword(account, password); } catch (RemoteException e) { @@ -355,6 +364,9 @@ public class AccountManager { * @param account the account whose password is to be cleared. Must not be null. */ public void clearPassword(final Account account) { + if (account == null) { + throw new IllegalArgumentException("the account must not be null"); + } try { mService.clearPassword(account); } catch (RemoteException e) { @@ -375,6 +387,12 @@ public class AccountManager { * @param value the value to set. May be null. */ public void setUserData(final Account account, final String key, final String value) { + if (account == null) { + throw new IllegalArgumentException("the account must not be null"); + } + if (key == null) { + throw new IllegalArgumentException("the key must not be null"); + } try { mService.setUserData(account, key, value); } catch (RemoteException e) { @@ -458,7 +476,7 @@ public class AccountManager { * @param account The account whose credentials are to be updated. * @param authTokenType the auth token to retrieve as part of updating the credentials. * May be null. - * @param loginOptions authenticator specific options for the request + * @param options authenticator specific options for the request * @param activity If the authenticator returns a {@link #KEY_INTENT} in the result then * the intent will be started with this activity. If activity is null then the result will * be returned as-is. @@ -474,7 +492,7 @@ public class AccountManager { * If the user presses "back" then the request will be canceled. */ public AccountManagerFuture<Bundle> getAuthToken( - final Account account, final String authTokenType, final Bundle loginOptions, + final Account account, final String authTokenType, final Bundle options, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { if (activity == null) throw new IllegalArgumentException("activity is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); @@ -482,7 +500,7 @@ public class AccountManager { public void doWork() throws RemoteException { mService.getAuthToken(mResponse, account, authTokenType, false /* notifyOnAuthFailure */, true /* expectActivityLaunch */, - loginOptions); + options); } }.start(); } @@ -584,6 +602,9 @@ public class AccountManager { final String authTokenType, final String[] requiredFeatures, final Bundle addAccountOptions, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { + if (accountType == null) { + throw new IllegalArgumentException(); + } return new AmsTask(activity, handler, callback) { public void doWork() throws RemoteException { mService.addAcount(mResponse, accountType, authTokenType, @@ -683,7 +704,7 @@ public class AccountManager { * @param account The account whose credentials are to be updated. * @param authTokenType the auth token to retrieve as part of updating the credentials. * May be null. - * @param loginOptions authenticator specific options for the request + * @param options authenticator specific options for the request * @param activity If the authenticator returns a {@link #KEY_INTENT} in the result then * the intent will be started with this activity. If activity is null then the result will * be returned as-is. @@ -702,13 +723,13 @@ public class AccountManager { */ public AccountManagerFuture<Bundle> updateCredentials(final Account account, final String authTokenType, - final Bundle loginOptions, final Activity activity, + final Bundle options, final Activity activity, final AccountManagerCallback<Bundle> callback, final Handler handler) { return new AmsTask(activity, handler, callback) { public void doWork() throws RemoteException { mService.updateCredentials(mResponse, account, authTokenType, activity != null, - loginOptions); + options); } }.start(); } @@ -1214,7 +1235,7 @@ public class AccountManager { * @param activityForPrompting The activity used to start any account management * activities that are required to fulfill this request. This may be null. * @param addAccountOptions authenticator-specific options used if an account needs to be added - * @param loginOptions authenticator-specific options passed to getAuthToken + * @param getAuthTokenOptions authenticator-specific options passed to getAuthToken * @param callback A callback to invoke when the request completes. If null then * no callback is invoked. * @param handler The {@link Handler} to use to invoke the callback. If null then the @@ -1232,13 +1253,13 @@ public class AccountManager { public AccountManagerFuture<Bundle> getAuthTokenByFeatures( final String accountType, final String authTokenType, final String[] features, final Activity activityForPrompting, final Bundle addAccountOptions, - final Bundle loginOptions, + final Bundle getAuthTokenOptions, final AccountManagerCallback<Bundle> callback, final Handler handler) { if (accountType == null) throw new IllegalArgumentException("account type is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); final GetAuthTokenByTypeAndFeaturesTask task = new GetAuthTokenByTypeAndFeaturesTask(accountType, authTokenType, features, - activityForPrompting, addAccountOptions, loginOptions, callback, handler); + activityForPrompting, addAccountOptions, getAuthTokenOptions, callback, handler); task.start(); return task; } 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 { |