Merge "Allow dex jars from prebuilt_apex to be used by hiddenapi" am: 320e170675 am: 915cb8c6d8

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1578285

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic96272d781806b7afb5b4afb2e81130ac131b43d
This commit is contained in:
Paul Duffin
2021-02-09 15:18:20 +00:00
committed by Automerger Merge Worker
3 changed files with 32 additions and 21 deletions

View File

@@ -144,12 +144,7 @@ func (h *hiddenAPI) hiddenAPIExtractAndEncode(ctx android.ModuleContext, name st
return dexJar
}
// More than one library with the same classes may need to be encoded but only one should be
// used as a source of information for hidden API processing otherwise it will result in
// duplicate entries in the files.
if primary {
h.hiddenAPIExtractInformation(ctx, dexJar, implementationJar)
}
h.hiddenAPIExtractInformation(ctx, dexJar, implementationJar, primary)
if !h.annotationsOnly {
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar").OutputPath
@@ -169,7 +164,18 @@ func (h *hiddenAPI) hiddenAPIExtractAndEncode(ctx android.ModuleContext, name st
//
// It also makes the dex jar available for use when generating the
// hiddenAPISingletonPathsStruct.stubFlags.
func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJar, classesJar android.Path) {
func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJar, classesJar android.Path, primary bool) {
if !h.active {
return
}
// More than one library with the same classes may need to be encoded but only one should be
// used as a source of information for hidden API processing otherwise it will result in
// duplicate entries in the files.
if !primary {
return
}
stubFlagsCSV := hiddenAPISingletonPaths(ctx).stubFlags
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")

View File

@@ -2917,6 +2917,9 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
if ctx.Device() {
configurationName := j.BaseModuleName()
primary := j.Prebuilt().UsePrebuilt()
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
// obtained from the associated deapexer module.
ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
@@ -2930,8 +2933,10 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Get the path of the dex implementation jar from the `deapexer` module.
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
j.dexJarFile = di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar")
if j.dexJarFile == nil {
if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil {
j.dexJarFile = dexOutputPath
j.hiddenAPI.hiddenAPIExtractInformation(ctx, dexOutputPath, outputFile, primary)
} else {
// This should never happen as a variant for a prebuilt_apex is only created if the
// prebuilt_apex has been configured to export the java library dex file.
ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt_apex %q", deapexerModule.Name())
@@ -2961,9 +2966,6 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return
}
configurationName := j.BaseModuleName()
primary := j.Prebuilt().UsePrebuilt()
// Hidden API CSV generation and dex encoding
dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, configurationName, primary, dexOutputFile, outputFile,
proptools.Bool(j.dexProperties.Uncompress_dex))