Merge changes from topic "fix-vndk-core-variant"

* changes:
  Do not install VNDK lib in favor of VNDK APEX
  Fix apex_vndk with TARGET_VNDK_USE_CORE_VARIANT
  Do not follow deps for apex_vndk
diff --git a/apex/apex.go b/apex/apex.go
index 75da7da..4ad2680 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1176,7 +1176,7 @@
 					ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
 				}
 			}
-		} else {
+		} else if !a.vndkApex {
 			// indirect dependencies
 			if am, ok := child.(android.ApexModule); ok {
 				// We cannot use a switch statement on `depTag` here as the checked
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 54cd722..91a3c99 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -93,6 +93,11 @@
 					fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
 					if c.IsVndk() && !c.static() {
 						fmt.Fprintln(w, "LOCAL_SOONG_VNDK_VERSION := "+c.vndkVersion())
+						// VNDK libraries available to vendor are not installed because
+						// they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
+						if !c.isVndkExt() {
+							fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+						}
 					}
 				}
 			},
diff --git a/cc/vndk.go b/cc/vndk.go
index ec8f023..2805e56 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -337,6 +337,10 @@
 		return false
 	}
 
+	if !mctx.Device() {
+		return false
+	}
+
 	if m.Target().NativeBridge == android.NativeBridgeEnabled {
 		return false
 	}
@@ -350,8 +354,7 @@
 
 	if lib, ok := m.linker.(libraryInterface); ok {
 		useCoreVariant := m.vndkVersion() == mctx.DeviceConfig().PlatformVndkVersion() &&
-			mctx.DeviceConfig().VndkUseCoreVariant() &&
-			!inList(m.BaseModuleName(), config.VndkMustUseVendorVariantList)
+			mctx.DeviceConfig().VndkUseCoreVariant() && !m.MustUseVendorVariant()
 		return lib.shared() && m.UseVndk() && m.IsVndk() && !m.isVndkExt() && !useCoreVariant
 	}
 	return false