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

Commit f964610e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make roleholder override use same logic as DO setting."

parents 42b19dec 625f6e4a
Loading
Loading
Loading
Loading
+26 −19
Original line number Diff line number Diff line
@@ -15413,31 +15413,35 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                }
            }
            boolean compatible = !hasIncompatibleAccounts(am, accounts);
            if (compatible) {
                Slogf.w(LOG_TAG, "All accounts are compatible");
            } else {
                Slogf.e(LOG_TAG, "Found incompatible accounts");
            }
            return !compatible;
        });
    }
    private boolean hasIncompatibleAccounts(AccountManager am, Account[] accounts) {
        // TODO(b/244284408): Add test
        final String[] feature_allow =
                { DevicePolicyManager.ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED };
        final String[] feature_disallow =
                { DevicePolicyManager.ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_DISALLOWED };
            boolean compatible = true;
        for (Account account : accounts) {
            if (hasAccountFeatures(am, account, feature_disallow)) {
                Slogf.e(LOG_TAG, "%s has %s", account, feature_disallow[0]);
                    compatible = false;
                    break;
                return true;
            }
            if (!hasAccountFeatures(am, account, feature_allow)) {
                Slogf.e(LOG_TAG, "%s doesn't have %s", account, feature_allow[0]);
                    compatible = false;
                    break;
                }
                return true;
            }
            if (compatible) {
                Slogf.w(LOG_TAG, "All accounts are compatible");
            } else {
                Slogf.e(LOG_TAG, "Found incompatible accounts");
        }
            return !compatible;
        });
        return false;
    }
    private boolean hasAccountFeatures(AccountManager am, Account account, String[] features) {
@@ -18703,7 +18707,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        AccountManager am = AccountManager.get(mContext);
        Account[] accounts = am.getAccounts();
        return accounts.length == 0;
        if (accounts.length == 0) {
            return true;
        }
        return !hasIncompatibleAccounts(am, accounts);
    }
    private void setBypassDevicePolicyManagementRoleQualificationStateInternal(