Skip to content

Commit 682e023

Browse files
Ian PedowitzAndroid Git Automerger
authored andcommitted
am 845d14d: Revert "Permissions: GET_ACCOUNTS permission cleanup"
* commit '845d14db9066c3262f270237b52e315aa71508b2': Revert "Permissions: GET_ACCOUNTS permission cleanup"
2 parents ae351ec + 845d14d commit 682e023

3 files changed

Lines changed: 127 additions & 199 deletions

File tree

core/java/android/accounts/AbstractAccountAuthenticator.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ public void addAccount(IAccountAuthenticatorResponse response, String accountTyp
138138
new AccountAuthenticatorResponse(response),
139139
accountType, authTokenType, features, options);
140140
if (Log.isLoggable(TAG, Log.VERBOSE)) {
141-
if (result != null) {
142-
result.keySet(); // force it to be unparcelled
143-
}
141+
result.keySet(); // force it to be unparcelled
144142
Log.v(TAG, "addAccount: result " + AccountManager.sanitizeResult(result));
145143
}
146144
if (result != null) {
@@ -162,9 +160,7 @@ public void confirmCredentials(IAccountAuthenticatorResponse response,
162160
final Bundle result = AbstractAccountAuthenticator.this.confirmCredentials(
163161
new AccountAuthenticatorResponse(response), account, options);
164162
if (Log.isLoggable(TAG, Log.VERBOSE)) {
165-
if (result != null) {
166-
result.keySet(); // force it to be unparcelled
167-
}
163+
result.keySet(); // force it to be unparcelled
168164
Log.v(TAG, "confirmCredentials: result "
169165
+ AccountManager.sanitizeResult(result));
170166
}
@@ -189,9 +185,7 @@ public void getAuthTokenLabel(IAccountAuthenticatorResponse response,
189185
result.putString(AccountManager.KEY_AUTH_TOKEN_LABEL,
190186
AbstractAccountAuthenticator.this.getAuthTokenLabel(authTokenType));
191187
if (Log.isLoggable(TAG, Log.VERBOSE)) {
192-
if (result != null) {
193-
result.keySet(); // force it to be unparcelled
194-
}
188+
result.keySet(); // force it to be unparcelled
195189
Log.v(TAG, "getAuthTokenLabel: result "
196190
+ AccountManager.sanitizeResult(result));
197191
}
@@ -215,9 +209,7 @@ public void getAuthToken(IAccountAuthenticatorResponse response,
215209
new AccountAuthenticatorResponse(response), account,
216210
authTokenType, loginOptions);
217211
if (Log.isLoggable(TAG, Log.VERBOSE)) {
218-
if (result != null) {
219-
result.keySet(); // force it to be unparcelled
220-
}
212+
result.keySet(); // force it to be unparcelled
221213
Log.v(TAG, "getAuthToken: result " + AccountManager.sanitizeResult(result));
222214
}
223215
if (result != null) {
@@ -242,10 +234,7 @@ public void updateCredentials(IAccountAuthenticatorResponse response, Account ac
242234
new AccountAuthenticatorResponse(response), account,
243235
authTokenType, loginOptions);
244236
if (Log.isLoggable(TAG, Log.VERBOSE)) {
245-
// Result may be null.
246-
if (result != null) {
247-
result.keySet(); // force it to be unparcelled
248-
}
237+
result.keySet(); // force it to be unparcelled
249238
Log.v(TAG, "updateCredentials: result "
250239
+ AccountManager.sanitizeResult(result));
251240
}
@@ -501,7 +490,7 @@ public abstract Bundle getAuthToken(AccountAuthenticatorResponse response,
501490
* <ul>
502491
* <li> {@link AccountManager#KEY_INTENT}, or
503492
* <li> {@link AccountManager#KEY_ACCOUNT_NAME} and {@link AccountManager#KEY_ACCOUNT_TYPE} of
504-
* the account whose credentials were updated, or
493+
* the account that was added, or
505494
* <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to
506495
* indicate an error
507496
* </ul>

core/java/android/accounts/AccountManager.java

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public String getPassword(final Account account) {
333333
try {
334334
return mService.getPassword(account);
335335
} catch (RemoteException e) {
336-
// won't ever happen
336+
// will never happen
337337
throw new RuntimeException(e);
338338
}
339339
}
@@ -362,7 +362,7 @@ public String getUserData(final Account account, final String key) {
362362
try {
363363
return mService.getUserData(account, key);
364364
} catch (RemoteException e) {
365-
// won't ever happen
365+
// will never happen
366366
throw new RuntimeException(e);
367367
}
368368
}
@@ -415,10 +415,8 @@ public AuthenticatorDescription[] getAuthenticatorTypesAsUser(int userId) {
415415
*
416416
* <p>It is safe to call this method from the main thread.
417417
*
418-
* <p>Clients of this method that have not been granted the
419-
* {@link android.Manifest.permission#GET_ACCOUNTS} permission,
420-
* will only see those accounts managed by AbstractAccountAuthenticators whose
421-
* signature matches the client.
418+
* <p>This method requires the caller to hold the permission
419+
* {@link android.Manifest.permission#GET_ACCOUNTS}.
422420
*
423421
* @return An array of {@link Account}, one for each account. Empty
424422
* (never null) if no accounts have been added.
@@ -440,10 +438,8 @@ public Account[] getAccounts() {
440438
*
441439
* <p>It is safe to call this method from the main thread.
442440
*
443-
* <p>Clients of this method that have not been granted the
444-
* {@link android.Manifest.permission#GET_ACCOUNTS} permission,
445-
* will only see those accounts managed by AbstractAccountAuthenticators whose
446-
* signature matches the client.
441+
* <p>This method requires the caller to hold the permission
442+
* {@link android.Manifest.permission#GET_ACCOUNTS}.
447443
*
448444
* @return An array of {@link Account}, one for each account. Empty
449445
* (never null) if no accounts have been added.
@@ -470,7 +466,7 @@ public Account[] getAccountsForPackage(String packageName, int uid) {
470466
try {
471467
return mService.getAccountsForPackage(packageName, uid);
472468
} catch (RemoteException re) {
473-
// won't ever happen
469+
// possible security exception
474470
throw new RuntimeException(re);
475471
}
476472
}
@@ -487,7 +483,7 @@ public Account[] getAccountsByTypeForPackage(String type, String packageName) {
487483
try {
488484
return mService.getAccountsByTypeForPackage(type, packageName);
489485
} catch (RemoteException re) {
490-
// won't ever happen
486+
// possible security exception
491487
throw new RuntimeException(re);
492488
}
493489
}
@@ -501,10 +497,9 @@ public Account[] getAccountsByTypeForPackage(String type, String packageName) {
501497
*
502498
* <p>It is safe to call this method from the main thread.
503499
*
504-
* <p>Clients of this method that have not been granted the
505-
* {@link android.Manifest.permission#GET_ACCOUNTS} permission,
506-
* will only see those accounts managed by AbstractAccountAuthenticators whose
507-
* signature matches the client.
500+
* <p>This method requires the caller to hold the permission
501+
* {@link android.Manifest.permission#GET_ACCOUNTS} or share a uid with the
502+
* authenticator that owns the account type.
508503
*
509504
* <p><b>NOTE:</b> If targeting your app to work on API level 22 and before,
510505
* GET_ACCOUNTS permission is needed for those platforms, irrespective of uid
@@ -590,8 +585,7 @@ public String bundleToResult(Bundle bundle) throws AuthenticatorException {
590585
* {@link AccountManagerFuture} must not be used on the main thread.
591586
*
592587
* <p>This method requires the caller to hold the permission
593-
* {@link android.Manifest.permission#GET_ACCOUNTS} or be a signature
594-
* match with the AbstractAccountAuthenticator that manages the account.
588+
* {@link android.Manifest.permission#GET_ACCOUNTS}.
595589
*
596590
* @param account The {@link Account} to test
597591
* @param features An array of the account features to check
@@ -634,10 +628,9 @@ public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException {
634628
* <p>This method may be called from any thread, but the returned
635629
* {@link AccountManagerFuture} must not be used on the main thread.
636630
*
637-
* <p>Clients of this method that have not been granted the
638-
* {@link android.Manifest.permission#GET_ACCOUNTS} permission,
639-
* will only see those accounts managed by AbstractAccountAuthenticators whose
640-
* signature matches the client.
631+
* <p>This method requires the caller to hold the permission
632+
* {@link android.Manifest.permission#GET_ACCOUNTS} or share a uid with the
633+
* authenticator that owns the account type.
641634
*
642635
* @param type The type of accounts to return, must not be null
643636
* @param features An array of the account features to require,
@@ -708,7 +701,7 @@ public boolean addAccountExplicitly(Account account, String password, Bundle use
708701
try {
709702
return mService.addAccountExplicitly(account, password, userdata);
710703
} catch (RemoteException e) {
711-
// Can happen if there was a SecurityException was thrown.
704+
// won't ever happen
712705
throw new RuntimeException(e);
713706
}
714707
}
@@ -973,7 +966,7 @@ public boolean removeAccountExplicitly(Account account) {
973966
try {
974967
return mService.removeAccountExplicitly(account);
975968
} catch (RemoteException e) {
976-
// May happen if the caller doesn't match the signature of the authenticator.
969+
// won't ever happen
977970
throw new RuntimeException(e);
978971
}
979972
}
@@ -1121,7 +1114,7 @@ public void setUserData(final Account account, final String key, final String va
11211114
try {
11221115
mService.setUserData(account, key, value);
11231116
} catch (RemoteException e) {
1124-
// Will happen if there is not signature match.
1117+
// won't ever happen
11251118
throw new RuntimeException(e);
11261119
}
11271120
}
@@ -1740,7 +1733,7 @@ public void doWork() throws RemoteException {
17401733
* with these fields if an activity was supplied and the account
17411734
* credentials were successfully updated:
17421735
* <ul>
1743-
* <li> {@link #KEY_ACCOUNT_NAME} - the name of the account
1736+
* <li> {@link #KEY_ACCOUNT_NAME} - the name of the account created
17441737
* <li> {@link #KEY_ACCOUNT_TYPE} - the type of the account
17451738
* </ul>
17461739
*
@@ -2508,13 +2501,11 @@ public void onReceive(final Context context, final Intent intent) {
25082501
* listeners are added in an Activity or Service's {@link Activity#onCreate}
25092502
* and removed in {@link Activity#onDestroy}.
25102503
*
2511-
* <p>The listener will only be informed of accounts that would be returned
2512-
* to the caller via {@link #getAccounts()}. Typically this means that to
2513-
* get any accounts, the caller will need to be grated the GET_ACCOUNTS
2514-
* permission.
2515-
*
25162504
* <p>It is safe to call this method from the main thread.
25172505
*
2506+
* <p>This method requires the caller to hold the permission
2507+
* {@link android.Manifest.permission#GET_ACCOUNTS}.
2508+
*
25182509
* @param listener The listener to send notifications to
25192510
* @param handler {@link Handler} identifying the thread to use
25202511
* for notifications, null for the main thread

0 commit comments

Comments
 (0)