@@ -3,7 +3,6 @@ package io.github.sds100.keymapper.base.actions
33import android.content.pm.PackageManager
44import android.os.Build
55import androidx.annotation.DrawableRes
6- import androidx.annotation.RequiresApi
76import androidx.annotation.StringRes
87import androidx.compose.material.icons.Icons
98import androidx.compose.material.icons.automirrored.outlined.ArrowBack
@@ -96,8 +95,6 @@ import io.github.sds100.keymapper.system.permissions.Permission
9695
9796object ActionUtils {
9897
99- val isSystemBridgeSupported = Build .VERSION .SDK_INT >= Constants .SYSTEM_BRIDGE_MIN_API
100-
10198 @StringRes
10299 fun getCategoryLabel (category : ActionCategory ): Int = when (category) {
103100 ActionCategory .NAVIGATION -> R .string.action_cat_navigation
@@ -750,42 +747,44 @@ object ActionUtils {
750747 else -> emptyList()
751748 }
752749
753- @RequiresApi(Constants .SYSTEM_BRIDGE_MIN_API )
754750 fun isSystemBridgeRequired (id : ActionId ): Boolean {
751+ // Actions are only tested on Android 10 and higher.
755752 return when (id) {
756753 ActionId .ENABLE_WIFI ,
757754 ActionId .DISABLE_WIFI ,
758755 ActionId .TOGGLE_WIFI ,
759- -> true
756+ -> Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q
760757
761758 ActionId .TOGGLE_MOBILE_DATA ,
762759 ActionId .ENABLE_MOBILE_DATA ,
763760 ActionId .DISABLE_MOBILE_DATA ,
764- -> true
761+ -> Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q
765762
766763 ActionId .TOGGLE_HOTSPOT ,
767764 ActionId .ENABLE_HOTSPOT ,
768765 ActionId .DISABLE_HOTSPOT ,
769- -> true
766+ -> Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q
770767
771768 ActionId .ENABLE_NFC ,
772769 ActionId .DISABLE_NFC ,
773770 ActionId .TOGGLE_NFC ,
774- -> true
771+ -> Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q
775772
776773 ActionId .TOGGLE_AIRPLANE_MODE ,
777774 ActionId .ENABLE_AIRPLANE_MODE ,
778775 ActionId .DISABLE_AIRPLANE_MODE ,
779- -> true
776+ -> Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q
780777
781778 ActionId .TOGGLE_BLUETOOTH ,
782779 ActionId .ENABLE_BLUETOOTH ,
783780 ActionId .DISABLE_BLUETOOTH ,
784781 -> Build .VERSION .SDK_INT >= Build .VERSION_CODES .S_V2
785782
786- ActionId .POWER_ON_OFF_DEVICE -> true
783+ ActionId .POWER_ON_OFF_DEVICE -> Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q
787784
788- ActionId .FORCE_STOP_APP , ActionId .CLEAR_RECENT_APP -> true
785+ ActionId .FORCE_STOP_APP , ActionId .CLEAR_RECENT_APP ->
786+ Build .VERSION .SDK_INT >=
787+ Build .VERSION_CODES .Q
789788
790789 else -> false
791790 }
@@ -796,7 +795,7 @@ object ActionUtils {
796795 ActionId .TOGGLE_MOBILE_DATA ,
797796 ActionId .ENABLE_MOBILE_DATA ,
798797 ActionId .DISABLE_MOBILE_DATA ,
799- -> return if (isSystemBridgeSupported ) {
798+ -> return if (Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q ) {
800799 emptyList()
801800 } else {
802801 listOf (Permission .ROOT )
@@ -869,7 +868,7 @@ object ActionUtils {
869868 ActionId .ENABLE_NFC ,
870869 ActionId .DISABLE_NFC ,
871870 ActionId .TOGGLE_NFC ,
872- -> return if (isSystemBridgeSupported ) {
871+ -> return if (Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q ) {
873872 emptyList()
874873 } else {
875874 listOf (Permission .ROOT )
@@ -887,7 +886,7 @@ object ActionUtils {
887886 ActionId .TOGGLE_AIRPLANE_MODE ,
888887 ActionId .ENABLE_AIRPLANE_MODE ,
889888 ActionId .DISABLE_AIRPLANE_MODE ,
890- -> return if (isSystemBridgeSupported ) {
889+ -> return if (Build . VERSION . SDK_INT >= Build . VERSION_CODES . Q ) {
891890 emptyList()
892891 } else {
893892 listOf (Permission .ROOT )
@@ -903,11 +902,12 @@ object ActionUtils {
903902
904903 ActionId .SECURE_LOCK_DEVICE -> return listOf (Permission .DEVICE_ADMIN )
905904
906- ActionId .POWER_ON_OFF_DEVICE -> return if (isSystemBridgeSupported) {
907- emptyList()
908- } else {
909- listOf (Permission .ROOT )
910- }
905+ ActionId .POWER_ON_OFF_DEVICE ->
906+ return if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
907+ emptyList()
908+ } else {
909+ listOf (Permission .ROOT )
910+ }
911911
912912 ActionId .DISMISS_ALL_NOTIFICATIONS ,
913913 ActionId .DISMISS_MOST_RECENT_NOTIFICATION ,
0 commit comments