From cbac8e0b63438d76653cfdfd0ba7be28c29c3f45 Mon Sep 17 00:00:00 2001 From: Paul Duffin <paulduffin@google.com> Date: Wed, 13 May 2020 12:28:49 +0100 Subject: [PATCH] Switch framework-tethering to use java_sdk_library The names of the individual modules do not quite follow the pattern that java_sdk_library uses so this temporarily sets the following: naming_scheme: "frameworks-modules" That causes java_sdk_library to use a naming scheme that matches the one used by the individual modules of this. It will be cleaned up later. Part of the purpose of the java_sdk_library is to hide the implementation code and force users of the library to depend on stubs for a well defined API. Ideally, it would allow access to the implementation in those cases where it is safe, e.g. from within the same APEX, or from tests for the implementation. Unfortunately, due to limitations in the build it does not yet have enough information to make that decision correctly which means that any code that needs to compile against the implementation is broken which would prevent us from converting the module to java_sdk_library. However, the only way to provide the additional information to allow the implementation to be correctly exposed is to convert the modules to java_sdk_library; a cycle. In order to break that cycle the java_sdk_library creates a special <module>.impl target which is used directly by tests and any other code that needs it. Once all the modules have been converted to a java_sdk_library then we can resolve the limitations in the build and remove the direct references to <module>.impl. Test: m Tethering InProcessTethering checkapi Bug: 155164730 Merged-In: If5c115f482751f9f4b5f047e9e401a18e36799ef Change-Id: Id1c2e848430c49a2da7402244814cd084f5da77c --- Tethering/Android.bp | 2 +- Tethering/common/TetheringLib/Android.bp | 101 ++--------------------- Tethering/tests/unit/Android.bp | 4 +- 3 files changed, 12 insertions(+), 95 deletions(-) diff --git a/Tethering/Android.bp b/Tethering/Android.bp index 1ee017be50..8ae30a5c6f 100644 --- a/Tethering/Android.bp +++ b/Tethering/Android.bp @@ -33,7 +33,7 @@ java_defaults { "net-utils-framework-common", ], libs: [ - "framework-tethering", + "framework-tethering.impl", "framework-wifi-stubs-systemapi", "unsupportedappusage", ], diff --git a/Tethering/common/TetheringLib/Android.bp b/Tethering/common/TetheringLib/Android.bp index ae4bb3e5e2..408725c865 100644 --- a/Tethering/common/TetheringLib/Android.bp +++ b/Tethering/common/TetheringLib/Android.bp @@ -13,31 +13,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -java_library { +java_sdk_library { name: "framework-tethering", - sdk_version: "module_current", + defaults: ["framework-module-defaults"], srcs: [ ":framework-tethering-srcs", ], + + // TODO(b/155480189) - Remove naming_scheme once references have been resolved. + // Temporary java_sdk_library component naming scheme to use to ease the transition from separate + // modules to java_sdk_library. + naming_scheme: "framework-modules", + jarjar_rules: "jarjar-rules.txt", installable: true, - libs: [ - "framework-annotations-lib", - ], - hostdex: true, // for hiddenapi check visibility: ["//frameworks/base/packages/Tethering:__subpackages__"], + stubs_library_visibility: ["//visibility:public"], apex_available: ["com.android.tethering"], permitted_packages: ["android.net"], } -stubs_defaults { - name: "framework-tethering-stubs-defaults", - srcs: [":framework-tethering-srcs"], - dist: { dest: "framework-tethering.txt" }, -} - filegroup { name: "framework-tethering-srcs", srcs: [ @@ -55,83 +52,3 @@ filegroup { ], path: "src" } - -droidstubs { - name: "framework-tethering-stubs-srcs-publicapi", - defaults: [ - "framework-module-stubs-defaults-publicapi", - "framework-tethering-stubs-defaults", - ], - check_api: { - last_released: { - api_file: ":framework-tethering.api.public.latest", - removed_api_file: ":framework-tethering-removed.api.public.latest", - }, - api_lint: { - new_since: ":framework-tethering.api.public.latest", - }, - }, -} - -droidstubs { - name: "framework-tethering-stubs-srcs-systemapi", - defaults: [ - "framework-module-stubs-defaults-systemapi", - "framework-tethering-stubs-defaults", - ], - check_api: { - last_released: { - api_file: ":framework-tethering.api.system.latest", - removed_api_file: ":framework-tethering-removed.api.system.latest", - }, - api_lint: { - new_since: ":framework-tethering.api.system.latest", - }, - }, -} - -droidstubs { - name: "framework-tethering-api-module_libs_api", - defaults: [ - "framework-module-api-defaults-module_libs_api", - "framework-tethering-stubs-defaults", - ], - check_api: { - last_released: { - api_file: ":framework-tethering.api.module-lib.latest", - removed_api_file: ":framework-tethering-removed.api.module-lib.latest", - }, - api_lint: { - new_since: ":framework-tethering.api.module-lib.latest", - }, - }, -} - -droidstubs { - name: "framework-tethering-stubs-srcs-module_libs_api", - defaults: [ - "framework-module-stubs-defaults-module_libs_api", - "framework-tethering-stubs-defaults", - ], -} - -java_library { - name: "framework-tethering-stubs-publicapi", - srcs: [":framework-tethering-stubs-srcs-publicapi"], - defaults: ["framework-module-stubs-lib-defaults-publicapi"], - dist: { dest: "framework-tethering.jar" }, -} - -java_library { - name: "framework-tethering-stubs-systemapi", - srcs: [":framework-tethering-stubs-srcs-systemapi"], - defaults: ["framework-module-stubs-lib-defaults-systemapi"], - dist: { dest: "framework-tethering.jar" }, -} - -java_library { - name: "framework-tethering-stubs-module_libs_api", - srcs: [":framework-tethering-stubs-srcs-module_libs_api"], - defaults: ["framework-module-stubs-lib-defaults-module_libs_api"], - dist: { dest: "framework-tethering.jar" }, -} diff --git a/Tethering/tests/unit/Android.bp b/Tethering/tests/unit/Android.bp index e00435b0c3..fccc6902e3 100644 --- a/Tethering/tests/unit/Android.bp +++ b/Tethering/tests/unit/Android.bp @@ -29,7 +29,7 @@ java_library { sdk_version: "core_platform", libs: [ "framework-minus-apex", - "framework-tethering", + "framework-tethering.impl", ], visibility: ["//cts/tests/tests/tethering"], } @@ -59,7 +59,7 @@ java_defaults { "ext", "framework-minus-apex", "framework-res", - "framework-tethering", + "framework-tethering.impl", "framework-wifi-stubs-module_libs_api", ], jni_libs: [ -- GitLab