File tree 3 files changed +21
-18
lines changed
src/main/kotlin/app/revanced
3 files changed +21
-18
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,11 @@ fun main(args: Array<String>) {
18
18
}
19
19
20
20
object : Handler () {
21
- override fun publish (record : LogRecord ) = formatter.format(record).let {
22
- if (record.level.intValue() > Level .INFO .intValue()) {
23
- System .err.write(it.toByteArray())
24
- } else {
25
- System .out .write(it.toByteArray())
26
- }
21
+ override fun publish (record : LogRecord ) = formatter.format(record).toByteArray().let {
22
+ if (record.level.intValue() > Level .INFO .intValue())
23
+ System .err.write(it)
24
+ else
25
+ System .out .write(it)
27
26
}
28
27
29
28
override fun flush () {
Original file line number Diff line number Diff line change @@ -2,17 +2,21 @@ package app.revanced.utils.adb
2
2
3
3
import se.vidstige.jadb.JadbDevice
4
4
import se.vidstige.jadb.RemoteFile
5
+ import se.vidstige.jadb.ShellProcessBuilder
5
6
import java.io.File
6
- import java.util.concurrent.Callable
7
- import java.util.concurrent.Executors
8
-
9
- // return the input or output stream, depending on which first returns a value
10
- internal fun JadbDevice.run (command : String , su : Boolean = false) = with (this .startCommand(command, su)) {
11
- Executors .newFixedThreadPool(2 ).let { service ->
12
- arrayOf(inputStream, errorStream).map { stream ->
13
- Callable { stream.bufferedReader().use { it.readLine() } }
14
- }.let { tasks -> service.invokeAny(tasks).also { service.shutdown() } }
15
- }
7
+
8
+
9
+ internal fun JadbDevice.buildCommand (command : String , su : Boolean = true): ShellProcessBuilder {
10
+ if (su) return shellProcessBuilder(" su -c \' $command \' " )
11
+
12
+ val args = command.split(" " ) as ArrayList <String >
13
+ val cmd = args.removeFirst()
14
+
15
+ return shellProcessBuilder(cmd, * args.toTypedArray())
16
+ }
17
+
18
+ internal fun JadbDevice.run (command : String , su : Boolean = true): Int {
19
+ return this .buildCommand(command, su).start().waitFor()
16
20
}
17
21
18
22
internal fun JadbDevice.hasSu () =
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ internal object Constants {
24
24
25
25
internal const val INSTALL_MOUNT = " mv $TMP_PATH $MOUNT_PATH && chmod +x $MOUNT_PATH "
26
26
27
- internal const val MOUNT_SCRIPT =
27
+ internal val MOUNT_SCRIPT =
28
28
"""
29
29
#!/system/bin/sh
30
30
MAGISKTMP="${' $' } (magisk --path)" || MAGISKTMP=/sbin
@@ -36,5 +36,5 @@ internal object Constants {
36
36
37
37
chcon u:object_r:apk_data_file:s0 ${' $' } base_path
38
38
mount -o bind ${' $' } MIRROR${' $' } base_path ${' $' } stock_path
39
- """
39
+ """ .trimIndent()
40
40
}
You can’t perform that action at this time.
0 commit comments