1// Copyright (C) 2020 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 15package { 16 default_visibility: ["//visibility:private"], 17 // See: http://go/android-license-faq 18 // A large-scale-change added 'default_applicable_licenses' to import 19 // all of the 'license_kinds' from "frameworks_base_license" 20 // to get the below license kinds: 21 // SPDX-license-identifier-Apache-2.0 22 // SPDX-license-identifier-MIT 23 // SPDX-license-identifier-Unicode-DFS 24 default_applicable_licenses: ["frameworks_base_license"], 25} 26 27bootstrap_go_package { 28 name: "soong-api", 29 pkgPath: "android/soong/api", 30 deps: [ 31 "blueprint", 32 "blueprint-proptools", 33 "soong", 34 "soong-android", 35 "soong-genrule", 36 "soong-java", 37 ], 38 srcs: ["api.go"], 39 testSrcs: ["api_test.go"], 40 pluginFor: ["soong_build"], 41} 42 43python_binary_host { 44 name: "merge_annotation_zips", 45 srcs: ["merge_annotation_zips.py"], 46} 47 48python_test_host { 49 name: "merge_annotation_zips_test", 50 main: "merge_annotation_zips_test.py", 51 srcs: [ 52 "merge_annotation_zips.py", 53 "merge_annotation_zips_test.py", 54 ], 55 test_options: { 56 unit_test: true, 57 }, 58} 59 60metalava_cmd = "$(location metalava)" 61// Silence reflection warnings. See b/168689341 62metalava_cmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED " 63metalava_cmd += " --quiet " 64 65combined_apis { 66 name: "frameworks-base-api", 67 bootclasspath: [ 68 "android.net.ipsec.ike", 69 "art.module.public.api", 70 "conscrypt.module.public.api", 71 "framework-adservices", 72 "framework-appsearch", 73 "framework-bluetooth", 74 "framework-configinfrastructure", 75 "framework-connectivity", 76 "framework-connectivity-b", 77 "framework-connectivity-t", 78 "framework-devicelock", 79 "framework-graphics", 80 "framework-healthfitness", 81 "framework-location", 82 "framework-media", 83 "framework-mediaprovider", 84 "framework-nfc", 85 "framework-ondevicepersonalization", 86 "framework-pdf", 87 "framework-pdf-v", 88 "framework-permission", 89 "framework-permission-s", 90 "framework-profiling", 91 "framework-photopicker", 92 "framework-scheduling", 93 "framework-sdkextensions", 94 "framework-statsd", 95 "framework-sdksandbox", 96 "framework-tethering", 97 "framework-uwb", 98 "framework-virtualization", 99 "framework-wifi", 100 "i18n.module.public.api", 101 ] + select(soong_config_variable("ANDROID", "release_crashrecovery_module"), { 102 "true": [ 103 "framework-crashrecovery", 104 ], 105 default: [ 106 "framework-platformcrashrecovery", 107 ], 108 }) + select(release_flag("RELEASE_ONDEVICE_INTELLIGENCE_MODULE"), { 109 true: [ 110 "framework-ondeviceintelligence", 111 ], 112 default: [ 113 "framework-ondeviceintelligence-platform", 114 ], 115 }) + select(release_flag("RELEASE_RANGING_STACK"), { 116 true: [ 117 "framework-ranging", 118 ], 119 default: [], 120 }), 121 system_server_classpath: [ 122 "service-art", 123 "service-configinfrastructure", 124 "service-healthfitness", 125 "service-media-s", 126 "service-permission", 127 "service-rkp", 128 "service-sdksandbox", 129 ] + select(release_flag("RELEASE_ONDEVICE_INTELLIGENCE_MODULE"), { 130 true: [ 131 "service-ondeviceintelligence", 132 ], 133 default: [], 134 }) + select(soong_config_variable("ANDROID", "release_crashrecovery_module"), { 135 "true": [ 136 "service-crashrecovery", 137 ], 138 default: [], 139 }), 140} 141 142// Create a single file containing the latest released version of the whole 143// Android public API. 144java_genrule { 145 name: "android.api.merged.public.latest", 146 srcs: [ 147 ":android.api.combined.public.latest", 148 ], 149 out: ["public-latest.txt"], 150 tools: ["metalava"], 151 cmd: metalava_cmd + " merge-signatures --format=2.0 $(in) --out $(out)", 152} 153 154// Make sure that the Android public API is compatible with the 155// previously released public API. 156java_genrule { 157 name: "frameworks-base-api-current-compat", 158 srcs: [ 159 ":android.api.merged.public.latest", 160 ":android-incompatibilities.api.public.latest", 161 ":frameworks-base-api-current.txt", 162 ], 163 out: ["updated-baseline.txt"], 164 tools: ["metalava"], 165 cmd: metalava_cmd + 166 "--check-compatibility:api:released $(location :android.api.merged.public.latest) " + 167 "--baseline:compatibility:released $(location :android-incompatibilities.api.public.latest) " + 168 "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " + 169 "$(location :frameworks-base-api-current.txt)", 170} 171 172// Create a single file containing the latest released version of the whole 173// Android system API. 174java_genrule { 175 name: "android.api.merged.system.latest", 176 srcs: [ 177 ":android.api.combined.system.latest", 178 ], 179 out: ["system-latest.txt"], 180 tools: ["metalava"], 181 cmd: metalava_cmd + " merge-signatures --format=2.0 $(in) --out $(out)", 182} 183 184// Make sure that the Android system API is compatible with the 185// previously released system API. 186java_genrule { 187 name: "frameworks-base-api-system-current-compat", 188 srcs: [ 189 ":android.api.merged.system.latest", 190 ":android-incompatibilities.api.system.latest", 191 ":frameworks-base-api-current.txt", 192 ":frameworks-base-api-system-current.txt", 193 ], 194 out: ["updated-baseline.txt"], 195 tools: ["metalava"], 196 cmd: metalava_cmd + 197 "--check-compatibility:api:released $(location :android.api.merged.system.latest) " + 198 "--baseline:compatibility:released $(location :android-incompatibilities.api.system.latest) " + 199 "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " + 200 "$(location :frameworks-base-api-current.txt) " + 201 "$(location :frameworks-base-api-system-current.txt)", 202} 203 204// Create a single file containing the latest released version of the whole 205// Android module-lib API. 206java_genrule { 207 name: "android.api.merged.module-lib.latest", 208 srcs: [ 209 ":android.api.combined.module-lib.latest", 210 ], 211 out: ["module-lib-latest.txt"], 212 tools: ["metalava"], 213 cmd: metalava_cmd + " merge-signatures --format=2.0 $(in) --out $(out)", 214} 215 216// Make sure that the Android module-lib API is compatible with the 217// previously released module-lib API. 218java_genrule { 219 name: "frameworks-base-api-module-lib-current-compat", 220 srcs: [ 221 ":android.api.merged.module-lib.latest", 222 ":android-incompatibilities.api.module-lib.latest", 223 ":frameworks-base-api-current.txt", 224 ":frameworks-base-api-system-current.txt", 225 ":frameworks-base-api-module-lib-current.txt", 226 ], 227 out: ["updated-baseline.txt"], 228 tools: ["metalava"], 229 cmd: metalava_cmd + 230 "--check-compatibility:api:released $(location :android.api.merged.module-lib.latest) " + 231 "--baseline:compatibility:released $(location :android-incompatibilities.api.module-lib.latest) " + 232 "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " + 233 "$(location :frameworks-base-api-current.txt) " + 234 "$(location :frameworks-base-api-system-current.txt) " + 235 "$(location :frameworks-base-api-module-lib-current.txt)", 236} 237 238java_genrule { 239 name: "frameworks-base-api-current.srcjar", 240 tools: ["merge_zips"], 241 out: ["current.srcjar"], 242 cmd: "$(location merge_zips) $(out) $(in)", 243 srcs: [ 244 ":api-stubs-docs-non-updatable{.exportable}", 245 ":all-modules-public-stubs-source-exportable", 246 ], 247 visibility: ["//visibility:private"], // Used by make module in //development, mind 248} 249 250// This produces the same annotations.zip as framework-doc-stubs, but by using 251// outputs from individual modules instead of all the source code. 252genrule_defaults { 253 name: "sdk-annotations-defaults", 254 out: ["annotations.zip"], 255 tools: [ 256 "merge_annotation_zips", 257 "soong_zip", 258 ], 259 cmd: "$(location merge_annotation_zips) $(genDir)/out $(in) && " + 260 "$(location soong_zip) -o $(out) -C $(genDir)/out -D $(genDir)/out", 261} 262 263java_genrule { 264 name: "sdk-annotations.zip", 265 defaults: ["sdk-annotations-defaults"], 266 srcs: [ 267 ":android-non-updatable-doc-stubs{.exportable.annotations.zip}", 268 ":all-modules-public-annotations", 269 ], 270} 271 272java_genrule { 273 name: "sdk-annotations-system.zip", 274 defaults: ["sdk-annotations-defaults"], 275 srcs: [ 276 ":android-non-updatable-doc-stubs-system{.exportable.annotations.zip}", 277 ":all-modules-system-annotations", 278 ], 279} 280 281java_genrule { 282 name: "sdk-annotations-module-lib.zip", 283 defaults: ["sdk-annotations-defaults"], 284 srcs: [ 285 ":android-non-updatable-doc-stubs-module-lib{.exportable.annotations.zip}", 286 ":all-modules-module-lib-annotations", 287 ], 288} 289 290java_genrule { 291 name: "sdk-annotations-system-server.zip", 292 defaults: ["sdk-annotations-defaults"], 293 srcs: [ 294 ":android-non-updatable-doc-stubs-system-server{.exportable.annotations.zip}", 295 ":all-modules-system-server-annotations", 296 ], 297} 298 299java_genrule { 300 name: "combined-removed-dex", 301 visibility: [ 302 "//frameworks/base/boot", 303 ], 304 srcs: [ 305 ":frameworks-base-api-removed.txt", 306 ":frameworks-base-api-system-removed.txt", 307 ":android.car-stubs-docs{.removed-api.txt}", 308 ":android.car-system-stubs-docs{.removed-api.txt}", 309 ], 310 tool_files: ["gen_combined_removed_dex.sh"], 311 tools: ["metalava"], 312 out: ["combined-removed-dex.txt"], 313 cmd: "$(location gen_combined_removed_dex.sh) $(location metalava) $(genDir) $(in) > $(out)", 314} 315 316java_genrule { 317 name: "api_fingerprint", 318 srcs: [ 319 ":frameworks-base-api-current.txt", 320 ":frameworks-base-api-system-current.txt", 321 ":frameworks-base-api-module-lib-current.txt", 322 ":frameworks-base-api-system-server-current.txt", 323 ], 324 out: ["api_fingerprint.txt"], 325 cmd: "cat $(in) | md5sum | cut -d' ' -f1 > $(out)", 326} 327 328packages_to_document = [ 329 "android", 330 "dalvik", 331 "java", 332 "javax", 333 "junit", 334 "org.apache.http", 335 "org.json", 336 "org.w3c.dom", 337 "org.xml.sax", 338 "org.xmlpull", 339] 340 341// These are libs from framework-internal-utils that are required (i.e. being referenced) 342// from framework-non-updatable-sources. Add more here when there's a need. 343// DO NOT add the entire framework-internal-utils. It might cause unnecessary circular 344// dependencies when the list gets bigger. 345android_non_updatable_stubs_libs = [ 346 "android.hardware.cas-V1.2-java", 347 "android.hardware.health-V1.0-java-constants", 348 "android.hardware.thermal-V1.0-java-constants", 349 "android.hardware.thermal-V2.0-java", 350 "android.hardware.tv.input-V1.0-java-constants", 351 "android.hardware.usb-V1.0-java-constants", 352 "android.hardware.usb-V1.1-java-constants", 353 "android.hardware.usb.gadget-V1.0-java", 354 "android.hardware.vibrator-V1.3-java", 355 "framework-protos", 356] 357 358java_defaults { 359 name: "android-non-updatable-stubs-libs-defaults", 360 libs: android_non_updatable_stubs_libs, 361} 362 363// Defaults for all stubs that include the non-updatable framework. These defaults do not include 364// module symbols, so will not compile correctly on their own. Users must add module APIs to the 365// classpath (or sources) somehow. 366stubs_defaults { 367 name: "android-non-updatable-stubs-defaults", 368 aconfig_declarations: ["framework-minus-apex-aconfig-declarations"], 369 srcs: [":android-non-updatable-stub-sources"], 370 sdk_version: "none", 371 system_modules: "none", 372 java_version: "1.8", 373 arg_files: [":frameworks-base-core-AndroidManifest.xml"], 374 aidl: { 375 include_dirs: [ 376 "frameworks/av/aidl", 377 "frameworks/base/media/aidl", 378 "frameworks/base/telephony/java", 379 "frameworks/native/libs/permission/aidl", 380 "packages/modules/Bluetooth/framework/aidl-export", 381 "packages/modules/Connectivity/framework/aidl-export", 382 "packages/modules/Media/apex/aidl/stable", 383 "hardware/interfaces/biometrics/common/aidl", 384 "hardware/interfaces/biometrics/fingerprint/aidl", 385 "hardware/interfaces/common/aidl", 386 "hardware/interfaces/common/fmq/aidl", 387 "hardware/interfaces/graphics/common/aidl", 388 "hardware/interfaces/keymaster/aidl", 389 "hardware/interfaces/power/aidl", 390 "system/hardware/interfaces/media/aidl", 391 ], 392 }, 393 // These are libs from framework-internal-utils that are required (i.e. being referenced) 394 // from framework-non-updatable-sources. Add more here when there's a need. 395 // DO NOT add the entire framework-internal-utils. It might cause unnecessary circular 396 // dependencies gets bigger. 397 libs: android_non_updatable_stubs_libs, 398 flags: [ 399 "--error NoSettingsProvider", 400 "--error UnhiddenSystemApi", 401 "--error UnflaggedApi", 402 "--error FlaggedApiLiteral", 403 "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.*", 404 // Disable CallbackInterface, as Java 8 default interface methods avoid the extensibility 405 // issue interfaces had previously. 406 "--hide CallbackInterface", 407 // Disable HiddenSuperclass, as Metalava handles this fine (it should be hidden by default) 408 "--hide HiddenSuperclass", 409 "--manifest $(location :frameworks-base-core-AndroidManifest.xml)", 410 ], 411 filter_packages: packages_to_document, 412 high_mem: true, // Lots of sources => high memory use, see b/170701554 413 installable: false, 414 annotations_enabled: true, 415 merge_annotations_dirs: ["metalava-manual"], 416 defaults_visibility: ["//frameworks/base/api"], 417 visibility: [ 418 "//frameworks/base/api", 419 "//frameworks/base/core/api", 420 ], 421} 422 423soong_config_module_type { 424 name: "non_updatable_exportable_droidstubs", 425 module_type: "droidstubs", 426 config_namespace: "ANDROID", 427 bool_variables: [ 428 "release_hidden_api_exportable_stubs", 429 ], 430 properties: [ 431 "dists", 432 ], 433} 434 435// We resolve dependencies on APIs in modules by depending on a prebuilt of the whole 436// platform (sdk_system_current_android). That prebuilt does not include module-lib APIs, 437// so use the prebuilt module-lib stubs for modules that export module-lib stubs that the 438// non-updatable part depends on. 439non_updatable_api_deps_on_modules = [ 440 "sdk_module-lib_current_framework-tethering", 441 "sdk_module-lib_current_framework-connectivity-t", 442 "sdk_system_current_android", 443] 444 445java_defaults { 446 name: "module-classpath-java-defaults", 447 libs: non_updatable_api_deps_on_modules, 448} 449 450// Defaults with module APIs in the classpath (mostly from prebuilts). 451// Suitable for compiling android-non-updatable. 452stubs_defaults { 453 name: "module-classpath-stubs-defaults", 454 aidl: { 455 include_dirs: [ 456 "packages/modules/Bluetooth/framework/aidl-export", 457 "packages/modules/Connectivity/framework/aidl-export", 458 "packages/modules/Media/apex/aidl/stable", 459 ], 460 }, 461 libs: non_updatable_api_deps_on_modules, 462} 463 464// Defaults for the java_sdk_libraries of unbundled jars from framework. 465// java_sdk_libraries using these defaults should also add themselves to the 466// non_updatable_modules list in frameworks/base/api/api.go 467java_defaults { 468 name: "framework-non-updatable-unbundled-defaults", 469 defaults: [ 470 "framework-non-updatable-lint-defaults", 471 "non-updatable-framework-module-defaults", 472 ], 473 public: { 474 libs: ["android_module_lib_stubs_current"], 475 }, 476 system: { 477 libs: ["android_module_lib_stubs_current"], 478 }, 479 module_lib: { 480 libs: ["android_module_lib_stubs_current"], 481 }, 482 test: { 483 libs: ["android_test_frameworks_core_stubs_current"], 484 }, 485 sdk_version: "core_platform", 486 stub_only_libs: ["framework-protos"], 487 impl_only_libs: ["framework-minus-apex-headers"], // the framework, including hidden API 488 impl_library_visibility: ["//frameworks/base"], 489 defaults_visibility: [ 490 "//frameworks/base/location", 491 "//frameworks/base/packages/CrashRecovery/framework", 492 "//frameworks/base/nfc", 493 "//packages/modules/NeuralNetworks:__subpackages__", 494 ], 495 plugins: ["error_prone_android_framework"], 496 errorprone: { 497 javacflags: [ 498 "-Xep:AndroidFrameworkCompatChange:ERROR", 499 "-Xep:AndroidFrameworkUid:ERROR", 500 ], 501 }, 502 // Include manual annotations in API txt files 503 merge_annotations_dirs: ["metalava-manual"], 504} 505 506build = [ 507 "ApiDocs.bp", 508 "StubLibraries.bp", 509] 510 511genrule_defaults { 512 name: "flag-api-mapping-generation-defaults", 513 cmd: "$(location extract-flagged-apis) $(in) $(out)", 514 tools: ["extract-flagged-apis"], 515} 516 517java_genrule { 518 name: "flag-api-mapping-PublicApi", 519 defaults: ["flag-api-mapping-generation-defaults"], 520 srcs: [":frameworks-base-api-current.txt"], 521 out: ["flag_api_map.textproto"], 522 dist: { 523 targets: ["droid"], 524 }, 525} 526 527java_genrule { 528 name: "flag-api-mapping-SystemApi", 529 defaults: ["flag-api-mapping-generation-defaults"], 530 srcs: [":frameworks-base-api-system-current.txt"], 531 out: ["system_flag_api_map.textproto"], 532 dist: { 533 targets: ["droid"], 534 }, 535} 536 537java_genrule { 538 name: "flag-api-mapping-ModuleLibApi", 539 defaults: ["flag-api-mapping-generation-defaults"], 540 srcs: [":frameworks-base-api-module-lib-current.txt"], 541 out: ["module_lib_flag_api_map.textproto"], 542 dist: { 543 targets: ["droid"], 544 }, 545} 546 547java_genrule { 548 name: "flag-api-mapping-SystemServerApi", 549 defaults: ["flag-api-mapping-generation-defaults"], 550 srcs: [":frameworks-base-api-system-server-current.txt"], 551 out: ["system_server_flag_api_map.textproto"], 552 dist: { 553 targets: ["droid"], 554 }, 555} 556 557phony_rule { 558 name: "checkapi", 559 phony_deps: [ 560 "frameworks-base-api-current-compat", 561 "frameworks-base-api-system-current-compat", 562 "frameworks-base-api-module-lib-current-compat", 563 ], 564} 565