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

Commit 92661d78 authored by Elis Elliott's avatar Elis Elliott
Browse files

Revert^2 "Introduce a new headless-user-mode attribute"

6953b903

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
     name: "device_policy_exported_aconfig_flags_lib",
> -    aconfig_declarations: "device_policy_aconfig_flags",
> -    defaults: ["framework-minus-apex-aconfig-java-defaults"],
> -    mode: "exported",
> -}
> -
> -java_aconfig_library {
> --- core/java/android/app/admin/flags/flags.aconfig
> +++ core/java/android/app/admin/flags/flags.aconfig
> -    is_exported: true

Original patch:
 diff --git a/AconfigFlags.bp b/AconfigFlags.bp
old mode 100644
new mode 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -1030,18 +1030,10 @@
     name: "device_policy_aconfig_flags",
     package: "android.app.admin.flags",
     container: "system",
-    exportable: true,
     srcs: [
         "core/java/android/app/admin/flags/flags.aconfig",
     ],
 }
-
-java_aconfig_library {
-    name: "device_policy_exported_aconfig_flags_lib",
-    aconfig_declarations: "device_policy_aconfig_flags",
-    defaults: ["framework-minus-apex-aconfig-java-defaults"],
-    mode: "exported",
-}
 
 java_aconfig_library {
     name: "device_policy_aconfig_flags_lib",
diff --git a/core/java/android/app/admin/flags/flags.aconfig b/core/java/android/app/admin/flags/flags.aconfig
old mode 100644
new mode 100644
--- a/core/java/android/app/admin/flags/flags.aconfig
+++ b/core/java/android/app/admin/flags/flags.aconfig
@@ -309,7 +309,6 @@
     namespace: "enterprise"
     description: "Fix for compatibility issue introduced fro
[[[Original patch trimmed due to size. Decoded string size: 1172. Decoded string SHA1: 261aeabafee16b48f9e43ce21ee28f4be6436f2c.]]]

Result patch:
 diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index b650c1c..a42adad 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -1030,20 +1030,12 @@
     name: "device_policy_aconfig_flags",
     package: "android.app.admin.flags",
     container: "system",
-    exportable: true,
     srcs: [
         "core/java/android/app/admin/flags/flags.aconfig",
     ],
 }
 
 java_aconfig_library {
-    name: "device_policy_exported_aconfig_flags_lib",
-    aconfig_declarations: "device_policy_aconfig_flags",
-    defaults: ["framework-minus-apex-aconfig-java-defaults"],
-    mode: "exported",
-}
-
-java_aconfig_library {
     name: "device_policy_aconfig_flags_lib",
     aconfig_declarations: "device_policy_aconfig_flags",
     defaults: ["framework-minus-apex-aconfig-java-defaults"],
diff --git a/core/java/android/app/admin/flags/flags.aconfig b/core/java/android/app/admin/flags/flags.aconfig
index 83daa45..93576aef 100644
--- a/core/java/android/app/admin/flags/flags.aconfig
+++ b/core/java/android/app/admin/flags/flags.
[[[Result patch trimmed due to size. Decoded string size: 1291. Decoded string SHA1: 53d6d985ceac329174f1319fbf43613934767e4a.]]]

Change-Id: I854c4eefd0f43bbdcf4d862080277e12dba9602e
parent 6953b903
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -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;
@@ -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;

@@ -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;
@@ -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");
                        }
                    }
                }
            }
+20 −0
Original line number Diff line number Diff line
@@ -303,3 +303,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
    }
}
+6 −3
Original line number Diff line number Diff line
@@ -21610,9 +21610,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.");
            }