feat(android): add isolated lvbu persona build and pinned asset selection

This commit is contained in:
zenord
2026-10-14 16:41:36 +08:00
parent 3371997252
commit 5a7be557d0
23 changed files with 1507 additions and 31 deletions
+28
View File
@@ -0,0 +1,28 @@
package org.json
// Bounded flat AUTH/HELLO response adapter. Outbound JSON uses production protocol.
// This does not exercise Android's JSON parser, which the APK build compiles.
class JSONObject() {
private val fields=linkedMapOf<String,Any>()
constructor(text: String):this() {
check(text.length<2048 && text.startsWith("{") && text.endsWith("}"))
val entries=Regex("\"([a-z_]+)\":(\"[a-z_]+\"|true|false|[0-9]+)").findAll(text)
entries.forEach {
val raw=it.groupValues[2]
fields[it.groupValues[1]]=when {
raw.startsWith("\"") -> raw.removeSurrounding("\"")
raw=="true" -> true
raw=="false" -> false
else -> raw.toLong()
}
}
}
fun put(key: String,value: Any): JSONObject {fields[key]=value;return this}
fun opt(key: String): Any?=fields[key]
fun optString(key: String,fallback: String=""): String=fields[key] as? String ?: fallback
fun optBoolean(key: String,fallback: Boolean=false): Boolean=fields[key] as? Boolean ?: fallback
fun optLong(key: String,fallback: Long=0): Long=(fields[key] as? Number)?.toLong() ?: fallback
override fun toString()=fields.entries.joinToString(",","{","}") { (k,v) ->
"\"$k\":"+if(v is String) "\"$v\"" else v.toString()
}
}