diff options
| author | 2022-02-10 15:41:46 +1100 | |
|---|---|---|
| committer | 2022-02-24 10:15:27 +1100 | |
| commit | de8417c7076949606bd3767e6112d1e2390d9678 (patch) | |
| tree | 2b67f5479ce7a13cb238c39af2b30ec1fee1b55e /java/java_test.go | |
| parent | 7309742728063ebea25eff41df6ce0483fbe7f84 (diff) | |
Add AIDL enforce_permissions attribute
When set to true, this attribute will pass down the
-Wmissing-permission-annotation flag to the aidl compiler. It is
possible to declare a set of exceptions (for a graduable adoption). For
now, only Java is supported.
Test: build having the attribute enabled for frameworks/base
Bug: 220214993
Change-Id: I54350199b4d980aef0050519e3daf1fef616d08c
Diffstat (limited to 'java/java_test.go')
| -rw-r--r-- | java/java_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go index 21c76b6c1..f095c5e48 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1333,6 +1333,42 @@ func TestAidlFlagsWithMinSdkVersion(t *testing.T) { } } +func TestAidlEnforcePermissions(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "foo", + srcs: ["aidl/foo/IFoo.aidl"], + aidl: { enforce_permissions: true }, + } + `) + + aidlCommand := ctx.ModuleForTests("foo", "android_common").Rule("aidl").RuleParams.Command + expectedAidlFlag := "-Wmissing-permission-annotation -Werror" + if !strings.Contains(aidlCommand, expectedAidlFlag) { + t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) + } +} + +func TestAidlEnforcePermissionsException(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "foo", + srcs: ["aidl/foo/IFoo.aidl", "aidl/foo/IFoo2.aidl"], + aidl: { enforce_permissions: true, enforce_permissions_exceptions: ["aidl/foo/IFoo2.aidl"] }, + } + `) + + aidlCommand := ctx.ModuleForTests("foo", "android_common").Rule("aidl").RuleParams.Command + expectedAidlFlag := "$$FLAGS -Wmissing-permission-annotation -Werror aidl/foo/IFoo.aidl" + if !strings.Contains(aidlCommand, expectedAidlFlag) { + t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) + } + expectedAidlFlag = "$$FLAGS aidl/foo/IFoo2.aidl" + if !strings.Contains(aidlCommand, expectedAidlFlag) { + t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) + } +} + func TestDataNativeBinaries(t *testing.T) { ctx, _ := testJava(t, ` java_test_host { |