Enforce hidden api usage in vendor (soong)
From aosp/588578, if vendor app doesn't fill sdk_version, build scirpt overwrites system_current to sdk_version.
But there is no similar enforcement in soong.
So, as make does, sdkVersion() returns "system_current" if it is device-specific or soc-specific module. and sdk_version is not filled.
Test: pass soong test
Bug: 132780927
Change-Id: I69bb3d7bfcf7c27c2db4d0efbe046f9c7879b4bc
diff --git a/java/java.go b/java/java.go
index a2e9ab0..0378436 100644
--- a/java/java.go
+++ b/java/java.go
@@ -426,6 +426,18 @@
usesLibTag = dependencyTag{name: "uses-library"}
)
+func defaultSdkVersion(ctx checkVendorModuleContext) string {
+ if ctx.SocSpecific() || ctx.DeviceSpecific() {
+ return "system_current"
+ }
+ return ""
+}
+
+type checkVendorModuleContext interface {
+ SocSpecific() bool
+ DeviceSpecific() bool
+}
+
type sdkDep struct {
useModule, useFiles, useDefaultLibs, invalidVersion bool
@@ -465,7 +477,7 @@
}
func (j *Module) sdkVersion() string {
- return String(j.deviceProperties.Sdk_version)
+ return proptools.StringDefault(j.deviceProperties.Sdk_version, defaultSdkVersion(j))
}
func (j *Module) minSdkVersion() string {
@@ -1869,7 +1881,7 @@
}
func (j *Import) sdkVersion() string {
- return String(j.properties.Sdk_version)
+ return proptools.StringDefault(j.properties.Sdk_version, defaultSdkVersion(j))
}
func (j *Import) minSdkVersion() string {