Skip to content

Commit

Permalink
add min app version field
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 1, 2024
1 parent 36f0211 commit fa24a61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/andbootmgr/app/DeviceInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/andbootmgr/app/DroidBootFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fa24a61

Please sign in to comment.