From 35b7404d87561c81e6020a3474b1e68a9578257b Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 29 May 2020 02:08:05 -0400 Subject: [PATCH] Suppress WrongConstant for TETHERING_SERVICE --- .../main/java/be/mygod/vpnhotspot/net/TetheringManager.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt index 8b9e55cb..81216cd8 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt @@ -1,5 +1,6 @@ package be.mygod.vpnhotspot.net +import android.annotation.SuppressLint import android.annotation.TargetApi import android.content.BroadcastReceiver import android.content.Context @@ -148,7 +149,11 @@ object TetheringManager { @get:RequiresApi(30) private val clazz by lazy { Class.forName("android.net.TetheringManager") } @get:RequiresApi(30) - private val instance by lazy @TargetApi(30) { app.getSystemService(TETHERING_SERVICE) } + private val instance by lazy @TargetApi(30) { + @SuppressLint("WrongConstant") // hidden services are not included in constants as of R preview 4 + val service = app.getSystemService(TETHERING_SERVICE) + service + } @get:RequiresApi(30) val resolvedService by lazy @TargetApi(30) { app.packageManager.queryIntentServices(Intent(TETHERING_CONNECTOR_CLASS),