Loading core/java/android/app/admin/DeviceAdminInfo.java +28 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.admin.flags.Flags.FLAG_HEADLESS_DEVICE_OWNER_SINGLE_US import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.app.admin.flags.Flags; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -176,6 +177,10 @@ public final class DeviceAdminInfo implements Parcelable { * provisioned into "affiliated" mode when on a Headless System User Mode device. * * <p>This mode adds a Profile Owner to all users other than the user the Device Owner is on. * * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM}, * DPCs should set the value of attribute "headless-device-owner-mode" inside the * "headless-system-user" tag as "affiliated". */ public static final int HEADLESS_DEVICE_OWNER_MODE_AFFILIATED = 1; Loading @@ -185,6 +190,10 @@ public final class DeviceAdminInfo implements Parcelable { * * <p>This mode only allows a single secondary user on the device blocking the creation of * additional secondary users. * * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM}, * DPCs should set the value of attribute "headless-device-owner-mode" inside the * "headless-system-user" tag as "single_user". */ @FlaggedApi(FLAG_HEADLESS_DEVICE_OWNER_SINGLE_USER_ENABLED) public static final int HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER = 2; Loading Loading @@ -383,17 +392,30 @@ public final class DeviceAdminInfo implements Parcelable { } mSupportsTransferOwnership = true; } else if (tagName.equals("headless-system-user")) { String deviceOwnerModeStringValue = String deviceOwnerModeStringValue = null; if (Flags.headlessSingleUserCompatibilityFix()) { deviceOwnerModeStringValue = parser.getAttributeValue( null, "headless-device-owner-mode"); } if (deviceOwnerModeStringValue == null) { deviceOwnerModeStringValue = parser.getAttributeValue(null, "device-owner-mode"); } if (deviceOwnerModeStringValue.equalsIgnoreCase("unsupported")) { if ("unsupported".equalsIgnoreCase(deviceOwnerModeStringValue)) { mHeadlessDeviceOwnerMode = HEADLESS_DEVICE_OWNER_MODE_UNSUPPORTED; } else if (deviceOwnerModeStringValue.equalsIgnoreCase("affiliated")) { } else if ("affiliated".equalsIgnoreCase(deviceOwnerModeStringValue)) { mHeadlessDeviceOwnerMode = HEADLESS_DEVICE_OWNER_MODE_AFFILIATED; } else if (deviceOwnerModeStringValue.equalsIgnoreCase("single_user")) { } else if ("single_user".equalsIgnoreCase(deviceOwnerModeStringValue)) { mHeadlessDeviceOwnerMode = HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER; } else { throw new XmlPullParserException("headless-system-user mode must be valid"); if (Flags.headlessSingleUserCompatibilityFix()) { Log.e(TAG, "Unknown headless-system-user mode: " + deviceOwnerModeStringValue); } else { throw new XmlPullParserException( "headless-system-user mode must be valid"); } } } } Loading core/java/android/app/admin/flags/flags.aconfig +20 −0 Original line number Diff line number Diff line Loading @@ -313,3 +313,23 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "headless_single_user_compatibility_fix" namespace: "enterprise" description: "Fix for compatibility issue introduced from using single_user mode on pre-Android V builds" bug: "338050276" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "headless_single_min_target_sdk" namespace: "enterprise" description: "Only allow DPCs targeting Android V to provision into single user mode" bug: "338588825" metadata { purpose: PURPOSE_BUGFIX } } services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +6 −3 Original line number Diff line number Diff line Loading @@ -21605,9 +21605,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { == HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER; } if (Flags.headlessSingleUserFixes() && mInjector.userManagerIsHeadlessSystemUserMode() && isSingleUserMode && !mInjector.isChangeEnabled( PROVISION_SINGLE_USER_MODE, deviceAdmin.getPackageName(), caller.getUserId())) { if (Flags.headlessSingleMinTargetSdk() && mInjector.userManagerIsHeadlessSystemUserMode() && isSingleUserMode && !mInjector.isChangeEnabled( PROVISION_SINGLE_USER_MODE, deviceAdmin.getPackageName(), caller.getUserId())) { throw new IllegalStateException("Device admin is not targeting Android V."); } Loading
core/java/android/app/admin/DeviceAdminInfo.java +28 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.admin.flags.Flags.FLAG_HEADLESS_DEVICE_OWNER_SINGLE_US import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.app.admin.flags.Flags; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -176,6 +177,10 @@ public final class DeviceAdminInfo implements Parcelable { * provisioned into "affiliated" mode when on a Headless System User Mode device. * * <p>This mode adds a Profile Owner to all users other than the user the Device Owner is on. * * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM}, * DPCs should set the value of attribute "headless-device-owner-mode" inside the * "headless-system-user" tag as "affiliated". */ public static final int HEADLESS_DEVICE_OWNER_MODE_AFFILIATED = 1; Loading @@ -185,6 +190,10 @@ public final class DeviceAdminInfo implements Parcelable { * * <p>This mode only allows a single secondary user on the device blocking the creation of * additional secondary users. * * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM}, * DPCs should set the value of attribute "headless-device-owner-mode" inside the * "headless-system-user" tag as "single_user". */ @FlaggedApi(FLAG_HEADLESS_DEVICE_OWNER_SINGLE_USER_ENABLED) public static final int HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER = 2; Loading Loading @@ -383,17 +392,30 @@ public final class DeviceAdminInfo implements Parcelable { } mSupportsTransferOwnership = true; } else if (tagName.equals("headless-system-user")) { String deviceOwnerModeStringValue = String deviceOwnerModeStringValue = null; if (Flags.headlessSingleUserCompatibilityFix()) { deviceOwnerModeStringValue = parser.getAttributeValue( null, "headless-device-owner-mode"); } if (deviceOwnerModeStringValue == null) { deviceOwnerModeStringValue = parser.getAttributeValue(null, "device-owner-mode"); } if (deviceOwnerModeStringValue.equalsIgnoreCase("unsupported")) { if ("unsupported".equalsIgnoreCase(deviceOwnerModeStringValue)) { mHeadlessDeviceOwnerMode = HEADLESS_DEVICE_OWNER_MODE_UNSUPPORTED; } else if (deviceOwnerModeStringValue.equalsIgnoreCase("affiliated")) { } else if ("affiliated".equalsIgnoreCase(deviceOwnerModeStringValue)) { mHeadlessDeviceOwnerMode = HEADLESS_DEVICE_OWNER_MODE_AFFILIATED; } else if (deviceOwnerModeStringValue.equalsIgnoreCase("single_user")) { } else if ("single_user".equalsIgnoreCase(deviceOwnerModeStringValue)) { mHeadlessDeviceOwnerMode = HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER; } else { throw new XmlPullParserException("headless-system-user mode must be valid"); if (Flags.headlessSingleUserCompatibilityFix()) { Log.e(TAG, "Unknown headless-system-user mode: " + deviceOwnerModeStringValue); } else { throw new XmlPullParserException( "headless-system-user mode must be valid"); } } } } Loading
core/java/android/app/admin/flags/flags.aconfig +20 −0 Original line number Diff line number Diff line Loading @@ -313,3 +313,23 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "headless_single_user_compatibility_fix" namespace: "enterprise" description: "Fix for compatibility issue introduced from using single_user mode on pre-Android V builds" bug: "338050276" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "headless_single_min_target_sdk" namespace: "enterprise" description: "Only allow DPCs targeting Android V to provision into single user mode" bug: "338588825" metadata { purpose: PURPOSE_BUGFIX } }
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +6 −3 Original line number Diff line number Diff line Loading @@ -21605,9 +21605,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { == HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER; } if (Flags.headlessSingleUserFixes() && mInjector.userManagerIsHeadlessSystemUserMode() && isSingleUserMode && !mInjector.isChangeEnabled( PROVISION_SINGLE_USER_MODE, deviceAdmin.getPackageName(), caller.getUserId())) { if (Flags.headlessSingleMinTargetSdk() && mInjector.userManagerIsHeadlessSystemUserMode() && isSingleUserMode && !mInjector.isChangeEnabled( PROVISION_SINGLE_USER_MODE, deviceAdmin.getPackageName(), caller.getUserId())) { throw new IllegalStateException("Device admin is not targeting Android V."); }