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

Commit aca2594a authored by Yvonne Jiang's avatar Yvonne Jiang Committed by Android (Google) Code Review
Browse files

Merge "Add new DevicePolicyConstant for indicating that the testOnly admin...

Merge "Add new DevicePolicyConstant for indicating that the testOnly admin should be used as the supervision component." into sc-dev
parents 07033a21 f0bdeb32
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -48,6 +48,11 @@ public class DevicePolicyConstants {
    private static final String BATTERY_THRESHOLD_CHARGING_KEY =
            "battery_threshold_charging";

    // TODO(b/182994391): Replace with more generic solution to override the supervision
    // component.
    private static final String USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT_KEY =
            "use_test_admin_as_supervision_component";

    /**
     * The back-off before re-connecting, when a service binding died, due to the owner
     * crashing repeatedly.
@@ -79,6 +84,12 @@ public class DevicePolicyConstants {
     */
    public final int BATTERY_THRESHOLD_CHARGING;

    /**
     * Whether to default to considering the current DO/PO as the supervision component
     * if they are a testOnly admin.
     */
    public final boolean USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT;


    private DevicePolicyConstants(String settings) {

@@ -110,6 +121,9 @@ public class DevicePolicyConstants {
        int batteryThresholdCharging = parser.getInt(
                BATTERY_THRESHOLD_CHARGING_KEY, 20);

        boolean useTestAdminAsSupervisionComponent = parser.getBoolean(
                USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT_KEY, false);

        // Set minimum: 5 seconds.
        dasDiedServiceReconnectBackoffSec = Math.max(5, dasDiedServiceReconnectBackoffSec);

@@ -128,6 +142,7 @@ public class DevicePolicyConstants {
                dasDiedServiceStableConnectionThresholdSec;
        BATTERY_THRESHOLD_NOT_CHARGING = batteryThresholdNotCharging;
        BATTERY_THRESHOLD_CHARGING = batteryThresholdCharging;
        USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT = useTestAdminAsSupervisionComponent;
    }

    public static DevicePolicyConstants loadFromString(String settings) {
+9 −5
Original line number Diff line number Diff line
@@ -8799,12 +8799,16 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            final ComponentName doComponent = mOwners.getDeviceOwnerComponent();
            final ComponentName poComponent =
                    mOwners.getProfileOwnerComponent(userHandle.getIdentifier());
            // Return test only admin by default.
            // Return test only admin if configured to do so.
            // TODO(b/182994391): Replace with more generic solution to override the supervision
            // component.
            if (mConstants.USE_TEST_ADMIN_AS_SUPERVISION_COMPONENT) {
                if (isAdminTestOnlyLocked(doComponent, userHandle.getIdentifier())) {
                    return doComponent;
                } else if (isAdminTestOnlyLocked(poComponent, userHandle.getIdentifier())) {
                    return poComponent;
                }
            }
            final String supervisor = mContext.getResources().getString(
                    com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
            if (supervisor == null) {