Fix catastrophic error
This commit is contained in:
@@ -28,21 +28,23 @@ object DhcpWorkaround : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
val shouldEnable get() = app.pref.getBoolean(KEY_ENABLED, false)
|
val shouldEnable get() = app.pref.getBoolean(KEY_ENABLED, false)
|
||||||
fun enable(enabled: Boolean) = GlobalScope.launch {
|
fun enable(enabled: Boolean) = GlobalScope.launch {
|
||||||
val action = if (enabled) "add" else "del"
|
val action = if (enabled) "add" else "del"
|
||||||
RootSession.use {
|
try {
|
||||||
try {
|
RootSession.use {
|
||||||
it.exec("ip rule $action iif lo uidrange 0-0 lookup local_network priority 11000")
|
try {
|
||||||
} catch (e: RootSession.UnexpectedOutputException) {
|
it.exec("ip rule $action iif lo uidrange 0-0 lookup local_network priority 11000")
|
||||||
if (e.result.out.isEmpty() && (e.result.code == 2 || e.result.code == 254) && if (enabled) {
|
} catch (e: RootSession.UnexpectedOutputException) {
|
||||||
e.result.err.joinToString("\n") == "RTNETLINK answers: File exists"
|
if (e.result.out.isEmpty() && (e.result.code == 2 || e.result.code == 254) && if (enabled) {
|
||||||
} else {
|
e.result.err.joinToString("\n") == "RTNETLINK answers: File exists"
|
||||||
e.result.err.joinToString("\n") == "RTNETLINK answers: No such file or directory"
|
} else {
|
||||||
}) return@use
|
e.result.err.joinToString("\n") == "RTNETLINK answers: No such file or directory"
|
||||||
Timber.w(IOException("Failed to tweak dhcp workaround rule", e))
|
}) return@use
|
||||||
SmartSnackbar.make(e).show()
|
Timber.w(IOException("Failed to tweak dhcp workaround rule", e))
|
||||||
} catch (e: Exception) {
|
SmartSnackbar.make(e).show()
|
||||||
Timber.w(e)
|
}
|
||||||
SmartSnackbar.make(e).show()
|
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.w(e)
|
||||||
|
SmartSnackbar.make(e).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user