Remove global state from VNDK apexes

Use the name of the apex instead of a global map to find the right
VNDK apex for each VNDK version.

Bug: 181689854
Test: apex tests
Change-Id: If9f8fb10d09e125c9e7d44228e1aa746bf53c082
diff --git a/apex/vndk_test.go b/apex/vndk_test.go
index ccf4e57..74a79e1 100644
--- a/apex/vndk_test.go
+++ b/apex/vndk_test.go
@@ -11,12 +11,12 @@
 func TestVndkApexForVndkLite(t *testing.T) {
 	ctx, _ := testApex(t, `
 		apex_vndk {
-			name: "myapex",
-			key: "myapex.key",
+			name: "com.android.vndk.current",
+			key: "com.android.vndk.current.key",
 		}
 
 		apex_key {
-			name: "myapex.key",
+			name: "com.android.vndk.current.key",
 			public_key: "testkey.avbpubkey",
 			private_key: "testkey.pem",
 		}
@@ -31,7 +31,7 @@
 			},
 			system_shared_libs: [],
 			stl: "none",
-			apex_available: [ "myapex" ],
+			apex_available: [ "com.android.vndk.current" ],
 		}
 
 		cc_library {
@@ -45,13 +45,13 @@
 			},
 			system_shared_libs: [],
 			stl: "none",
-			apex_available: [ "myapex" ],
+			apex_available: [ "com.android.vndk.current" ],
 		}
 	`+vndkLibrariesTxtFiles("current"), func(fs map[string][]byte, config android.Config) {
 		config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("")
 	})
 	// VNDK-Lite contains only core variants of VNDK-Sp libraries
-	ensureExactContents(t, ctx, "myapex", "android_common_image", []string{
+	ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
 		"lib/libvndksp.so",
 		"lib/libc++.so",
 		"lib64/libvndksp.so",
@@ -67,7 +67,7 @@
 func TestVndkApexUsesVendorVariant(t *testing.T) {
 	bp := `
 		apex_vndk {
-			name: "myapex",
+			name: "com.android.vndk.current",
 			key: "mykey",
 		}
 		apex_key {
@@ -94,7 +94,7 @@
 				return
 			}
 		}
-		t.Fail()
+		t.Errorf("expected path %q not found", path)
 	}
 
 	t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
@@ -106,7 +106,7 @@
 		}
 
 		// VNDK APEX doesn't create apex variant
-		files := getFiles(t, ctx, "myapex", "android_common_image")
+		files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
 		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
 	})
 
@@ -116,7 +116,7 @@
 			config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
 		})
 
-		files := getFiles(t, ctx, "myapex", "android_common_image")
+		files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
 		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
 	})
 
@@ -126,10 +126,10 @@
 			config.TestProductVariables.Native_coverage = proptools.BoolPtr(true)
 		})
 
-		files := getFiles(t, ctx, "myapex", "android_common_image")
+		files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
 		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
 
-		files = getFiles(t, ctx, "myapex", "android_common_cov_image")
+		files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov_image")
 		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so")
 	})
 }