From 9b62bc81f7aeecbc9fd8603ac70f3d6d73035391 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 13 Sep 2021 21:11:05 +0900 Subject: [PATCH] Keep only the classes in the android.test.mock package framework-core-sources-for-test-mock has some classes that are outside of the android.test.mock package. It is necessary just to provide private APIs to the mock classes, but not to include them in the impl library. Removing the unnecessary classes by using jarjar. Bug: 199529199 Test: m Change-Id: I4d0de6132245c4923a4b17a4004c300cd864c116 --- test-mock/Android.bp | 12 +++++++++++- test-mock/jarjar-rules.txt | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test-mock/jarjar-rules.txt diff --git a/test-mock/Android.bp b/test-mock/Android.bp index 460a26d63cd6d..0bb61987a5142 100644 --- a/test-mock/Android.bp +++ b/test-mock/Android.bp @@ -32,7 +32,9 @@ java_sdk_library { ":android-test-mock-sources", // Note: Below are NOT APIs of this library. We only take APIs under // the android.test.mock package. They however provide private APIs that - // android.test.mock APIs references to. + // android.test.mock APIs references to. We need to have the classes in + // source code form to have access to the @hide comment which disappears + // when the classes are compiled into a Jar library. ":framework-core-sources-for-test-mock", ":framework_native_aidl", ], @@ -46,6 +48,14 @@ java_sdk_library { api_packages: [ "android.test.mock", ], + // Only include android.test.mock.* classes. Jarjar rules below removes + // classes in other packages like android.content. In order to keep the + // list up-to-date, permitted_packages ensures that the library contains + // clases under android.test.mock after the jarjar rules are applied. + jarjar_rules: "jarjar-rules.txt", + permitted_packages: [ + "android.test.mock", + ], compile_dex: true, default_to_stubs: true, dist_group: "android", diff --git a/test-mock/jarjar-rules.txt b/test-mock/jarjar-rules.txt new file mode 100644 index 0000000000000..4420a4413f5b8 --- /dev/null +++ b/test-mock/jarjar-rules.txt @@ -0,0 +1,7 @@ +zap android.accounts.** +zap android.app.** +zap android.content.** +zap android.database.** +zap android.os.** +zap android.util.** +zap android.view.**