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
This commit is contained in:
Spandan Das
2023-03-03 21:20:36 +00:00
parent 7947b31a55
commit 8c9ae7ed67
18 changed files with 83 additions and 71 deletions

View File

@@ -811,7 +811,7 @@ func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberCo
// If the min_sdk_version was set then add the canonical representation of the API level to the
// snapshot.
if j.deviceProperties.Min_sdk_version != nil {
canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.ApiLevel.String())
canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.String())
p.MinSdkVersion = proptools.StringPtr(canonical)
}
@@ -1874,7 +1874,7 @@ type Import struct {
hideApexVariantFromMake bool
sdkVersion android.SdkSpec
minSdkVersion android.SdkSpec
minSdkVersion android.ApiLevel
}
var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
@@ -1891,11 +1891,11 @@ func (j *Import) SystemModules() string {
return "none"
}
func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if j.properties.Min_sdk_version != nil {
return android.SdkSpecFrom(ctx, *j.properties.Min_sdk_version)
return android.ApiLevelFrom(ctx, *j.properties.Min_sdk_version)
}
return j.SdkVersion(ctx)
return j.SdkVersion(ctx).ApiLevel
}
func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -2161,15 +2161,14 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
func (j *Import) 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)
}