Add min_sdk_version when generating cc modules

Those listed hidl_interface modules are used by mainline
modules(APEX/APK) and they should declare min_sdk_version accordingly.

Setting this prop doesn't change any build outputs, but will let the
module authors know that they contribute the mainlines modules which
target and should run on declared sdk version.

Bug: 152655956
Test: m
Merged-In: If342e3b6f1bc9df2e7f87ea2cfec947c05d670b8
Change-Id: If342e3b6f1bc9df2e7f87ea2cfec947c05d670b8
(cherry picked from commit b1a31146d4f5db8c147178f97e04bef04cdcceb7)
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index 865d2d3..71f4a68 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -655,6 +655,7 @@
 			}),
 			Export_generated_headers: []string{name.headersName()},
 			Apex_available:           i.properties.Apex_available,
+			Min_sdk_version:          getMinSdkVersion(name.string()),
 		}, &i.properties.VndkProperties)
 	}
 
@@ -935,6 +936,37 @@
 	return i
 }
 
+var minSdkVersion = map[string]string{
+	"android.hardware.cas.native@1.0":           "29",
+	"android.hardware.cas@1.0":                  "29",
+	"android.hardware.graphics.allocator@2.0":   "29",
+	"android.hardware.graphics.allocator@3.0":   "29",
+	"android.hardware.graphics.bufferqueue@1.0": "29",
+	"android.hardware.graphics.bufferqueue@2.0": "29",
+	"android.hardware.graphics.common@1.0":      "29",
+	"android.hardware.graphics.common@1.1":      "29",
+	"android.hardware.graphics.common@1.2":      "29",
+	"android.hardware.graphics.mapper@2.0":      "29",
+	"android.hardware.graphics.mapper@2.1":      "29",
+	"android.hardware.graphics.mapper@3.0":      "29",
+	"android.hardware.media.bufferpool@2.0":     "29",
+	"android.hardware.media.c2@1.0":             "29",
+	"android.hardware.media.omx@1.0":            "29",
+	"android.hardware.media@1.0":                "29",
+	"android.hidl.allocator@1.0":                "29",
+	"android.hidl.memory.token@1.0":             "29",
+	"android.hidl.memory@1.0":                   "29",
+	"android.hidl.safe_union@1.0":               "29",
+	"android.hidl.token@1.0":                    "29",
+}
+
+func getMinSdkVersion(name string) *string {
+	if ver, ok := minSdkVersion[name]; ok {
+		return proptools.StringPtr(ver)
+	}
+	return nil
+}
+
 var doubleLoadablePackageNames = []string{
 	"android.frameworks.bufferhub@1.0",
 	"android.hardware.cas@1.0",
diff --git a/build/properties.go b/build/properties.go
index e945515..b0b4b85 100644
--- a/build/properties.go
+++ b/build/properties.go
@@ -42,6 +42,7 @@
 	Double_loadable           *bool
 	Cflags                    []string
 	Apex_available            []string
+	Min_sdk_version           *string
 }
 
 type javaProperties struct {