diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TetherTimeoutMonitor.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TetherTimeoutMonitor.kt index 35b413c9..7915b383 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TetherTimeoutMonitor.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TetherTimeoutMonitor.kt @@ -86,7 +86,7 @@ class TetherTimeoutMonitor(private val timeout: Long = 0, fun onClientsChanged(noClient: Boolean) { this.noClient = noClient if (!noClient) close() else if (timeoutJob == null) timeoutJob = GlobalScope.launch(context) { - delay(if (timeout == 0L) defaultTimeout.toLong() else timeout) + delay(if (timeout <= 0L) defaultTimeout.toLong() else timeout) onTimeout() } } 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 37c46c11..aa5c724e 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 @@ -548,7 +548,16 @@ data class SoftApConfigurationCompat( setChannelsCompat(builder, channels) setBssid(builder, bssid?.toPlatform()) setMaxNumberOfClients(builder, maxNumberOfClients) - setShutdownTimeoutMillis(builder, shutdownTimeoutMillis) + try { + setShutdownTimeoutMillis(builder, shutdownTimeoutMillis) + } catch (e: InvocationTargetException) { + if (e.targetException is IllegalArgumentException) try { + setShutdownTimeoutMillis(builder, -1 - shutdownTimeoutMillis) + } catch (e2: InvocationTargetException) { + e2.addSuppressed(e) + throw e2 + } else throw e + } setAutoShutdownEnabled(builder, isAutoShutdownEnabled) setClientControlByUserEnabled(builder, isClientControlByUserEnabled) setHiddenSsid(builder, isHiddenSsid) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt index 84e4a664..f9d54f79 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt @@ -152,7 +152,7 @@ class WifiApDialogFragment : AlertDialogFragment - if (text.isNullOrEmpty()) defaultTimeout else text.toString().toLong() + if (text.isNullOrEmpty()) 0 else text.toString().toLong() } if (Build.VERSION.SDK_INT >= 23 || arg.p2pMode) channels = generateChannels() bssid = if (dialogView.bssid.length() != 0) { @@ -289,8 +289,6 @@ class WifiApDialogFragment : AlertDialogFragment= 23 || arg.p2pMode) { dialogView.bandPrimary.setSelection(locate(0)) if (Build.VERSION.SDK_INT >= 31 && !arg.p2pMode) {