Respect `required` property of apex modules

This CL fixes a bug that `required` property of apex modules is not
reflected to the generated Android.mk file.

Bug: N/A
Test: m nothing
Change-Id: I36ccf538882f083f9433bd3eb05b3a5127f3822b
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 78a6bb8..e7c63b9 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -8328,6 +8328,46 @@
 		})
 }
 
+func TestAndroidMk_RequiredModules(t *testing.T) {
+	ctx := testApex(t, `
+		apex {
+			name: "myapex",
+			key: "myapex.key",
+			updatable: false,
+			java_libs: ["foo"],
+			required: ["otherapex"],
+		}
+
+		apex {
+			name: "otherapex",
+			key: "myapex.key",
+			updatable: false,
+			java_libs: ["foo"],
+			required: ["otherapex"],
+		}
+
+		apex_key {
+			name: "myapex.key",
+			public_key: "testkey.avbpubkey",
+			private_key: "testkey.pem",
+		}
+
+		java_library {
+			name: "foo",
+			srcs: ["foo.java"],
+			apex_available: ["myapex", "otherapex"],
+			installable: true,
+		}
+	`)
+
+	apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
+	data := android.AndroidMkDataForTest(t, ctx, apexBundle)
+	var builder strings.Builder
+	data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
+	androidMk := builder.String()
+	ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherapex")
+}
+
 func TestMain(m *testing.M) {
 	os.Exit(m.Run())
 }