diff --git a/android/config.go b/android/config.go index c8d7cfdc9..cd1ac31dc 100644 --- a/android/config.go +++ b/android/config.go @@ -322,7 +322,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string DeviceName: stringPtr("test_device"), Platform_sdk_version: intPtr(30), Platform_sdk_codename: stringPtr("S"), - Platform_version_active_codenames: []string{"S"}, + Platform_version_active_codenames: []string{"S", "Tiramisu"}, DeviceSystemSdkVersions: []string{"14", "15"}, Platform_systemsdk_versions: []string{"29", "30"}, AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, diff --git a/apex/apex_test.go b/apex/apex_test.go index dcf68328e..888311137 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -215,7 +215,9 @@ var prepareForApexTest = android.GroupFixturePreparers( variables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} variables.Platform_sdk_codename = proptools.StringPtr("Q") variables.Platform_sdk_final = proptools.BoolPtr(false) - variables.Platform_version_active_codenames = []string{"Q"} + // "Tiramisu" needs to be in the next line for compatibility with soong code, + // not because of these tests specifically (it's not used by the tests) + variables.Platform_version_active_codenames = []string{"Q", "Tiramisu"} variables.Platform_vndk_version = proptools.StringPtr("29") }), ) diff --git a/java/sdk_library.go b/java/sdk_library.go index 906f859fd..ea8b2221a 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1589,22 +1589,29 @@ func (module *SdkLibrary) UniqueApexVariations() bool { // Creates the xml file that publicizes the runtime library func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { + moduleMinApiLevel := module.Library.MinSdkVersion(mctx).ApiLevel + var moduleMinApiLevelStr = moduleMinApiLevel.String() + if moduleMinApiLevel == android.NoneApiLevel { + moduleMinApiLevelStr = "current" + } props := struct { - Name *string - Lib_name *string - Apex_available []string - On_bootclasspath_since *string - On_bootclasspath_before *string - Min_device_sdk *string - Max_device_sdk *string + Name *string + Lib_name *string + Apex_available []string + On_bootclasspath_since *string + On_bootclasspath_before *string + Min_device_sdk *string + Max_device_sdk *string + Sdk_library_min_api_level *string }{ - Name: proptools.StringPtr(module.xmlPermissionsModuleName()), - Lib_name: proptools.StringPtr(module.BaseModuleName()), - Apex_available: module.ApexProperties.Apex_available, - On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since, - On_bootclasspath_before: module.commonSdkLibraryProperties.On_bootclasspath_before, - Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, - Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, + Name: proptools.StringPtr(module.xmlPermissionsModuleName()), + Lib_name: proptools.StringPtr(module.BaseModuleName()), + Apex_available: module.ApexProperties.Apex_available, + On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since, + On_bootclasspath_before: module.commonSdkLibraryProperties.On_bootclasspath_before, + Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, + Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, + Sdk_library_min_api_level: &moduleMinApiLevelStr, } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -2427,6 +2434,11 @@ type sdkLibraryXmlProperties struct { // // This means that the device won't recognise this library as installed. Max_device_sdk *string + + // The SdkLibrary's min api level as a string + // + // This value comes from the ApiLevel of the MinSdkVersion property. + Sdk_library_min_api_level *string } // java_sdk_library_xml builds the permission xml file for a java_sdk_library. @@ -2534,6 +2546,14 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_before", module.properties.On_bootclasspath_before) minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min_device_sdk", module.properties.Min_device_sdk) maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max_device_sdk", module.properties.Max_device_sdk) + // is understood in all android versions whereas is only understood from API T (and ignored before that). + // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T + var libraryTag string + if module.properties.Min_device_sdk != nil { + libraryTag = ` \n`, @@ -2552,7 +2572,7 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri ` limitations under the License.\n`, `-->\n`, `\n`, - `