Perform CheckMinSdkVersion for java_sdk_library.

In a follow up, apex would expect that any module that implements
ModuleWithMinSdkVersionCheck to have performed appropate checks on
min_sdk_version, to allow relaxing some of the existing conditions.

This change moves the responsibility of checking min_sdk_version
of java_sdk_library to java_sdk_library itself.

Bug: 205923322
Test: presubmit
Change-Id: I79b5a1fc34098fff60221e416db6e6e69e01f531
This commit is contained in:
satayev
2021-12-06 11:40:46 +00:00
parent ad99149a62
commit 8f088b09d8
2 changed files with 104 additions and 2 deletions

View File

@@ -1129,6 +1129,20 @@ func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext)
return generatedScopes
}
func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) {
android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx).ApiLevel, func(c android.ModuleContext, do android.PayloadDepsCallback) {
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
isExternal := !module.depIsInSameApex(ctx, child)
if am, ok := child.(android.ApexModule); ok {
if !do(ctx, parent, am, isExternal) {
return false
}
}
return !isExternal
})
})
}
type sdkLibraryComponentTag struct {
blueprint.BaseDependencyTag
name string
@@ -1214,6 +1228,10 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
}
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if proptools.String(module.deviceProperties.Min_sdk_version) != "" {
module.CheckMinSdkVersion(ctx)
}
module.generateCommonBuildActions(ctx)
// Only build an implementation library if required.
@@ -2605,12 +2623,12 @@ func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleConte
func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries {
if module.hideApexVariantFromMake {
return []android.AndroidMkEntries{android.AndroidMkEntries{
return []android.AndroidMkEntries{{
Disabled: true,
}}
}
return []android.AndroidMkEntries{android.AndroidMkEntries{
return []android.AndroidMkEntries{{
Class: "ETC",
OutputFile: android.OptionalPathForPath(module.outputFilePath),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{