apex: checks min_sdk_version for preview/current
If we don't check "current", it won't be checked even in the finalized
branch.
If we don't check "preview", it should be done during the SDK
finalization. It'd be better done before the SDK finalization regarding
that setting min_sdk_version is to get approval from deps library owners.
Bug: 177833148
Test: m (soong tests)
Change-Id: I712b61cfe5a134fbb69c73956d26fb3a1e5c011e
diff --git a/apex/apex.go b/apex/apex.go
index 384d6c7..ade8fa9 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -854,11 +854,17 @@
Contents: apexContents,
})
+ minSdkVersion := a.minSdkVersion(mctx)
+ // When min_sdk_version is not set, the apex is built against FutureApiLevel.
+ if minSdkVersion.IsNone() {
+ minSdkVersion = android.FutureApiLevel
+ }
+
// This is the main part of this mutator. Mark the collected dependencies that they need to
// be built for this apexBundle.
apexInfo := android.ApexInfo{
ApexVariationName: mctx.ModuleName(),
- MinSdkVersionStr: a.minSdkVersion(mctx).String(),
+ MinSdkVersionStr: minSdkVersion.String(),
RequiredSdks: a.RequiredSdks(),
Updatable: a.Updatable(),
InApexes: []string{mctx.ModuleName()},
@@ -2116,17 +2122,13 @@
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
ver := proptools.String(a.properties.Min_sdk_version)
if ver == "" {
- return android.FutureApiLevel
+ return android.NoneApiLevel
}
apiLevel, err := android.ApiLevelFromUser(ctx, ver)
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
return android.NoneApiLevel
}
- if apiLevel.IsPreview() {
- // All codenames should build against "current".
- return android.FutureApiLevel
- }
return apiLevel
}