Move SSD package version selection to typed Kotlin
ober
0a981c40d3a8d1473130e7cf9dd85b08ee2b42fd
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -4695,6 +4695,7 @@ (typed-library (com sfb ssdreview) (export clientLogPayloadJson clientLogCrashFields clientLogFallbackPayload appLogPackageInfo appLogVersionInfo + androidPackageVersionCode deviceLogInfoJson throwableLogJson statusLogFields truncateClientLogStack) (type JSONObject) @@ -4758,6 +4759,11 @@ (json-object-put-string! out "version-name" versionName) (json-object-put-int! out "version-code" versionCode) out))) + (def (androidPackageVersionCode (sdk : Int32) + (apiP : Int32) + (longVersionCode : Int) + (legacyVersionCode : Int)) : Int + (if (>= sdk apiP) longVersionCode legacyVersionCode)) (def (deviceLogInfoJson (sdk : Int32) (release : String) (manufacturer : String) @@ -6821,10 +6827,9 @@ " val out = appLogPackageInfo(packageName)" " return try {" " val info = packageManager.getPackageInfo(packageName, 0)" - " val versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) info.longVersionCode else {" - " @Suppress(\"DEPRECATION\")" - " info.versionCode.toLong()" - " }" + " @Suppress(\"DEPRECATION\")" + " val legacyVersionCode = info.versionCode.toLong()" + " val versionCode = androidPackageVersionCode(Build.VERSION.SDK_INT, Build.VERSION_CODES.P, info.longVersionCode, legacyVersionCode)" " appLogVersionInfo(packageName, info.versionName ?: \"\", versionCode)" " } catch (_: Exception) { out }" " }"