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

Commit 625f6e4a authored by Jonathan Scott's avatar Jonathan Scott
Browse files

Make roleholder override use same logic as DO setting.

Test: Manual
Bug: 241871133
Change-Id: I183cef42162f38b45906fd31fd08f46904282244
parent 46b0e5ff
Loading
Loading
Loading
Loading
+26 −19
Original line number Diff line number Diff line
@@ -15409,31 +15409,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(