Fix missing missing (min|max)_sdk_version in bootclasspath.pb

bootclasspath.pb.textproto of an apex contains
min_sdk_version/max_sdk_version information of its exported libraries.
It is populated using the stateful minSdkVersion/maxSdkVersion
properties of the SdkLibrary module. These were previously indirectly
populated by invoking `module.Library.GenerateAndroidBuildActions(ctx)`,
which has been removed https://r.android.com/3079425.

This CL updates the implementation to use `MinSdkVersion(ctx)` and
`MaxSdkVersion(ctx)` to get the appropriate values directly and not rely
on GenerateAndroidBuildActions.

Bug: 345621958
Test: cat out/soong/.intermediates/packages/providers/MediaProvider/apex/com.android.mediaprovider-bootclasspath-fragment/android_common_apex30/c49cac19acc21350e0f3590de64d2f7f/bootclasspath.pb.textproto
jars {
path: "/apex/com.android.mediaprovider/javalib/framework-mediaprovider.jar"
classpath: BOOTCLASSPATH
min_sdk_version: "30"
max_sdk_version: ""
}
jars {
path: "/apex/com.android.mediaprovider/javalib/framework-pdf.jar"
classpath: BOOTCLASSPATH
min_sdk_version: "30"
max_sdk_version: ""
}
jars {
path: "/apex/com.android.mediaprovider/javalib/framework-pdf-v.jar"
classpath: BOOTCLASSPATH
min_sdk_version: "34"
max_sdk_version: ""
}
// min_sdk_version values were empty previously

Change-Id: Ia547747b16d255c1a093deee96a1abb61fd47dff
This commit is contained in:
Spandan Das 2024-06-12 17:02:40 +00:00
parent 3125b75d5d
commit 306804fe41

View file

@ -128,19 +128,21 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars
return m.Name() == configuredJars.Jar(i)
}, func(m android.Module) {
if s, ok := m.(*SdkLibrary); ok {
minSdkVersion := s.MinSdkVersion(ctx)
maxSdkVersion := s.MaxSdkVersion(ctx)
// TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current"
if s.minSdkVersion.Specified() {
if s.minSdkVersion.IsCurrent() {
if minSdkVersion.Specified() {
if minSdkVersion.IsCurrent() {
jar.minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
} else {
jar.minSdkVersion = s.minSdkVersion.String()
jar.minSdkVersion = minSdkVersion.String()
}
}
if s.maxSdkVersion.Specified() {
if s.maxSdkVersion.IsCurrent() {
if maxSdkVersion.Specified() {
if maxSdkVersion.IsCurrent() {
jar.maxSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
} else {
jar.maxSdkVersion = s.maxSdkVersion.String()
jar.maxSdkVersion = maxSdkVersion.String()
}
}
}