Suppress errors when stopping
This commit is contained in:
@@ -27,7 +27,7 @@ class LocalOnlyInterfaceManager(val downstream: String) : UpstreamMonitor.Callba
|
|||||||
}
|
}
|
||||||
override fun onLost() {
|
override fun onLost() {
|
||||||
val routing = routing ?: return
|
val routing = routing ?: return
|
||||||
if (!routing.stop()) app.toast(R.string.noisy_su_failure)
|
routing.stop()
|
||||||
initRouting(null, routing.hostAddress, emptyList())
|
initRouting(null, routing.hostAddress, emptyList())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +59,6 @@ class LocalOnlyInterfaceManager(val downstream: String) : UpstreamMonitor.Callba
|
|||||||
fun stop() {
|
fun stop() {
|
||||||
UpstreamMonitor.unregisterCallback(this)
|
UpstreamMonitor.unregisterCallback(this)
|
||||||
app.cleanRoutings -= this
|
app.cleanRoutings -= this
|
||||||
if (routing?.stop() == false) app.toast(R.string.noisy_su_failure)
|
routing?.stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package be.mygod.vpnhotspot
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.widget.Toast
|
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.manage.TetheringFragment
|
import be.mygod.vpnhotspot.manage.TetheringFragment
|
||||||
import be.mygod.vpnhotspot.net.IpNeighbourMonitor
|
import be.mygod.vpnhotspot.net.IpNeighbourMonitor
|
||||||
@@ -33,9 +32,8 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
|||||||
private var receiverRegistered = false
|
private var receiverRegistered = false
|
||||||
private val receiver = broadcastReceiver { _, intent ->
|
private val receiver = broadcastReceiver { _, intent ->
|
||||||
synchronized(routings) {
|
synchronized(routings) {
|
||||||
val failed = (routings.keys - TetheringManager.getTetheredIfaces(intent.extras))
|
for (iface in routings.keys - TetheringManager.getTetheredIfaces(intent.extras))
|
||||||
.any { routings.remove(it)?.stop() == false }
|
routings.remove(iface)?.stop()
|
||||||
if (failed) Toast.makeText(this, getText(R.string.noisy_su_failure), Toast.LENGTH_SHORT).show()
|
|
||||||
updateRoutingsLocked()
|
updateRoutingsLocked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +46,6 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
|||||||
var failed = false
|
var failed = false
|
||||||
for ((downstream, value) in routings) if (value == null || value.upstream != upstream)
|
for ((downstream, value) in routings) if (value == null || value.upstream != upstream)
|
||||||
try {
|
try {
|
||||||
if (value?.stop() == false) failed = true
|
|
||||||
// system tethering already has working forwarding rules
|
// system tethering already has working forwarding rules
|
||||||
// so it doesn't make sense to add additional forwarding rules
|
// so it doesn't make sense to add additional forwarding rules
|
||||||
val routing = Routing(upstream, downstream).rule().forward()
|
val routing = Routing(upstream, downstream).rule().forward()
|
||||||
@@ -92,8 +89,7 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
|||||||
val iface = intent.getStringExtra(EXTRA_ADD_INTERFACE)
|
val iface = intent.getStringExtra(EXTRA_ADD_INTERFACE)
|
||||||
synchronized(routings) {
|
synchronized(routings) {
|
||||||
if (iface != null) routings[iface] = null
|
if (iface != null) routings[iface] = null
|
||||||
if (routings.remove(intent.getStringExtra(EXTRA_REMOVE_INTERFACE))?.stop() == false)
|
routings.remove(intent.getStringExtra(EXTRA_REMOVE_INTERFACE))?.stop()
|
||||||
Toast.makeText(this, getText(R.string.noisy_su_failure), Toast.LENGTH_SHORT).show()
|
|
||||||
updateRoutingsLocked()
|
updateRoutingsLocked()
|
||||||
}
|
}
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
@@ -109,14 +105,12 @@ class TetheringService : IpNeighbourMonitoringService(), UpstreamMonitor.Callbac
|
|||||||
override fun onLost() {
|
override fun onLost() {
|
||||||
upstream = null
|
upstream = null
|
||||||
this.dns = emptyList()
|
this.dns = emptyList()
|
||||||
var failed = false
|
|
||||||
synchronized(routings) {
|
synchronized(routings) {
|
||||||
for ((iface, routing) in routings) {
|
for ((iface, routing) in routings) {
|
||||||
if (routing?.stop() == false) failed = true
|
routing?.stop()
|
||||||
routings[iface] = null
|
routings[iface] = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failed) Toast.makeText(this, getText(R.string.noisy_su_failure), Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user