Revert^2 "Prevent unspecified values in soong_config_string_variable""

This reverts commit 38944c70c473c0976a97be774f49a4dfeb60525f.

Reason for revert: Reintroduce this change now that fixes have been made in the affected products.

Change-Id: I6a4cb37a75fb108145b9cf10a9c9aaa35fb5ea0b
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go
index 212b752..8dd9b89 100644
--- a/android/soongconfig/modules.go
+++ b/android/soongconfig/modules.go
@@ -639,9 +639,13 @@
 // Extracts an interface from values containing the properties to apply based on config.
 // If config does not match a value with a non-nil property set, the default value will be returned.
 func (s *stringVariable) PropertiesToApply(config SoongConfig, values reflect.Value) (interface{}, error) {
+	configValue := config.String(s.variable)
+	if configValue != "" && !InList(configValue, s.values) {
+		return nil, fmt.Errorf("Soong config property %q must be one of %v, found %q", s.variable, s.values, configValue)
+	}
 	for j, v := range s.values {
 		f := values.Field(j)
-		if config.String(s.variable) == v && !f.Elem().IsNil() {
+		if configValue == v && !f.Elem().IsNil() {
 			return f.Interface(), nil
 		}
 	}
@@ -858,3 +862,13 @@
 }
 
 var emptyInterfaceType = reflect.TypeOf(emptyInterfaceStruct{}).Field(0).Type
+
+// InList checks if the string belongs to the list
+func InList(s string, list []string) bool {
+	for _, s2 := range list {
+		if s2 == s {
+			return true
+		}
+	}
+	return false
+}