Suppress more CancellationException
This commit is contained in:
@@ -23,7 +23,6 @@ import be.mygod.vpnhotspot.net.TetheringManager
|
|||||||
import be.mygod.vpnhotspot.net.wifi.SoftApConfigurationCompat
|
import be.mygod.vpnhotspot.net.wifi.SoftApConfigurationCompat
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiApManager
|
import be.mygod.vpnhotspot.net.wifi.WifiApManager
|
||||||
import be.mygod.vpnhotspot.root.WifiApCommands
|
import be.mygod.vpnhotspot.root.WifiApCommands
|
||||||
import be.mygod.vpnhotspot.util.getRootCause
|
|
||||||
import be.mygod.vpnhotspot.util.readableMessage
|
import be.mygod.vpnhotspot.util.readableMessage
|
||||||
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -102,7 +101,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
|||||||
data.notifyChange()
|
data.notifyChange()
|
||||||
}
|
}
|
||||||
override fun onException(e: Exception) {
|
override fun onException(e: Exception) {
|
||||||
if (e.getRootCause() !is SecurityException) Timber.w(e)
|
super.onException(e)
|
||||||
GlobalScope.launch(Dispatchers.Main.immediate) {
|
GlobalScope.launch(Dispatchers.Main.immediate) {
|
||||||
val context = parent.context ?: app
|
val context = parent.context ?: app
|
||||||
Toast.makeText(context, e.readableMessage, Toast.LENGTH_LONG).show()
|
Toast.makeText(context, e.readableMessage, Toast.LENGTH_LONG).show()
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import be.mygod.vpnhotspot.net.TetheringManager
|
|||||||
import be.mygod.vpnhotspot.net.TetheringManager.tetheredIfaces
|
import be.mygod.vpnhotspot.net.TetheringManager.tetheredIfaces
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiApManager
|
import be.mygod.vpnhotspot.net.wifi.WifiApManager
|
||||||
import be.mygod.vpnhotspot.util.broadcastReceiver
|
import be.mygod.vpnhotspot.util.broadcastReceiver
|
||||||
import be.mygod.vpnhotspot.util.getRootCause
|
|
||||||
import be.mygod.vpnhotspot.util.readableMessage
|
import be.mygod.vpnhotspot.util.readableMessage
|
||||||
import be.mygod.vpnhotspot.util.stopAndUnbind
|
import be.mygod.vpnhotspot.util.stopAndUnbind
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -125,7 +124,7 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
|
|||||||
updateTile()
|
updateTile()
|
||||||
}
|
}
|
||||||
override fun onException(e: Exception) {
|
override fun onException(e: Exception) {
|
||||||
if (e.getRootCause() !is SecurityException) Timber.w(e)
|
super.onException(e)
|
||||||
GlobalScope.launch(Dispatchers.Main.immediate) {
|
GlobalScope.launch(Dispatchers.Main.immediate) {
|
||||||
Toast.makeText(this@TetheringTileService, e.readableMessage, Toast.LENGTH_LONG).show()
|
Toast.makeText(this@TetheringTileService, e.readableMessage, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.lang.reflect.InvocationHandler
|
|||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import java.lang.reflect.Proxy
|
import java.lang.reflect.Proxy
|
||||||
|
import java.util.concurrent.CancellationException
|
||||||
import java.util.concurrent.Executor
|
import java.util.concurrent.Executor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +57,12 @@ object TetheringManager {
|
|||||||
/**
|
/**
|
||||||
* ADDED: Called when a local Exception occurred.
|
* ADDED: Called when a local Exception occurred.
|
||||||
*/
|
*/
|
||||||
fun onException(e: Exception) { }
|
fun onException(e: Exception) {
|
||||||
|
when (e.getRootCause()) {
|
||||||
|
is SecurityException, is CancellationException -> { }
|
||||||
|
else -> Timber.w(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,7 +326,7 @@ object TetheringManager {
|
|||||||
} catch (eRoot: Exception) {
|
} catch (eRoot: Exception) {
|
||||||
try { // last resort: start tethering without trying to bypass entitlement check
|
try { // last resort: start tethering without trying to bypass entitlement check
|
||||||
startTethering(type, false, showProvisioningUi, executor, proxy(callback))
|
startTethering(type, false, showProvisioningUi, executor, proxy(callback))
|
||||||
Timber.w(eRoot)
|
if (eRoot !is CancellationException) Timber.w(eRoot)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.addSuppressed(eRoot)
|
e.addSuppressed(eRoot)
|
||||||
callback.onException(e)
|
callback.onException(e)
|
||||||
@@ -356,7 +362,7 @@ object TetheringManager {
|
|||||||
}.value
|
}.value
|
||||||
} catch (eRoot: Exception) {
|
} catch (eRoot: Exception) {
|
||||||
eRoot.addSuppressed(e)
|
eRoot.addSuppressed(e)
|
||||||
Timber.w(eRoot)
|
if (eRoot !is CancellationException) Timber.w(eRoot)
|
||||||
callback.onException(eRoot)
|
callback.onException(eRoot)
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user