From 5207958bfe8be8658e50f52442888dc5f7450e8d Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 13 May 2020 20:33:29 +0100 Subject: [PATCH] Switch framework-wifi to use java_sdk_library Had to build from srcs rather than statically linking to framework-wifi-pre-jarjar as java_sdk_library requires srcs because otherwise it cannot generate the stubs source or the API. 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 .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 .impl. Test: m droid checkapi Bug: 155164730 Change-Id: I5e1172761f260cf6a0b4f17e5247af92c520407f --- wifi/Android.bp | 121 ++++++++---------------------------------------- 1 file changed, 19 insertions(+), 102 deletions(-) diff --git a/wifi/Android.bp b/wifi/Android.bp index fe1938d075339..63c14e9350cbe 100644 --- a/wifi/Android.bp +++ b/wifi/Android.bp @@ -96,12 +96,26 @@ java_library { } // post-jarjar version of framework-wifi -java_library { +java_sdk_library { name: "framework-wifi", - sdk_version: "module_current", + defaults: ["framework-module-defaults"], static_libs: [ - "framework-wifi-pre-jarjar", + "framework-wifi-util-lib", + "android.hardware.wifi-V1.0-java-constants", ], + libs: [ + "unsupportedappusage", // for android.compat.annotation.UnsupportedAppUsage + ], + srcs: [ + ":framework-wifi-updatable-sources", + ":framework-wifi-util-lib-aidls", + ], + + // 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: ":wifi-jarjar-rules", installable: true, @@ -112,6 +126,7 @@ java_library { visibility: [ "//frameworks/opt/net/wifi/service:__subpackages__", ] + test_access_hidden_api_whitelist, + stubs_library_visibility: ["//visibility:public"], apex_available: [ "com.android.wifi", "test_com.android.wifi", @@ -125,104 +140,6 @@ java_library { ], } -stubs_defaults { - name: "framework-wifi-stubs-srcs-defaults", - srcs: [ - ":framework-wifi-updatable-sources", - ":framework-wifi-util-lib-aidls", - ], - libs: [ - "framework-annotations-lib", - "framework-wifi-util-lib", - ], - sdk_version: "module_current", - dist: { dest: "framework-wifi.txt" }, -} - -droidstubs { - name: "framework-wifi-stubs-srcs-publicapi", - defaults: [ - "framework-module-stubs-defaults-publicapi", - "framework-wifi-stubs-srcs-defaults", - ], - check_api: { - last_released: { - api_file: ":framework-wifi.api.public.latest", - removed_api_file: ":framework-wifi-removed.api.public.latest", - }, - api_lint: { - new_since: ":framework-wifi.api.public.latest", - baseline_file: "api/lint-baseline.txt", - }, - }, -} - -droidstubs { - name: "framework-wifi-stubs-srcs-systemapi", - defaults: [ - "framework-module-stubs-defaults-systemapi", - "framework-wifi-stubs-srcs-defaults", - ], - check_api: { - last_released: { - api_file: ":framework-wifi.api.system.latest", - removed_api_file: ":framework-wifi-removed.api.system.latest", - }, - api_lint: { - new_since: ":framework-wifi.api.system.latest", - baseline_file: "api/system-lint-baseline.txt", - }, - }, -} - -droidstubs { - name: "framework-wifi-api-module_libs_api", - defaults: [ - "framework-module-api-defaults-module_libs_api", - "framework-wifi-stubs-srcs-defaults", - ], - check_api: { - last_released: { - api_file: ":framework-wifi.api.module-lib.latest", - removed_api_file: ":framework-wifi-removed.api.module-lib.latest", - }, - api_lint: { - new_since: ":framework-wifi.api.module-lib.latest", - }, - }, -} - -droidstubs { - name: "framework-wifi-stubs-srcs-module_libs_api", - defaults: [ - "framework-module-stubs-defaults-module_libs_api", - "framework-wifi-stubs-srcs-defaults", - ], -} - -java_library { - name: "framework-wifi-stubs-publicapi", - srcs: [":framework-wifi-stubs-srcs-publicapi"], - defaults: ["framework-module-stubs-lib-defaults-publicapi"], - dist: { dest: "framework-wifi.jar" }, -} - -java_library { - name: "framework-wifi-stubs-systemapi", - srcs: [":framework-wifi-stubs-srcs-systemapi"], - libs: ["framework-annotations-lib"], - defaults: ["framework-module-stubs-lib-defaults-systemapi"], - dist: { dest: "framework-wifi.jar" }, -} - -java_library { - name: "framework-wifi-stubs-module_libs_api", - srcs: [":framework-wifi-stubs-srcs-module_libs_api"], - libs: ["framework-annotations-lib"], - defaults: ["framework-module-stubs-lib-defaults-module_libs_api"], - dist: { dest: "framework-wifi.jar" }, -} - // defaults for tests that need to build against framework-wifi's @hide APIs java_defaults { name: "framework-wifi-test-defaults", @@ -230,7 +147,7 @@ java_defaults { libs: [ // order matters: classes in framework-wifi are resolved before framework, meaning // @hide APIs in framework-wifi are resolved before @SystemApi stubs in framework - "framework-wifi", + "framework-wifi.impl", "framework", // if sdk_version="" this gets automatically included, but here we need to add manually.