Implement android_test_import

Test: app_test.go, prebuilt CTS tests
Fixes: 132371143
Change-Id: Ife12ba691dfa597dde90faf0957224a6f444e139
diff --git a/java/androidmk.go b/java/androidmk.go
index 9101b25..0e8e422 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -122,6 +122,15 @@
 	}
 }
 
+func testSuiteComponentEntries(entries *android.AndroidMkEntries, test_suites []string) {
+	entries.SetString("LOCAL_MODULE_TAGS", "tests")
+	if len(test_suites) > 0 {
+		entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
+	} else {
+		entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
+	}
+}
+
 func (j *Test) AndroidMk() android.AndroidMkData {
 	data := j.Library.AndroidMk()
 	data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
@@ -632,6 +641,15 @@
 	}
 }
 
+func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
+	entries := a.AndroidAppImport.AndroidMkEntries()
+	entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+		testSuiteComponentEntries(entries, a.testProperties.Test_suites)
+		androidMkEntriesWriteTestData(a.data, entries)
+	})
+	return entries
+}
+
 func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
 	var testFiles []string
 	for _, d := range data {
@@ -643,3 +661,11 @@
 		})
 	}
 }
+
+func androidMkEntriesWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
+	var testFiles []string
+	for _, d := range data {
+		testFiles = append(testFiles, d.String()+":"+d.Rel())
+	}
+	entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
+}