Target API 31 on Google variant
This commit is contained in:
@@ -320,12 +320,11 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
onTetheringStarted() // force flush
|
||||
}
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
if (Build.VERSION.SDK_INT < 31 || parent.requireContext().checkSelfPermission(
|
||||
Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
|
||||
if (Build.VERSION.SDK_INT < 31) return
|
||||
if (parent.requireContext().checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) ==
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
tethering.ensureInit(parent.requireContext())
|
||||
} else if (parent.shouldShowRequestPermissionRationale(Manifest.permission.BLUETOOTH_CONNECT)) {
|
||||
parent.requestBluetooth.launch(Manifest.permission.BLUETOOTH_CONNECT)
|
||||
}
|
||||
} else parent.requestBluetooth.launch(Manifest.permission.BLUETOOTH_CONNECT)
|
||||
}
|
||||
override fun onDestroy(owner: LifecycleOwner) = tethering.close()
|
||||
|
||||
|
||||
@@ -3,31 +3,22 @@ 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 java.lang.reflect.Method
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
|
||||
/**
|
||||
* The central object for accessing all the useful blocked APIs. Thanks Google!
|
||||
*
|
||||
* Lazy cannot be used directly as it will create inner classes.
|
||||
*/
|
||||
@RequiresApi(28)
|
||||
@SuppressLint("BlockedPrivateApi", "DiscouragedPrivateApi")
|
||||
@Suppress("FunctionName")
|
||||
object UnblockCentral {
|
||||
/**
|
||||
* Retrieve this property before doing dangerous shit.
|
||||
*/
|
||||
private val init by lazy {
|
||||
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(""))
|
||||
}
|
||||
private val init by lazy { UnblockHelper(app) }
|
||||
|
||||
@RequiresApi(31)
|
||||
fun setUserConfiguration(clazz: Class<*>) = init.let {
|
||||
|
||||
Reference in New Issue
Block a user