Update min_sdk_version from SdkSpec to ApiLevel
This relands aosp/2457063. The original change broke T and U since those
branches still contain soong modules of type (kind+level). Those soong
modules have been cleaned up now
Test: Used go/abtd to test T and U branches with this change
Bug: 208456999
Change-Id: I0ef7933c055f88cb512a02108f1173e51156ef1c
diff --git a/java/base.go b/java/base.go
index 7e95abd..a3f6e3c 100644
--- a/java/base.go
+++ b/java/base.go
@@ -489,7 +489,7 @@
hideApexVariantFromMake bool
sdkVersion android.SdkSpec
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
maxSdkVersion android.SdkSpec
sourceExtensions []string
@@ -665,11 +665,11 @@
return proptools.String(j.deviceProperties.System_modules)
}
-func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if j.deviceProperties.Min_sdk_version != nil {
- return android.SdkSpecFrom(ctx, *j.deviceProperties.Min_sdk_version)
+ return android.ApiLevelFrom(ctx, *j.deviceProperties.Min_sdk_version)
}
- return j.SdkVersion(ctx)
+ return j.SdkVersion(ctx).ApiLevel
}
func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -685,7 +685,7 @@
}
func (j *Module) MinSdkVersionString() string {
- return j.minSdkVersion.Raw
+ return j.minSdkVersion.String()
}
func (j *Module) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -881,7 +881,7 @@
j.ignoredAidlPermissionList = android.PathsForModuleSrcExcludes(ctx, exceptions, nil)
}
- aidlMinSdkVersion := j.MinSdkVersion(ctx).ApiLevel.String()
+ aidlMinSdkVersion := j.MinSdkVersion(ctx).String()
flags = append(flags, "--min_sdk_version="+aidlMinSdkVersion)
return strings.Join(flags, " "), deps
@@ -1542,9 +1542,9 @@
}
if ctx.Device() {
- lintSDKVersion := func(sdkSpec android.SdkSpec) int {
- if v := sdkSpec.ApiLevel; !v.IsPreview() {
- return v.FinalInt()
+ lintSDKVersion := func(apiLevel android.ApiLevel) int {
+ if !apiLevel.IsPreview() {
+ return apiLevel.FinalInt()
} else {
// When running metalava, we pass --version-codename. When that value
// is not REL, metalava will add 1 to the --current-version argument.
@@ -1575,8 +1575,8 @@
j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...)
j.linter.classes = j.implementationJarFile
j.linter.minSdkVersion = lintSDKVersion(j.MinSdkVersion(ctx))
- j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx))
- j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx))
+ j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx).ApiLevel)
+ j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx).ApiLevel)
j.linter.compileSdkKind = j.SdkVersion(ctx).Kind
j.linter.javaLanguageLevel = flags.javaVersion.String()
j.linter.kotlinLanguageLevel = "1.3"
@@ -1846,15 +1846,14 @@
// Implements android.ApexModule
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
sdkVersionSpec := j.SdkVersion(ctx)
- minSdkVersionSpec := j.MinSdkVersion(ctx)
- if !minSdkVersionSpec.Specified() {
+ minSdkVersion := j.MinSdkVersion(ctx)
+ if !minSdkVersion.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
// If the module is compiling against core (via sdk_version), skip comparison check.
if sdkVersionSpec.Kind == android.SdkCore {
return nil
}
- minSdkVersion := minSdkVersionSpec.ApiLevel
if minSdkVersion.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
}