diff --git a/android/config.go b/android/config.go index 8300ef9bb..213fa2f6b 100644 --- a/android/config.go +++ b/android/config.go @@ -167,8 +167,7 @@ func (c Config) RunningInsideUnitTest() bool { } // 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) RunningInsideUnitTest() bool { 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 81be33dd1..fbc0197d6 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -358,7 +358,7 @@ func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, // 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 @@ func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc st // 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)