Revert "Move MutateApexTransition shortcut later"

Revert submission 3477737-move_apex_shortcut

Reason for revert: Likely culprit for b/394990888 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Reverted changes: /q/submissionid:3477737-move_apex_shortcut

Change-Id: I67459460e847451d06e733a01249e3dd8017a2e0
diff --git a/android/apex.go b/android/apex.go
index a5ccd52..c2f73a9 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -616,26 +616,25 @@
 		apexInfos = allApexInfos.ApexInfos
 	}
 
-	if platformVariation && !ctx.Host() && !module.AvailableFor(AvailableToPlatform) && module.NotAvailableForPlatform() {
-		// Do not install the module for platform, but still allow it to output
-		// uninstallable AndroidMk entries in certain cases when they have side
-		// effects.  TODO(jiyong): move this routine to somewhere else
-		module.MakeUninstallable()
+	// Shortcut
+	if len(apexInfos) == 0 {
+		return
 	}
 
 	// Do some validity checks.
 	// TODO(jiyong): is this the right place?
 	base.checkApexAvailableProperty(ctx)
 
-	// Shortcut
-	if len(apexInfos) == 0 {
-		return
-	}
-
 	if !module.UniqueApexVariations() && !base.ApexProperties.UniqueApexVariationsForDeps {
 		apexInfos, _ = mergeApexVariations(apexInfos)
 	}
 
+	if platformVariation && !ctx.Host() && !module.AvailableFor(AvailableToPlatform) && module.NotAvailableForPlatform() {
+		// Do not install the module for platform, but still allow it to output
+		// uninstallable AndroidMk entries in certain cases when they have side
+		// effects.  TODO(jiyong): move this routine to somewhere else
+		module.MakeUninstallable()
+	}
 	if !platformVariation {
 		var thisApexInfo ApexInfo
 
diff --git a/cc/testing.go b/cc/testing.go
index c9d362d..14a6b7a 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -193,7 +193,7 @@
 			},
 			apex_available: [
 				"//apex_available:platform",
-				"//apex_available:anyapex",
+				"myapex"
 			],
 			llndk: {
 				symbol_file: "libm.map.txt",
@@ -253,7 +253,7 @@
 			},
 			apex_available: [
 				"//apex_available:platform",
-				"//apex_available:anyapex",
+				"myapex"
 			],
 			llndk: {
 				symbol_file: "libdl.map.txt",
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index ad315bf..36f0010 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -759,13 +759,6 @@
 			bootclasspath_fragments: ["mybootclasspathfragment"],
 		}
 
-		apex {
-			name: "myapex",
-			key: "myapex.key",
-			min_sdk_version: "1",
-			bootclasspath_fragments: ["mybootclasspathfragment"],
-		}
-
 		bootclasspath_fragment {
 			name: "mybootclasspathfragment",
 			image_name: "art",
@@ -808,7 +801,7 @@
 		java_import {
 			name: "mybootlib",
 			visibility: ["//visibility:public"],
-			apex_available: ["myapex"],
+			apex_available: ["com.android.art"],
 			jars: ["java/mybootlib.jar"],
 		}
 	`),
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 5bac67d..939477f 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -805,19 +805,13 @@
 			native_shared_libs: ["mynativelib"],
 		}
 
-		apex {
-			name: "myapex",
-			key: "myapex.key",
-			min_sdk_version: "1",
-		}
-
 		cc_library_shared {
 			name: "mynativelib",
 			srcs: [
 				"Test.cpp",
 				"aidl/foo/bar/Test.aidl",
 			],
-			apex_available: ["myapex"],
+			apex_available: ["apex1", "apex2"],
 			export_include_dirs: ["myinclude"],
 			aidl: {
 				export_aidl_headers: true,
@@ -827,18 +821,6 @@
 	`)
 
 	CheckSnapshot(t, result, "mysdk", "",
-		snapshotTestPreparer(checkSnapshotWithoutSource,
-			android.FixtureMergeMockFs(android.MockFS{
-				"myapex/Android.bp": []byte(`
-				apex {
-					name: "myapex",
-					key: "myapex.key",
-					min_sdk_version: "1",
-				}
-				`),
-				"myapex/apex_manifest.json": nil,
-			}),
-		),
 		checkAndroidBpContents(`
 // This is auto-generated. DO NOT EDIT.
 
@@ -851,7 +833,10 @@
     name: "mynativelib",
     prefer: false,
     visibility: ["//visibility:public"],
-    apex_available: ["myapex"],
+    apex_available: [
+        "apex1",
+        "apex2",
+    ],
     stl: "none",
     compile_multilib: "both",
     export_include_dirs: ["include/myinclude"],
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 7ebdcd4..60e5b95 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -87,18 +87,6 @@
 
 	CheckSnapshot(t, result, "mysdk", "",
 		checkAndroidBpContents(expectedSdkSnapshot),
-		snapshotTestPreparer(checkSnapshotWithoutSource,
-			android.FixtureMergeMockFs(android.MockFS{
-				"myapex/Android.bp": []byte(`
-				apex {
-					name: "myapex",
-					key: "myapex.key",
-					min_sdk_version: "1",
-				}
-				`),
-				"myapex/apex_manifest.json": nil,
-			}),
-		),
 	)
 }