Restrict verify_overlaps to pre S modules

The runtime in S and above does not have the same constraints that
require the hiddenapi flags to be generated in a monolithic manner.
This CL restricts the verify_overlaps to pre S modules. This will
filter out hiddenapi signature discrepancies that do not require
any action.

Test: verify_overlaps diff with this change https://diff.googleplex.com/#key=xxB0ky93hZRn
Test: presubmits
Bug: 313672880

Change-Id: Ie626a6779fc924563bec90b6c1ab0c7e8b4b23c2
This commit is contained in:
Spandan Das 2024-02-12 15:00:15 +00:00
parent 1c9213d89f
commit 38c64f62cf
3 changed files with 24 additions and 9 deletions

View file

@ -288,6 +288,8 @@ var FirstPackedRelocationsVersion = uncheckedFinalApiLevel(23)
// a core-for-system-modules.jar for the module-lib API scope.
var LastWithoutModuleLibCoreSystemModules = uncheckedFinalApiLevel(31)
var ApiLevelR = uncheckedFinalApiLevel(30)
// ReplaceFinalizedCodenames returns the API level number associated with that API level
// if the `raw` input is the codename of an API level has been finalized.
// If the input is *not* a finalized codename, the input is returned unmodified.

View file

@ -86,6 +86,7 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) {
"bar-fragment",
],
updatable: false,
min_sdk_version: "30", // R
}
apex_key {
@ -138,6 +139,7 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) {
sdk_version: "none",
compile_dex: true,
permitted_packages: ["bar"],
min_sdk_version: "30", // R
}
java_sdk_library {
@ -162,12 +164,12 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) {
android.AssertPathsRelativeToTopEquals(t, message, expected, info.FlagsFilesByCategory[category])
}
android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/index.csv"}, info.IndexPaths)
android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/index.csv"}, info.IndexPaths)
android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
}
// TestPlatformBootclasspath_LegacyPrebuiltFragment verifies that the

View file

@ -68,7 +68,7 @@ func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory F
case *ClasspathFragmentElement:
fragment := e.Module()
if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
monolithicInfo.append(&info)
monolithicInfo.append(ctx, fragment, &info)
} else {
ctx.ModuleErrorf("%s does not provide hidden API information", fragment)
}
@ -79,14 +79,25 @@ func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory F
}
// append appends all the files from the supplied info to the corresponding files in this struct.
func (i *MonolithicHiddenAPIInfo) append(other *HiddenAPIInfo) {
func (i *MonolithicHiddenAPIInfo) append(ctx android.ModuleContext, otherModule android.Module, other *HiddenAPIInfo) {
i.FlagsFilesByCategory.append(other.FlagFilesByCategory)
i.AnnotationFlagsPaths = append(i.AnnotationFlagsPaths, other.AnnotationFlagsPath)
i.MetadataPaths = append(i.MetadataPaths, other.MetadataPath)
i.IndexPaths = append(i.IndexPaths, other.IndexPath)
i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset())
i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset())
apexInfo, ok := android.OtherModuleProvider(ctx, otherModule, android.ApexInfoProvider)
if !ok {
ctx.ModuleErrorf("Could not determine min_version_version of %s\n", otherModule.Name())
return
}
if apexInfo.MinSdkVersion.LessThanOrEqualTo(android.ApiLevelR) {
// Restrict verify_overlaps to R and older modules.
// The runtime in S does not have the same restriction that
// requires the hiddenapi flags to be generated in a monolithic
// invocation.
i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset())
i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset())
}
}
var MonolithicHiddenAPIInfoProvider = blueprint.NewProvider[MonolithicHiddenAPIInfo]()