diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts index 078885c4..a8f6072f 100644 --- a/mobile/build.gradle.kts +++ b/mobile/build.gradle.kts @@ -95,7 +95,7 @@ dependencies { implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0") implementation("eu.chainfire:librootjava:1.3.0") implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.2") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8") testImplementation("junit:junit:4.13") androidTestImplementation("androidx.room:room-testing:$roomVersion") androidTestImplementation("androidx.test:runner:1.2.0") diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt index a6cbb350..c93aa390 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt @@ -151,7 +151,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(), override fun onStateChanged(state: Int, failureReason: Int) { if (state < 10 || state > 14) { - Timber.w(Exception("Unknown state $state")) + Timber.w(Exception("Unknown state $state, $failureReason")) return } this.failureReason = if (state == 14) failureReason else null // WIFI_AP_STATE_FAILED diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/DhcpWorkaround.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/DhcpWorkaround.kt index 50a62c8b..4c80803e 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/DhcpWorkaround.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/DhcpWorkaround.kt @@ -6,6 +6,7 @@ import be.mygod.vpnhotspot.net.Routing.Companion.IP import be.mygod.vpnhotspot.root.RoutingCommands import be.mygod.vpnhotspot.util.RootSession import be.mygod.vpnhotspot.widget.SmartSnackbar +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import timber.log.Timber @@ -40,6 +41,7 @@ object DhcpWorkaround : SharedPreferences.OnSharedPreferenceChangeListener { SmartSnackbar.make(e).show() } } + } catch (_: CancellationException) { } catch (e: Exception) { Timber.w(e) SmartSnackbar.make(e).show() diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index 1bbfec1e..f2da99f8 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -17,6 +17,7 @@ import be.mygod.vpnhotspot.util.RootSession import be.mygod.vpnhotspot.util.if_nametoindex import be.mygod.vpnhotspot.util.parseNumericAddress import be.mygod.vpnhotspot.widget.SmartSnackbar +import kotlinx.coroutines.CancellationException import timber.log.Timber import java.io.BufferedWriter import java.io.IOException @@ -340,7 +341,9 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh currentDns?.transaction?.revert() currentDns = if (ifindex == 0 || dns == null) null else try { DnsRoute(ifindex, dns) - } catch (e: RuntimeException) { + } catch (_: CancellationException) { + null + } catch (e: Exception) { Timber.w(e) SmartSnackbar.make(e).show() null diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/preference/UpstreamsPreference.kt b/mobile/src/main/java/be/mygod/vpnhotspot/preference/UpstreamsPreference.kt index cf853730..8c739dd9 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/preference/UpstreamsPreference.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/preference/UpstreamsPreference.kt @@ -16,7 +16,6 @@ import be.mygod.vpnhotspot.net.monitor.UpstreamMonitor import be.mygod.vpnhotspot.util.SpanFormatter import be.mygod.vpnhotspot.util.parseNumericAddress import timber.log.Timber -import java.lang.RuntimeException class UpstreamsPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs), DefaultLifecycleObserver { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/RootSession.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/RootSession.kt index ccf4233a..7b38a814 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/util/RootSession.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/RootSession.kt @@ -18,7 +18,7 @@ class RootSession : AutoCloseable { monitor.lock() val instance = try { RootSession() - } catch (e: RuntimeException) { + } catch (e: Exception) { monitor.unlock() throw e } @@ -41,11 +41,6 @@ class RootSession : AutoCloseable { server!!.execute(RoutingCommands.Process(listOf("sh", "-c", command), redirect)) } fun exec(command: String) = execQuiet(command).check(listOf(command)) - fun execOut(command: String): String { - val result = execQuiet(command) - result.check(listOf(command), false) - return result.out - } /** * This transaction is different from what you may have in mind since you can revert it after committing it.