Merge "Enforce hidden api usage in vendor (soong)" am: e65d84c84c
am: 7a22534a47
Change-Id: Iffbacc0f98fb208e6f71919bcefa19cb0e57efca
This commit is contained in:
commit
218964e76e
|
@ -510,7 +510,7 @@ type AARImport struct {
|
|||
}
|
||||
|
||||
func (a *AARImport) sdkVersion() string {
|
||||
return String(a.properties.Sdk_version)
|
||||
return proptools.StringDefault(a.properties.Sdk_version, defaultSdkVersion(a))
|
||||
}
|
||||
|
||||
func (a *AARImport) minSdkVersion() string {
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -520,7 +521,7 @@ func JavadocHostFactory() android.Module {
|
|||
var _ android.OutputFileProducer = (*Javadoc)(nil)
|
||||
|
||||
func (j *Javadoc) sdkVersion() string {
|
||||
return String(j.properties.Sdk_version)
|
||||
return proptools.StringDefault(j.properties.Sdk_version, defaultSdkVersion(j))
|
||||
}
|
||||
|
||||
func (j *Javadoc) minSdkVersion() string {
|
||||
|
|
16
java/java.go
16
java/java.go
|
@ -423,6 +423,18 @@ var (
|
|||
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
|
||||
|
||||
|
@ -462,7 +474,7 @@ func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -1862,7 +1874,7 @@ type Import struct {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -286,6 +286,32 @@ func TestSimple(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSdkVersion(t *testing.T) {
|
||||
ctx := testJava(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
foo := ctx.ModuleForTests("foo", "android_common").Module().(*Library)
|
||||
bar := ctx.ModuleForTests("bar", "android_common").Module().(*Library)
|
||||
|
||||
if foo.sdkVersion() != "system_current" {
|
||||
t.Errorf("If sdk version of vendor module is empty, it must change to system_current.")
|
||||
}
|
||||
|
||||
if bar.sdkVersion() != "" {
|
||||
t.Errorf("If sdk version of non-vendor module is empty, it keeps empty.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestArchSpecific(t *testing.T) {
|
||||
ctx := testJava(t, `
|
||||
java_library {
|
||||
|
|
Loading…
Reference in New Issue