summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jason Parks <jparks@google.com> 2025-03-05 14:49:07 -0600
committer Jason Parks <jparks@google.com> 2025-03-21 14:29:56 -0700
commit6a84225de0137c69bd75cd3c1ec8e5438988ae89 (patch)
tree562407e3a2b6844c8123d7fcc93f0cd7e9aebb02
parent8357002922ece75f74a734310844ee439f2b0d7c (diff)
Allow the SYSTEM_SUPERVISION role to be set for CTS
Bug: 378102594 Flag: android.app.supervision.flags.supervision_manager_apis Test: atest CtsSupervisionTestCases Relnote: N/A Change-Id: Iec86b5423299ae0d43d5e40ff5184ede0a8095b6
-rw-r--r--PermissionController/res/xml/roles.xml1
-rw-r--r--PermissionController/role-controller/java/com/android/role/controller/behavior/v33/SystemSupervisionRoleBehavior.java49
2 files changed, 50 insertions, 0 deletions
diff --git a/PermissionController/res/xml/roles.xml b/PermissionController/res/xml/roles.xml
index ae8adc5ab..1339152d7 100644
--- a/PermissionController/res/xml/roles.xml
+++ b/PermissionController/res/xml/roles.xml
@@ -1328,6 +1328,7 @@
<role
name="android.app.role.SYSTEM_SUPERVISION"
+ behavior="v33.SystemSupervisionRoleBehavior"
defaultHolders="config_systemSupervision"
exclusive="true"
exclusivity="user"
diff --git a/PermissionController/role-controller/java/com/android/role/controller/behavior/v33/SystemSupervisionRoleBehavior.java b/PermissionController/role-controller/java/com/android/role/controller/behavior/v33/SystemSupervisionRoleBehavior.java
new file mode 100644
index 000000000..e747897f1
--- /dev/null
+++ b/PermissionController/role-controller/java/com/android/role/controller/behavior/v33/SystemSupervisionRoleBehavior.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.role.controller.behavior.v33;
+
+import android.app.supervision.SupervisionManager;
+import android.content.Context;
+import android.os.Build;
+import android.permission.flags.Flags;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+
+
+import com.android.modules.utils.build.SdkLevel;
+import com.android.role.controller.model.Role;
+import com.android.role.controller.model.RoleBehavior;
+
+/**
+ * Class for behavior of the system supervision role.
+*/
+@RequiresApi(Build.VERSION_CODES.TIRAMISU)
+public class SystemSupervisionRoleBehavior implements RoleBehavior {
+
+ @Override
+ @Nullable
+ public Boolean shouldAllowBypassingQualification(@NonNull Role role, @NonNull Context context) {
+ if (!SdkLevel.isAtLeastB() || !Flags.enableSystemSupervisionRoleBehavior()) {
+ return false;
+ }
+
+ SupervisionManager supervisionManager = context.getSystemService(SupervisionManager.class);
+ return supervisionManager.shouldAllowBypassingSupervisionRoleQualification();
+ }
+}