Make repeater timeout configurable
This commit is contained in:
@@ -6,7 +6,6 @@ import android.content.DialogInterface
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.ServiceConnection
|
import android.content.ServiceConnection
|
||||||
import android.net.wifi.SoftApConfiguration
|
import android.net.wifi.SoftApConfiguration
|
||||||
import android.net.wifi.p2p.WifiP2pConfig
|
|
||||||
import android.net.wifi.p2p.WifiP2pGroup
|
import android.net.wifi.p2p.WifiP2pGroup
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -188,22 +187,26 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
|||||||
val networkName = RepeaterService.networkName
|
val networkName = RepeaterService.networkName
|
||||||
val passphrase = RepeaterService.passphrase
|
val passphrase = RepeaterService.passphrase
|
||||||
if (networkName != null && passphrase != null) {
|
if (networkName != null && passphrase != null) {
|
||||||
return SoftApConfigurationCompat().apply {
|
return SoftApConfigurationCompat(
|
||||||
ssid = networkName
|
ssid = networkName,
|
||||||
securityType = SoftApConfiguration.SECURITY_TYPE_WPA2_PSK // is not actually used
|
passphrase = passphrase,
|
||||||
this.passphrase = passphrase
|
band = RepeaterService.operatingBand,
|
||||||
band = RepeaterService.operatingBand
|
channel = RepeaterService.operatingChannel,
|
||||||
channel = RepeaterService.operatingChannel
|
securityType = SoftApConfiguration.SECURITY_TYPE_WPA2_PSK, // is not actually used
|
||||||
|
isAutoShutdownEnabled = RepeaterService.isAutoShutdownEnabled,
|
||||||
|
shutdownTimeoutMillis = RepeaterService.shutdownTimeoutMillis).apply {
|
||||||
bssid = RepeaterService.deviceAddress
|
bssid = RepeaterService.deviceAddress
|
||||||
} to false
|
} to false
|
||||||
}
|
}
|
||||||
} else binder?.let { binder ->
|
} else binder?.let { binder ->
|
||||||
val group = binder.group ?: binder.fetchPersistentGroup().let { binder.group }
|
val group = binder.group ?: binder.fetchPersistentGroup().let { binder.group }
|
||||||
if (group != null) return SoftApConfigurationCompat().run {
|
if (group != null) return SoftApConfigurationCompat(
|
||||||
ssid = group.networkName
|
ssid = group.networkName,
|
||||||
securityType = SoftApConfiguration.SECURITY_TYPE_WPA2_PSK // is not actually used
|
channel = RepeaterService.operatingChannel,
|
||||||
band = SoftApConfigurationCompat.BAND_ANY
|
band = SoftApConfigurationCompat.BAND_ANY,
|
||||||
channel = RepeaterService.operatingChannel
|
securityType = SoftApConfiguration.SECURITY_TYPE_WPA2_PSK, // is not actually used
|
||||||
|
isAutoShutdownEnabled = RepeaterService.isAutoShutdownEnabled,
|
||||||
|
shutdownTimeoutMillis = RepeaterService.shutdownTimeoutMillis).run {
|
||||||
try {
|
try {
|
||||||
val config = P2pSupplicantConfiguration(group)
|
val config = P2pSupplicantConfiguration(group)
|
||||||
config.init(RepeaterService.lastMac)
|
config.init(RepeaterService.lastMac)
|
||||||
@@ -225,6 +228,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
|||||||
private suspend fun updateConfiguration(config: SoftApConfigurationCompat) {
|
private suspend fun updateConfiguration(config: SoftApConfigurationCompat) {
|
||||||
if (RepeaterService.safeMode) {
|
if (RepeaterService.safeMode) {
|
||||||
RepeaterService.networkName = config.ssid
|
RepeaterService.networkName = config.ssid
|
||||||
|
RepeaterService.deviceAddress = config.bssid
|
||||||
RepeaterService.passphrase = config.passphrase
|
RepeaterService.passphrase = config.passphrase
|
||||||
RepeaterService.operatingBand = config.band
|
RepeaterService.operatingBand = config.band
|
||||||
} else holder.config?.let { master ->
|
} else holder.config?.let { master ->
|
||||||
@@ -240,6 +244,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
|
|||||||
holder.config = null
|
holder.config = null
|
||||||
}
|
}
|
||||||
RepeaterService.operatingChannel = config.channel
|
RepeaterService.operatingChannel = config.channel
|
||||||
RepeaterService.deviceAddress = config.bssid
|
RepeaterService.isAutoShutdownEnabled = config.isAutoShutdownEnabled
|
||||||
|
RepeaterService.shutdownTimeoutMillis = config.shutdownTimeoutMillis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ class TetherTimeoutMonitor(private val timeout: Long = 0,
|
|||||||
private var noClient = true
|
private var noClient = true
|
||||||
private var timeoutJob: Job? = null
|
private var timeoutJob: Job? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
onClientsChanged(true)
|
||||||
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
timeoutJob?.cancel()
|
timeoutJob?.cancel()
|
||||||
timeoutJob = null
|
timeoutJob = null
|
||||||
|
|||||||
Reference in New Issue
Block a user