Redirect error stream
This commit is contained in:
@@ -2,7 +2,6 @@ package be.mygod.vpnhotspot.util
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.R
|
|
||||||
import com.crashlytics.android.Crashlytics
|
import com.crashlytics.android.Crashlytics
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
@@ -16,20 +15,13 @@ fun loggerSuStream(command: String): InputStream? {
|
|||||||
val process = try {
|
val process = try {
|
||||||
ProcessBuilder("su", "-c", command)
|
ProcessBuilder("su", "-c", command)
|
||||||
.directory(app.deviceContext.cacheDir)
|
.directory(app.deviceContext.cacheDir)
|
||||||
|
.redirectErrorStream(true)
|
||||||
.start()
|
.start()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
Crashlytics.logException(e)
|
Crashlytics.logException(e)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
thread("LoggerSU-error") {
|
|
||||||
val err = process.errorStream.bufferedReader().readText()
|
|
||||||
if (err.isNotBlank()) {
|
|
||||||
Crashlytics.log(Log.ERROR, NOISYSU_TAG, err)
|
|
||||||
Crashlytics.logException(SuFailure())
|
|
||||||
app.toast(R.string.noisy_su_failure)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return process.inputStream
|
return process.inputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user