From 340954c017b680a014d6a444e99e2ac2c0d39165 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Fri, 1 May 2020 18:25:09 +0100 Subject: [PATCH] Enable api lint and check_last_api for modules This adds checking of module api compatibility to the individual module api rules. Until now, this checking has been done via the monolithic metalava runs which we are aiming to get rid of. Now is a good time to do this because we can compare them to the just finalized version 30 API, which we have no diffs with. Baseline the existing wifi failures that metalava fails to find in the previous API. Bug: 144149403 Test: m checkapi Change-Id: Id222895daa3a769c265965b052a17d5a1ca18462 --- apex/Android.bp | 12 ++++++++ apex/media/framework/Android.bp | 27 +++++++++++++++++ apex/permission/framework/Android.bp | 27 +++++++++++++++++ apex/permission/service/Android.bp | 9 ++++++ apex/sdkextensions/framework/Android.bp | 27 +++++++++++++++++ apex/statsd/framework/Android.bp | 27 +++++++++++++++++ .../Tethering/common/TetheringLib/Android.bp | 27 +++++++++++++++++ wifi/Android.bp | 29 +++++++++++++++++++ wifi/api/lint-baseline.txt | 13 +++++++++ wifi/api/system-lint-baseline.txt | 6 ++++ 10 files changed, 204 insertions(+) create mode 100644 wifi/api/lint-baseline.txt create mode 100644 wifi/api/system-lint-baseline.txt diff --git a/apex/Android.bp b/apex/Android.bp index 67cd0d7fcd1ec..51e030bd174d3 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -74,6 +74,9 @@ stubs_defaults { api_file: "api/current.txt", removed_api_file: "api/removed.txt", }, + api_lint: { + enabled: true, + }, }, dist: { targets: ["sdk", "win_sdk"], @@ -93,6 +96,9 @@ stubs_defaults { api_file: "api/system-current.txt", removed_api_file: "api/system-removed.txt", }, + api_lint: { + enabled: true, + }, }, dist: { targets: ["sdk", "win_sdk"], @@ -147,6 +153,9 @@ stubs_defaults { api_file: "api/module-lib-current.txt", removed_api_file: "api/module-lib-removed.txt", }, + api_lint: { + enabled: true, + }, }, dist: { targets: ["sdk", "win_sdk"], @@ -173,6 +182,9 @@ stubs_defaults { api_file: "api/current.txt", removed_api_file: "api/removed.txt", }, + api_lint: { + enabled: true, + }, }, dist: { targets: ["sdk", "win_sdk"], diff --git a/apex/media/framework/Android.bp b/apex/media/framework/Android.bp index a1c886a26562b..3bc4f7b0ab722 100644 --- a/apex/media/framework/Android.bp +++ b/apex/media/framework/Android.bp @@ -102,6 +102,15 @@ droidstubs { "framework-media-stubs-srcs-defaults", "framework-module-stubs-defaults-publicapi", ], + check_api: { + last_released: { + api_file: ":framework-media.api.public.latest", + removed_api_file: ":framework-media-removed.api.public.latest", + }, + api_lint: { + new_since: ":framework-media.api.public.latest", + }, + }, } droidstubs { @@ -110,6 +119,15 @@ droidstubs { "framework-media-stubs-srcs-defaults", "framework-module-stubs-defaults-systemapi", ], + check_api: { + last_released: { + api_file: ":framework-media.api.system.latest", + removed_api_file: ":framework-media-removed.api.system.latest", + }, + api_lint: { + new_since: ":framework-media.api.system.latest", + }, + }, } droidstubs { @@ -118,6 +136,15 @@ droidstubs { "framework-media-stubs-srcs-defaults", "framework-module-api-defaults-module_libs_api", ], + check_api: { + last_released: { + api_file: ":framework-media.api.module-lib.latest", + removed_api_file: ":framework-media-removed.api.module-lib.latest", + }, + api_lint: { + new_since: ":framework-media.api.module-lib.latest", + }, + }, } droidstubs { diff --git a/apex/permission/framework/Android.bp b/apex/permission/framework/Android.bp index 3119b7d29b362..68c27a8327cbc 100644 --- a/apex/permission/framework/Android.bp +++ b/apex/permission/framework/Android.bp @@ -55,6 +55,15 @@ droidstubs { "framework-module-stubs-defaults-publicapi", "framework-permission-stubs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-permission.api.public.latest", + removed_api_file: ":framework-permission-removed.api.public.latest", + }, + api_lint: { + new_since: ":framework-permission.api.public.latest", + }, + }, } droidstubs { @@ -63,6 +72,15 @@ droidstubs { "framework-module-stubs-defaults-systemapi", "framework-permission-stubs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-permission.api.system.latest", + removed_api_file: ":framework-permission-removed.api.system.latest", + }, + api_lint: { + new_since: ":framework-permission.api.system.latest", + }, + }, } droidstubs { @@ -71,6 +89,15 @@ droidstubs { "framework-module-api-defaults-module_libs_api", "framework-permission-stubs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-permission.api.module-lib.latest", + removed_api_file: ":framework-permission-removed.api.module-lib.latest", + }, + api_lint: { + new_since: ":framework-permission.api.module-lib.latest", + }, + }, } droidstubs { diff --git a/apex/permission/service/Android.bp b/apex/permission/service/Android.bp index 2d92d00b6309b..61449763540b7 100644 --- a/apex/permission/service/Android.bp +++ b/apex/permission/service/Android.bp @@ -41,6 +41,15 @@ droidstubs { name: "service-permission-stubs-srcs", srcs: [ ":service-permission-sources" ], defaults: ["service-module-stubs-srcs-defaults"], + check_api: { + last_released: { + api_file: ":service-permission.api.system-server.latest", + removed_api_file: ":service-permission-removed.api.system-server.latest", + }, + api_lint: { + new_since: ":service-permission.api.system-server.latest", + }, + }, visibility: ["//visibility:private"], dist: { dest: "service-permission.txt" }, } diff --git a/apex/sdkextensions/framework/Android.bp b/apex/sdkextensions/framework/Android.bp index 6a787116c005f..14e23ed9a8a1f 100644 --- a/apex/sdkextensions/framework/Android.bp +++ b/apex/sdkextensions/framework/Android.bp @@ -57,6 +57,15 @@ droidstubs { "framework-module-stubs-defaults-publicapi", "framework-sdkextensions-stubs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-sdkextensions.api.public.latest", + removed_api_file: ":framework-sdkextensions-removed.api.public.latest", + }, + api_lint: { + new_since: ":framework-sdkextensions.api.public.latest", + }, + }, } droidstubs { @@ -65,6 +74,15 @@ droidstubs { "framework-module-stubs-defaults-systemapi", "framework-sdkextensions-stubs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-sdkextensions.api.system.latest", + removed_api_file: ":framework-sdkextensions-removed.api.system.latest", + }, + api_lint: { + new_since: ":framework-sdkextensions.api.system.latest", + }, + }, } droidstubs { @@ -73,6 +91,15 @@ droidstubs { "framework-module-api-defaults-module_libs_api", "framework-sdkextensions-stubs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-sdkextensions.api.module-lib.latest", + removed_api_file: ":framework-sdkextensions-removed.api.module-lib.latest", + }, + api_lint: { + new_since: ":framework-sdkextensions.api.module-lib.latest", + }, + }, } droidstubs { diff --git a/apex/statsd/framework/Android.bp b/apex/statsd/framework/Android.bp index 7d0f2ee274cd5..9f5d933bb48ac 100644 --- a/apex/statsd/framework/Android.bp +++ b/apex/statsd/framework/Android.bp @@ -93,6 +93,15 @@ droidstubs { "framework-module-stubs-defaults-publicapi", "framework-statsd-stubs-srcs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-statsd.api.public.latest", + removed_api_file: ":framework-statsd-removed.api.public.latest", + }, + api_lint: { + new_since: ":framework-statsd.api.public.latest", + }, + }, } droidstubs { @@ -101,6 +110,15 @@ droidstubs { "framework-module-stubs-defaults-systemapi", "framework-statsd-stubs-srcs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-statsd.api.system.latest", + removed_api_file: ":framework-statsd-removed.api.system.latest", + }, + api_lint: { + new_since: ":framework-statsd.api.system.latest", + }, + }, } droidstubs { @@ -109,6 +127,15 @@ droidstubs { "framework-module-api-defaults-module_libs_api", "framework-statsd-stubs-srcs-defaults", ], + check_api: { + last_released: { + api_file: ":framework-statsd.api.module-lib.latest", + removed_api_file: ":framework-statsd-removed.api.module-lib.latest", + }, + api_lint: { + new_since: ":framework-statsd.api.module-lib.latest", + }, + }, } droidstubs { diff --git a/packages/Tethering/common/TetheringLib/Android.bp b/packages/Tethering/common/TetheringLib/Android.bp index 8ae1593949f1b..d029d2bded791 100644 --- a/packages/Tethering/common/TetheringLib/Android.bp +++ b/packages/Tethering/common/TetheringLib/Android.bp @@ -94,6 +94,15 @@ droidstubs { "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 { @@ -102,6 +111,15 @@ droidstubs { "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 { @@ -110,6 +128,15 @@ droidstubs { "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 { diff --git a/wifi/Android.bp b/wifi/Android.bp index 6a8600a5baa44..1e2c81a601784 100644 --- a/wifi/Android.bp +++ b/wifi/Android.bp @@ -143,6 +143,16 @@ droidstubs { "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 { @@ -151,6 +161,16 @@ droidstubs { "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 { @@ -159,6 +179,15 @@ droidstubs { "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 { diff --git a/wifi/api/lint-baseline.txt b/wifi/api/lint-baseline.txt new file mode 100644 index 0000000000000..892411f8c3a10 --- /dev/null +++ b/wifi/api/lint-baseline.txt @@ -0,0 +1,13 @@ +// Baseline format: 1.0 +GenericException: android.net.wifi.WifiManager.LocalOnlyHotspotReservation#finalize(): + Methods must not throw generic exceptions (`java.lang.Throwable`) +GenericException: android.net.wifi.WifiManager.MulticastLock#finalize(): + Methods must not throw generic exceptions (`java.lang.Throwable`) +GenericException: android.net.wifi.WifiManager.WifiLock#finalize(): + Methods must not throw generic exceptions (`java.lang.Throwable`) + + +VisiblySynchronized: PsiThisExpression:WifiManager.this: + Internal locks must not be exposed (synchronizing on this or class is still externally observable): method android.net.wifi.WifiManager.WifiLock.finalize() +VisiblySynchronized: android.net.wifi.WifiManager.WifiLock#finalize(): + Internal locks must not be exposed (synchronizing on this or class is still externally observable): method android.net.wifi.WifiManager.WifiLock.finalize() diff --git a/wifi/api/system-lint-baseline.txt b/wifi/api/system-lint-baseline.txt new file mode 100644 index 0000000000000..6547ee8a21883 --- /dev/null +++ b/wifi/api/system-lint-baseline.txt @@ -0,0 +1,6 @@ +// Baseline format: 1.0 +MissingGetterMatchingBuilder: android.net.wifi.rtt.RangingRequest.Builder#addResponder(android.net.wifi.rtt.ResponderConfig): + android.net.wifi.rtt.RangingRequest does not declare a `getResponders()` method matching method android.net.wifi.rtt.RangingRequest.Builder.addResponder(android.net.wifi.rtt.ResponderConfig) + +MissingNullability: android.net.wifi.rtt.RangingRequest.Builder#addResponder(android.net.wifi.rtt.ResponderConfig): +