Fix UnblockCentral not working lmao

This commit is contained in:
Mygod
2021-06-05 01:41:34 -04:00
parent 02e7f06e61
commit 60c299a44a
2 changed files with 12 additions and 11 deletions

View File

@@ -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;-><init>(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`

View File

@@ -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<*>>()::class.java)
val clazz = Class.forName("dalvik.system.VMRuntime")
val setHiddenApiExemptions = getDeclaredMethod(clazz, "setHiddenApiExemptions",
arrayOf(Array<String>::class.java)) as Method
setHiddenApiExemptions(clazz.getDeclaredMethod("getRuntime")(null), arrayOf(""))
}
@RequiresApi(31)