Test platform validity of bssid

This commit is contained in:
Mygod
2021-10-23 14:23:29 -04:00
parent 968777840f
commit 86a549248c
2 changed files with 7 additions and 2 deletions

View File

@@ -353,6 +353,8 @@ data class SoftApConfigurationCompat(
private val staticBuilder by lazy { classBuilder.newInstance() }
@RequiresApi(30)
fun testPlatformValidity(channels: SparseIntArray) = setChannelsCompat(staticBuilder, channels)
@RequiresApi(30)
fun testPlatformValidity(bssid: MacAddress) = setBssid(staticBuilder, bssid)
}
@Suppress("DEPRECATION")

View File

@@ -306,9 +306,12 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
dialogView.bandError.text = bandError
dialogView.bssidWrapper.error = null
val bssidValid = dialogView.bssid.length() == 0 || try {
MacAddressCompat.fromString(dialogView.bssid.text.toString())
val mac = MacAddressCompat.fromString(dialogView.bssid.text.toString())
if (Build.VERSION.SDK_INT >= 30 && !arg.p2pMode) {
SoftApConfigurationCompat.testPlatformValidity(mac.toPlatform())
}
true
} catch (e: IllegalArgumentException) {
} catch (e: Exception) {
dialogView.bssidWrapper.error = e.readableMessage
false
}