SdkSpec is fully using ApiLevel
Previously, SdkSpec was constructed only from the user string. It didn't
make use of the Config struct where information about the latest stable
SDK version, etc. is recorded. As a result, the build system couldn't
check if the sdk version "current" is referring to the in-development
(i.e. not-yet-frozen) SDK version or the latest stable version.
"current" was always assumed to be in-development (IsPreview() returns
true) even when Platform_sdk_final == true.
As the first step for fixing that, this change requires
android.EarlyModuleContext to be passed when constructing SdkSpec from
the user string.
In the following changes, "current" will be mapped to either
FutureApiLevel (10000) or one of the FinalApiLevels() depending on
whether the platform SDK was finalized or not.
Bug: 175678607
Test: m
Change-Id: Ifea12ebf147ecccf12e7266dd382819806571543
diff --git a/java/aar.go b/java/aar.go
index a122a94..04727e4 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -218,7 +218,7 @@
linkDeps = append(linkDeps, assetDeps...)
// SDK version flags
- minSdkVersion, err := sdkContext.MinSdkVersion().EffectiveVersionString(ctx)
+ minSdkVersion, err := sdkContext.MinSdkVersion(ctx).EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}
@@ -609,6 +609,9 @@
hideApexVariantFromMake bool
aarPath android.Path
+
+ sdkVersion android.SdkSpec
+ minSdkVersion android.SdkSpec
}
var _ android.OutputFileProducer = (*AARImport)(nil)
@@ -625,23 +628,23 @@
}
}
-func (a *AARImport) SdkVersion() android.SdkSpec {
- return android.SdkSpecFrom(String(a.properties.Sdk_version))
+func (a *AARImport) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+ return android.SdkSpecFrom(ctx, String(a.properties.Sdk_version))
}
func (a *AARImport) SystemModules() string {
return ""
}
-func (a *AARImport) MinSdkVersion() android.SdkSpec {
+func (a *AARImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
if a.properties.Min_sdk_version != nil {
- return android.SdkSpecFrom(*a.properties.Min_sdk_version)
+ return android.SdkSpecFrom(ctx, *a.properties.Min_sdk_version)
}
- return a.SdkVersion()
+ return a.SdkVersion(ctx)
}
-func (a *AARImport) TargetSdkVersion() android.SdkSpec {
- return a.SdkVersion()
+func (a *AARImport) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+ return a.SdkVersion(ctx)
}
func (a *AARImport) javaVersion() string {
@@ -727,6 +730,9 @@
return
}
+ a.sdkVersion = a.SdkVersion(ctx)
+ a.minSdkVersion = a.MinSdkVersion(ctx)
+
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
aarName := ctx.ModuleName() + ".aar"