Suppport in-process tethering module
This commit is contained in:
@@ -150,6 +150,7 @@ This is only meant to be an index. You can read more in the source code.
|
||||
Greylisted/blacklisted APIs or internal constants: (some constants are hardcoded or implicitly used)
|
||||
|
||||
* [`Landroid/net/ConnectivityManager;->getLastTetherError(Ljava/lang/String;)I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#144306)
|
||||
* (since API 30) `Landroid/net/ConnectivityModuleConnector;->IN_PROCESS_SUFFIX:Ljava/lang/String;`
|
||||
* (since API 30) [`Landroid/net/TetheringManager$TetheringEventCallback;->onTetherableInterfaceRegexpsChanged(Landroid/net/TetheringManager$TetheringInterfaceRegexps;)V,blacklist`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#148899)
|
||||
* (since API 30) `Landroid/net/TetheringManager;->TETHERING_WIGIG:I`
|
||||
* (prior to API 30) [`Landroid/net/wifi/WifiConfiguration$KeyMgmt;->FT_PSK:I,greylist-max-o`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#153923)
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.ResolveInfo
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.os.Build
|
||||
@@ -69,6 +70,8 @@ object TetheringManager {
|
||||
|
||||
@RequiresApi(30)
|
||||
private const val TETHERING_CONNECTOR_CLASS = "android.net.ITetheringConnector"
|
||||
@RequiresApi(30)
|
||||
private const val IN_PROCESS_SUFFIX = ".InProcess"
|
||||
|
||||
/**
|
||||
* This is a sticky broadcast since almost forever.
|
||||
@@ -165,9 +168,17 @@ object TetheringManager {
|
||||
val service = Services.context.getSystemService(TETHERING_SERVICE)
|
||||
service
|
||||
}
|
||||
|
||||
private fun resolveSystemService(action: String): ResolveInfo? {
|
||||
val result = app.packageManager.queryIntentServices(Intent(action), PackageManager.MATCH_SYSTEM_ONLY)
|
||||
check(result.size <= 1) { "Multiple system services handle $action: ${result.joinToString()}" }
|
||||
return result.firstOrNull()
|
||||
}
|
||||
@get:RequiresApi(30)
|
||||
val resolvedService get() = app.packageManager.queryIntentServices(Intent(TETHERING_CONNECTOR_CLASS),
|
||||
PackageManager.MATCH_SYSTEM_ONLY).single()
|
||||
val resolvedService get() = sequence {
|
||||
resolveSystemService(TETHERING_CONNECTOR_CLASS + IN_PROCESS_SUFFIX)?.let { yield(it) }
|
||||
resolveSystemService(TETHERING_CONNECTOR_CLASS)?.let { yield(it) }
|
||||
}.single()
|
||||
|
||||
@get:RequiresApi(24)
|
||||
private val classOnStartTetheringCallback by lazy {
|
||||
|
||||
Reference in New Issue
Block a user