am 492dbe17: am 4388b988: Merge change Idc4c7714 into eclair

Merge commit '492dbe17527e27ba712d185a1eac22ae149c67c0' into eclair-mr2-plus-aosp

* commit '492dbe17527e27ba712d185a1eac22ae149c67c0':
  Revert the changes that introduced new exception that wouldn't have occured before, applications don't seem to be able to handle them and we get crashes.
This commit is contained in:
Costin Manolache
2009-10-29 19:57:50 -07:00
committed by Android Git Automerger
2 changed files with 26 additions and 76 deletions

View File

@@ -321,7 +321,8 @@ public class AccountManager {
*/ */
public String peekAuthToken(final Account account, final String authTokenType) { public String peekAuthToken(final Account account, final String authTokenType) {
if (account == null) { if (account == null) {
throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "peekAuthToken: the account must not be null");
return null;
} }
if (authTokenType == null) { if (authTokenType == null) {
return null; return null;
@@ -346,7 +347,8 @@ public class AccountManager {
*/ */
public void setPassword(final Account account, final String password) { public void setPassword(final Account account, final String password) {
if (account == null) { if (account == null) {
throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null");
return;
} }
try { try {
mService.setPassword(account, password); mService.setPassword(account, password);
@@ -365,7 +367,8 @@ public class AccountManager {
*/ */
public void clearPassword(final Account account) { public void clearPassword(final Account account) {
if (account == null) { if (account == null) {
throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null");
return;
} }
try { try {
mService.clearPassword(account); mService.clearPassword(account);
@@ -388,10 +391,12 @@ public class AccountManager {
*/ */
public void setUserData(final Account account, final String key, final String value) { public void setUserData(final Account account, final String key, final String value) {
if (account == null) { if (account == null) {
throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null");
return;
} }
if (key == null) { if (key == null) {
throw new IllegalArgumentException("the key must not be null"); Log.e(TAG, "the key must not be null");
return;
} }
try { try {
mService.setUserData(account, key, value); mService.setUserData(account, key, value);
@@ -602,11 +607,14 @@ public class AccountManager {
final String authTokenType, final String[] requiredFeatures, final String authTokenType, final String[] requiredFeatures,
final Bundle addAccountOptions, final Bundle addAccountOptions,
final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) { final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
if (accountType == null) {
throw new IllegalArgumentException();
}
return new AmsTask(activity, handler, callback) { return new AmsTask(activity, handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
if (accountType == null) {
Log.e(TAG, "the account must not be null");
// to unblock caller waiting on Future.get()
set(new Bundle());
return;
}
mService.addAcount(mResponse, accountType, authTokenType, mService.addAcount(mResponse, accountType, authTokenType,
requiredFeatures, activity != null, addAccountOptions); requiredFeatures, activity != null, addAccountOptions);
} }
@@ -616,9 +624,13 @@ public class AccountManager {
public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures( public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures(
final String type, final String[] features, final String type, final String[] features,
AccountManagerCallback<Account[]> callback, Handler handler) { AccountManagerCallback<Account[]> callback, Handler handler) {
if (type == null) throw new IllegalArgumentException("type is null");
return new Future2Task<Account[]>(handler, callback) { return new Future2Task<Account[]>(handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
if (type == null) {
Log.e(TAG, "Type is null");
set(new Account[0]);
return;
}
mService.getAccountsByFeatures(mResponse, type, features); mService.getAccountsByFeatures(mResponse, type, features);
} }
public Account[] bundleToResult(Bundle bundle) throws AuthenticatorException { public Account[] bundleToResult(Bundle bundle) throws AuthenticatorException {
@@ -785,7 +797,7 @@ public class AccountManager {
//noinspection ThrowableInstanceNeverThrow //noinspection ThrowableInstanceNeverThrow
// Log.e(TAG, "calling this from your main thread can lead to deadlock and/or ANRs", // Log.e(TAG, "calling this from your main thread can lead to deadlock and/or ANRs",
// new Exception()); // new Exception());
// TODO(fredq) remove the log and throw this exception when the callers are fixed // TODO remove the log and throw this exception when the callers are fixed
// throw new IllegalStateException( // throw new IllegalStateException(
// "calling this from your main thread can lead to deadlock"); // "calling this from your main thread can lead to deadlock");
} }
@@ -1338,11 +1350,13 @@ public class AccountManager {
*/ */
public void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) { public void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) {
if (listener == null) { if (listener == null) {
throw new IllegalArgumentException("the listener is null"); Log.e(TAG, "Missing listener");
return;
} }
synchronized (mAccountsUpdatedListeners) { synchronized (mAccountsUpdatedListeners) {
if (!mAccountsUpdatedListeners.containsKey(listener)) { if (!mAccountsUpdatedListeners.containsKey(listener)) {
throw new IllegalStateException("this listener was not previously added"); Log.e(TAG, "Listener was not previously added");
return;
} }
mAccountsUpdatedListeners.remove(listener); mAccountsUpdatedListeners.remove(listener);
if (mAccountsUpdatedListeners.isEmpty()) { if (mAccountsUpdatedListeners.isEmpty()) {

View File

@@ -428,14 +428,6 @@ public class AccountManagerService
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { 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(); new RemoveAccountSession(response, account).bind();
} finally { } finally {
restoreCallingIdentity(identityToken); restoreCallingIdentity(identityToken);
@@ -705,22 +697,6 @@ public class AccountManagerService
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { 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 // if the caller has permission, do the peek. otherwise go the more expensive
// route of starting a Session // route of starting a Session
if (permissionGranted) { if (permissionGranted) {
@@ -886,16 +862,6 @@ public class AccountManagerService
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { 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) { new Session(response, accountType, expectActivityLaunch) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures, mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
@@ -921,16 +887,6 @@ public class AccountManagerService
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { 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) { new Session(response, account.type, expectActivityLaunch) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.confirmCredentials(this, account, options); mAuthenticator.confirmCredentials(this, account, options);
@@ -951,16 +907,6 @@ public class AccountManagerService
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { 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) { new Session(response, account.type, expectActivityLaunch) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions); mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions);
@@ -983,16 +929,6 @@ public class AccountManagerService
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { 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) { new Session(response, accountType, expectActivityLaunch) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.editProperties(this, mAccountType); mAuthenticator.editProperties(this, mAccountType);