summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyConstants.java15
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java14
2 files changed, 24 insertions, 5 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyConstants.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyConstants.java
index 464d6f5ea835..37983349be2f 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyConstants.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyConstants.java
@@ -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) {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 7260732bbcb6..bbcb538d381a 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -8689,11 +8689,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
final ComponentName doComponent = mOwners.getDeviceOwnerComponent();
final ComponentName poComponent =
mOwners.getProfileOwnerComponent(userHandle.getIdentifier());
- // Return test only admin by default.
- if (isAdminTestOnlyLocked(doComponent, userHandle.getIdentifier())) {
- return doComponent;
- } else if (isAdminTestOnlyLocked(poComponent, userHandle.getIdentifier())) {
- return poComponent;
+ // 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);