Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AdbShellCommandRunner : ShellCommandRunner {
override fun runCommand(command: String) = device.shellProcessBuilder(command).start().let { process ->
object : RunResult {
override val exitCode by lazy { process.waitFor() }
override val output by lazy { process.inputStream.bufferedReader().readText() }
override val output by lazy { process.inputStream.bufferedReader().readText().removeSuffix("\n") }
override val error by lazy { process.errorStream.bufferedReader().readText() }

override fun waitFor() {
Expand All @@ -44,7 +44,7 @@ class AdbShellCommandRunner : ShellCommandRunner {
}
}

override fun hasRootPermission(): Boolean = invoke("whoami").exitCode == 0
override fun hasRootPermission(): Boolean = invoke("su -c whoami").exitCode == 0

override fun write(content: InputStream, targetFilePath: String) =
device.push(content, System.currentTimeMillis(), 644, RemoteFile(targetFilePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ abstract class ShellCommandRunner internal constructor() {
*/
internal operator fun invoke(
command: String,
) = runCommand("su -c \'$command\'")
) = runCommand(command)
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ abstract class RootInstaller internal constructor(
/**
* Runs a command on the device.
*/
protected operator fun String.invoke() = shellCommandRunner(this)
protected operator fun String.invoke() = shellCommandRunner("su -c \'$this\'")

/**
* Moves the given file to the given [targetFilePath].
Expand Down
Loading