Make DHCP workaround global

This commit is contained in:
Mygod
2019-02-01 16:55:38 +08:00
parent 6a7a16a0c7
commit a71a3b3bb0
6 changed files with 45 additions and 25 deletions

View File

@@ -60,12 +60,12 @@ class RootSession : AutoCloseable {
val msg = StringBuilder("$command exited with ${result.code}")
if (out) result.out.forEach { msg.append("\n$it") }
if (err) result.err.forEach { msg.append("\nE $it") }
if (!result.isSuccess || out || err) throw UnexpectedOutputException(msg.toString())
if (!result.isSuccess || out || err) throw UnexpectedOutputException(msg.toString(), result)
return msg.toString()
}
}
class UnexpectedOutputException(msg: String) : RuntimeException(msg)
class UnexpectedOutputException(msg: String, val result: Shell.Result) : RuntimeException(msg)
private val shell = Shell.newInstance("su")
private val stdout = ArrayList<String>()