aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/app.go2
-rw-r--r--java/app_test.go54
-rw-r--r--java/config/config.go7
-rw-r--r--java/hiddenapi.go14
-rw-r--r--java/java.go23
-rw-r--r--java/java_test.go2
6 files changed, 27 insertions, 75 deletions
diff --git a/java/app.go b/java/app.go
index 08b2d915..c08aefd1 100644
--- a/java/app.go
+++ b/java/app.go
@@ -392,7 +392,7 @@ func (a *AndroidApp) collectAppDeps(ctx android.ModuleContext) ([]jniLib, []Cert
func (a *AndroidApp) getCertString(ctx android.BaseContext) string {
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
if overridden {
- return certificate
+ return ":" + certificate
}
return String(a.appProperties.Certificate)
}
diff --git a/java/app_test.go b/java/app_test.go
index 313844fa..317c7528 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -747,57 +747,3 @@ func TestPackageNameOverride(t *testing.T) {
})
}
}
-
-func TestOverrideModule(t *testing.T) {
- ctx := testJava(t, `
- android_app {
- name: "foo",
- srcs: ["a.java"],
- }
-
- override_module {
- name: "bar",
- base: "foo",
- certificate: ":new_certificate",
- manifest_package_name: "org.dandroid.bp",
- }
-
- android_app_certificate {
- name: "new_certificate",
- certificate: "cert/new_cert",
- }
- `)
-
- // The base module still contains all the final outputs after overrides.
- foo := ctx.ModuleForTests("foo", "android_common")
-
- // Check the final apk name
- outputs := foo.AllOutputs()
- e := buildDir + "/target/product/test_device/system/app/bar/bar.apk"
- found := false
- for _, o := range outputs {
- if o == e {
- found = true
- break
- }
- }
- if !found {
- t.Errorf("Can't find %q in output files.\nAll outputs:%v", e, outputs)
- }
-
- // Check the certificate paths
- signapk := foo.Output("foo.apk")
- signFlags := signapk.Args["certificates"]
- e = "cert/new_cert.x509.pem cert/new_cert.pk8"
- if e != signFlags {
- t.Errorf("Incorrect signing flags, expected: %q, got: %q", e, signFlags)
- }
-
- // Check the manifest package name
- res := foo.Output("package-res.apk")
- aapt2Flags := res.Args["flags"]
- e = "--rename-manifest-package org.dandroid.bp"
- if !strings.Contains(aapt2Flags, e) {
- t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", e, aapt2Flags)
- }
-}
diff --git a/java/config/config.go b/java/config/config.go
index 2602e6b0..75be9e21 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -33,12 +33,7 @@ var (
DefaultLambdaStubsLibrary = "core-lambda-stubs"
SdkLambdaStubsPath = "prebuilts/sdk/tools/core-lambda-stubs.jar"
- // A list of the non-boot jars that provide hidden APIs, i.e. libraries.
- HiddenAPIProvidingNonBootJars = []string{
- "android.test.base",
- }
-
- // A list of the non-boot jars that provide information about usages of the hidden API.
+ // A list of the jars that provide information about usages of the hidden API.
HiddenAPIExtraAppUsageJars = []string{
// The core-oj-hiddenapi provides information for the core-oj jar.
"core-oj-hiddenapi",
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index 104cd767..51ed3dda 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -57,14 +57,7 @@ func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOu
if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
isBootJar := inList(ctx.ModuleName(), ctx.Config().BootJars())
- // Check to see if this module provides part of the hiddenapi, i.e. is a boot jar or a white listed
- // library.
- isProvidingJar := isBootJar || inList(ctx.ModuleName(), config.HiddenAPIProvidingNonBootJars)
-
- // If this module provides part of the hiddenapi or is a special module that simply provides information
- // about the hiddenapi then extract information about the hiddenapi from the UnsupportedAppUsage
- // annotations compiled into the classes.jar.
- if isProvidingJar || inList(ctx.ModuleName(), config.HiddenAPIExtraAppUsageJars) {
+ if isBootJar || inList(ctx.ModuleName(), config.HiddenAPIExtraAppUsageJars) {
// Derive the greylist from classes jar.
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv")
@@ -72,10 +65,7 @@ func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOu
h.flagsCSVPath = flagsCSV
h.metadataCSVPath = metadataCSV
}
-
- // If this module provides part of the hiddenapi then encode the information about the hiddenapi into
- // the dex file created for this module.
- if isProvidingJar {
+ if isBootJar {
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", ctx.ModuleName()+".jar")
h.bootDexJarPath = dexJar
hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex)
diff --git a/java/java.go b/java/java.go
index 35011746..ecc36089 100644
--- a/java/java.go
+++ b/java/java.go
@@ -168,6 +168,9 @@ type CompilerProperties struct {
}
Instrument bool `blueprint:"mutated"`
+
+ // List of files to include in the META-INF/services folder of the resulting jar.
+ Services []string `android:"arch_variant"`
}
type CompilerDeviceProperties struct {
@@ -478,6 +481,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
android.ExtractSourceDeps(ctx, j.properties.Manifest)
android.ExtractSourceDeps(ctx, j.properties.Jarjar_rules)
+ android.ExtractSourcesDeps(ctx, j.properties.Services)
if j.hasSrcExt(".proto") {
protoDeps(ctx, &j.protoProperties)
@@ -1136,6 +1140,25 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest"))
}
+ services := ctx.ExpandSources(j.properties.Services, nil)
+ if len(services) > 0 {
+ servicesJar := android.PathForModuleOut(ctx, "services", jarName)
+ var zipargs []string
+ for _, file := range services {
+ serviceFile := file.String()
+ zipargs = append(zipargs, "-C", filepath.Dir(serviceFile), "-f", serviceFile)
+ }
+ ctx.Build(pctx, android.BuildParams{
+ Rule: zip,
+ Output: servicesJar,
+ Implicits: services,
+ Args: map[string]string{
+ "jarArgs": "-P META-INF/services/ " + strings.Join(proptools.NinjaAndShellEscape(zipargs), " "),
+ },
+ })
+ jars = append(jars, servicesJar)
+ }
+
// Combine the classes built from sources, any manifests, and any static libraries into
// classes.jar. If there is only one input jar this step will be skipped.
var outputFile android.ModuleOutPath
diff --git a/java/java_test.go b/java/java_test.go
index bbcc9ede..8d3efcb8 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -81,13 +81,11 @@ func testContext(config android.Config, bp string,
ctx.RegisterModuleType("droiddoc_host", android.ModuleFactoryAdaptor(DroiddocHostFactory))
ctx.RegisterModuleType("droiddoc_template", android.ModuleFactoryAdaptor(ExportedDroiddocDirFactory))
ctx.RegisterModuleType("java_sdk_library", android.ModuleFactoryAdaptor(SdkLibraryFactory))
- ctx.RegisterModuleType("override_module", android.ModuleFactoryAdaptor(android.OverrideModuleFactory))
ctx.RegisterModuleType("prebuilt_apis", android.ModuleFactoryAdaptor(PrebuiltApisFactory))
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.TopDown("load_hooks", android.LoadHookMutator).Parallel()
ctx.TopDown("prebuilt_apis", PrebuiltApisMutator).Parallel()
ctx.TopDown("java_sdk_library", SdkLibraryMutator).Parallel()
})