From bfedbfe614d0b98287363c4dec7bbdd68c368395 Mon Sep 17 00:00:00 2001 From: Mygod Date: Mon, 31 May 2021 19:37:08 -0400 Subject: [PATCH] Set p2p unsafe channel properly --- .../vpnhotspot/net/wifi/SoftApConfigurationCompat.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt index 1f92e1bb..657a9090 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt @@ -359,7 +359,13 @@ data class SoftApConfigurationCompat( return result } fun setChannel(channel: Int, band: Int = BAND_LEGACY) { - channels = SparseIntArray(1).apply { append(band, channel) } + channels = SparseIntArray(1).apply { + append(when { + channel <= 0 || band != BAND_LEGACY -> band + channel > 14 -> BAND_5GHZ + else -> BAND_2GHZ + }, channel) + } } fun optimizeChannels(channels: SparseIntArray = this.channels) { this.channels = SparseIntArray(channels.size()).apply {