From e739f1ed9fb7ec7ae269a2615c03d0e44f7dc981 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 29 May 2020 11:24:51 +0100 Subject: [PATCH] Collect permitted packages from java_sdk_library instances Switching an updatable boot jar from java_library to java_sdk_library changed the contents of the updatable-bcp-packages.txt due to the code requiring the module to be *Library. This change updates that to allow it to be any module that implements the PermittedPackagesForUpdatableBootJars interface which is *Library and anything that embeds that like *SdkLibrary. Bug: 155164730 Test: m droid and check the contents of system/etc/updatable-bcp-packages.txt Change-Id: I464af74628da311734f102f77ec8158daec5b32d --- java/dexpreopt_bootjars.go | 4 ++-- java/java.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 90457d07d..ed61d4bd3 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -619,10 +619,10 @@ func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConf // Collect `permitted_packages` for updatable boot jars. var updatablePackages []string ctx.VisitAllModules(func(module android.Module) { - if j, ok := module.(*Library); ok { + if j, ok := module.(PermittedPackagesForUpdatableBootJars); ok { name := ctx.ModuleName(module) if i := android.IndexList(name, updatableModules); i != -1 { - pp := j.properties.Permitted_packages + pp := j.PermittedPackagesForUpdatableBootJars() if len(pp) > 0 { updatablePackages = append(updatablePackages, pp...) } else { diff --git a/java/java.go b/java/java.go index 162141d83..76bfa86d6 100644 --- a/java/java.go +++ b/java/java.go @@ -1840,6 +1840,17 @@ type Library struct { InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths) } +// Provides access to the list of permitted packages from updatable boot jars. +type PermittedPackagesForUpdatableBootJars interface { + PermittedPackagesForUpdatableBootJars() []string +} + +var _ PermittedPackagesForUpdatableBootJars = (*Library)(nil) + +func (j *Library) PermittedPackagesForUpdatableBootJars() []string { + return j.properties.Permitted_packages +} + func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bool { // Store uncompressed (and aligned) any dex files from jars in APEXes. if am, ok := ctx.Module().(android.ApexModule); ok && !am.IsForPlatform() {