Use reflection instead of parcel magic to get around networkName check
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package be.mygod.vpnhotspot.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.net.wifi.p2p.WifiP2pConfig
|
||||
import androidx.annotation.RequiresApi
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* The central object for accessing all the useful blocked APIs. Thanks Google!
|
||||
*
|
||||
* Lazy cannot be used directly as it will create inner classes.
|
||||
*/
|
||||
@SuppressLint("DiscouragedPrivateApi")
|
||||
@SuppressLint("BlockedPrivateApi", "DiscouragedPrivateApi")
|
||||
@Suppress("FunctionName")
|
||||
object UnblockCentral {
|
||||
/**
|
||||
@@ -27,4 +30,9 @@ object UnblockCentral {
|
||||
|
||||
@RequiresApi(31)
|
||||
fun getApInstanceIdentifier(clazz: Class<*>) = init.let { clazz.getDeclaredMethod("getApInstanceIdentifier") }
|
||||
|
||||
@get:RequiresApi(29)
|
||||
val WifiP2pConfig_Builder_mNetworkName get() = init.let {
|
||||
WifiP2pConfig.Builder::class.java.getDeclaredField("mNetworkName").apply { isAccessible = true }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user