soong: Fix AndroidMk with *Required properties

java.Module is using "Custom" function to write Android.mk.
And if "hostdex" is set to "true", it writes "hostdex" module definition
as well as original module.

As of now, Required/Host_required/Target_required props are filled in
the AndroidMkEntries structure(aosp/939505). But these are not
passed to old AndroidMkData.Custom function.

So, if a java_library declares "hostdex:true" and "required:[...]"
together, "required" is not applied to the "hostdex" variant.

This change copies *Required props from AndroidMkEntries to
AndroidMkData before calling its Custom callback.

Test: m (runs soong unit tests)
Change-Id: I5f85714f721a2a0917ab18072dbea52294c770e7
diff --git a/android/util.go b/android/util.go
index 3b8bc78..97bec10 100644
--- a/android/util.go
+++ b/android/util.go
@@ -115,6 +115,17 @@
 	return false
 }
 
+// IndexListPred returns the index of the element which in the given `list` satisfying the predicate, or -1 if there is no such element.
+func IndexListPred(pred func(s string) bool, list []string) int {
+	for i, l := range list {
+		if pred(l) {
+			return i
+		}
+	}
+
+	return -1
+}
+
 func FilterList(list []string, filter []string) (remainder []string, filtered []string) {
 	for _, l := range list {
 		if InList(l, filter) {