From fbcd5fe31d17f5576c7c28883e6c2b141e46a75c Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 30 Sep 2024 22:30:39 +0000 Subject: Enforce partition property on apex system server jars This is a followup AI from https://r.android.com/3288083, which installs dexpreopt files of apex system server jars in the same partition as the top-level apex. This CL enforces that the partition properties of the apex and the java library match. This has been implemented in a bottomup manner. systemserverclasspath_fragment module sets `LibraryNameToPartitionInfoProvider`. The top-level apex uses this info and raies an exception if the partition properties do not match. This enforcement is done only for source apexes for now. It is not needed for prebuilts since - The dexpreopt rules of jars in prebuilt apexes are generated in the top-level `prebuiltApex`/ `apexSet` - We do not have prebuilts of system_ext apexes today (com.android.compos is not part of mainline) Test: m nothing --no-skip-soong-tests Change-Id: Ib4df634457f315d5421681bdb0afebc2b1bf92d9 --- java/systemserver_classpath_fragment.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'java/systemserver_classpath_fragment.go') diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index 924abd460..aad106007 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -127,6 +127,26 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo configuredJars = configuredJars.AppendList(&standaloneConfiguredJars) classpathJars = append(classpathJars, standaloneClasspathJars...) s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) + s.setPartitionInfoOfLibraries(ctx) +} + +// Map of java library name to their install partition. +type LibraryNameToPartitionInfo struct { + LibraryNameToPartition map[string]string +} + +// LibraryNameToPartitionInfoProvider will be used by the top-level apex to enforce that dexpreopt files +// of apex system server jars are installed in the same partition as the top-level apex. +var LibraryNameToPartitionInfoProvider = blueprint.NewProvider[LibraryNameToPartitionInfo]() + +func (s *SystemServerClasspathModule) setPartitionInfoOfLibraries(ctx android.ModuleContext) { + libraryNameToPartition := map[string]string{} + ctx.VisitDirectDepsWithTag(systemServerClasspathFragmentContentDepTag, func(m android.Module) { + libraryNameToPartition[m.Name()] = m.PartitionTag(ctx.DeviceConfig()) + }) + android.SetProvider(ctx, LibraryNameToPartitionInfoProvider, LibraryNameToPartitionInfo{ + LibraryNameToPartition: libraryNameToPartition, + }) } func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { -- cgit v1.2.3-59-g8ed1b