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

Commit cfba5937 authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Automerger Merge Worker
Browse files

Merge "Persist bypassDevicePolicyMmanagementRoleQualification in global...

Merge "Persist bypassDevicePolicyMmanagementRoleQualification in global setting" into tm-dev am: bc161600

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17384583



Change-Id: I2561cae5f147b866fdf1458794f84bbd836b19d6
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 506646c2 bc161600
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -11474,6 +11474,15 @@ public final class Settings {
        @Readable
        @Readable
        public static final String DEVICE_PROVISIONED = "device_provisioned";
        public static final String DEVICE_PROVISIONED = "device_provisioned";
        /**
         * Whether bypassing the device policy management role holder qualifcation is allowed,
         * (0 = false, 1 = true).
         *
         * @hide
         */
        public static final String BYPASS_DEVICE_POLICY_MANAGEMENT_ROLE_QUALIFICATIONS =
                "bypass_device_policy_management_role_qualifications";
        /**
        /**
         * Indicates whether mobile data should be allowed while the device is being provisioned.
         * Indicates whether mobile data should be allowed while the device is being provisioned.
         * This allows the provisioning process to turn off mobile data before the user
         * This allows the provisioning process to turn off mobile data before the user
+1 −0
Original line number Original line Diff line number Diff line
@@ -236,6 +236,7 @@ public class SettingsBackupTest {
                    Settings.Global.DEVICE_NAME,
                    Settings.Global.DEVICE_NAME,
                    Settings.Global.DEVICE_POLICY_CONSTANTS,
                    Settings.Global.DEVICE_POLICY_CONSTANTS,
                    Settings.Global.DEVICE_PROVISIONED,
                    Settings.Global.DEVICE_PROVISIONED,
                    Settings.Global.BYPASS_DEVICE_POLICY_MANAGEMENT_ROLE_QUALIFICATIONS,
                    Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED,
                    Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED,
                    Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD,
                    Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD,
                    Settings.Global.DISPLAY_PANEL_LPM,
                    Settings.Global.DISPLAY_PANEL_LPM,
+19 −5
Original line number Original line Diff line number Diff line
@@ -136,6 +136,7 @@ import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_DEFAULT
import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE;
import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE;
import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK;
import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK;
import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK;
import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK;
import static android.provider.Settings.Global.BYPASS_DEVICE_POLICY_MANAGEMENT_ROLE_QUALIFICATIONS;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
import static android.provider.Settings.Secure.MANAGED_PROVISIONING_DPC_DOWNLOADED;
import static android.provider.Settings.Secure.MANAGED_PROVISIONING_DPC_DOWNLOADED;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
@@ -18782,13 +18783,26 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        Preconditions.checkCallAuthorization(hasCallingOrSelfPermission(
        Preconditions.checkCallAuthorization(hasCallingOrSelfPermission(
                android.Manifest.permission.MANAGE_ROLE_HOLDERS));
                android.Manifest.permission.MANAGE_ROLE_HOLDERS));
        return mInjector.binderWithCleanCallingIdentity(() -> {
        return mInjector.binderWithCleanCallingIdentity(() -> {
            if (mInjector.settingsGlobalGetInt(
                    BYPASS_DEVICE_POLICY_MANAGEMENT_ROLE_QUALIFICATIONS, /* def= */ 0) == 1) {
                return true;
            }
            if (shouldAllowBypassingDevicePolicyManagementRoleQualificationInternal()) {
                mInjector.settingsGlobalPutInt(
                        BYPASS_DEVICE_POLICY_MANAGEMENT_ROLE_QUALIFICATIONS, /* value= */ 1);
                return true;
            }
            return false;
        });
    }
    private boolean shouldAllowBypassingDevicePolicyManagementRoleQualificationInternal() {
        if (mUserManager.getUserCount() > 1) {
        if (mUserManager.getUserCount() > 1) {
            return false;
            return false;
        }
        }
        AccountManager am = AccountManager.get(mContext);
        AccountManager am = AccountManager.get(mContext);
        Account[] accounts = am.getAccounts();
        Account[] accounts = am.getAccounts();
        return accounts.length == 0;
        return accounts.length == 0;
        });
    }
    }
    @Override
    @Override