Revert "Revert "Supports VNDK APEX with different versions""

This reverts commit 48dd4b5ea480319da29359a668191d52e9d8c9c2.

Bug: 141451661
Bug: 139772411
Test: m (soong tests)
Test: boot with aosp_arm64 system image on Q vendor device
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 2cebb6d..8ed0afb 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -130,13 +130,7 @@
 func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
 	flags Flags, deps PathDeps, objs Objects) android.Path {
 
-	arches := ctx.DeviceConfig().Arches()
-	if len(arches) == 0 || arches[0].ArchType.String() != p.arch() {
-		ctx.Module().SkipInstall()
-		return nil
-	}
-
-	if ctx.DeviceConfig().BinderBitness() != p.binderBit() {
+	if !p.matchesWithDevice(ctx.DeviceConfig()) {
 		ctx.Module().SkipInstall()
 		return nil
 	}
@@ -153,6 +147,20 @@
 	return nil
 }
 
+func (p *vndkPrebuiltLibraryDecorator) matchesWithDevice(config android.DeviceConfig) bool {
+	arches := config.Arches()
+	if len(arches) == 0 || arches[0].ArchType.String() != p.arch() {
+		return false
+	}
+	if config.BinderBitness() != p.binderBit() {
+		return false
+	}
+	if len(p.properties.Srcs) == 0 {
+		return false
+	}
+	return true
+}
+
 func (p *vndkPrebuiltLibraryDecorator) nativeCoverage() bool {
 	return false
 }