From 34feb68b28338ebed35d7de4c56e87bb7bd9b3e8 Mon Sep 17 00:00:00 2001 From: Alyssa Ketpreechasawat Date: Wed, 13 Sep 2023 03:40:02 +0000 Subject: [PATCH] Disable hiddenapi check for building from prebuilts. Add ReleaseDefaultModuleBuildFromSource to config.productVariables and use this parameter to disable hiddenapi check. Test: DEFAULT_MODULE_BUILD_FROM_SOURCE=false m (not failing hiddenapi check after disabling) Bug: 301871981 Change-Id: I86b3f3bc21d546022a503a1c6a8a641d4e785565 --- android/config.go | 13 +++++++++++-- android/variable.go | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/android/config.go b/android/config.go index f9d616d9a..3a4bf8c45 100644 --- a/android/config.go +++ b/android/config.go @@ -167,7 +167,8 @@ 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, +// 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 // 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. @@ -176,7 +177,8 @@ 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)) + Bool(c.productVariables.Eng) || + !c.ReleaseDefaultModuleBuildFromSource()) } // MaxPageSizeSupported returns the max page size supported by the device. This @@ -221,6 +223,13 @@ func (c Config) ReleaseAconfigFlagDefaultPermission() string { return c.config.productVariables.ReleaseAconfigFlagDefaultPermission } +// The flag indicating behavior for the tree wrt building modules or using prebuilts +// derived from RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE +func (c Config) ReleaseDefaultModuleBuildFromSource() bool { + return c.config.productVariables.ReleaseDefaultModuleBuildFromSource == nil || + Bool(c.config.productVariables.ReleaseDefaultModuleBuildFromSource) +} + // A DeviceConfig object represents the configuration for a particular device // being built. For now there will only be one of these, but in the future there // may be multiple devices being built. diff --git a/android/variable.go b/android/variable.go index d33294c16..79f585e30 100644 --- a/android/variable.go +++ b/android/variable.go @@ -481,6 +481,8 @@ type ProductVariables struct { ReleaseAconfigFlagDefaultPermission string `json:",omitempty"` + ReleaseDefaultModuleBuildFromSource *bool `json:",omitempty"` + KeepVndk *bool `json:",omitempty"` CheckVendorSeappViolations *bool `json:",omitempty"`