add variant_version property to apexBundle

This property allows modifying the variant version that is put into the
APEX manifest.

Bug: 285138555
Change-Id: I42b8c0ddad8822a0a329e99ec4ec62f8c3546ee9
This commit is contained in:
Sam Delmerico
2023-06-05 15:55:57 -04:00
parent ca81653730
commit 6d65a0fc3d
3 changed files with 102 additions and 0 deletions

View File

@@ -275,6 +275,22 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs,
manifestJsonFullOut := android.PathForModuleOut(ctx, "apex_manifest_full.json")
defaultVersion := android.DefaultUpdatableModuleVersion
if a.properties.Variant_version != nil {
defaultVersionInt, err := strconv.Atoi(defaultVersion)
if err != nil {
ctx.ModuleErrorf("expected DefaultUpdatableModuleVersion to be an int, but got %s", defaultVersion)
}
if defaultVersionInt%10 != 0 {
ctx.ModuleErrorf("expected DefaultUpdatableModuleVersion to end in a zero, but got %s", defaultVersion)
}
variantVersion := []rune(*a.properties.Variant_version)
if len(variantVersion) != 1 || variantVersion[0] < '0' || variantVersion[0] > '9' {
ctx.PropertyErrorf("variant_version", "expected an integer between 0-9; got %s", *a.properties.Variant_version)
}
defaultVersionRunes := []rune(defaultVersion)
defaultVersionRunes[len(defaultVersion)-1] = []rune(variantVersion)[0]
defaultVersion = string(defaultVersionRunes)
}
if override := ctx.Config().Getenv("OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION"); override != "" {
defaultVersion = override
}