Fix UnblockCentral not working lmao
This commit is contained in:
@@ -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 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 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 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;-><init>(Ljava/lang/Class;I)V,unsupported`
|
||||||
* (since API 26) `Ljava/lang/invoke/MethodHandles$Lookup;->ALL_MODES:I,lo-prio,max-target-o`
|
* (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`
|
* (prior to API 29) `Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;,core-platform-api,max-target-p`
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package be.mygod.vpnhotspot.util
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.net.wifi.SoftApConfiguration
|
import android.net.wifi.SoftApConfiguration
|
||||||
import android.net.wifi.p2p.WifiP2pConfig
|
import android.net.wifi.p2p.WifiP2pConfig
|
||||||
|
import android.os.Build
|
||||||
import androidx.annotation.RequiresApi
|
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!
|
* 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.
|
* Retrieve this property before doing dangerous shit.
|
||||||
*/
|
*/
|
||||||
@get:RequiresApi(28)
|
|
||||||
private val init by lazy {
|
private val init by lazy {
|
||||||
try {
|
if (Build.VERSION.SDK_INT < 28) return@lazy
|
||||||
Class.forName("dalvik.system.VMDebug").getDeclaredMethod("allowHiddenApiReflectionFrom", Class::class.java)
|
// TODO: fix this not working when targeting API 30+
|
||||||
.invoke(null, UnblockCentral::class.java)
|
val getDeclaredMethod = Class::class.java.getDeclaredMethod("getDeclaredMethod",
|
||||||
true
|
String::class.java, arrayOf<Class<*>>()::class.java)
|
||||||
} catch (e: ReflectiveOperationException) {
|
val clazz = Class.forName("dalvik.system.VMRuntime")
|
||||||
Timber.w(e)
|
val setHiddenApiExemptions = getDeclaredMethod(clazz, "setHiddenApiExemptions",
|
||||||
false
|
arrayOf(Array<String>::class.java)) as Method
|
||||||
}
|
setHiddenApiExemptions(clazz.getDeclaredMethod("getRuntime")(null), arrayOf(""))
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(31)
|
@RequiresApi(31)
|
||||||
|
|||||||
Reference in New Issue
Block a user