@@ -333,7 +333,7 @@ public String getPassword(final Account account) {
333333 try {
334334 return mService .getPassword (account );
335335 } catch (RemoteException e ) {
336- // will never happen
336+ // won't ever 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- // will never happen
365+ // won't ever happen
366366 throw new RuntimeException (e );
367367 }
368368 }
@@ -415,8 +415,10 @@ public AuthenticatorDescription[] getAuthenticatorTypesAsUser(int userId) {
415415 *
416416 * <p>It is safe to call this method from the main thread.
417417 *
418- * <p>This method requires the caller to hold the permission
419- * {@link android.Manifest.permission#GET_ACCOUNTS}.
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.
420422 *
421423 * @return An array of {@link Account}, one for each account. Empty
422424 * (never null) if no accounts have been added.
@@ -438,8 +440,10 @@ public Account[] getAccounts() {
438440 *
439441 * <p>It is safe to call this method from the main thread.
440442 *
441- * <p>This method requires the caller to hold the permission
442- * {@link android.Manifest.permission#GET_ACCOUNTS}.
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.
443447 *
444448 * @return An array of {@link Account}, one for each account. Empty
445449 * (never null) if no accounts have been added.
@@ -466,7 +470,7 @@ public Account[] getAccountsForPackage(String packageName, int uid) {
466470 try {
467471 return mService .getAccountsForPackage (packageName , uid );
468472 } catch (RemoteException re ) {
469- // possible security exception
473+ // won't ever happen
470474 throw new RuntimeException (re );
471475 }
472476 }
@@ -483,7 +487,7 @@ public Account[] getAccountsByTypeForPackage(String type, String packageName) {
483487 try {
484488 return mService .getAccountsByTypeForPackage (type , packageName );
485489 } catch (RemoteException re ) {
486- // possible security exception
490+ // won't ever happen
487491 throw new RuntimeException (re );
488492 }
489493 }
@@ -497,9 +501,10 @@ public Account[] getAccountsByTypeForPackage(String type, String packageName) {
497501 *
498502 * <p>It is safe to call this method from the main thread.
499503 *
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.
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.
503508 *
504509 * <p><b>NOTE:</b> If targeting your app to work on API level 22 and before,
505510 * GET_ACCOUNTS permission is needed for those platforms, irrespective of uid
@@ -585,7 +590,8 @@ public String bundleToResult(Bundle bundle) throws AuthenticatorException {
585590 * {@link AccountManagerFuture} must not be used on the main thread.
586591 *
587592 * <p>This method requires the caller to hold the permission
588- * {@link android.Manifest.permission#GET_ACCOUNTS}.
593+ * {@link android.Manifest.permission#GET_ACCOUNTS} or be a signature
594+ * match with the AbstractAccountAuthenticator that manages the account.
589595 *
590596 * @param account The {@link Account} to test
591597 * @param features An array of the account features to check
@@ -628,9 +634,10 @@ public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException {
628634 * <p>This method may be called from any thread, but the returned
629635 * {@link AccountManagerFuture} must not be used on the main thread.
630636 *
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.
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.
634641 *
635642 * @param type The type of accounts to return, must not be null
636643 * @param features An array of the account features to require,
@@ -701,7 +708,7 @@ public boolean addAccountExplicitly(Account account, String password, Bundle use
701708 try {
702709 return mService .addAccountExplicitly (account , password , userdata );
703710 } catch (RemoteException e ) {
704- // won't ever happen
711+ // Can happen if there was a SecurityException was thrown.
705712 throw new RuntimeException (e );
706713 }
707714 }
@@ -966,7 +973,7 @@ public boolean removeAccountExplicitly(Account account) {
966973 try {
967974 return mService .removeAccountExplicitly (account );
968975 } catch (RemoteException e ) {
969- // won 't ever happen
976+ // May happen if the caller doesn 't match the signature of the authenticator.
970977 throw new RuntimeException (e );
971978 }
972979 }
@@ -1114,7 +1121,7 @@ public void setUserData(final Account account, final String key, final String va
11141121 try {
11151122 mService .setUserData (account , key , value );
11161123 } catch (RemoteException e ) {
1117- // won't ever happen
1124+ // Will happen if there is not signature match.
11181125 throw new RuntimeException (e );
11191126 }
11201127 }
@@ -1733,7 +1740,7 @@ public void doWork() throws RemoteException {
17331740 * with these fields if an activity was supplied and the account
17341741 * credentials were successfully updated:
17351742 * <ul>
1736- * <li> {@link #KEY_ACCOUNT_NAME} - the name of the account created
1743+ * <li> {@link #KEY_ACCOUNT_NAME} - the name of the account
17371744 * <li> {@link #KEY_ACCOUNT_TYPE} - the type of the account
17381745 * </ul>
17391746 *
@@ -2501,10 +2508,12 @@ public void onReceive(final Context context, final Intent intent) {
25012508 * listeners are added in an Activity or Service's {@link Activity#onCreate}
25022509 * and removed in {@link Activity#onDestroy}.
25032510 *
2504- * <p>It is safe to call this method from the main thread.
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.
25052515 *
2506- * <p>This method requires the caller to hold the permission
2507- * {@link android.Manifest.permission#GET_ACCOUNTS}.
2516+ * <p>It is safe to call this method from the main thread.
25082517 *
25092518 * @param listener The listener to send notifications to
25102519 * @param handler {@link Handler} identifying the thread to use
0 commit comments