Support new fields in SoftApInfo
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package be.mygod.vpnhotspot.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.annotation.RequiresApi
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* The central object for accessing all the useful blocked APIs. Thanks Google!
|
||||
*/
|
||||
@SuppressLint("DiscouragedPrivateApi")
|
||||
@Suppress("FunctionName")
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(31)
|
||||
fun SoftApInfo_getApInstanceIdentifier(clazz: Class<*>) = init.let {
|
||||
clazz.getDeclaredMethod("getApInstanceIdentifier")
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,15 @@ fun CharSequence.format(locale: Locale, vararg args: Any) = SpannableStringBuild
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> Iterable<T>.joinToSpanned(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "",
|
||||
limit: Int = -1, truncated: CharSequence = "...",
|
||||
transform: ((T) -> CharSequence)? = null) =
|
||||
joinTo(SpannableStringBuilder(), separator, prefix, postfix, limit, truncated, transform)
|
||||
fun <T> Sequence<T>.joinToSpanned(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "",
|
||||
limit: Int = -1, truncated: CharSequence = "...",
|
||||
transform: ((T) -> CharSequence)? = null) =
|
||||
joinTo(SpannableStringBuilder(), separator, prefix, postfix, limit, truncated, transform)
|
||||
|
||||
fun makeIpSpan(ip: InetAddress) = ip.hostAddress.let {
|
||||
// exclude all bogon IP addresses supported by Android APIs
|
||||
if (!app.hasTouch || ip.isMulticastAddress || ip.isAnyLocalAddress || ip.isLoopbackAddress ||
|
||||
|
||||
Reference in New Issue
Block a user