feat: compatibility by versionCode #6

Merged
Cossale merged 2 commits from feat/compatible-version-codes into main 2026-10-25 23:13:32 +00:00
Member

Summary

Patches can now pin app versions by android:versionCode, not only by version name. While adding this, I found and fixed a bug in how the engine handled versionCode.

Fix: versionCode is a signed 32-bit integer

a truncating as i32 cast:

  • setVersionCode(3_000_000_000u) silently wrote -1294967296.
  • A negative decimal code was reported as missing, while a hex code like 0xFFFFFFFF was read as 4294967295 (Android sees -1).

versionCode is now i32 from the manifest reader through to the JNI bridge and ApkMetadata.version_code.

Breaking (patch API): ManifestScope.versionCode is now Int? and setVersionCode takes Int.

component.setVersionCode(Int.MAX_VALUE)   // was Int.MAX_VALUE.toUInt()

Feature: pin versions by code

CompatiblePackage gets versionCodes: List. An APK matches when its version name or its version code is listed. With both lists empty, every version still matches.

// One version, by name or code
compatibleWith("com.example.app"("2.14.0", 214001))

// Codes only, for builds that share a version name
compatibleWith(CompatiblePackage("com.example.app", versionCodes = listOf(214001, 214002)))

// Several versions: entries for the same package add up
compatibleWith(
    "com.example.app"("2.14.0", 214001),
    "com.example.app"("2.15.0", 215003),
)
## Summary Patches can now pin app versions by `android:versionCode`, not only by version name. While adding this, I found and fixed a bug in how the engine handled versionCode. ## Fix: versionCode is a signed 32-bit integer a truncating `as i32` cast: - `setVersionCode(3_000_000_000u)` silently wrote `-1294967296`. - A negative decimal code was reported as missing, while a hex code like `0xFFFFFFFF` was read as `4294967295` (Android sees `-1`). versionCode is now `i32` from the manifest reader through to the JNI bridge and `ApkMetadata.version_code`. **Breaking (patch API):** `ManifestScope.versionCode` is now `Int?` and `setVersionCode` takes `Int`. ```kotlin component.setVersionCode(Int.MAX_VALUE) // was Int.MAX_VALUE.toUInt() ``` ## Feature: pin versions by code CompatiblePackage gets versionCodes: List<Int>. An APK matches when its version name or its version code is listed. With both lists empty, every version still matches. ```kotlin // One version, by name or code compatibleWith("com.example.app"("2.14.0", 214001)) // Codes only, for builds that share a version name compatibleWith(CompatiblePackage("com.example.app", versionCodes = listOf(214001, 214002))) // Several versions: entries for the same package add up compatibleWith( "com.example.app"("2.14.0", 214001), "com.example.app"("2.15.0", 215003), ) ```
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
reseam/reseam!6
No description provided.