Disable verify_overlaps test instead of hiddenapi check.
Disabling hiddenapi check entirely can be dangerous and it might change the
accessibility of @hide Api too. We should only disable verify_overlaps
test which is required for module_sdk and apexes mismatch.
Test: atest CtsInlineMockingTestCases
Bug: 308187068
Bug: 307480026
Change-Id: I44f48e85d802b3a8f2711bc2047bdab721369f08
diff --git a/android/config.go b/android/config.go
index 8300ef9..213fa2f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -167,8 +167,7 @@
}
// DisableHiddenApiChecks returns true if hiddenapi checks have been disabled.
-// For 'eng' target variant hiddenapi checks are disabled by default for performance optimisation
-// Hiddenapi checks are also disabled when RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE is set to false
+// For 'eng' target variant hiddenapi checks are disabled by default for performance optimisation,
// but can be enabled by setting environment variable ENABLE_HIDDENAPI_FLAGS=true.
// For other target variants hiddenapi check are enabled by default but can be disabled by
// setting environment variable UNSAFE_DISABLE_HIDDENAPI_FLAGS=true.
@@ -177,8 +176,16 @@
func (c Config) DisableHiddenApiChecks() bool {
return !c.IsEnvTrue("ENABLE_HIDDENAPI_FLAGS") &&
(c.IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") ||
- Bool(c.productVariables.Eng) ||
- !c.ReleaseDefaultModuleBuildFromSource())
+ Bool(c.productVariables.Eng))
+}
+
+// DisableVerifyOverlaps returns true if verify_overlaps is skipped.
+// Mismatch in version of apexes and module SDK is required for mainline prebuilts to work in
+// trunk stable.
+// Thus, verify_overlaps is disabled when RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE is set to false.
+// TODO(b/308174018): Re-enable verify_overlaps for both builr from source/mainline prebuilts.
+func (c Config) DisableVerifyOverlaps() bool {
+ return c.IsEnvTrue("DISABLE_VERIFY_OVERLAPS") || !c.ReleaseDefaultModuleBuildFromSource()
}
// MaxPageSizeSupported returns the max page size supported by the device. This
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 81be33d..fbc0197 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -358,7 +358,7 @@
// If there are stub flag files that have been generated by fragments on which this depends then
// use them to validate the stub flag file generated by the rules created by this method.
- if len(stubFlagSubsets) > 0 {
+ if !ctx.Config().DisableVerifyOverlaps() && len(stubFlagSubsets) > 0 {
validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, stubFlagSubsets,
HIDDENAPI_STUB_FLAGS_IMPL_FLAGS)
@@ -1006,7 +1006,7 @@
// If there are flag files that have been generated by fragments on which this depends then use
// them to validate the flag file generated by the rules created by this method.
- if len(flagSubsets) > 0 {
+ if !ctx.Config().DisableVerifyOverlaps() && len(flagSubsets) > 0 {
validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, flagSubsets,
HIDDENAPI_FLAGS_CSV_IMPL_FLAGS)