mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-24 02:55:48 +01:00
fix: fix running commands not running
This commit is contained in:
parent
52c3be23f2
commit
2c7fcaf4ad
@ -18,12 +18,11 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
object : Handler() {
|
||||
override fun publish(record: LogRecord) = formatter.format(record).let {
|
||||
if (record.level.intValue() > Level.INFO.intValue()) {
|
||||
System.err.write(it.toByteArray())
|
||||
} else {
|
||||
System.out.write(it.toByteArray())
|
||||
}
|
||||
override fun publish(record: LogRecord) = formatter.format(record).toByteArray().let {
|
||||
if (record.level.intValue() > Level.INFO.intValue())
|
||||
System.err.write(it)
|
||||
else
|
||||
System.out.write(it)
|
||||
}
|
||||
|
||||
override fun flush() {
|
||||
|
@ -2,17 +2,21 @@ package app.revanced.utils.adb
|
||||
|
||||
import se.vidstige.jadb.JadbDevice
|
||||
import se.vidstige.jadb.RemoteFile
|
||||
import se.vidstige.jadb.ShellProcessBuilder
|
||||
import java.io.File
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
// return the input or output stream, depending on which first returns a value
|
||||
internal fun JadbDevice.run(command: String, su: Boolean = false) = with(this.startCommand(command, su)) {
|
||||
Executors.newFixedThreadPool(2).let { service ->
|
||||
arrayOf(inputStream, errorStream).map { stream ->
|
||||
Callable { stream.bufferedReader().use { it.readLine() } }
|
||||
}.let { tasks -> service.invokeAny(tasks).also { service.shutdown() } }
|
||||
}
|
||||
|
||||
internal fun JadbDevice.buildCommand(command: String, su: Boolean = true): ShellProcessBuilder {
|
||||
if (su) return shellProcessBuilder("su -c \'$command\'")
|
||||
|
||||
val args = command.split(" ") as ArrayList<String>
|
||||
val cmd = args.removeFirst()
|
||||
|
||||
return shellProcessBuilder(cmd, *args.toTypedArray())
|
||||
}
|
||||
|
||||
internal fun JadbDevice.run(command: String, su: Boolean = true): Int {
|
||||
return this.buildCommand(command, su).start().waitFor()
|
||||
}
|
||||
|
||||
internal fun JadbDevice.hasSu() =
|
||||
|
@ -24,7 +24,7 @@ internal object Constants {
|
||||
|
||||
internal const val INSTALL_MOUNT = "mv $TMP_PATH $MOUNT_PATH && chmod +x $MOUNT_PATH"
|
||||
|
||||
internal const val MOUNT_SCRIPT =
|
||||
internal val MOUNT_SCRIPT =
|
||||
"""
|
||||
#!/system/bin/sh
|
||||
MAGISKTMP="${'$'}(magisk --path)" || MAGISKTMP=/sbin
|
||||
@ -36,5 +36,5 @@ internal object Constants {
|
||||
|
||||
chcon u:object_r:apk_data_file:s0 ${'$'}base_path
|
||||
mount -o bind ${'$'}MIRROR${'$'}base_path ${'$'}stock_path
|
||||
"""
|
||||
""".trimIndent()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user