Merge changes I831da5fa,I866916c9

* changes:
  Move logic for selecting the primary module into initHiddenAPI()
  Ensure that <x>-hiddenapi modules are included in hiddenapi-index.csv
diff --git a/dexpreopt/class_loader_context.go b/dexpreopt/class_loader_context.go
index ec62eb3..ad52b00 100644
--- a/dexpreopt/class_loader_context.go
+++ b/dexpreopt/class_loader_context.go
@@ -489,20 +489,16 @@
 }
 
 // Class loader contexts that come from Make via JSON dexpreopt.config. JSON CLC representation is
-// slightly different: it uses a map of library names to their CLC (instead of a list of structs
-// that including the name, as in the Soong CLC representation). The difference is insubstantial, it
-// is caused only by the language differerences between Go and JSON.
+// the same as Soong representation except that SDK versions and paths are represented with strings.
 type jsonClassLoaderContext struct {
+	Name        string
 	Host        string
 	Device      string
-	Subcontexts map[string]*jsonClassLoaderContext
+	Subcontexts []*jsonClassLoaderContext
 }
 
-// A map of <uses-library> name to its on-host and on-device build paths and CLC.
-type jsonClassLoaderContexts map[string]*jsonClassLoaderContext
-
 // A map from SDK version (represented with a JSON string) to JSON CLCs.
-type jsonClassLoaderContextMap map[string]map[string]*jsonClassLoaderContext
+type jsonClassLoaderContextMap map[string][]*jsonClassLoaderContext
 
 // Convert JSON CLC map to Soong represenation.
 func fromJsonClassLoaderContext(ctx android.PathContext, jClcMap jsonClassLoaderContextMap) ClassLoaderContextMap {
@@ -522,11 +518,11 @@
 }
 
 // Recursive helper for fromJsonClassLoaderContext.
-func fromJsonClassLoaderContextRec(ctx android.PathContext, jClcs map[string]*jsonClassLoaderContext) []*ClassLoaderContext {
+func fromJsonClassLoaderContextRec(ctx android.PathContext, jClcs []*jsonClassLoaderContext) []*ClassLoaderContext {
 	clcs := make([]*ClassLoaderContext, 0, len(jClcs))
-	for lib, clc := range jClcs {
+	for _, clc := range jClcs {
 		clcs = append(clcs, &ClassLoaderContext{
-			Name:        lib,
+			Name:        clc.Name,
 			Host:        constructPath(ctx, clc.Host),
 			Device:      clc.Device,
 			Subcontexts: fromJsonClassLoaderContextRec(ctx, clc.Subcontexts),
@@ -546,14 +542,15 @@
 }
 
 // Recursive helper for toJsonClassLoaderContext.
-func toJsonClassLoaderContextRec(clcs []*ClassLoaderContext) map[string]*jsonClassLoaderContext {
-	jClcs := make(map[string]*jsonClassLoaderContext, len(clcs))
+func toJsonClassLoaderContextRec(clcs []*ClassLoaderContext) []*jsonClassLoaderContext {
+	jClcs := make([]*jsonClassLoaderContext, len(clcs))
 	for _, clc := range clcs {
-		jClcs[clc.Name] = &jsonClassLoaderContext{
+		jClcs = append(jClcs, &jsonClassLoaderContext{
+			Name:        clc.Name,
 			Host:        clc.Host.String(),
 			Device:      clc.Device,
 			Subcontexts: toJsonClassLoaderContextRec(clc.Subcontexts),
-		}
+		})
 	}
 	return jClcs
 }
diff --git a/rust/compiler.go b/rust/compiler.go
index 586063e..224e201 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -254,7 +254,7 @@
 	if !Bool(compiler.Properties.No_stdlibs) {
 		for _, stdlib := range config.Stdlibs {
 			// If we're building for the primary arch of the build host, use the compiler's stdlibs
-			if ctx.Target().Os == android.BuildOs && ctx.TargetPrimary() {
+			if ctx.Target().Os == android.BuildOs {
 				stdlib = stdlib + "_" + ctx.toolchain().RustTriple()
 			}
 
diff --git a/rust/testing.go b/rust/testing.go
index 4c4df4a..1afe27e 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -46,6 +46,30 @@
 				sysroot: true,
 		}
 		rust_prebuilt_library {
+				name: "libstd_i686-unknown-linux-gnu",
+                                crate_name: "std",
+                                rlib: {
+                                    srcs: ["libstd.rlib"],
+                                },
+                                dylib: {
+                                    srcs: ["libstd.so"],
+                                },
+				host_supported: true,
+				sysroot: true,
+		}
+		rust_prebuilt_library {
+				name: "libtest_i686-unknown-linux-gnu",
+                                crate_name: "test",
+                                rlib: {
+                                    srcs: ["libtest.rlib"],
+                                },
+                                dylib: {
+                                    srcs: ["libtest.so"],
+                                },
+				host_supported: true,
+				sysroot: true,
+		}
+		rust_prebuilt_library {
 				name: "libstd_x86_64-apple-darwin",
                                 crate_name: "std",
                                 rlib: {
diff --git a/scripts/build-mainline-modules.sh b/scripts/build-mainline-modules.sh
index b8485ea..ac67438 100755
--- a/scripts/build-mainline-modules.sh
+++ b/scripts/build-mainline-modules.sh
@@ -26,6 +26,8 @@
   platform-mainline-test-exports
   runtime-module-host-exports
   runtime-module-sdk
+  stats-log-api-gen-exports
+  statsd-module-sdk
   tzdata-module-test-exports
 )