From c26da4e5baaad401e7d532239253cb17ca7e25bb Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 16 Apr 2021 14:51:18 -0400 Subject: [PATCH] Fix callbacks not registered correctly on Android 12 DP --- .../main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt index 8f085443..4fc71f39 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt @@ -162,7 +162,9 @@ object WifiApManager { if (Build.VERSION.SDK_INT < 30) Timber.w(Exception("Unexpected onInfoChanged")) if (noArgs != 1) Timber.w("Unexpected args for $name: $args") val softApInfo = args!![0] - callback.onInfoChanged(getFrequency(softApInfo) as Int, getBandwidth(softApInfo) as Int) + if (softApInfo != null && classSoftApInfo.isAssignableFrom(softApInfo.javaClass)) { + callback.onInfoChanged(getFrequency(softApInfo) as Int, getBandwidth(softApInfo) as Int) + } else Timber.w(Exception("Unexpected arg for $name: $softApInfo")) } "onCapabilityChanged" -> @TargetApi(30) { if (Build.VERSION.SDK_INT < 30) Timber.w(Exception("Unexpected onCapabilityChanged"))