Acquire WiFi lock when baresip is using WiFi network
This commit is contained in:
@@ -1134,15 +1134,22 @@ class BaresipService: Service() {
|
|||||||
if (selectedNetwork != null) {
|
if (selectedNetwork != null) {
|
||||||
activeNetwork = selectedNetwork
|
activeNetwork = selectedNetwork
|
||||||
if (isServiceRunning) {
|
if (isServiceRunning) {
|
||||||
updateLinkProperties(caps!!, props!!)
|
updateLinkProperties(props!!)
|
||||||
} else {
|
} else {
|
||||||
dnsServers = props!!.dnsServers
|
dnsServers = props!!.dnsServers
|
||||||
linkAddresses = props.linkAddresses
|
linkAddresses = props.linkAddresses
|
||||||
}
|
}
|
||||||
|
if (caps!!.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
||||||
|
Log.d(TAG, "Acquiring WiFi Lock")
|
||||||
|
wifiLock.acquire()
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Releasing WiFi Lock")
|
||||||
|
wifiLock.release()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLinkProperties(caps: NetworkCapabilities, props: LinkProperties) {
|
private fun updateLinkProperties(props: LinkProperties) {
|
||||||
if (dynDns && (dnsServers != props.dnsServers)) {
|
if (dynDns && (dnsServers != props.dnsServers)) {
|
||||||
if (isServiceRunning)
|
if (isServiceRunning)
|
||||||
if (Config.updateDnsServers(props.dnsServers) != 0)
|
if (Config.updateDnsServers(props.dnsServers) != 0)
|
||||||
@@ -1153,13 +1160,6 @@ class BaresipService: Service() {
|
|||||||
dnsServers = props.dnsServers
|
dnsServers = props.dnsServers
|
||||||
}
|
}
|
||||||
updateLinkAddresses(props.linkAddresses)
|
updateLinkAddresses(props.linkAddresses)
|
||||||
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
|
||||||
Log.d(TAG, "Acquiring WiFi Lock")
|
|
||||||
wifiLock.acquire()
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Releasing WiFi Lock")
|
|
||||||
wifiLock.release()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLinkAddresses(linkAddrs: List<LinkAddress>) {
|
private fun updateLinkAddresses(linkAddrs: List<LinkAddress>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user