Add header_abi_checker properties for vendor, product, and platform

The developers can apply different configurations to vendor, product,
and platform libraries. In LSDUMP_PATHS_FILE, the vendor and product
variants are tagged with VENDOR and PRODUCT. Their ABI dumps will not be
generated in the directories under prebuilts/abi-dumps.

Test: make libutils.vendor libutils
Bug: 227282691
Change-Id: I747ceb174a070a67d592c5a47fcc848a6129661d
diff --git a/cc/sabi.go b/cc/sabi.go
index e62ca66..4cd776a 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -26,6 +26,40 @@
 	lsdumpPathsLock sync.Mutex
 )
 
+// Properties for ABI compatibility checker in Android.bp.
+type headerAbiCheckerProperties struct {
+	// Enable ABI checks (even if this is not an LLNDK/VNDK lib)
+	Enabled *bool
+
+	// Path to a symbol file that specifies the symbols to be included in the generated
+	// ABI dump file
+	Symbol_file *string `android:"path"`
+
+	// Symbol versions that should be ignored from the symbol file
+	Exclude_symbol_versions []string
+
+	// Symbol tags that should be ignored from the symbol file
+	Exclude_symbol_tags []string
+
+	// Run checks on all APIs (in addition to the ones referred by
+	// one of exported ELF symbols.)
+	Check_all_apis *bool
+
+	// Extra flags passed to header-abi-diff
+	Diff_flags []string
+
+	// Opt-in reference dump directories
+	Ref_dump_dirs []string
+}
+
+func (props *headerAbiCheckerProperties) enabled() bool {
+	return Bool(props.Enabled)
+}
+
+func (props *headerAbiCheckerProperties) explicitlyDisabled() bool {
+	return !BoolDefault(props.Enabled, true)
+}
+
 type SAbiProperties struct {
 	// Whether ABI dump should be created for this module.
 	// Set by `sabiDepsMutator` if this module is a shared library that needs ABI check, or a static
@@ -67,7 +101,8 @@
 // Returns an empty string if ABI check is disabled for this library.
 func classifySourceAbiDump(ctx android.BaseModuleContext) string {
 	m := ctx.Module().(*Module)
-	if m.library.headerAbiCheckerExplicitlyDisabled() {
+	headerAbiChecker := m.library.getHeaderAbiCheckerProperties(ctx)
+	if headerAbiChecker.explicitlyDisabled() {
 		return ""
 	}
 	// Return NDK if the library is both NDK and LLNDK.
@@ -92,7 +127,16 @@
 			}
 		}
 	}
-	if m.library.headerAbiCheckerEnabled() || m.library.hasStubsVariants() {
+	if m.library.hasStubsVariants() && !m.InProduct() && !m.InVendor() {
+		return "PLATFORM"
+	}
+	if headerAbiChecker.enabled() {
+		if m.InProduct() {
+			return "PRODUCT"
+		}
+		if m.InVendor() {
+			return "VENDOR"
+		}
 		return "PLATFORM"
 	}
 	return ""