diff options
2 files changed, 20 insertions, 7 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 2be2bb968fb6..438a9d6753b6 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -680,7 +680,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // to decide whether an existing policy in the {@link #DEVICE_POLICIES_XML} needs to // be upgraded. See {@link PolicyVersionUpgrader} on instructions how to add an upgrade // step. - static final int DPMS_VERSION = 5; + static final int DPMS_VERSION = 6; static { SECURE_SETTINGS_ALLOWLIST = new ArraySet<>(); @@ -876,8 +876,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { private static final boolean DEFAULT_ENABLE_DEVICE_POLICY_ENGINE_FOR_FINANCE_FLAG = true; // TODO(b/265683382) remove the flag after rollout. - private static final String KEEP_PROFILES_RUNNING_FLAG = "enable_keep_profiles_running"; - public static final boolean DEFAULT_KEEP_PROFILES_RUNNING_FLAG = true; + public static final boolean DEFAULT_KEEP_PROFILES_RUNNING_FLAG = false; // TODO(b/261999445) remove the flag after rollout. private static final String HEADLESS_FLAG = "headless"; @@ -23011,10 +23010,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } private static boolean isKeepProfilesRunningFlagEnabled() { - return DeviceConfig.getBoolean( - NAMESPACE_DEVICE_POLICY_MANAGER, - KEEP_PROFILES_RUNNING_FLAG, - DEFAULT_KEEP_PROFILES_RUNNING_FLAG); + return DEFAULT_KEEP_PROFILES_RUNNING_FLAG; } private boolean isUnicornFlagEnabled() { diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java index 733b1d98f3e2..f060426ec827 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/PolicyVersionUpgrader.java @@ -117,6 +117,19 @@ public class PolicyVersionUpgrader { currentVersion = 5; } + if (currentVersion == 5) { + Slog.i(LOG_TAG, String.format("Upgrading from version %d", currentVersion)); + // No-op upgrade here: + // DevicePolicyData.mEffectiveKeepProfilesRunning is only stored in XML file when it is + // different from its default value, otherwise the tag is not written. When loading, if + // the tag is missing, the field retains the value previously assigned in the + // constructor, which is the default value. + // In version 5 the default value was 'true', in version 6 it is 'false', so when + // loading XML version 5 we need to initialize the field to 'true' for it to be restored + // correctly in case the tag is missing. This is done in loadDataForUser(). + currentVersion = 6; + } + writePoliciesAndVersion(allUsers, allUsersData, ownersData, currentVersion); } @@ -282,6 +295,10 @@ public class PolicyVersionUpgrader { private DevicePolicyData loadDataForUser( int userId, int loadVersion, ComponentName ownerComponent) { DevicePolicyData policy = new DevicePolicyData(userId); + // See version 5 -> 6 step in upgradePolicy() + if (loadVersion == 5 && userId == UserHandle.USER_SYSTEM) { + policy.mEffectiveKeepProfilesRunning = true; + } DevicePolicyData.load(policy, mProvider.makeDevicePoliciesJournaledFile(userId), mProvider.getAdminInfoSupplier(userId), |