fix: lspatch metadata decode crash

Co-Authored-By: o0kam1 <duzhaokun2@outlook.com>
This commit is contained in:
NkBe 2025-08-18 13:36:07 +08:00
parent b4d1726708
commit 155a76a43e
No known key found for this signature in database
GPG Key ID: 75EF144ED8F4D7B8
2 changed files with 10 additions and 7 deletions

View File

@ -51,10 +51,10 @@ val verCode by extra(commitCount)
val verName by extra("0.7.1") val verName by extra("0.7.1")
val coreVerCode by extra(coreCommitCount) val coreVerCode by extra(coreCommitCount)
val coreVerName by extra(coreLatestTag) val coreVerName by extra(coreLatestTag)
val androidMinSdkVersion by extra(28) val androidMinSdkVersion by extra(27)
val androidTargetSdkVersion by extra(36) val androidTargetSdkVersion by extra(36)
val androidCompileSdkVersion by extra(36) val androidCompileSdkVersion by extra(36)
val androidCompileNdkVersion by extra("29.0.13113456") val androidCompileNdkVersion by extra("29.0.13846066")
val androidBuildToolsVersion by extra("36.0.0") val androidBuildToolsVersion by extra("36.0.0")
val androidSourceCompatibility by extra(JavaVersion.VERSION_21) val androidSourceCompatibility by extra(JavaVersion.VERSION_21)
val androidTargetCompatibility by extra(JavaVersion.VERSION_21) val androidTargetCompatibility by extra(JavaVersion.VERSION_21)

View File

@ -40,11 +40,14 @@ class AppManageViewModel : ViewModel() {
val appList: List<Pair<AppInfo, PatchConfig>> by derivedStateOf { val appList: List<Pair<AppInfo, PatchConfig>> by derivedStateOf {
LSPPackageManager.appList.mapNotNull { appInfo -> LSPPackageManager.appList.mapNotNull { appInfo ->
appInfo.app.metaData?.getString("lspatch")?.let { runCatching {
val json = Base64.decode(it, Base64.DEFAULT).toString(Charsets.UTF_8) appInfo.app.metaData?.getString("lspatch")?.let {
Log.d(TAG, "Read patched config: $json") val json = Base64.decode(it, Base64.DEFAULT).toString(Charsets.UTF_8)
appInfo to Gson().fromJson(json, PatchConfig::class.java) Log.d(TAG, "Read patched config: $json")
} val config = Gson().fromJson(json, PatchConfig::class.java)
if (config?.lspConfig == null) null else appInfo to config
}
}.getOrNull()
}.also { }.also {
Log.d(TAG, "Loaded ${it.size} patched apps") Log.d(TAG, "Loaded ${it.size} patched apps")
} }