summaryrefslogtreecommitdiff
path: root/java/hiddenapi.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2020-06-24 16:22:38 +0100
committer Paul Duffin <paulduffin@google.com> 2020-06-29 19:05:19 +0100
commita2058f8b7d8f616f8749eb185e6c2f43ecaf8d4c (patch)
tree06221e2935cfa83616f2faa2e56f4b40341662e9 /java/hiddenapi.go
parent5e291c238f122b3f7692ba317c276b652e57b3ee (diff)
Apply hiddenapi encoding to java_sdk_library .impl
Adds a ConfigurationName property, and ConfigurationName() method that allows a library to separate its name (e.g. framework-tethering.impl) from the name used in the build configuration, e.g. ctx.Config().BootJars(). Updates hiddenapi processing to use ConfigurationName() instead of ctx.ModuleName(). Changes java_sdk_library to set the ConfigurationName property of the implementation library to the name of the module instead of <module>.impl so that it will match the name in the boot jars list. Bug: 159683330 Test: m framework-tethering dexdump ${PRODUCT_OUT}/apex/com.android.tethering/javalib/framework-tethering.jar | grep hiddenapi | wc -l Verify that there are >0 hiddenapi entries. Add java_sdk_library_import prefer=true for framework-tethering and repeat the above to verify that there are 0 hiddenapi entries. Apply this change, repeat above and verify that there are the same # of entries as before. Remove the prebuilt for framework-tethering Repeat the above and verify that there is no change to the # of entries Merged-In: I6c3016c35d0fcb1b95d4f9b37a307a69878f8e0a Change-Id: I6c3016c35d0fcb1b95d4f9b37a307a69878f8e0a (cherry picked from commit c4422106a7cf4731e27d664646bc0d57ad3f37fa)
Diffstat (limited to 'java/hiddenapi.go')
-rw-r--r--java/hiddenapi.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index ce624bfc1..130b63496 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -59,10 +59,9 @@ type hiddenAPIIntf interface {
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
-func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOutPath,
+func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, name string, primary bool, dexJar android.ModuleOutPath,
implementationJar android.Path, uncompressDex bool) android.ModuleOutPath {
if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
- name := ctx.ModuleName()
// Modules whose names are of the format <x>-hiddenapi provide hiddenapi information
// for the boot jar module <x>. Otherwise, the module provides information for itself.
@@ -90,7 +89,14 @@ func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOu
// the gathered information in the generated dex file.
if name == bootJarName {
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar")
- h.bootDexJarPath = dexJar
+
+ // More than one library with the same classes can be encoded but only one can
+ // be added to the global set of flags, otherwise it will result in duplicate
+ // classes which is an error. Therefore, only add the dex jar of one of them
+ // to the global set of flags.
+ if primary {
+ h.bootDexJarPath = dexJar
+ }
hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex)
dexJar = hiddenAPIJar
}