Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a34c3d40 authored by Felipe Leme's avatar Felipe Leme
Browse files

Log userId on DPMS.hasAccountFeatures() failure.

Test: manual verification
Bug: 417943524
Flag: EXEMPT logging only

Change-Id: I25695cfee07a98d596138e298c14497e689df41b
parent 6fe1f853
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -18876,16 +18876,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            return results;
            return results;
        }
        }
        private boolean userHasIncompatibleAccounts(int id) {
        private boolean userHasIncompatibleAccounts(@UserIdInt int userId) {
            AccountManager am = mContext.createContextAsUser(UserHandle.of(id), /* flags= */ 0)
            AccountManager am = mContext.createContextAsUser(UserHandle.of(userId), /* flags= */ 0)
                    .getSystemService(AccountManager.class);
                    .getSystemService(AccountManager.class);
            Account[] accounts = am.getAccounts();
            Account[] accounts = am.getAccounts();
            for (Account account : accounts) {
            for (Account account : accounts) {
                if (hasAccountFeatures(am, account, FEATURE_DISALLOW)) {
                if (hasAccountFeatures(userId, am, account, FEATURE_DISALLOW)) {
                    return true;
                    return true;
                }
                }
                if (!hasAccountFeatures(am, account, FEATURE_ALLOW)) {
                if (!hasAccountFeatures(userId, am, account, FEATURE_ALLOW)) {
                    return true;
                    return true;
                }
                }
            }
            }
@@ -18900,13 +18900,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            Slogf.i(LOG_TAG, "Finished calculating hasIncompatibleAccountsTask");
            Slogf.i(LOG_TAG, "Finished calculating hasIncompatibleAccountsTask");
        }
        }
        private static boolean hasAccountFeatures(AccountManager am, Account account,
        private static boolean hasAccountFeatures(@UserIdInt int userId, AccountManager am,
                String[] features) {
                Account account, String[] features) {
            try {
            try {
                return am.hasFeatures(account, features, null, null)
                return am.hasFeatures(account, features, /* callback= */ null, /* handler= */ null)
                        .getResult(30, TimeUnit.SECONDS);
                        .getResult(30, TimeUnit.SECONDS);
            } catch (Exception e) {
            } catch (Exception e) {
                Slogf.w(LOG_TAG, "Failed to get account feature", e);
                Slogf.w(LOG_TAG, e, "Failed to get account feature for user %d", userId);
                return false;
                return false;
            }
            }
        }
        }