Enforce hidden apis usage in product(soong)
Only if PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE is set, every app and java library in product cannot use hidden APIs anymore. checkSdkVersion() checks if sdk_version of app and library is narrow enough, checkLinkType() checks every library that app links agianst Bug: 132780927 Test: m Test: set PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE, and check whether build error occurs. Change-Id: Ic630503b875040f730feda4fef826ed6d71da111
This commit is contained in:
@@ -666,6 +666,44 @@ func TestJNIABI(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppSdkVersionByPartition(t *testing.T) {
|
||||
testJavaError(t, "sdk_version must have a value when the module is located at vendor or product", `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
vendor: true,
|
||||
platform_apis: true,
|
||||
}
|
||||
`)
|
||||
|
||||
testJava(t, `
|
||||
android_app {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
platform_apis: true,
|
||||
}
|
||||
`)
|
||||
|
||||
for _, enforce := range []bool{true, false} {
|
||||
|
||||
config := testConfig(nil)
|
||||
config.TestProductVariables.EnforceProductPartitionInterface = proptools.BoolPtr(enforce)
|
||||
bp := `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
product_specific: true,
|
||||
platform_apis: true,
|
||||
}
|
||||
`
|
||||
if enforce {
|
||||
testJavaErrorWithConfig(t, "sdk_version must have a value when the module is located at vendor or product", bp, config)
|
||||
} else {
|
||||
testJavaWithConfig(t, bp, config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestJNIPackaging(t *testing.T) {
|
||||
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
|
||||
cc_library {
|
||||
|
Reference in New Issue
Block a user