Loading core/java/android/accounts/AccountManager.java +26 −12 Original line number Diff line number Diff line Loading @@ -321,7 +321,8 @@ public class AccountManager { */ public String peekAuthToken(final Account account, final String authTokenType) { 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) { return null; Loading @@ -346,7 +347,8 @@ public class AccountManager { */ public void setPassword(final Account account, final String password) { if (account == null) { throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null"); return; } try { mService.setPassword(account, password); Loading @@ -365,7 +367,8 @@ public class AccountManager { */ public void clearPassword(final Account account) { if (account == null) { throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null"); return; } try { mService.clearPassword(account); Loading @@ -388,10 +391,12 @@ public class AccountManager { */ public void setUserData(final Account account, final String key, final String value) { 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) { throw new IllegalArgumentException("the key must not be null"); Log.e(TAG, "the key must not be null"); return; } try { mService.setUserData(account, key, value); Loading Loading @@ -602,11 +607,14 @@ 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 { 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, requiredFeatures, activity != null, addAccountOptions); } Loading @@ -616,9 +624,13 @@ public class AccountManager { public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures( final String type, final String[] features, AccountManagerCallback<Account[]> callback, Handler handler) { if (type == null) throw new IllegalArgumentException("type is null"); return new Future2Task<Account[]>(handler, callback) { public void doWork() throws RemoteException { if (type == null) { Log.e(TAG, "Type is null"); set(new Account[0]); return; } mService.getAccountsByFeatures(mResponse, type, features); } public Account[] bundleToResult(Bundle bundle) throws AuthenticatorException { Loading Loading @@ -785,7 +797,7 @@ public class AccountManager { //noinspection ThrowableInstanceNeverThrow // Log.e(TAG, "calling this from your main thread can lead to deadlock and/or ANRs", // 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( // "calling this from your main thread can lead to deadlock"); } Loading Loading @@ -1338,11 +1350,13 @@ public class AccountManager { */ public void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) { if (listener == null) { throw new IllegalArgumentException("the listener is null"); Log.e(TAG, "Missing listener"); return; } synchronized (mAccountsUpdatedListeners) { 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); if (mAccountsUpdatedListeners.isEmpty()) { Loading core/java/android/accounts/AccountManagerService.java +0 −64 Original line number Diff line number Diff line Loading @@ -428,14 +428,6 @@ 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); Loading Loading @@ -705,22 +697,6 @@ 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) { Loading Loading @@ -886,16 +862,6 @@ 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, Loading @@ -921,16 +887,6 @@ 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); Loading @@ -951,16 +907,6 @@ 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); Loading @@ -983,16 +929,6 @@ 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); Loading Loading
core/java/android/accounts/AccountManager.java +26 −12 Original line number Diff line number Diff line Loading @@ -321,7 +321,8 @@ public class AccountManager { */ public String peekAuthToken(final Account account, final String authTokenType) { 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) { return null; Loading @@ -346,7 +347,8 @@ public class AccountManager { */ public void setPassword(final Account account, final String password) { if (account == null) { throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null"); return; } try { mService.setPassword(account, password); Loading @@ -365,7 +367,8 @@ public class AccountManager { */ public void clearPassword(final Account account) { if (account == null) { throw new IllegalArgumentException("the account must not be null"); Log.e(TAG, "the account must not be null"); return; } try { mService.clearPassword(account); Loading @@ -388,10 +391,12 @@ public class AccountManager { */ public void setUserData(final Account account, final String key, final String value) { 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) { throw new IllegalArgumentException("the key must not be null"); Log.e(TAG, "the key must not be null"); return; } try { mService.setUserData(account, key, value); Loading Loading @@ -602,11 +607,14 @@ 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 { 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, requiredFeatures, activity != null, addAccountOptions); } Loading @@ -616,9 +624,13 @@ public class AccountManager { public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures( final String type, final String[] features, AccountManagerCallback<Account[]> callback, Handler handler) { if (type == null) throw new IllegalArgumentException("type is null"); return new Future2Task<Account[]>(handler, callback) { public void doWork() throws RemoteException { if (type == null) { Log.e(TAG, "Type is null"); set(new Account[0]); return; } mService.getAccountsByFeatures(mResponse, type, features); } public Account[] bundleToResult(Bundle bundle) throws AuthenticatorException { Loading Loading @@ -785,7 +797,7 @@ public class AccountManager { //noinspection ThrowableInstanceNeverThrow // Log.e(TAG, "calling this from your main thread can lead to deadlock and/or ANRs", // 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( // "calling this from your main thread can lead to deadlock"); } Loading Loading @@ -1338,11 +1350,13 @@ public class AccountManager { */ public void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) { if (listener == null) { throw new IllegalArgumentException("the listener is null"); Log.e(TAG, "Missing listener"); return; } synchronized (mAccountsUpdatedListeners) { 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); if (mAccountsUpdatedListeners.isEmpty()) { Loading
core/java/android/accounts/AccountManagerService.java +0 −64 Original line number Diff line number Diff line Loading @@ -428,14 +428,6 @@ 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); Loading Loading @@ -705,22 +697,6 @@ 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) { Loading Loading @@ -886,16 +862,6 @@ 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, Loading @@ -921,16 +887,6 @@ 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); Loading @@ -951,16 +907,6 @@ 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); Loading @@ -983,16 +929,6 @@ 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); Loading