From 2dae2729036102026a6e74e612fbe45264cf9baa Mon Sep 17 00:00:00 2001 From: Paul Duffin 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 .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 update-api Bug: 155164730 Merged-In: If5c115f482751f9f4b5f047e9e401a18e36799ef Merged-In: Id1c2e848430c49a2da7402244814cd084f5da77c Change-Id: Id1c2e848430c49a2da7402244814cd084f5da77c --- Tethering/Android.bp | 4 +- Tethering/common/TetheringLib/Android.bp | 74 +++---------------- .../api/module-lib-lint-baseline.txt | 39 ++++++++++ .../TetheringLib/api/system-lint-baseline.txt | 25 +++++++ Tethering/tests/unit/Android.bp | 4 +- 5 files changed, 77 insertions(+), 69 deletions(-) create mode 100644 Tethering/common/TetheringLib/api/module-lib-lint-baseline.txt create mode 100644 Tethering/common/TetheringLib/api/system-lint-baseline.txt diff --git a/Tethering/Android.bp b/Tethering/Android.bp index eb72b81fb7..33c2b5828d 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", "unsupportedappusage", ], plugins: ["java_api_finder"], @@ -96,7 +96,7 @@ java_defaults { "res", ], libs: [ - "framework-tethering", + "framework-tethering.impl", ], jarjar_rules: "jarjar-rules.txt", optimize: { diff --git a/Tethering/common/TetheringLib/Android.bp b/Tethering/common/TetheringLib/Android.bp index 79a178297a..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,56 +52,3 @@ filegroup { ], path: "src" } - -droidstubs { - name: "framework-tethering-stubs-srcs-publicapi", - defaults: [ - "framework-module-stubs-defaults-publicapi", - "framework-tethering-stubs-defaults", - ], -} - -droidstubs { - name: "framework-tethering-stubs-srcs-systemapi", - defaults: [ - "framework-module-stubs-defaults-systemapi", - "framework-tethering-stubs-defaults", - ], -} - -droidstubs { - name: "framework-tethering-api-module_libs_api", - defaults: [ - "framework-module-api-defaults-module_libs_api", - "framework-tethering-stubs-defaults", - ], -} - -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/common/TetheringLib/api/module-lib-lint-baseline.txt b/Tethering/common/TetheringLib/api/module-lib-lint-baseline.txt new file mode 100644 index 0000000000..af7ad52c07 --- /dev/null +++ b/Tethering/common/TetheringLib/api/module-lib-lint-baseline.txt @@ -0,0 +1,39 @@ +// Baseline format: 1.0 +ActionValue: android.net.TetheringConstants#EXTRA_ADD_TETHER_TYPE: + Inconsistent extra value; expected `android.net.extra.ADD_TETHER_TYPE`, was `extraAddTetherType` +ActionValue: android.net.TetheringConstants#EXTRA_PROVISION_CALLBACK: + Inconsistent extra value; expected `android.net.extra.PROVISION_CALLBACK`, was `extraProvisionCallback` +ActionValue: android.net.TetheringConstants#EXTRA_REM_TETHER_TYPE: + Inconsistent extra value; expected `android.net.extra.REM_TETHER_TYPE`, was `extraRemTetherType` +ActionValue: android.net.TetheringConstants#EXTRA_RUN_PROVISION: + Inconsistent extra value; expected `android.net.extra.RUN_PROVISION`, was `extraRunProvision` +ActionValue: android.net.TetheringConstants#EXTRA_SET_ALARM: + Inconsistent extra value; expected `android.net.extra.SET_ALARM`, was `extraSetAlarm` +ActionValue: android.net.TetheringManager#ACTION_TETHER_STATE_CHANGED: + Inconsistent action value; expected `android.net.action.TETHER_STATE_CHANGED`, was `android.net.conn.TETHER_STATE_CHANGED` +ActionValue: android.net.TetheringManager#EXTRA_ACTIVE_TETHER: + Inconsistent extra value; expected `android.net.extra.ACTIVE_TETHER`, was `tetherArray` +ActionValue: android.net.TetheringManager#EXTRA_AVAILABLE_TETHER: + Inconsistent extra value; expected `android.net.extra.AVAILABLE_TETHER`, was `availableArray` +ActionValue: android.net.TetheringManager#EXTRA_ERRORED_TETHER: + Inconsistent extra value; expected `android.net.extra.ERRORED_TETHER`, was `erroredArray` + + +CallbackInterface: android.net.TetheringManager.StartTetheringCallback: + Callbacks must be abstract class instead of interface to enable extension in future API levels: StartTetheringCallback +CallbackInterface: android.net.TetheringManager.TetheringEventCallback: + Callbacks must be abstract class instead of interface to enable extension in future API levels: TetheringEventCallback + + +ManagerConstructor: android.net.TetheringManager#TetheringManager(android.content.Context, java.util.function.Supplier): + Managers must always be obtained from Context; no direct constructors + + +MissingGetterMatchingBuilder: android.net.TetheringManager.TetheringRequest.Builder#setShouldShowEntitlementUi(boolean): + android.net.TetheringManager.TetheringRequest does not declare a `shouldShowEntitlementUi()` method matching method android.net.TetheringManager.TetheringRequest.Builder.setShouldShowEntitlementUi(boolean) +MissingGetterMatchingBuilder: android.net.TetheringManager.TetheringRequest.Builder#setStaticIpv4Addresses(android.net.LinkAddress, android.net.LinkAddress): + android.net.TetheringManager.TetheringRequest does not declare a `getStaticIpv4Addresses()` method matching method android.net.TetheringManager.TetheringRequest.Builder.setStaticIpv4Addresses(android.net.LinkAddress,android.net.LinkAddress) + + +StaticFinalBuilder: android.net.TetheringManager.TetheringRequest.Builder: + Builder must be final: android.net.TetheringManager.TetheringRequest.Builder diff --git a/Tethering/common/TetheringLib/api/system-lint-baseline.txt b/Tethering/common/TetheringLib/api/system-lint-baseline.txt new file mode 100644 index 0000000000..f8d291ca2a --- /dev/null +++ b/Tethering/common/TetheringLib/api/system-lint-baseline.txt @@ -0,0 +1,25 @@ +// Baseline format: 1.0 +ActionValue: android.net.TetheringManager#ACTION_TETHER_STATE_CHANGED: + Inconsistent action value; expected `android.net.action.TETHER_STATE_CHANGED`, was `android.net.conn.TETHER_STATE_CHANGED` +ActionValue: android.net.TetheringManager#EXTRA_ACTIVE_TETHER: + Inconsistent extra value; expected `android.net.extra.ACTIVE_TETHER`, was `tetherArray` +ActionValue: android.net.TetheringManager#EXTRA_AVAILABLE_TETHER: + Inconsistent extra value; expected `android.net.extra.AVAILABLE_TETHER`, was `availableArray` +ActionValue: android.net.TetheringManager#EXTRA_ERRORED_TETHER: + Inconsistent extra value; expected `android.net.extra.ERRORED_TETHER`, was `erroredArray` + + +CallbackInterface: android.net.TetheringManager.StartTetheringCallback: + Callbacks must be abstract class instead of interface to enable extension in future API levels: StartTetheringCallback +CallbackInterface: android.net.TetheringManager.TetheringEventCallback: + Callbacks must be abstract class instead of interface to enable extension in future API levels: TetheringEventCallback + + +MissingGetterMatchingBuilder: android.net.TetheringManager.TetheringRequest.Builder#setShouldShowEntitlementUi(boolean): + android.net.TetheringManager.TetheringRequest does not declare a `shouldShowEntitlementUi()` method matching method android.net.TetheringManager.TetheringRequest.Builder.setShouldShowEntitlementUi(boolean) +MissingGetterMatchingBuilder: android.net.TetheringManager.TetheringRequest.Builder#setStaticIpv4Addresses(android.net.LinkAddress, android.net.LinkAddress): + android.net.TetheringManager.TetheringRequest does not declare a `getStaticIpv4Addresses()` method matching method android.net.TetheringManager.TetheringRequest.Builder.setStaticIpv4Addresses(android.net.LinkAddress,android.net.LinkAddress) + + +StaticFinalBuilder: android.net.TetheringManager.TetheringRequest.Builder: + Builder must be final: android.net.TetheringManager.TetheringRequest.Builder diff --git a/Tethering/tests/unit/Android.bp b/Tethering/tests/unit/Android.bp index d1e8f5fc77..15727689a4 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", ], jni_libs: [ // For mockito extended