Merge "apex: checks min_sdk_version for preview/current" am: 99afe0d442 am: 3f4cc86f15 am: 2ebe689bbf

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1557545

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I24256763c59562e7f878ff86dd637803ad081168
This commit is contained in:
Treehugger Robot
2021-01-28 14:57:42 +00:00
committed by Automerger Merge Worker
5 changed files with 83 additions and 10 deletions

View File

@@ -854,11 +854,17 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
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) checkMinSdkVersion(ctx android.ModuleContext) {
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
}