Prevent depending on blacklisted API

This commit is contained in:
Mygod
2020-05-28 12:17:19 -04:00
parent f4e540e919
commit d56905603d

View File

@@ -333,18 +333,9 @@ object TetheringManager {
* multiple times later upon changes. * multiple times later upon changes.
* *
* *@param reg The new regular expressions. * *@param reg The new regular expressions.
* @param tetherableBluetoothRegexs an array of 0 or more regular expression Strings defining
* what interfaces are considered tetherable bluetooth interfaces.
* @param tetherableUsbRegexs an array of 0 or more regular expression Strings defining
* what interfaces are considered tetherable usb interfaces.
* @param tetherableWifiRegexs an array of 0 or more regular expression Strings defining
* what interfaces are considered tetherable wifi interfaces.
*
* @hide * @hide
*/ */
fun onTetherableInterfaceRegexpsChanged(tetherableBluetoothRegexs: List<String?>, fun onTetherableInterfaceRegexpsChanged() {}
tetherableUsbRegexs: List<String?>,
tetherableWifiRegexs: List<String?>) {}
/** /**
* Called when there was a change in the list of tetherable interfaces. Tetherable * Called when there was a change in the list of tetherable interfaces. Tetherable
@@ -401,23 +392,6 @@ object TetheringManager {
fun onOffloadStatusChanged(status: Int) {} fun onOffloadStatusChanged(status: Int) {}
} }
@get:RequiresApi(30)
private val classTetheringInterfaceRegexps by lazy {
Class.forName("android.net.TetheringManager\$TetheringInterfaceRegexps")
}
@get:RequiresApi(30)
private val getTetherableBluetoothRegexs by lazy {
classTetheringInterfaceRegexps.getDeclaredMethod("getTetherableBluetoothRegexs")
}
@get:RequiresApi(30)
private val getTetherableUsbRegexs by lazy {
classTetheringInterfaceRegexps.getDeclaredMethod("getTetherableUsbRegexs")
}
@get:RequiresApi(30)
private val getTetherableWifiRegexs by lazy {
classTetheringInterfaceRegexps.getDeclaredMethod("getTetherableWifiRegexs")
}
@get:RequiresApi(30) @get:RequiresApi(30)
private val interfaceTetheringEventCallback by lazy { private val interfaceTetheringEventCallback by lazy {
Class.forName("android.net.TetheringManager\$TetheringEventCallback") Class.forName("android.net.TetheringManager\$TetheringEventCallback")
@@ -464,13 +438,7 @@ object TetheringManager {
null null
} }
"onTetherableInterfaceRegexpsChanged" -> { "onTetherableInterfaceRegexpsChanged" -> {
if (args.size > 1) Timber.w("Unexpected args for $name: $args") callback?.onTetherableInterfaceRegexpsChanged()
val reg = args[0]
@Suppress("UNCHECKED_CAST")
callback?.onTetherableInterfaceRegexpsChanged(
getTetherableBluetoothRegexs.invoke(reg) as List<String?>,
getTetherableUsbRegexs.invoke(reg) as List<String?>,
getTetherableWifiRegexs.invoke(reg) as List<String?>)
null null
} }
"onTetherableInterfacesChanged" -> { "onTetherableInterfacesChanged" -> {