File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- exec $ETC /boot.rc 2>&1 | tee $TEMP /boot.log
1+ exec $ETC /boot.rc
Original file line number Diff line number Diff 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
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments