Skip to content

Commit d8464b7

Browse files
committed
Upload file
1 parent afc17dc commit d8464b7

4 files changed

Lines changed: 11 additions & 283 deletions

File tree

568 Bytes
Binary file not shown.

pio/src/main/assets/root/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
exec $ETC/boot.rc 2>&1 | tee $TEMP/boot.log
1+
exec $ETC/boot.rc

pio/src/main/java/com/projectkr/shell/SplashActivity.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,10 @@ class SplashActivity : AppCompatActivity() {
196196
}
197197

198198
private fun runBeforeStartSh(config: KrScriptConfig, hasRoot: Boolean) {
199+
// Coroutine IO
199200
lifecycleScope.launch(Dispatchers.IO) {
200201
try {
201-
val process = if (hasRoot)
202-
ShellExecutor.getSuperUserRuntime()
203-
else
204-
ShellExecutor.getRuntime()
202+
val process = if (hasRoot) ShellExecutor.getSuperUserRuntime() else ShellExecutor.getRuntime()
205203
process?.let {
206204
DataOutputStream(it.outputStream).use { os ->
207205
ScriptEnvironmen.executeShell(
@@ -213,11 +211,17 @@ class SplashActivity : AppCompatActivity() {
213211
"pio-splash"
214212
)
215213
}
214+
215+
// Đọc stdout và stderr bằng coroutine con
216+
launch { readStreamAsync(it.inputStream.bufferedReader()) }
217+
launch { readStreamAsync(it.errorStream.bufferedReader()) }
218+
219+
it.waitFor()
216220
}
217-
} catch (_: Exception) {
221+
} finally {
222+
withContext(Dispatchers.Main) { gotoHome() }
218223
}
219224
}
220-
gotoHome()
221225
}
222226

223227
// Buffer lưu 4 dòng cuối

pio/src/main/java/com/projectkr/shell/SplashActivity.kt.bak

Lines changed: 0 additions & 276 deletions
This file was deleted.

0 commit comments

Comments
 (0)