Allow dex jars from prebuilt_apex to be used by hiddenapi
Invokes hiddenAPIExtractInformation() on the dex jar provided by the deapexer (on behalf of prebuilt_apex) so that hiddenAPI can extract the information it needs, if anything, from the dex file (and accompanying classes implementation file). The dex file provided by deapexer has already had the hiddenapi information encoded into it so it does not need to do that again. This change adds the primary parameter to hiddenAPIExtractInformation() and checks it (and also the hiddenAPI.active property) before it does anything. That ensures that it behaves correctly when called directly as well as when called from hiddenAPIExtractAndEncode(). Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Also verified that the hiddenapi files created when using the prebuilts (using SOONG_CONFIG_art_module_source_build=false) are the same as when using the source. There is a slight difference in the order but otherwise identical. Change-Id: I7abb63fd310bb94787ab7f4821e5fd283dc03046
This commit is contained in:
parent
4fd997bc13
commit
9d67ca6ab7
|
@ -4526,9 +4526,10 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||||
|
|
||||||
// Make sure that the dex file from the prebuilt_apex does NOT contribute to the hiddenapi index
|
// Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file.
|
||||||
// file.
|
checkHiddenAPIIndexInputs(t, ctx, `
|
||||||
checkHiddenAPIIndexInputs(t, ctx, ``)
|
.intermediates/libfoo/android_common_myapex/hiddenapi/index.csv
|
||||||
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt with source library preferred", func(t *testing.T) {
|
t.Run("prebuilt with source library preferred", func(t *testing.T) {
|
||||||
|
@ -4599,9 +4600,10 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||||
|
|
||||||
// Make sure that the dex file from the prebuilt_apex does NOT contribute to the hiddenapi index
|
// Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file.
|
||||||
// file.
|
checkHiddenAPIIndexInputs(t, ctx, `
|
||||||
checkHiddenAPIIndexInputs(t, ctx, ``)
|
.intermediates/prebuilt_libfoo/android_common_myapex/hiddenapi/index.csv
|
||||||
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt with source apex preferred", func(t *testing.T) {
|
t.Run("prebuilt with source apex preferred", func(t *testing.T) {
|
||||||
|
@ -4698,9 +4700,10 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||||
|
|
||||||
// Make sure that the dex file from the prebuilt_apex does NOT contribute to the hiddenapi index
|
// Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file.
|
||||||
// file.
|
checkHiddenAPIIndexInputs(t, ctx, `
|
||||||
checkHiddenAPIIndexInputs(t, ctx, ``)
|
.intermediates/prebuilt_libfoo/android_common_prebuilt_myapex/hiddenapi/index.csv
|
||||||
|
`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,12 +144,7 @@ func (h *hiddenAPI) hiddenAPIExtractAndEncode(ctx android.ModuleContext, name st
|
||||||
return dexJar
|
return dexJar
|
||||||
}
|
}
|
||||||
|
|
||||||
// More than one library with the same classes may need to be encoded but only one should be
|
h.hiddenAPIExtractInformation(ctx, dexJar, implementationJar, primary)
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !h.annotationsOnly {
|
if !h.annotationsOnly {
|
||||||
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar").OutputPath
|
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
|
// It also makes the dex jar available for use when generating the
|
||||||
// hiddenAPISingletonPathsStruct.stubFlags.
|
// 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
|
stubFlagsCSV := hiddenAPISingletonPaths(ctx).stubFlags
|
||||||
|
|
||||||
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
|
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
|
||||||
|
|
12
java/java.go
12
java/java.go
|
@ -2917,6 +2917,9 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
|
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
|
||||||
|
|
||||||
if ctx.Device() {
|
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
|
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
|
||||||
// obtained from the associated deapexer module.
|
// obtained from the associated deapexer module.
|
||||||
ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
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.
|
// Get the path of the dex implementation jar from the `deapexer` module.
|
||||||
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
|
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
|
||||||
j.dexJarFile = di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar")
|
if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil {
|
||||||
if j.dexJarFile == 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
|
// 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.
|
// 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())
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configurationName := j.BaseModuleName()
|
|
||||||
primary := j.Prebuilt().UsePrebuilt()
|
|
||||||
|
|
||||||
// Hidden API CSV generation and dex encoding
|
// Hidden API CSV generation and dex encoding
|
||||||
dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, configurationName, primary, dexOutputFile, outputFile,
|
dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, configurationName, primary, dexOutputFile, outputFile,
|
||||||
proptools.Bool(j.dexProperties.Uncompress_dex))
|
proptools.Bool(j.dexProperties.Uncompress_dex))
|
||||||
|
|
Loading…
Reference in New Issue