Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Jan 18, 2025
1 parent ec229f9 commit 172c9bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/src/main/java/org/andbootmgr/app/util/Terminal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import com.topjohnwu.superuser.io.SuFileOutputStream
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -25,10 +26,10 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.andbootmgr.app.R
import java.io.File
import java.io.FileOutputStream
import java.io.OutputStream

private class BudgetCallbackList(private val scope: CoroutineScope,
private val log: FileOutputStream?)
private val log: OutputStream?)
: MutableList<String>, TerminalList {
override var isCancelled by mutableStateOf<Boolean?>(null)
override var cancel: (() -> Unit)? = null
Expand Down Expand Up @@ -171,13 +172,13 @@ fun TerminalWork(logFile: String? = null, action: suspend (TerminalList) -> Unit
val ctx = LocalContext.current.applicationContext
LaunchedEffect(Unit) {
val logDispatcher = Dispatchers.IO.limitedParallelism(1)
val log = logFile?.let { FileOutputStream(File(ctx.externalCacheDir, it)) }
val log = logFile?.let { SuFileOutputStream.open(File(ctx.externalCacheDir, it)) }
val s = BudgetCallbackList(CoroutineScope(logDispatcher), log)
StayAliveConnection(ctx, {
withContext(Dispatchers.Default) {
try {
action(s)
} catch (e: TerminalCancelException) {
} catch (_: TerminalCancelException) {
s.add(ctx.getString(R.string.install_canceled))
} catch (e: Throwable) {
s.add(ctx.getString(R.string.term_failure))
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<string name="connecting_text">(Connecting…)</string>
<string name="downloading">Downloading…</string>
<string name="downloading_s">Downloading %s…</string>
<string name="provide_images">Please now provide images for all required IDs. You can use the recommended ones using the \"Download\" button!</string>
<string name="provide_images">If you have already downloaded some files, you can select to use them here. Otherwise, the app will download all files it requires for you when you press \"Install\".</string>
<string name="user_selected">User-selected</string>
<string name="undo">Undo</string>
<string name="download_progress">%s of %s downloaded</string>
Expand Down

0 comments on commit 172c9bb

Please sign in to comment.