Update usages of min_sdk_version that relies on (kind+level)

The type of min_sdk_version is being migrated from
android.SdkSpec(kind+level) to android.ApiLevel(level). This affects
`ShouldSupportSdkVersion` for java modules. This function skips the
check for modules compiling against `core`, and that requires access to
SdkVersion and not MinSdkVersion after the migration.

Skip the check explicitly using SdkVersion.

Test: go test ./java
Test: No change in ninja file
Bug: 208456999
Change-Id: I14eca4f8e8c5d7477ded00c4fe54097323fab4a2
This commit is contained in:
Spandan Das
2023-02-24 18:38:56 +00:00
parent 50885c0524
commit 7fa982c0ec
3 changed files with 44 additions and 10 deletions

View File

@@ -2166,15 +2166,18 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
// Implements android.ApexModule
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
sdkVersion android.ApiLevel) error {
sdkSpec := j.MinSdkVersion(ctx)
if !sdkSpec.Specified() {
sdkVersionSpec := j.SdkVersion(ctx)
minSdkVersionSpec := j.MinSdkVersion(ctx)
if !minSdkVersionSpec.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
if sdkSpec.Kind == android.SdkCore {
// If the module is compiling against core (via sdk_version), skip comparison check.
if sdkVersionSpec.Kind == android.SdkCore {
return nil
}
if sdkSpec.ApiLevel.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel)
minSdkVersion := minSdkVersionSpec.ApiLevel
if minSdkVersion.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
}
return nil
}