From fa24a615ab9fb130279d5a97829ecd2f868db419 Mon Sep 17 00:00:00 2001 From: nift4 Date: Thu, 1 Aug 2024 10:31:55 +0200 Subject: [PATCH] add min app version field --- app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt | 5 ++++- app/src/main/java/org/andbootmgr/app/DeviceInfo.kt | 2 ++ app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt b/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt index 8aeb075f..0d9c0b0a 100644 --- a/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt +++ b/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt @@ -357,7 +357,10 @@ private fun Shop(c: CreatePartDataHolder) { } catch (e: FileNotFoundException) { URL("https://raw.githubusercontent.com/Android-Boot-Manager/ABM-json/master/devices/" + c.vm.codename + ".json").readText() } - json = JSONTokener(jsonText).nextValue() as JSONObject + val jjson = JSONTokener(jsonText).nextValue() as JSONObject + if (BuildConfig.VERSION_CODE < jjson.getInt("minAppVersion")) + throw IllegalStateException("please upgrade app") + json = jjson //Log.i("ABM shop:", jsonText) } catch (e: Exception) { Log.e("ABM shop", Log.getStackTraceString(e)) diff --git a/app/src/main/java/org/andbootmgr/app/DeviceInfo.kt b/app/src/main/java/org/andbootmgr/app/DeviceInfo.kt index 5e52dca6..31c0da32 100644 --- a/app/src/main/java/org/andbootmgr/app/DeviceInfo.kt +++ b/app/src/main/java/org/andbootmgr/app/DeviceInfo.kt @@ -95,6 +95,8 @@ class JsonDeviceInfoFactory(private val ctx: Context) { } val jsonRoot = JSONTokener(jsonText).nextValue() as JSONObject? ?: return null val json = jsonRoot.getJSONObject("deviceInfo") + if (BuildConfig.VERSION_CODE < json.getInt("minAppVersion")) + throw IllegalStateException("please upgrade app") if (fromNet) { val newRoot = JSONObject() newRoot.put("deviceInfo", json) diff --git a/app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt b/app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt index 12d6d80f..1cc44e5f 100644 --- a/app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt +++ b/app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt @@ -148,6 +148,8 @@ fun SelectDroidBoot(vm: WizardActivityState) { val jsonText = URL("https://raw.githubusercontent.com/Android-Boot-Manager/ABM-json/master/devices/" + vm.codename + ".json").readText() val json = JSONTokener(jsonText).nextValue() as JSONObject + if (BuildConfig.VERSION_CODE < json.getInt("minAppVersion")) + throw IllegalStateException("please upgrade app") val bl = json.getJSONObject("bootloader") val url = bl.getString("url") val sha = if (bl.has("sha256")) bl.getString("sha256") else null @@ -197,6 +199,8 @@ fun SelectInstallSh(vm: WizardActivityState) { val jsonText = URL("https://raw.githubusercontent.com/Android-Boot-Manager/ABM-json/master/devices/" + vm.codename + ".json").readText() val json = JSONTokener(jsonText).nextValue() as JSONObject + if (BuildConfig.VERSION_CODE < json.getInt("minAppVersion")) + throw IllegalStateException("please upgrade app") val i = json.getJSONObject("installScript") val url = i.getString("url") val sha = if (i.has("sha256")) i.getString("sha256") else null