@@ -528,7 +528,7 @@ public Map<Account, Integer> getAccountsAndVisibilityForPackage(String packageNa
528528 private Map <Account , Integer > getAccountsAndVisibilityForPackage (String packageName ,
529529 List <String > accountTypes , Integer callingUid , UserAccounts accounts ) {
530530 if (!packageExistsForUser (packageName , accounts .userId )) {
531- Log .d (TAG , "Package not found " + packageName );
531+ Log .w (TAG , "getAccountsAndVisibilityForPackage# Package not found " + packageName );
532532 return new LinkedHashMap <>();
533533 }
534534
@@ -677,7 +677,7 @@ private Integer resolveAccountVisibility(Account account, @NonNull String packag
677677 restoreCallingIdentity (identityToken );
678678 }
679679 } catch (NameNotFoundException e ) {
680- Log .d (TAG , "Package not found " + e .getMessage ());
680+ Log .w (TAG , "resolveAccountVisibility# Package not found " + e .getMessage ());
681681 return AccountManager .VISIBILITY_NOT_VISIBLE ;
682682 }
683683
@@ -756,7 +756,7 @@ private boolean isPreOApplication(String packageName) {
756756 }
757757 return true ;
758758 } catch (NameNotFoundException e ) {
759- Log .d (TAG , "Package not found " + e .getMessage ());
759+ Log .w (TAG , "isPreOApplication# Package not found " + e .getMessage ());
760760 return true ;
761761 }
762762 }
@@ -4063,7 +4063,7 @@ public boolean hasAccountAccess(@NonNull Account account, @NonNull String packa
40634063 int uid = mPackageManager .getPackageUidAsUser (packageName , userId );
40644064 return hasAccountAccess (account , packageName , uid );
40654065 } catch (NameNotFoundException e ) {
4066- Log .d (TAG , "Package not found " + e .getMessage ());
4066+ Log .w (TAG , "hasAccountAccess# Package not found " + e .getMessage ());
40674067 return false ;
40684068 }
40694069 }
@@ -4195,7 +4195,7 @@ public boolean someUserHasAccount(@NonNull final Account account) {
41954195 }
41964196 final long token = Binder .clearCallingIdentity ();
41974197 try {
4198- AccountAndUser [] allAccounts = getAllAccounts ();
4198+ AccountAndUser [] allAccounts = getAllAccountsForSystemProcess ();
41994199 for (int i = allAccounts .length - 1 ; i >= 0 ; i --) {
42004200 if (allAccounts [i ].account .equals (account )) {
42014201 return true ;
@@ -4345,37 +4345,46 @@ public Account[] getAccounts(int userId, String opPackageName) {
43454345 /**
43464346 * Returns accounts for all running users, ignores visibility values.
43474347 *
4348+ * Should only be called by System process.
43484349 * @hide
43494350 */
43504351 @ NonNull
4351- public AccountAndUser [] getRunningAccounts () {
4352+ public AccountAndUser [] getRunningAccountsForSystem () {
43524353 final int [] runningUserIds ;
43534354 try {
43544355 runningUserIds = ActivityManager .getService ().getRunningUserIds ();
43554356 } catch (RemoteException e ) {
43564357 // Running in system_server; should never happen
43574358 throw new RuntimeException (e );
43584359 }
4359- return getAccounts (runningUserIds );
4360+ return getAccountsForSystem (runningUserIds );
43604361 }
43614362
43624363 /**
43634364 * Returns accounts for all users, ignores visibility values.
43644365 *
4366+ * Should only be called by system process
4367+ *
43654368 * @hide
43664369 */
43674370 @ NonNull
4368- public AccountAndUser [] getAllAccounts () {
4371+ public AccountAndUser [] getAllAccountsForSystemProcess () {
43694372 final List <UserInfo > users = getUserManager ().getAliveUsers ();
43704373 final int [] userIds = new int [users .size ()];
43714374 for (int i = 0 ; i < userIds .length ; i ++) {
43724375 userIds [i ] = users .get (i ).id ;
43734376 }
4374- return getAccounts (userIds );
4377+ return getAccountsForSystem (userIds );
43754378 }
43764379
4380+ /**
4381+ * Returns all accounts for the given user, ignores all visibility checks.
4382+ * This should only be called by system process.
4383+ *
4384+ * @hide
4385+ */
43774386 @ NonNull
4378- private AccountAndUser [] getAccounts (int [] userIds ) {
4387+ private AccountAndUser [] getAccountsForSystem (int [] userIds ) {
43794388 final ArrayList <AccountAndUser > runningAccounts = Lists .newArrayList ();
43804389 for (int userId : userIds ) {
43814390 UserAccounts userAccounts = getUserAccounts (userId );
@@ -4384,7 +4393,7 @@ private AccountAndUser[] getAccounts(int[] userIds) {
43844393 userAccounts ,
43854394 null /* type */ ,
43864395 Binder .getCallingUid (),
4387- null /* packageName */ ,
4396+ "android" /* packageName */ ,
43884397 false /* include managed not visible*/ );
43894398 for (Account account : accounts ) {
43904399 runningAccounts .add (new AccountAndUser (account , userId ));
@@ -5355,7 +5364,7 @@ private void dumpUser(UserAccounts userAccounts, FileDescriptor fd, PrintWriter
53555364 }
53565365 } else {
53575366 Account [] accounts = getAccountsFromCache (userAccounts , null /* type */ ,
5358- Process .SYSTEM_UID , null /* packageName */ , false );
5367+ Process .SYSTEM_UID , "android" /* packageName */ , false );
53595368 fout .println ("Accounts: " + accounts .length );
53605369 for (Account account : accounts ) {
53615370 fout .println (" " + account .toString ());
@@ -5550,7 +5559,7 @@ private boolean isPrivileged(int callingUid) {
55505559 return true ;
55515560 }
55525561 } catch (PackageManager .NameNotFoundException e ) {
5553- Log .d (TAG , "Package not found " + e .getMessage ());
5562+ Log .w (TAG , "isPrivileged# Package not found " + e .getMessage ());
55545563 }
55555564 }
55565565 } finally {
@@ -6074,7 +6083,7 @@ private Map<Account, Integer> filterSharedAccounts(UserAccounts userAccounts,
60746083 }
60756084 }
60766085 } catch (NameNotFoundException e ) {
6077- Log .d (TAG , "Package not found " + e .getMessage ());
6086+ Log .w (TAG , "filterSharedAccounts# Package not found " + e .getMessage ());
60786087 }
60796088 Map <Account , Integer > filtered = new LinkedHashMap <>();
60806089 for (Map .Entry <Account , Integer > entry : unfiltered .entrySet ()) {
0 commit comments