Reverted previous commit for better reliability
This commit is contained in:
@ -85,21 +85,21 @@ class BaresipService: Service() {
|
||||
override fun onAvailable(network: Network) {
|
||||
super.onAvailable(network)
|
||||
Log.i(LOG_TAG, "Network $network is available")
|
||||
updateNetwork(false)
|
||||
updateNetwork()
|
||||
}
|
||||
|
||||
override fun onLost(network: Network) {
|
||||
super.onLost(network)
|
||||
Log.i(LOG_TAG, "Network $network is lost")
|
||||
if (activeNetwork == "$network")
|
||||
updateNetwork(false)
|
||||
updateNetwork()
|
||||
}
|
||||
|
||||
override fun onLinkPropertiesChanged(network: Network, props: LinkProperties) {
|
||||
super.onLinkPropertiesChanged(network, props)
|
||||
Log.i(LOG_TAG, "Network $network link properties changed")
|
||||
if (activeNetwork == "$network")
|
||||
updateNetwork(true)
|
||||
updateNetwork()
|
||||
}
|
||||
|
||||
override fun onCapabilitiesChanged(network: Network, caps: NetworkCapabilities) {
|
||||
@ -483,7 +483,7 @@ class BaresipService: Service() {
|
||||
}
|
||||
if ((ev.size > 1) && (ev[1] == "Software caused connection abort")) {
|
||||
// Perhaps due to VPN connect/disconnect
|
||||
updateNetwork(false)
|
||||
updateNetwork()
|
||||
}
|
||||
if (!Utils.isVisible())
|
||||
return
|
||||
@ -1028,7 +1028,7 @@ class BaresipService: Service() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateNetwork(change: Boolean) {
|
||||
private fun updateNetwork() {
|
||||
// Use VPN network if available
|
||||
for (n in cm.allNetworks) {
|
||||
val caps = cm.getNetworkCapabilities(n) ?: continue
|
||||
@ -1036,13 +1036,7 @@ class BaresipService: Service() {
|
||||
if (isNetworkActive(n) && caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) {
|
||||
Log.i(LOG_TAG, "Active VPN network $n is available with caps: " +
|
||||
"$caps, props: $props")
|
||||
if (!change && ("$n" == activeNetwork))
|
||||
return
|
||||
activeNetwork = "$n"
|
||||
if (!isConfigInitialized)
|
||||
Log.i("Baresip", "Config is NOT initialized")
|
||||
else
|
||||
Log.i("Baresip", "Config is initialized")
|
||||
if (isConfigInitialized) {
|
||||
Utils.updateLinkProperties(props)
|
||||
} else {
|
||||
@ -1061,8 +1055,6 @@ class BaresipService: Service() {
|
||||
if (isNetworkActive(n) && caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
|
||||
Log.i(LOG_TAG, "Active Internet network $n is available with caps: " +
|
||||
"$caps, props: $props")
|
||||
if (!change && ("$n" == activeNetwork))
|
||||
return
|
||||
activeNetwork = "$n"
|
||||
if (isServiceRunning) {
|
||||
Utils.updateLinkProperties(props)
|
||||
@ -1080,8 +1072,6 @@ class BaresipService: Service() {
|
||||
if (isNetworkActive(n)) {
|
||||
Log.i(LOG_TAG, "Active network $n is available with caps: " +
|
||||
"$caps, props: $props")
|
||||
if (!change && ("$n" == activeNetwork))
|
||||
return
|
||||
activeNetwork = "$n"
|
||||
if (isServiceRunning) {
|
||||
Utils.updateLinkProperties(props)
|
||||
|
||||
@ -56,11 +56,9 @@ class UserAgent(val uap: String) {
|
||||
return null
|
||||
}
|
||||
|
||||
fun register(reRegister: Boolean) {
|
||||
fun register() {
|
||||
for (ua in BaresipService.uas) {
|
||||
if (ua.account.regint > 0) {
|
||||
if ((reRegister == false) && Api.ua_isregistered(ua.uap))
|
||||
continue
|
||||
if (Api.ua_register(ua.uap) != 0)
|
||||
Log.d("Baresip", "Failed to register ${ua.account.aor}")
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ object Utils {
|
||||
Api.uag_reset_transp(true, true)
|
||||
Api.net_debug()
|
||||
} else {
|
||||
UserAgent.register(false)
|
||||
UserAgent.register()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user