From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Pratyush <codelab@pratyush.dev>
Date: Fri, 15 Oct 2021 08:55:52 +0530
Subject: [PATCH] ui fix for special runtime permission

Toggles were not working correctly for API < 23.
---
 .../permissioncontroller/permission/utils/KotlinUtils.kt        | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PermissionController/src/com/android/permissioncontroller/permission/utils/KotlinUtils.kt b/PermissionController/src/com/android/permissioncontroller/permission/utils/KotlinUtils.kt
index da93d4f78..96f6e356f 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/utils/KotlinUtils.kt
+++ b/PermissionController/src/com/android/permissioncontroller/permission/utils/KotlinUtils.kt
@@ -547,6 +547,7 @@ object KotlinUtils {
         val pkgInfo = group.packageInfo
         val user = UserHandle.getUserHandleForUid(pkgInfo.uid)
         val supportsRuntime = pkgInfo.targetSdkVersion >= Build.VERSION_CODES.M
+                || Utils.isSpecialRuntimePermission(perm.name)
         val isGrantingAllowed = (!pkgInfo.isInstantApp || perm.isInstantPerm) &&
             (supportsRuntime || !perm.isRuntimeOnly)
         // Do not touch permissions fixed by the system, or permissions that cannot be granted
@@ -776,6 +777,7 @@ object KotlinUtils {
         var newFlags = perm.flags
         var isGranted = perm.isGrantedIncludingAppOp
         val supportsRuntime = group.packageInfo.targetSdkVersion >= Build.VERSION_CODES.M
+                || Utils.isSpecialRuntimePermission(perm.name)
         var shouldKill = false
 
         val affectsAppOp = permissionToOp(perm.name) != null || perm.isBackgroundPermission
