Share vdex files in the ART apex between architectures (via symlinks).

Test: aosp_walleye-userdebug boots.

Test: Check symlinks to *.vdex files in the ART apex:
$ adb shell 'find /apex/com.android.art -name '*.vdex' | xargs ls -l'
  lrw-r--r-- 1 system system   23 1970-01-01 01:00 /apex/com.android.art/javalib/arm/boot-apache-xml.vdex -> ../boot-apache-xml.vdex
  lrw-r--r-- 1 system system   25 1970-01-01 01:00 /apex/com.android.art/javalib/arm/boot-bouncycastle.vdex -> ../boot-bouncycastle.vdex
  lrw-r--r-- 1 system system   23 1970-01-01 01:00 /apex/com.android.art/javalib/arm/boot-core-icu4j.vdex -> ../boot-core-icu4j.vdex
  lrw-r--r-- 1 system system   24 1970-01-01 01:00 /apex/com.android.art/javalib/arm/boot-core-libart.vdex -> ../boot-core-libart.vdex
  lrw-r--r-- 1 system system   19 1970-01-01 01:00 /apex/com.android.art/javalib/arm/boot-okhttp.vdex -> ../boot-okhttp.vdex
  lrw-r--r-- 1 system system   12 1970-01-01 01:00 /apex/com.android.art/javalib/arm/boot.vdex -> ../boot.vdex
  lrw-r--r-- 1 system system   23 1970-01-01 01:00 /apex/com.android.art/javalib/arm64/boot-apache-xml.vdex -> ../boot-apache-xml.vdex
  lrw-r--r-- 1 system system   25 1970-01-01 01:00 /apex/com.android.art/javalib/arm64/boot-bouncycastle.vdex -> ../boot-bouncycastle.vdex
  lrw-r--r-- 1 system system   23 1970-01-01 01:00 /apex/com.android.art/javalib/arm64/boot-core-icu4j.vdex -> ../boot-core-icu4j.vdex
  lrw-r--r-- 1 system system   24 1970-01-01 01:00 /apex/com.android.art/javalib/arm64/boot-core-libart.vdex -> ../boot-core-libart.vdex
  lrw-r--r-- 1 system system   19 1970-01-01 01:00 /apex/com.android.art/javalib/arm64/boot-okhttp.vdex -> ../boot-okhttp.vdex
  lrw-r--r-- 1 system system   12 1970-01-01 01:00 /apex/com.android.art/javalib/arm64/boot.vdex -> ../boot.vdex
  -rw-r--r-- 1 system system 1229 1970-01-01 01:00 /apex/com.android.art/javalib/boot-apache-xml.vdex
  -rw-r--r-- 1 system system 2043 1970-01-01 01:00 /apex/com.android.art/javalib/boot-bouncycastle.vdex
  -rw-r--r-- 1 system system 2883 1970-01-01 01:00 /apex/com.android.art/javalib/boot-core-icu4j.vdex
  -rw-r--r-- 1 system system  865 1970-01-01 01:00 /apex/com.android.art/javalib/boot-core-libart.vdex
  -rw-r--r-- 1 system system  395 1970-01-01 01:00 /apex/com.android.art/javalib/boot-okhttp.vdex
  -rw-r--r-- 1 system system 7125 1970-01-01 01:00 /apex/com.android.art/javalib/boot.vdex

Bug: 150934453

Change-Id: Ifbceb845749f4c218693f4118e8b35b59ff26de1
diff --git a/apex/apex.go b/apex/apex.go
index cddd72b..ab6ceff 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2315,7 +2315,10 @@
 	// Build rules are generated by the dexpreopt singleton, and here we access build artifacts
 	// via the global boot image config.
 	if a.artApex {
-		for arch, files := range java.DexpreoptedArtApexJars(ctx) {
+		artAndOatFiles, vdexFiles := java.DexpreoptedArtApexJars(ctx)
+
+		// Copy *.art and *.oat files to arch-specific subdirectories.
+		for arch, files := range artAndOatFiles {
 			dirInApex := filepath.Join("javalib", arch.String())
 			for _, f := range files {
 				localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
@@ -2323,6 +2326,18 @@
 				filesInfo = append(filesInfo, af)
 			}
 		}
+
+		// Copy *.vdex files to a common subdirectory.
+		for _, file := range vdexFiles {
+			dirInApex := "javalib"
+			localModule := "javalib_" + filepath.Base(file.String())
+			af := newApexFile(ctx, file, localModule, dirInApex, etc, nil)
+			// Add a symlink to the *.vdex file for each arch-specific subdirectory.
+			for arch := range artAndOatFiles {
+				af.symlinks = append(af.symlinks, filepath.Join(arch.String(), filepath.Base(file.String())))
+			}
+			filesInfo = append(filesInfo, af)
+		}
 	}
 
 	if a.private_key_file == nil {