Fix Kotlin stupid bug (KT-47881)
This commit is contained in:
@@ -280,7 +280,9 @@ object TetheringManager {
|
||||
@Suppress("NAME_SHADOWING") val callback = reference.get()
|
||||
return when {
|
||||
method.matches("onTetheringStarted") -> callback?.onTetheringStarted()
|
||||
method.matches1<Int>("onTetheringFailed") -> callback?.onTetheringFailed(args?.get(0) as Int)
|
||||
method.matches("onTetheringFailed", Integer.TYPE) -> {
|
||||
callback?.onTetheringFailed(args?.get(0) as Int)
|
||||
}
|
||||
else -> callSuper(interfaceStartTetheringCallback, proxy, method, args)
|
||||
}
|
||||
}
|
||||
@@ -539,7 +541,7 @@ object TetheringManager {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val callback = reference.get()
|
||||
return when {
|
||||
method.matches1<Boolean>("onTetheringSupported") -> {
|
||||
method.matches("onTetheringSupported", Boolean::class.java) -> {
|
||||
callback?.onTetheringSupported(args!![0] as Boolean)
|
||||
}
|
||||
method.matches1<Network>("onUpstreamChanged") -> {
|
||||
@@ -559,13 +561,13 @@ object TetheringManager {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
callback?.onTetheredInterfacesChanged(args!![0] as List<String?>)
|
||||
}
|
||||
method.matches2<String, Int>("onError") -> {
|
||||
method.matches("onError", String::class.java, Integer.TYPE) -> {
|
||||
callback?.onError(args!![0] as String, args[1] as Int)
|
||||
}
|
||||
method.matches1<java.util.Collection<*>>("onClientsChanged") -> {
|
||||
callback?.onClientsChanged(args!![0] as Collection<*>)
|
||||
}
|
||||
method.matches1<Int>("onOffloadStatusChanged") -> {
|
||||
method.matches("onOffloadStatusChanged", Integer.TYPE) -> {
|
||||
callback?.onOffloadStatusChanged(args!![0] as Int)
|
||||
}
|
||||
else -> callSuper(interfaceTetheringEventCallback, proxy, method, args)
|
||||
|
||||
@@ -257,10 +257,10 @@ object WifiApManager {
|
||||
|
||||
private fun invokeActual(proxy: Any, method: Method, args: Array<out Any?>?): Any? {
|
||||
return when {
|
||||
method.matches2<Int, Int>("onStateChanged") -> {
|
||||
method.matches("onStateChanged", Integer.TYPE, Integer.TYPE) -> {
|
||||
callback.onStateChanged(args!![0] as Int, args[1] as Int)
|
||||
}
|
||||
method.matches1<Int>("onNumClientsChanged") -> @Suppress("DEPRECATION") {
|
||||
method.matches("onNumClientsChanged", Integer.TYPE) -> @Suppress("DEPRECATION") {
|
||||
if (Build.VERSION.SDK_INT >= 30) Timber.w(Exception("Unexpected onNumClientsChanged"))
|
||||
callback.onNumClientsChanged(args!![0] as Int)
|
||||
}
|
||||
|
||||
@@ -58,8 +58,6 @@ fun Method.matches(name: String, vararg classes: Class<*>) = this.name == name &
|
||||
(0 until parameterCount).all { i -> parameters[i].type == classes[i] }
|
||||
@RequiresApi(26)
|
||||
inline fun <reified T> Method.matches1(name: String) = matches(name, T::class.java)
|
||||
@RequiresApi(26)
|
||||
inline fun <reified T0, reified T1> Method.matches2(name: String) = matches(name, T0::class.java, T1::class.java)
|
||||
|
||||
fun Context.ensureReceiverUnregistered(receiver: BroadcastReceiver) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user