Move imageMutator before archMutator

Run the imageMutator between osMutator and archMutator so that
different arch variants can be set for the different partitions.

Bug: 142286466
Test: m checkbuild
Change-Id: I65d05714b75aa462bf9816da60fdc2deda4de593
Merged-In: I65d05714b75aa462bf9816da60fdc2deda4de593
(cherry picked from commit 9c8f687584986f6e36ebfdbda22c3cc6c21cf02d)
diff --git a/android/arch.go b/android/arch.go
index 0519e76..276dd3b 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -822,7 +822,7 @@
 
 	os := base.commonProperties.CompileOS
 	osTargets := mctx.Config().Targets[os]
-
+	image := base.commonProperties.ImageVariation
 	// Filter NativeBridge targets unless they are explicitly supported
 	if os == Android && !Bool(base.commonProperties.Native_bridge_supported) {
 		var targets []Target
@@ -859,6 +859,12 @@
 		}
 	}
 
+	if image == RecoveryVariation {
+		primaryArch := mctx.Config().DevicePrimaryArchType()
+		targets = filterToArch(targets, primaryArch)
+		multiTargets = filterToArch(multiTargets, primaryArch)
+	}
+
 	if len(targets) == 0 {
 		base.commonProperties.Enabled = boolPtr(false)
 		return
@@ -907,6 +913,16 @@
 	}
 }
 
+func filterToArch(targets []Target, arch ArchType) []Target {
+	for i := 0; i < len(targets); i++ {
+		if targets[i].Arch.ArchType != arch {
+			targets = append(targets[:i], targets[i+1:]...)
+			i--
+		}
+	}
+	return targets
+}
+
 // createArchType takes a reflect.Type that is either a struct or a pointer to a struct, and returns a list of
 // reflect.Type that contains the arch-variant properties inside structs for each architecture, os, target, multilib,
 // etc.