1// Copyright (C) 2019 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// How stubs are generated: 16// 17// raw source files --(metalava)--> stub source files --(javac)--> stub jar files 18// 19// - The metalava conversion is done by droidstub modules 20// - The javac compilation is done by java_library modules 21// 22// The metalava conversion is also responsible for creating API signature files 23// and comparing them against the checked in API signature, and also checking compatibility 24// with the latest frozen API signature. 25 26///////////////////////////////////////////////////////////////////// 27// These modules provide source files for the stub libraries 28///////////////////////////////////////////////////////////////////// 29 30droidstubs { 31 name: "api-stubs-docs-non-updatable", 32 defaults: [ 33 "android-non-updatable-stubs-defaults", 34 "module-classpath-stubs-defaults", 35 ], 36 args: metalava_framework_docs_args, 37 check_api: { 38 current: { 39 api_file: "core/api/current.txt", 40 removed_api_file: "core/api/removed.txt", 41 }, 42 last_released: { 43 api_file: ":android-non-updatable.api.public.latest", 44 removed_api_file: ":android-non-updatable-removed.api.public.latest", 45 baseline_file: ":android-non-updatable-incompatibilities.api.public.latest", 46 }, 47 api_lint: { 48 enabled: true, 49 new_since: ":android.api.public.latest", 50 }, 51 }, 52 dists: [ 53 { 54 targets: ["sdk"], 55 dir: "apistubs/android/public/api", 56 dest: "android-non-updatable.txt", 57 tag: ".api.txt", 58 }, 59 { 60 targets: ["sdk"], 61 dir: "apistubs/android/public/api", 62 dest: "android-non-updatable-removed.txt", 63 tag: ".removed-api.txt", 64 }, 65 ], 66} 67 68priv_apps = " --show-annotation android.annotation.SystemApi\\(" + 69 "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" + 70 "\\)" 71 72priv_apps_in_stubs = " --show-for-stub-purposes-annotation android.annotation.SystemApi\\(" + 73 "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" + 74 "\\)" 75 76test = " --show-annotation android.annotation.TestApi" 77 78module_libs = " --show-annotation android.annotation.SystemApi\\(" + 79 "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" + 80 "\\)" 81 82droidstubs { 83 name: "system-api-stubs-docs-non-updatable", 84 defaults: [ 85 "android-non-updatable-stubs-defaults", 86 "module-classpath-stubs-defaults", 87 ], 88 args: metalava_framework_docs_args + priv_apps, 89 check_api: { 90 current: { 91 api_file: "core/api/system-current.txt", 92 removed_api_file: "core/api/system-removed.txt", 93 }, 94 last_released: { 95 api_file: ":android-non-updatable.api.system.latest", 96 removed_api_file: ":android-non-updatable-removed.api.system.latest", 97 baseline_file: ":android-non-updatable-incompatibilities.api.system.latest", 98 }, 99 api_lint: { 100 enabled: true, 101 new_since: ":android.api.system.latest", 102 baseline_file: "core/api/system-lint-baseline.txt", 103 }, 104 }, 105 dists: [ 106 { 107 targets: ["sdk"], 108 dir: "apistubs/android/system/api", 109 dest: "android-non-updatable.txt", 110 tag: ".api.txt", 111 }, 112 { 113 targets: ["sdk"], 114 dir: "apistubs/android/system/api", 115 dest: "android-non-updatable-removed.txt", 116 tag: ".removed-api.txt", 117 }, 118 ], 119} 120 121droidstubs { 122 name: "test-api-stubs-docs-non-updatable", 123 defaults: [ 124 "android-non-updatable-stubs-defaults", 125 "module-classpath-stubs-defaults", 126 ], 127 args: metalava_framework_docs_args + test + priv_apps_in_stubs, 128 check_api: { 129 current: { 130 api_file: "core/api/test-current.txt", 131 removed_api_file: "core/api/test-removed.txt", 132 }, 133 api_lint: { 134 enabled: true, 135 baseline_file: "core/api/test-lint-baseline.txt", 136 }, 137 }, 138 dists: [ 139 { 140 targets: ["sdk"], 141 dir: "apistubs/android/test/api", 142 dest: "android.txt", 143 tag: ".api.txt", 144 }, 145 { 146 targets: ["sdk"], 147 dir: "apistubs/android/test/api", 148 dest: "removed.txt", 149 tag: ".removed-api.txt", 150 }, 151 { 152 targets: ["sdk"], 153 dir: "apistubs/android/test/api", 154 dest: "android-non-updatable.txt", 155 tag: ".api.txt", 156 }, 157 { 158 targets: ["sdk"], 159 dir: "apistubs/android/test/api", 160 dest: "android-non-updatable-removed.txt", 161 tag: ".removed-api.txt", 162 }, 163 ], 164} 165 166droidstubs { 167 name: "module-lib-api-stubs-docs-non-updatable", 168 defaults: [ 169 "android-non-updatable-stubs-defaults", 170 "module-classpath-stubs-defaults", 171 ], 172 args: metalava_framework_docs_args + priv_apps_in_stubs + module_libs, 173 check_api: { 174 current: { 175 api_file: "core/api/module-lib-current.txt", 176 removed_api_file: "core/api/module-lib-removed.txt", 177 }, 178 last_released: { 179 api_file: ":android-non-updatable.api.module-lib.latest", 180 removed_api_file: ":android-non-updatable-removed.api.module-lib.latest", 181 baseline_file: ":android-non-updatable-incompatibilities.api.module-lib.latest", 182 }, 183 api_lint: { 184 enabled: true, 185 new_since: ":android.api.module-lib.latest", 186 baseline_file: "core/api/module-lib-lint-baseline.txt", 187 }, 188 }, 189 dists: [ 190 { 191 targets: ["sdk"], 192 dir: "apistubs/android/module-lib/api", 193 dest: "android-non-updatable.txt", 194 tag: ".api.txt", 195 }, 196 { 197 targets: ["sdk"], 198 dir: "apistubs/android/module-lib/api", 199 dest: "android-non-updatable-removed.txt", 200 tag: ".removed-api.txt", 201 }, 202 ], 203} 204 205///////////////////////////////////////////////////////////////////// 206// android_*_stubs_current modules are the stubs libraries compiled 207// from stub sources 208///////////////////////////////////////////////////////////////////// 209 210java_defaults { 211 name: "android.jar_defaults", 212 sdk_version: "none", 213 system_modules: "none", 214 java_version: "1.8", 215 compile_dex: true, 216 defaults_visibility: ["//visibility:private"], 217 visibility: ["//visibility:public"], 218} 219 220java_defaults { 221 name: "android-non-updatable_defaults_stubs_current", 222 libs: ["stub-annotations"], 223 static_libs: ["framework-res-package-jar"], // Export package of framework-res 224 sdk_version: "none", 225 system_modules: "none", 226 java_version: "1.8", 227 compile_dex: true, 228 dist: { 229 targets: ["sdk"], 230 tag: ".jar", 231 dest: "android-non-updatable.jar", 232 }, 233 defaults_visibility: ["//visibility:private"], 234 visibility: ["//visibility:private"], 235} 236 237java_library { 238 name: "android-non-updatable.stubs", 239 defaults: ["android-non-updatable_defaults_stubs_current"], 240 srcs: [":api-stubs-docs-non-updatable"], 241 libs: ["all-modules-public-stubs"], 242 dist: { 243 dir: "apistubs/android/public", 244 }, 245} 246 247java_library { 248 name: "android-non-updatable.stubs.system", 249 defaults: ["android-non-updatable_defaults_stubs_current"], 250 srcs: [":system-api-stubs-docs-non-updatable"], 251 libs: ["all-modules-system-stubs"], 252 dist: { 253 dir: "apistubs/android/system", 254 }, 255} 256 257java_library { 258 name: "android-non-updatable.stubs.module_lib", 259 defaults: ["android-non-updatable_defaults_stubs_current"], 260 srcs: [":module-lib-api-stubs-docs-non-updatable"], 261 libs: [ 262 "sdk_module-lib_current_framework-tethering", 263 "sdk_module-lib_current_framework-connectivity-t", 264 "sdk_public_current_framework-bluetooth", 265 // NOTE: The below can be removed once the prebuilt stub contains bluetooth. 266 "sdk_system_current_android", 267 // NOTE: The below can be removed once the prebuilt stub contains IKE. 268 "sdk_system_current_android.net.ipsec.ike", 269 ], 270 dist: { 271 dir: "apistubs/android/module-lib", 272 }, 273} 274 275java_library { 276 name: "android-non-updatable.stubs.test", 277 defaults: ["android-non-updatable_defaults_stubs_current"], 278 srcs: [":test-api-stubs-docs-non-updatable"], 279 libs: ["all-modules-system-stubs"], 280 dist: { 281 dir: "apistubs/android/test", 282 }, 283} 284 285java_defaults { 286 name: "android_stubs_dists_default", 287 dist: { 288 targets: ["sdk"], 289 tag: ".jar", 290 dest: "android.jar", 291 }, 292 defaults_visibility: ["//frameworks/base/services"], 293} 294 295java_library { 296 name: "android_stubs_current", 297 static_libs: [ 298 "all-modules-public-stubs", 299 "android-non-updatable.stubs", 300 "private-stub-annotations-jar", 301 ], 302 defaults: ["android.jar_defaults"], 303} 304 305java_library { 306 name: "android_system_stubs_current", 307 static_libs: [ 308 "all-modules-system-stubs", 309 "android-non-updatable.stubs.system", 310 "private-stub-annotations-jar", 311 ], 312 defaults: [ 313 "android.jar_defaults", 314 "android_stubs_dists_default", 315 ], 316 dist: { 317 dir: "apistubs/android/system", 318 }, 319 dists: [ 320 { 321 // Legacy dist path 322 targets: ["sdk"], 323 tag: ".jar", 324 dest: "android_system.jar", 325 }, 326 ], 327} 328 329java_library { 330 name: "android_test_stubs_current", 331 // Modules do not have test APIs, but we want to include their SystemApis, like we include 332 // the SystemApi of framework-non-updatable-sources. 333 static_libs: [ 334 "all-modules-system-stubs", 335 "android-non-updatable.stubs.test", 336 "private-stub-annotations-jar", 337 ], 338 defaults: [ 339 "android.jar_defaults", 340 "android_stubs_dists_default", 341 ], 342 dist: { 343 dir: "apistubs/android/test", 344 }, 345} 346 347java_library { 348 name: "android_module_lib_stubs_current", 349 defaults: [ 350 "android.jar_defaults", 351 "android_stubs_dists_default", 352 ], 353 static_libs: [ 354 "android-non-updatable.stubs.module_lib", 355 "art.module.public.api.stubs.module_lib", 356 "i18n.module.public.api.stubs", 357 ], 358 dist: { 359 dir: "apistubs/android/module-lib", 360 }, 361} 362 363java_library { 364 name: "android_system_server_stubs_current", 365 defaults: ["android_stubs_dists_default"], 366 srcs: [":services-non-updatable-stubs"], 367 installable: false, 368 static_libs: [ 369 "android_module_lib_stubs_current", 370 ], 371 sdk_version: "none", 372 system_modules: "none", 373 java_version: "1.8", 374 dist: { 375 dir: "apistubs/android/system-server", 376 }, 377} 378 379//////////////////////////////////////////////////////////////////////// 380// api-versions.xml generation, for public and system. This API database 381// also contains the android.test.* APIs. 382//////////////////////////////////////////////////////////////////////// 383 384java_library { 385 name: "android_stubs_current_with_test_libs", 386 static_libs: [ 387 "android_stubs_current", 388 "android.test.base.stubs", 389 "android.test.mock.stubs", 390 "android.test.runner.stubs", 391 ], 392 defaults: ["android.jar_defaults"], 393 visibility: [ 394 "//visibility:override", 395 "//visibility:private", 396 ], 397} 398 399java_library { 400 name: "android_system_stubs_current_with_test_libs", 401 static_libs: [ 402 "android_system_stubs_current", 403 "android.test.base.stubs.system", 404 "android.test.mock.stubs.system", 405 "android.test.runner.stubs.system", 406 ], 407 defaults: ["android.jar_defaults"], 408 visibility: [ 409 "//visibility:override", 410 "//visibility:private", 411 ], 412} 413 414droidstubs { 415 name: "api_versions_public", 416 srcs: [":android_stubs_current_with_test_libs{.jar}"], 417 generate_stubs: false, 418 api_levels_annotations_enabled: true, 419 api_levels_annotations_dirs: [ 420 "sdk-dir", 421 "api-versions-jars-dir", 422 ], 423} 424 425droidstubs { 426 name: "api_versions_system", 427 srcs: [":android_system_stubs_current_with_test_libs{.jar}"], 428 generate_stubs: false, 429 api_levels_annotations_enabled: true, 430 api_levels_annotations_dirs: [ 431 "sdk-dir", 432 "api-versions-jars-dir", 433 ], 434 api_levels_sdk_type: "system", 435} 436 437///////////////////////////////////////////////////////////////////// 438// hwbinder.stubs provides APIs required for building HIDL Java 439// libraries. 440///////////////////////////////////////////////////////////////////// 441 442droidstubs { 443 name: "hwbinder-stubs-docs", 444 srcs: [ 445 "core/java/android/os/HidlSupport.java", 446 "core/java/android/os/HidlMemory.java", 447 "core/java/android/os/HwBinder.java", 448 "core/java/android/os/HwBlob.java", 449 "core/java/android/os/HwParcel.java", 450 "core/java/android/os/IHwBinder.java", 451 "core/java/android/os/IHwInterface.java", 452 "core/java/android/os/DeadObjectException.java", 453 "core/java/android/os/DeadSystemException.java", 454 "core/java/android/os/NativeHandle.java", 455 "core/java/android/os/RemoteException.java", 456 "core/java/android/util/AndroidException.java", 457 ], 458 libs: ["framework-annotations-lib"], 459 installable: false, 460 sdk_version: "core_platform", 461 annotations_enabled: true, 462 previous_api: ":android.api.public.latest", 463 merge_annotations_dirs: [ 464 "metalava-manual", 465 ], 466 args: priv_apps, 467 visibility: ["//visibility:private"], 468} 469 470java_library { 471 name: "hwbinder.stubs", 472 sdk_version: "core_current", 473 libs: ["framework-annotations-lib"], 474 srcs: [ 475 ":hwbinder-stubs-docs", 476 ], 477 visibility: ["//visibility:public"], 478} 479