summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rwxr-xr-xjava/app.go68
-rw-r--r--java/bootclasspath_fragment.go22
-rw-r--r--java/dexpreopt.go5
-rw-r--r--java/dexpreopt_bootjars.go19
-rw-r--r--java/hiddenapi_modular.go37
-rw-r--r--java/java.go89
-rw-r--r--java/lint.go5
-rw-r--r--java/lint_test.go28
-rw-r--r--java/platform_bootclasspath.go9
-rw-r--r--java/robolectric.go2
-rw-r--r--java/sdk_library.go52
11 files changed, 180 insertions, 156 deletions
diff --git a/java/app.go b/java/app.go
index fc1ace07b..4e967ad45 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1213,7 +1213,7 @@ func (u *usesLibrary) addLib(lib string, optional bool) {
}
func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) {
- if !ctx.Config().UnbundledBuild() {
+ if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
ctx.AddVariationDependencies(nil, usesLibTag, u.usesLibraryProperties.Uses_libs...)
ctx.AddVariationDependencies(nil, usesLibTag, u.presentOptionalUsesLibs(ctx)...)
// Only add these extra dependencies if the module depends on framework libs. This avoids
@@ -1245,36 +1245,52 @@ func replaceInList(list []string, oldstr, newstr string) {
}
}
-// Returns a map of module names of shared library dependencies to the paths
-// to their dex jars on host and on device.
+// Returns a map of module names of shared library dependencies to the paths to their dex jars on
+// host and on device.
func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap {
clcMap := make(dexpreopt.ClassLoaderContextMap)
- if !ctx.Config().UnbundledBuild() {
- ctx.VisitDirectDeps(func(m android.Module) {
- if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok {
- dep := ctx.OtherModuleName(m)
- if lib, ok := m.(UsesLibraryDependency); ok {
- libName := dep
- if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
- libName = *ulib.ProvidesUsesLib()
- // Replace module name with library name in `uses_libs`/`optional_uses_libs`
- // in order to pass verify_uses_libraries check (which compares these
- // properties against library names written in the manifest).
- replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
- replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
- }
- clcMap.AddContext(ctx, tag.sdkVersion, libName,
- lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ClassLoaderContexts())
- } else if ctx.Config().AllowMissingDependencies() {
- ctx.AddMissingDependencies([]string{dep})
- } else {
- ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep)
- }
- }
- })
+ // Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false. With
+ // UnbundledBuildImage() it is necessary to generate dexpreopt.config for post-dexpreopting.
+ if ctx.Config().UnbundledBuild() && !ctx.Config().UnbundledBuildImage() {
+ return clcMap
}
+ ctx.VisitDirectDeps(func(m android.Module) {
+ tag, isUsesLibTag := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag)
+ if !isUsesLibTag {
+ return
+ }
+
+ dep := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(m))
+
+ // Skip stub libraries. A dependency on the implementation library has been added earlier,
+ // so it will be added to CLC, but the stub shouldn't be. Stub libraries can be distingushed
+ // from implementation libraries by their name, which is different as it has a suffix.
+ if comp, ok := m.(SdkLibraryComponentDependency); ok {
+ if impl := comp.OptionalSdkLibraryImplementation(); impl != nil && *impl != dep {
+ return
+ }
+ }
+
+ if lib, ok := m.(UsesLibraryDependency); ok {
+ libName := dep
+ if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
+ libName = *ulib.ProvidesUsesLib()
+ // Replace module name with library name in `uses_libs`/`optional_uses_libs` in
+ // order to pass verify_uses_libraries check (which compares these properties
+ // against library names written in the manifest).
+ replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
+ replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
+ }
+ clcMap.AddContext(ctx, tag.sdkVersion, libName,
+ lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ClassLoaderContexts())
+ } else if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{dep})
+ } else {
+ ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep)
+ }
+ })
return clcMap
}
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index bdf0daeaf..503c31fd7 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -579,25 +579,9 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.
// Create hidden API input structure.
input := b.createHiddenAPIFlagInput(ctx, contents, fragments)
- var output *HiddenAPIOutput
-
- // Hidden API processing is conditional as a temporary workaround as not all
- // bootclasspath_fragments provide the appropriate information needed for hidden API processing
- // which leads to breakages of the build.
- // TODO(b/179354495): Stop hidden API processing being conditional once all bootclasspath_fragment
- // modules have been updated to support it.
- if input.canPerformHiddenAPIProcessing(ctx, b.properties) {
- // Delegate the production of the hidden API all-flags.csv file to a module type specific method.
- common := ctx.Module().(commonBootclasspathFragment)
- output = common.produceHiddenAPIOutput(ctx, contents, input)
- } else {
- // As hidden API processing cannot be performed fall back to trying to retrieve the legacy
- // encoded boot dex files, i.e. those files encoded by the individual libraries and returned
- // from the DexJarBuildPath() method.
- output = &HiddenAPIOutput{
- EncodedBootDexFilesByModule: retrieveLegacyEncodedBootDexFiles(ctx, contents),
- }
- }
+ // Delegate the production of the hidden API all-flags.csv file to a module type specific method.
+ common := ctx.Module().(commonBootclasspathFragment)
+ output := common.produceHiddenAPIOutput(ctx, contents, input)
// Initialize a HiddenAPIInfo structure.
hiddenAPIInfo := HiddenAPIInfo{
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 2e46d74fa..0faae36ba 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -141,10 +141,9 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr
}
}
- // If it is neither app nor test, make config files regardless of its dexpreopt setting.
+ // If it is test, make config files regardless of its dexpreopt setting.
// The config files are required for apps defined in make which depend on the lib.
- // TODO(b/158843648): The config for apps should be generated as well regardless of setting.
- if (d.isApp || d.isTest) && d.dexpreoptDisabled(ctx) {
+ if d.isTest && d.dexpreoptDisabled(ctx) {
return
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 19c65cac7..dff9543e4 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -154,12 +154,23 @@ import (
// PRODUCT_BOOT_JARS_EXTRA variables. The AOSP makefiles specify some common Framework libraries,
// but more product-specific libraries can be added in the product makefiles.
//
-// Each component of the PRODUCT_BOOT_JARS and PRODUCT_BOOT_JARS_EXTRA variables is either a simple
-// name (if the library is a part of the Platform), or a colon-separated pair <apex, name> (if the
-// library is a part of a non-updatable APEX).
+// Each component of the PRODUCT_BOOT_JARS and PRODUCT_BOOT_JARS_EXTRA variables is a
+// colon-separated pair <apex>:<library>, where <apex> is the variant name of a non-updatable APEX,
+// "platform" if the library is a part of the platform in the system partition, or "system_ext" if
+// it's in the system_ext partition.
+//
+// In these variables APEXes are identified by their "variant names", i.e. the names they get
+// mounted as in /apex on device. In Soong modules that is the name set in the "apex_name"
+// properties, which default to the "name" values. For example, many APEXes have both
+// com.android.xxx and com.google.android.xxx modules in Soong, but take the same place
+// /apex/com.android.xxx at runtime. In these cases the variant name is always com.android.xxx,
+// regardless which APEX goes into the product. See also android.ApexInfo.ApexVariationName and
+// apex.apexBundleProperties.Apex_name.
//
// A related variable PRODUCT_UPDATABLE_BOOT_JARS contains bootclasspath libraries that are in
-// updatable APEXes. They are not included in the boot image.
+// APEXes. They are not included in the boot image. The only exception here is core-icu4j.jar that
+// has been historically part of the boot image and is now in a non updatable apex; it is treated
+// as being part of PRODUCT_BOOT_JARS and is in the boot image.
//
// One exception to the above rules are "coverage" builds (a special build flavor which requires
// setting environment variable EMMA_INSTRUMENT_FRAMEWORK=true). In coverage builds the Java code in
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index c4832d2f8..654ebb743 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -20,7 +20,6 @@ import (
"android/soong/android"
"github.com/google/blueprint"
- "github.com/google/blueprint/proptools"
)
// Contains support for processing hiddenAPI in a modular fashion.
@@ -712,42 +711,6 @@ func newHiddenAPIFlagInput() HiddenAPIFlagInput {
return input
}
-// canPerformHiddenAPIProcessing determines whether hidden API processing should be performed.
-//
-// A temporary workaround to avoid existing bootclasspath_fragments that do not provide the
-// appropriate information needed for hidden API processing breaking the build.
-// TODO(b/179354495): Remove this workaround.
-func (i *HiddenAPIFlagInput) canPerformHiddenAPIProcessing(ctx android.ModuleContext, properties bootclasspathFragmentProperties) bool {
- // Performing hidden API processing without stubs is not supported and it is unlikely to ever be
- // required as the whole point of adding something to the bootclasspath fragment is to add it to
- // the bootclasspath in order to be used by something else in the system. Without any stubs it
- // cannot do that.
- if len(i.StubDexJarsByScope) == 0 {
- return false
- }
-
- // Hidden API processing is always enabled in tests.
- if ctx.Config().TestProductVariables != nil {
- return true
- }
-
- // A module that has fragments should have access to the information it needs in order to perform
- // hidden API processing.
- if len(properties.Fragments) != 0 {
- return true
- }
-
- // The art bootclasspath fragment does not depend on any other fragments but already supports
- // hidden API processing.
- imageName := proptools.String(properties.Image_name)
- if imageName == "art" {
- return true
- }
-
- // Disable it for everything else.
- return false
-}
-
// gatherStubLibInfo gathers information from the stub libs needed by hidden API processing from the
// dependencies added in hiddenAPIAddStubLibDependencies.
//
diff --git a/java/java.go b/java/java.go
index be1ad874f..e38a7143b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -21,7 +21,6 @@ package java
import (
"fmt"
"path/filepath"
- "strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -131,11 +130,19 @@ var (
PropertyName: "java_boot_libs",
SupportsSdk: true,
},
- // Temporarily export implementation classes jar for java_boot_libs as it is required for the
- // hiddenapi processing.
- // TODO(b/179354495): Revert once hiddenapi processing has been modularized.
- exportImplementationClassesJar,
- sdkSnapshotFilePathForJar,
+ func(ctx android.SdkMemberContext, j *Library) android.Path {
+ // Java boot libs are only provided in the SDK to provide access to their dex implementation
+ // jar for use by dexpreopting and boot jars package check. They do not need to provide an
+ // actual implementation jar but the java_import will need a file that exists so just copy an
+ // empty file. Any attempt to use that file as a jar will cause a build error.
+ return ctx.SnapshotBuilder().EmptyFile()
+ },
+ func(osPrefix, name string) string {
+ // Create a special name for the implementation jar to try and provide some useful information
+ // to a developer that attempts to compile against this.
+ // TODO(b/175714559): Provide a proper error message in Soong not ninja.
+ return filepath.Join(osPrefix, "java_boot_libs", "snapshot", "jars", "are", "invalid", name+jarFileSuffix)
+ },
onlyCopyJarToSnapshot,
}
@@ -581,6 +588,10 @@ type librarySdkMemberProperties struct {
JarToExport android.Path `android:"arch_variant"`
AidlIncludeDirs android.Paths
+
+ // The list of permitted packages that need to be passed to the prebuilts as they are used to
+ // create the updatable-bcp-packages.txt file.
+ PermittedPackages []string
}
func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
@@ -589,6 +600,8 @@ func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberCo
p.JarToExport = ctx.MemberType().(*librarySdkMemberType).jarToExportGetter(ctx, j)
p.AidlIncludeDirs = j.AidlIncludeDirs()
+
+ p.PermittedPackages = j.PermittedPackagesForUpdatableBootJars()
}
func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
@@ -607,6 +620,10 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte
propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
}
+ if len(p.PermittedPackages) > 0 {
+ propertySet.AddProperty("permitted_packages", p.PermittedPackages)
+ }
+
// Do not copy anything else to the snapshot.
if memberType.onlyCopyJarToSnapshot {
return
@@ -1127,6 +1144,10 @@ type ImportProperties struct {
Installable *bool
+ // If not empty, classes are restricted to the specified packages and their sub-packages.
+ // This information is used to generate the updatable-bcp-packages.txt file.
+ Permitted_packages []string
+
// List of shared java libs that this module has dependencies to
Libs []string
@@ -1166,7 +1187,8 @@ type Import struct {
properties ImportProperties
// output file containing classes.dex and resources
- dexJarFile android.Path
+ dexJarFile android.Path
+ dexJarInstallFile android.Path
combinedClasspathFile android.Path
classLoaderContexts dexpreopt.ClassLoaderContextMap
@@ -1178,6 +1200,12 @@ type Import struct {
minSdkVersion android.SdkSpec
}
+var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
+
+func (j *Import) PermittedPackagesForUpdatableBootJars() []string {
+ return j.properties.Permitted_packages
+}
+
func (j *Import) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
return android.SdkSpecFrom(ctx, String(j.properties.Sdk_version))
}
@@ -1311,6 +1339,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil {
j.dexJarFile = dexOutputPath
+ j.dexJarInstallFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName()))
// Initialize the hiddenapi structure.
j.initHiddenAPI(ctx, dexOutputPath, outputFile, nil)
@@ -1351,6 +1380,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile)
j.dexJarFile = dexOutputFile
+ j.dexJarInstallFile = android.PathForModuleInstall(ctx, "framework", jarName)
}
}
@@ -1392,7 +1422,7 @@ func (j *Import) DexJarBuildPath() android.Path {
}
func (j *Import) DexJarInstallPath() android.Path {
- return nil
+ return j.dexJarInstallFile
}
func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
@@ -1462,11 +1492,7 @@ func (j *Import) IDECustomizedModuleName() string {
// TODO(b/113562217): Extract the base module name from the Import name, often the Import name
// has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better
// solution to get the Import name.
- name := j.Name()
- if strings.HasPrefix(name, removedPrefix) {
- name = strings.TrimPrefix(name, removedPrefix)
- }
- return name
+ return android.RemoveOptionalPrebuiltPrefix(j.Name())
}
var _ android.PrebuiltInterface = (*Import)(nil)
@@ -1768,22 +1794,16 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
return
}
- // Find out if the dependency is either an SDK library or an ordinary library that is disguised
- // as an SDK library by the means of `provides_uses_lib` property. If yes, the library is itself
- // a <uses-library> and should be added as a node in the CLC tree, and its CLC should be added
- // as subtree of that node. Otherwise the library is not a <uses_library> and should not be
- // added to CLC, but the transitive <uses-library> dependencies from its CLC should be added to
- // the current CLC.
- var implicitSdkLib *string
- comp, isComp := depModule.(SdkLibraryComponentDependency)
- if isComp {
- implicitSdkLib = comp.OptionalImplicitSdkLibrary()
- // OptionalImplicitSdkLibrary() may be nil so need to fall through to ProvidesUsesLib().
- }
- if implicitSdkLib == nil {
- if ulib, ok := depModule.(ProvidesUsesLib); ok {
- implicitSdkLib = ulib.ProvidesUsesLib()
- }
+ depName := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(depModule))
+
+ var sdkLib *string
+ if lib, ok := depModule.(SdkLibraryDependency); ok && lib.sharedLibrary() {
+ // A shared SDK library. This should be added as a top-level CLC element.
+ sdkLib = &depName
+ } else if ulib, ok := depModule.(ProvidesUsesLib); ok {
+ // A non-SDK library disguised as an SDK library by the means of `provides_uses_lib`
+ // property. This should be handled in the same way as a shared SDK library.
+ sdkLib = ulib.ProvidesUsesLib()
}
depTag := ctx.OtherModuleDependencyTag(depModule)
@@ -1793,7 +1813,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
// Propagate <uses-library> through static library dependencies, unless it is a component
// library (such as stubs). Component libraries have a dependency on their SDK library,
// which should not be pulled just because of a static component library.
- if implicitSdkLib != nil {
+ if sdkLib != nil {
return
}
} else {
@@ -1801,11 +1821,14 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
return
}
- if implicitSdkLib != nil {
- clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *implicitSdkLib,
+ // If this is an SDK (or SDK-like) library, then it should be added as a node in the CLC tree,
+ // and its CLC should be added as subtree of that node. Otherwise the library is not a
+ // <uses_library> and should not be added to CLC, but the transitive <uses-library> dependencies
+ // from its CLC should be added to the current CLC.
+ if sdkLib != nil {
+ clcMap.AddContext(ctx, dexpreopt.AnySdkVersion, *sdkLib,
dep.DexJarBuildPath(), dep.DexJarInstallPath(), dep.ClassLoaderContexts())
} else {
- depName := ctx.OtherModuleName(depModule)
clcMap.AddContextMap(dep.ClassLoaderContexts(), depName)
}
}
diff --git a/java/lint.go b/java/lint.go
index dd5e4fb13..fe3218e90 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -391,8 +391,9 @@ func (l *linter) lint(ctx android.ModuleContext) {
rule.Command().Text("rm -f").Output(html).Output(text).Output(xml)
var apiVersionsName, apiVersionsPrebuilt string
- if l.compileSdkKind == android.SdkModule {
- // When compiling an SDK module we use the filtered database because otherwise lint's
+ if l.compileSdkKind == android.SdkModule || l.compileSdkKind == android.SdkSystemServer {
+ // When compiling an SDK module (or system server) we use the filtered
+ // database because otherwise lint's
// NewApi check produces too many false positives; This database excludes information
// about classes created in mainline modules hence removing those false positives.
apiVersionsName = "api_versions_public_filtered.xml"
diff --git a/java/lint_test.go b/java/lint_test.go
index 9cf1c33fe..456e6ba73 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -261,6 +261,9 @@ func TestJavaLintDatabaseSelectionFull(t *testing.T) {
}
func TestJavaLintDatabaseSelectionPublicFiltered(t *testing.T) {
+ testCases := []string{
+ "module_current", "system_server_current",
+ }
bp := `
java_library {
name: "foo",
@@ -274,17 +277,20 @@ func TestJavaLintDatabaseSelectionPublicFiltered(t *testing.T) {
},
}
`
- result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules).
- RunTestWithBp(t, bp)
+ for _, testCase := range testCases {
+ thisBp := strings.Replace(bp, "XXX", testCase, 1)
+ result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules).
+ RunTestWithBp(t, thisBp)
- foo := result.ModuleForTests("foo", "android_common")
- sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
- if !strings.Contains(*sboxProto.Commands[0].Command,
- "/api_versions_public_filtered.xml") {
- t.Error("did not use public-filtered lint api database", *sboxProto.Commands[0].Command)
- }
- if strings.Contains(*sboxProto.Commands[0].Command,
- "/api_versions.xml") {
- t.Error("used full api database")
+ foo := result.ModuleForTests("foo", "android_common")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "/api_versions_public_filtered.xml") {
+ t.Error("did not use public-filtered lint api database for case", testCase)
+ }
+ if strings.Contains(*sboxProto.Commands[0].Command,
+ "/api_versions.xml") {
+ t.Error("used full api database for case", testCase)
+ }
}
}
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index c1e14b21e..8bed3e9e5 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -423,8 +423,13 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.
// Generate the framework profile rule
bootFrameworkProfileRule(ctx, imageConfig)
- // Generate the updatable bootclasspath packages rule.
- generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules)
+ // If always using prebuilt sdks then do not generate the updatable-bcp-packages.txt file as it
+ // will break because the prebuilts do not yet specify a permitted_packages property.
+ // TODO(b/193889859): Remove when the prebuilts have been updated.
+ if !ctx.Config().AlwaysUsePrebuiltSdks() {
+ // Generate the updatable bootclasspath packages rule.
+ generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules)
+ }
// Copy non-updatable module dex jars to their predefined locations.
nonUpdatableBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, nonUpdatableModules)
diff --git a/java/robolectric.go b/java/robolectric.go
index 00f233ebf..a37a118f6 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -179,7 +179,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
continue
} else if strings.HasSuffix(s, "/BaseRobolectricTest.java") {
continue
- } else if strings.HasPrefix(s, "src/") {
+ } else {
s = strings.TrimPrefix(s, "src/")
}
r.tests = append(r.tests, s)
diff --git a/java/sdk_library.go b/java/sdk_library.go
index ed9aeffd4..268e7970d 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -981,13 +981,15 @@ func (e *EmbeddableSdkLibraryComponent) SdkLibraryName() *string {
}
// to satisfy SdkLibraryComponentDependency
-func (e *EmbeddableSdkLibraryComponent) OptionalImplicitSdkLibrary() *string {
- return e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack
-}
-
-// to satisfy SdkLibraryComponentDependency
func (e *EmbeddableSdkLibraryComponent) OptionalSdkLibraryImplementation() *string {
- // Currently implementation library name is the same as the SDK library name.
+ // For shared libraries, this is the same as the SDK library name. If a Java library or app
+ // depends on a component library (e.g. a stub library) it still needs to know the name of the
+ // run-time library and the corresponding module that provides the implementation. This name is
+ // passed to manifest_fixer (to be added to AndroidManifest.xml) and added to CLC (to be used
+ // in dexpreopt).
+ //
+ // For non-shared SDK (component or not) libraries this returns `nil`, as they are not
+ // <uses-library> and should not be added to the manifest or to CLC.
return e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack
}
@@ -999,12 +1001,6 @@ type SdkLibraryComponentDependency interface {
// SdkLibraryName returns the name of the java_sdk_library/_import module.
SdkLibraryName() *string
- // The optional name of the sdk library that should be implicitly added to the
- // AndroidManifest of an app that contains code which references the sdk library.
- //
- // Returns the name of the optional implicit SDK library or nil, if there isn't one.
- OptionalImplicitSdkLibrary() *string
-
// The name of the implementation library for the optional SDK library or nil, if there isn't one.
OptionalSdkLibraryImplementation() *string
}
@@ -1897,6 +1893,10 @@ type sdkLibraryImportProperties struct {
// If set to true, compile dex files for the stubs. Defaults to false.
Compile_dex *bool
+
+ // If not empty, classes are restricted to the specified packages and their sub-packages.
+ // This information is used to generate the updatable-bcp-packages.txt file.
+ Permitted_packages []string
}
type SdkLibraryImport struct {
@@ -1923,8 +1923,12 @@ type SdkLibraryImport struct {
// Is nil if the source module does not exist.
xmlPermissionsFileModule *sdkLibraryXml
- // Path to the dex implementation jar obtained from the prebuilt_apex, if any.
+ // Build path to the dex implementation jar obtained from the prebuilt_apex, if any.
dexJarFile android.Path
+
+ // Expected install file path of the source module(sdk_library)
+ // or dex implementation jar obtained from the prebuilt_apex, if any.
+ installFile android.Path
}
var _ SdkLibraryDependency = (*SdkLibraryImport)(nil)
@@ -1991,6 +1995,12 @@ func sdkLibraryImportFactory() android.Module {
return module
}
+var _ PermittedPackagesForUpdatableBootJars = (*SdkLibraryImport)(nil)
+
+func (module *SdkLibraryImport) PermittedPackagesForUpdatableBootJars() []string {
+ return module.properties.Permitted_packages
+}
+
func (module *SdkLibraryImport) Prebuilt() *android.Prebuilt {
return &module.prebuilt
}
@@ -2136,6 +2146,9 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
var deapexerModule android.Module
+ // Assume that source module(sdk_library) is installed in /<sdk_library partition>/framework
+ module.installFile = android.PathForModuleInstall(ctx, "framework", module.Stem()+".jar")
+
// Record the paths to the prebuilt stubs library and stubs source.
ctx.VisitDirectDeps(func(to android.Module) {
tag := ctx.OtherModuleDependencyTag(to)
@@ -2195,6 +2208,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(module.BaseModuleName())); dexOutputPath != nil {
module.dexJarFile = dexOutputPath
+ module.installFile = android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(module.BaseModuleName()))
module.initHiddenAPI(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
} else {
// This should never happen as a variant for a prebuilt_apex is only created if the
@@ -2249,11 +2263,7 @@ func (module *SdkLibraryImport) DexJarBuildPath() android.Path {
// to satisfy UsesLibraryDependency interface
func (module *SdkLibraryImport) DexJarInstallPath() android.Path {
- if module.implLibraryModule == nil {
- return nil
- } else {
- return module.implLibraryModule.DexJarInstallPath()
- }
+ return module.installFile
}
// to satisfy UsesLibraryDependency interface
@@ -2506,6 +2516,8 @@ type sdkLibrarySdkMemberProperties struct {
// The paths to the doctag files to add to the prebuilt.
Doctag_paths android.Paths
+
+ Permitted_packages []string
}
type scopeProperties struct {
@@ -2546,6 +2558,7 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe
s.Shared_library = proptools.BoolPtr(sdk.sharedLibrary())
s.Compile_dex = sdk.dexProperties.Compile_dex
s.Doctag_paths = sdk.doctagPaths
+ s.Permitted_packages = sdk.PermittedPackagesForUpdatableBootJars()
}
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
@@ -2558,6 +2571,9 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo
if s.Compile_dex != nil {
propertySet.AddProperty("compile_dex", *s.Compile_dex)
}
+ if len(s.Permitted_packages) > 0 {
+ propertySet.AddProperty("permitted_packages", s.Permitted_packages)
+ }
for _, apiScope := range allApiScopes {
if properties, ok := s.Scopes[apiScope]; ok {