Refine ABI check and enable ABI check on APEX exported libs

* Don't check ramdisk and recovery variants.
* Don't check bionic libraries of bootstrap variant.
* Don't check uninstallable libraries.
* Check APEX exported libraries.

Bug: 145608479
Test: Presubmit
Test: diff lsdump_paths.txt, verify the changes are as expected.
Change-Id: Ie540dba563277307c51b533cd982d7317796b48b
diff --git a/cc/sabi.go b/cc/sabi.go
index c658329..99e718e 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -130,6 +130,16 @@
 
 	// Module is shared library type.
 
+	// Don't check uninstallable modules.
+	if m.IsSkipInstall() {
+		return false
+	}
+
+	// Don't check ramdisk or recovery variants. Only check core, vendor or product variants.
+	if m.InRamdisk() || m.InVendorRamdisk() || m.InRecovery() {
+		return false
+	}
+
 	// Don't create ABI dump for prebuilts.
 	if m.Prebuilt() != nil || m.isSnapshotPrebuilt() {
 		return false
@@ -150,17 +160,17 @@
 		return false
 	}
 
-	// Special case for APEX variants.
-	if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
-		// Don't create ABI dump if this library is for APEX but isn't exported.
-		if !m.HasStubsVariants() {
+	isPlatformVariant := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+	if isPlatformVariant {
+		// Bionic libraries that are installed to the bootstrap directory are not ABI checked.
+		// Only the runtime APEX variants, which are the implementation libraries of bionic NDK stubs,
+		// are checked.
+		if InstallToBootstrap(m.BaseModuleName(), ctx.Config()) {
 			return false
 		}
-		if !m.library.headerAbiCheckerEnabled() {
-			// Skip ABI checks if this library is for APEX and did not explicitly enable
-			// ABI checks.
-			// TODO(b/145608479): ABI checks should be enabled by default. Remove this
-			// after evaluating the extra build time.
+	} else {
+		// Don't create ABI dump if this library is for APEX but isn't exported.
+		if !m.HasStubsVariants() {
 			return false
 		}
 	}