Skip to content

Commit 1308269

Browse files
committed
DroidBootFlow: Use abm.json if exists
1 parent 9c7b876 commit 1308269

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.compose.runtime.remember
1919
import androidx.compose.runtime.setValue
2020
import androidx.compose.ui.Alignment
2121
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.platform.LocalContext
2223
import androidx.compose.ui.res.stringResource
2324
import androidx.compose.ui.text.style.TextAlign
2425
import androidx.compose.ui.unit.dp
@@ -34,6 +35,7 @@ import org.andbootmgr.app.util.SDUtils
3435
import org.json.JSONObject
3536
import org.json.JSONTokener
3637
import java.io.File
38+
import java.io.FileNotFoundException
3739
import java.io.IOException
3840
import java.net.URL
3941

@@ -93,12 +95,17 @@ private fun Start(vm: WizardState) {
9395
fun LoadDroidBootJson(vm: WizardState, update: Boolean, content: @Composable () -> Unit) {
9496
var loading by remember { mutableStateOf(!vm.deviceInfo.isBooted(vm.logic) || vm.deviceInfo.postInstallScript || update) }
9597
var error by remember { mutableStateOf(false) }
98+
val ctx = LocalContext.current
9699
LaunchedEffect(Unit) {
97100
if (!loading) return@LaunchedEffect
98101
CoroutineScope(Dispatchers.IO).launch {
99102
try {
100-
val jsonText =
101-
URL("https://raw.githubusercontent.com/Android-Boot-Manager/ABM-json/master/devices/" + vm.codename + ".json").readText()
103+
val jsonText = try {
104+
ctx.assets.open("abm.json").readBytes().toString(Charsets.UTF_8)
105+
} catch (e: FileNotFoundException) {
106+
URL("https://raw.githubusercontent.com/Android-Boot-Manager/ABM-json/master/devices/" + vm.codename + ".json").readText()
107+
}
108+
102109
val json = JSONTokener(jsonText).nextValue() as JSONObject
103110
if (BuildConfig.VERSION_CODE < json.getInt("minAppVersion"))
104111
throw IllegalStateException("please upgrade app")

0 commit comments

Comments
 (0)