Refine DhcpWorkaround error processing

This commit is contained in:
Mygod
2019-02-02 02:54:36 +08:00
parent 25450fdc30
commit 74696ceba3

View File

@@ -28,10 +28,9 @@ object DhcpWorkaround : SharedPreferences.OnSharedPreferenceChangeListener {
try { try {
RootSession.use { it.exec("ip rule $action iif lo uidrange 0-0 lookup local_network priority 11000") } RootSession.use { it.exec("ip rule $action iif lo uidrange 0-0 lookup local_network priority 11000") }
} catch (e: RootSession.UnexpectedOutputException) { } catch (e: RootSession.UnexpectedOutputException) {
if (e.result.out.isEmpty() && if (enabled) { if (e.result.out.isEmpty() && (e.result.code == 2 || e.result.code == 254) && if (enabled) {
e.result.code == 2 && e.result.err.joinToString("\n") == "RTNETLINK answers: File exists" e.result.err.joinToString("\n") == "RTNETLINK answers: File exists"
} else { } else {
e.result.code == 254 &&
e.result.err.joinToString("\n") == "RTNETLINK answers: No such file or directory" e.result.err.joinToString("\n") == "RTNETLINK answers: No such file or directory"
}) return }) return
Timber.w(e) Timber.w(e)