Add support for excluding libraries from class loader contexts
A number of tests in the cts/tests/signature/api-check check for the accessibility of classes from the android.test.base, android.test.runner and android.test.mock libraries. Some tests expect to find the classes other do not. Unfortunately, the tests use libraries, specifically compatibility-device-util-axt, that depend on the android.test... libraries which causes Soong to implicitly add <uses-library> entries to the manifest so that they will be accessible at runtime. That causes the tests that do not expect to find the classes to fail. Bug: 209607558 Test: m nothing Change-Id: I54c194ab23d5a70df790ece3fe98f2b3d6a1c1f6
This commit is contained in:
@@ -267,11 +267,15 @@ var extractAssetsRule = pctx.AndroidStaticRule("extractAssets",
|
||||
})
|
||||
|
||||
func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext android.SdkContext,
|
||||
classLoaderContexts dexpreopt.ClassLoaderContextMap, extraLinkFlags ...string) {
|
||||
classLoaderContexts dexpreopt.ClassLoaderContextMap, excludedLibs []string,
|
||||
extraLinkFlags ...string) {
|
||||
|
||||
transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assetPackages, libDeps, libFlags :=
|
||||
aaptLibs(ctx, sdkContext, classLoaderContexts)
|
||||
|
||||
// Exclude any libraries from the supplied list.
|
||||
classLoaderContexts = classLoaderContexts.ExcludeLibs(excludedLibs)
|
||||
|
||||
// App manifest file
|
||||
manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
|
||||
manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile)
|
||||
@@ -530,7 +534,7 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
a.aapt.isLibrary = true
|
||||
a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
|
||||
a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts)
|
||||
a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts, nil)
|
||||
|
||||
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
|
||||
|
||||
|
Reference in New Issue
Block a user