diff --git a/README.md b/README.md index a0fd2398..0936a5ce 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,8 @@ Greylisted/blacklisted APIs or internal constants: (some constants are hardcoded * (since API 30) `Lcom/android/server/wifi/WifiContext;->ACTION_RESOURCES_APK:Ljava/lang/String;` * (since API 29) `Lcom/android/server/wifi/p2p/WifiP2pServiceImpl;->ANONYMIZED_DEVICE_ADDRESS:Ljava/lang/String;` * (since API 30) `Lcom/android/server/SystemServer;->TETHERING_CONNECTOR_CLASS:Ljava/lang/String;` -* (since API 29) `Ldalvik/system/VMDebug;->allowHiddenApiReflectionFrom(Ljava/lang/Class;)V,unsupported` +* (since API 29) `Ldalvik/system/VMRuntime;->getRuntime()Ldalvik/system/VMRuntime;,core-platform-api,greylist` +* (since API 29) `Ldalvik/system/VMRuntime;->setHiddenApiExemptions([Ljava/lang/String;)V,blacklist,core-platform-api` * (since API 26) `Ljava/lang/invoke/MethodHandles$Lookup;->(Ljava/lang/Class;I)V,unsupported` * (since API 26) `Ljava/lang/invoke/MethodHandles$Lookup;->ALL_MODES:I,lo-prio,max-target-o` * (prior to API 29) `Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;,core-platform-api,max-target-p` diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/UnblockCentral.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/UnblockCentral.kt index 0a9a7daa..d5b43755 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/util/UnblockCentral.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/UnblockCentral.kt @@ -3,8 +3,9 @@ package be.mygod.vpnhotspot.util import android.annotation.SuppressLint import android.net.wifi.SoftApConfiguration import android.net.wifi.p2p.WifiP2pConfig +import android.os.Build import androidx.annotation.RequiresApi -import timber.log.Timber +import java.lang.reflect.Method /** * The central object for accessing all the useful blocked APIs. Thanks Google! @@ -17,16 +18,15 @@ object UnblockCentral { /** * Retrieve this property before doing dangerous shit. */ - @get:RequiresApi(28) private val init by lazy { - try { - Class.forName("dalvik.system.VMDebug").getDeclaredMethod("allowHiddenApiReflectionFrom", Class::class.java) - .invoke(null, UnblockCentral::class.java) - true - } catch (e: ReflectiveOperationException) { - Timber.w(e) - false - } + if (Build.VERSION.SDK_INT < 28) return@lazy + // TODO: fix this not working when targeting API 30+ + val getDeclaredMethod = Class::class.java.getDeclaredMethod("getDeclaredMethod", + String::class.java, arrayOf>()::class.java) + val clazz = Class.forName("dalvik.system.VMRuntime") + val setHiddenApiExemptions = getDeclaredMethod(clazz, "setHiddenApiExemptions", + arrayOf(Array::class.java)) as Method + setHiddenApiExemptions(clazz.getDeclaredMethod("getRuntime")(null), arrayOf("")) } @RequiresApi(31)