Fix catastrophic error

This commit is contained in:
Mygod
2019-09-19 12:29:04 +08:00
parent 56a2c8bb4b
commit d6da72e43c

View File

@@ -28,6 +28,7 @@ object DhcpWorkaround : SharedPreferences.OnSharedPreferenceChangeListener {
val shouldEnable get() = app.pref.getBoolean(KEY_ENABLED, false)
fun enable(enabled: Boolean) = GlobalScope.launch {
val action = if (enabled) "add" else "del"
try {
RootSession.use {
try {
it.exec("ip rule $action iif lo uidrange 0-0 lookup local_network priority 11000")
@@ -39,12 +40,13 @@ object DhcpWorkaround : SharedPreferences.OnSharedPreferenceChangeListener {
}) return@use
Timber.w(IOException("Failed to tweak dhcp workaround rule", e))
SmartSnackbar.make(e).show()
}
}
} catch (e: Exception) {
Timber.w(e)
SmartSnackbar.make(e).show()
}
}
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == KEY_ENABLED) enable(shouldEnable)