summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jason Parks <jparks@google.com> 2025-03-24 07:14:09 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-24 07:14:09 -0700
commitb9be1d9650d4e7f308d591a9521b2e2cc5784c06 (patch)
treee08b7ce8a9ff057c89bc78a21d0efd88c9ba5a6c
parent2a76c9bb58373b806633942d8fd62c9c3da7e604 (diff)
parent6a84225de0137c69bd75cd3c1ec8e5438988ae89 (diff)
Merge "Allow the SYSTEM_SUPERVISION role to be set for CTS" into main
-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();
+ }
+}