Refine code style
This commit is contained in:
@@ -102,8 +102,8 @@ class ProcessListener(private val terminateRegex: Regex,
|
||||
try {
|
||||
launch(parent) {
|
||||
try {
|
||||
process.inputStream.bufferedReader().useLines {
|
||||
for (line in it) {
|
||||
process.inputStream.bufferedReader().useLines { lines ->
|
||||
for (line in lines) {
|
||||
trySend(ProcessData.StdoutLine(line)).onClosed { return@useLines }.onFailure { throw it!! }
|
||||
if (terminateRegex.containsMatchIn(line)) process.destroy()
|
||||
}
|
||||
@@ -112,8 +112,8 @@ class ProcessListener(private val terminateRegex: Regex,
|
||||
}
|
||||
launch(parent) {
|
||||
try {
|
||||
process.errorStream.bufferedReader().useLines {
|
||||
for (line in it) trySend(ProcessData.StdoutLine(line)).onClosed {
|
||||
process.errorStream.bufferedReader().useLines { lines ->
|
||||
for (line in lines) trySend(ProcessData.StdoutLine(line)).onClosed {
|
||||
return@useLines
|
||||
}.onFailure { throw it!! }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package be.mygod.vpnhotspot.root
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import be.mygod.librootkotlinx.*
|
||||
@@ -13,6 +14,7 @@ object RootManager : RootSession(), Logger {
|
||||
class RootInit : RootCommandNoResult {
|
||||
override suspend fun execute(): Parcelable? {
|
||||
Timber.plant(object : Timber.DebugTree() {
|
||||
@SuppressLint("LogNotTimber")
|
||||
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
|
||||
if (priority >= Log.WARN) {
|
||||
System.err.println("$priority/$tag: $message")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package be.mygod.vpnhotspot.root
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import be.mygod.librootkotlinx.RootCommand
|
||||
import be.mygod.librootkotlinx.RootCommandOneWay
|
||||
import be.mygod.vpnhotspot.net.Routing
|
||||
@@ -10,6 +9,7 @@ import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import timber.log.Timber
|
||||
|
||||
object RoutingCommands {
|
||||
@Parcelize
|
||||
@@ -20,7 +20,7 @@ object RoutingCommands {
|
||||
process.outputStream.bufferedWriter().use(Routing.Companion::appendCleanCommands)
|
||||
when (val code = process.waitFor()) {
|
||||
0 -> { }
|
||||
else -> Log.d("RoutingCommands.Clean", "Unexpected exit code $code")
|
||||
else -> Timber.w("Unexpected exit code $code")
|
||||
}
|
||||
check(process.waitFor() == 0)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package be.mygod.vpnhotspot.root
|
||||
|
||||
import android.net.MacAddress
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.RequiresApi
|
||||
import be.mygod.librootkotlinx.ParcelableBoolean
|
||||
@@ -58,7 +57,7 @@ object WifiApCommands {
|
||||
@Parcelize
|
||||
@RequiresApi(28)
|
||||
class RegisterSoftApCallback : RootCommandChannel<SoftApCallbackParcel> {
|
||||
override fun create(scope: CoroutineScope) = scope.produce<SoftApCallbackParcel>(capacity = capacity) {
|
||||
override fun create(scope: CoroutineScope) = scope.produce(capacity = capacity) {
|
||||
val finish = CompletableDeferred<Unit>()
|
||||
val key = WifiApManager.registerSoftApCallback(object : WifiApManager.SoftApCallbackCompat {
|
||||
private fun push(parcel: SoftApCallbackParcel) {
|
||||
|
||||
Reference in New Issue
Block a user