| // Copyright (C) 2020 The Android Open Source Project | 
 | // | 
 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
 | // you may not use this file except in compliance with the License. | 
 | // You may obtain a copy of the License at | 
 | // | 
 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
 | // | 
 | // Unless required by applicable law or agreed to in writing, software | 
 | // distributed under the License is distributed on an "AS IS" BASIS, | 
 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | // See the License for the specific language governing permissions and | 
 | // limitations under the License. | 
 |  | 
 | package { | 
 |     default_visibility: ["//visibility:private"], | 
 |     // See: http://go/android-license-faq | 
 |     // A large-scale-change added 'default_applicable_licenses' to import | 
 |     // all of the 'license_kinds' from "frameworks_base_license" | 
 |     // to get the below license kinds: | 
 |     //   SPDX-license-identifier-Apache-2.0 | 
 |     //   SPDX-license-identifier-MIT | 
 |     //   SPDX-license-identifier-Unicode-DFS | 
 |     default_applicable_licenses: ["frameworks_base_license"], | 
 | } | 
 |  | 
 | bootstrap_go_package { | 
 |     name: "soong-api", | 
 |     pkgPath: "android/soong/api", | 
 |     deps: [ | 
 |         "blueprint", | 
 |         "soong", | 
 |         "soong-android", | 
 |         "soong-genrule", | 
 |         "soong-java", | 
 |     ], | 
 |     srcs: ["api.go"], | 
 |     pluginFor: ["soong_build"], | 
 | } | 
 |  | 
 | python_binary_host { | 
 |     name: "merge_annotation_zips", | 
 |     srcs: ["merge_annotation_zips.py"], | 
 | } | 
 |  | 
 | python_test_host { | 
 |     name: "merge_annotation_zips_test", | 
 |     main: "merge_annotation_zips_test.py", | 
 |     srcs: [ | 
 |         "merge_annotation_zips.py", | 
 |         "merge_annotation_zips_test.py", | 
 |     ], | 
 |     test_options: { | 
 |         unit_test: true, | 
 |     }, | 
 | } | 
 |  | 
 | metalava_cmd = "$(location metalava)" | 
 | // Silence reflection warnings. See b/168689341 | 
 | metalava_cmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED " | 
 | metalava_cmd += " --quiet " | 
 |  | 
 | combined_apis { | 
 |     name: "frameworks-base-api", | 
 |     bootclasspath: [ | 
 |         "android.net.ipsec.ike", | 
 |         "art.module.public.api", | 
 |         "conscrypt.module.public.api", | 
 |         "framework-adservices", | 
 |         "framework-appsearch", | 
 |         "framework-bluetooth", | 
 |         "framework-configinfrastructure", | 
 |         "framework-connectivity", | 
 |         "framework-connectivity-t", | 
 |         "framework-devicelock", | 
 |         "framework-graphics", | 
 |         "framework-healthfitness", | 
 |         "framework-location", | 
 |         "framework-media", | 
 |         "framework-mediaprovider", | 
 |         "framework-nfc", | 
 |         "framework-ondevicepersonalization", | 
 |         "framework-pdf", | 
 |         "framework-permission", | 
 |         "framework-permission-s", | 
 |         "framework-scheduling", | 
 |         "framework-sdkextensions", | 
 |         "framework-statsd", | 
 |         "framework-sdksandbox", | 
 |         "framework-tethering", | 
 |         "framework-uwb", | 
 |         "framework-virtualization", | 
 |         "framework-wifi", | 
 |         "i18n.module.public.api", | 
 |     ], | 
 |     system_server_classpath: [ | 
 |         "service-art", | 
 |         "service-configinfrastructure", | 
 |         "service-healthfitness", | 
 |         "service-media-s", | 
 |         "service-permission", | 
 |         "service-rkp", | 
 |         "service-sdksandbox", | 
 |     ], | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "frameworks-base-api-current-compat", | 
 |     srcs: [ | 
 |         ":android.api.public.latest", | 
 |         ":android-incompatibilities.api.public.latest", | 
 |         ":frameworks-base-api-current.txt", | 
 |     ], | 
 |     out: ["updated-baseline.txt"], | 
 |     tools: ["metalava"], | 
 |     cmd: metalava_cmd + | 
 |         "--check-compatibility:api:released $(location :android.api.public.latest) " + | 
 |         "--baseline:compatibility:released $(location :android-incompatibilities.api.public.latest) " + | 
 |         "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " + | 
 |         "$(location :frameworks-base-api-current.txt)", | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "frameworks-base-api-system-current-compat", | 
 |     srcs: [ | 
 |         ":android.api.system.latest", | 
 |         ":android-incompatibilities.api.system.latest", | 
 |         ":frameworks-base-api-current.txt", | 
 |         ":frameworks-base-api-system-current.txt", | 
 |     ], | 
 |     out: ["updated-baseline.txt"], | 
 |     tools: ["metalava"], | 
 |     cmd: metalava_cmd + | 
 |         "--check-compatibility:api:released $(location :android.api.system.latest) " + | 
 |         "--check-compatibility:base $(location :frameworks-base-api-current.txt) " + | 
 |         "--baseline:compatibility:released $(location :android-incompatibilities.api.system.latest) " + | 
 |         "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " + | 
 |         "$(location :frameworks-base-api-system-current.txt)", | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "frameworks-base-api-module-lib-current-compat", | 
 |     srcs: [ | 
 |         ":android.api.module-lib.latest", | 
 |         ":android-incompatibilities.api.module-lib.latest", | 
 |         ":frameworks-base-api-current.txt", | 
 |         ":frameworks-base-api-module-lib-current.txt", | 
 |     ], | 
 |     out: ["updated-baseline.txt"], | 
 |     tools: ["metalava"], | 
 |     cmd: metalava_cmd + | 
 |         "--check-compatibility:api:released $(location :android.api.module-lib.latest) " + | 
 |         // Note: having "public" be the base of module-lib is not perfect -- it should | 
 |         // ideally be a merged public+system (which metalava is not currently able to generate). | 
 |         // This "base" will help when migrating from MODULE_LIBS -> public, but not when | 
 |         // migrating from MODULE_LIBS -> system (where it needs to instead be listed as | 
 |         // an incompatibility). | 
 |         "--check-compatibility:base $(location :frameworks-base-api-current.txt) " + | 
 |         "--baseline:compatibility:released $(location :android-incompatibilities.api.module-lib.latest) " + | 
 |         "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " + | 
 |         "$(location :frameworks-base-api-module-lib-current.txt)", | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "frameworks-base-api-current.srcjar", | 
 |     tools: ["merge_zips"], | 
 |     out: ["current.srcjar"], | 
 |     cmd: "$(location merge_zips) $(out) $(in)", | 
 |     srcs: [ | 
 |         ":api-stubs-docs-non-updatable", | 
 |         ":all-modules-public-stubs-source", | 
 |     ], | 
 |     visibility: ["//visibility:private"], // Used by make module in //development, mind | 
 | } | 
 |  | 
 | // This produces the same annotations.zip as framework-doc-stubs, but by using | 
 | // outputs from individual modules instead of all the source code. | 
 | genrule_defaults { | 
 |     name: "sdk-annotations-defaults", | 
 |     out: ["annotations.zip"], | 
 |     tools: [ | 
 |         "merge_annotation_zips", | 
 |         "soong_zip", | 
 |     ], | 
 |     cmd: "$(location merge_annotation_zips) $(genDir)/out $(in) && " + | 
 |         "$(location soong_zip) -o $(out) -C $(genDir)/out -D $(genDir)/out", | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "sdk-annotations.zip", | 
 |     defaults: ["sdk-annotations-defaults"], | 
 |     srcs: [ | 
 |         ":android-non-updatable-doc-stubs{.annotations.zip}", | 
 |         ":all-modules-public-annotations", | 
 |     ], | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "sdk-annotations-system.zip", | 
 |     defaults: ["sdk-annotations-defaults"], | 
 |     srcs: [ | 
 |         ":android-non-updatable-doc-stubs-system{.annotations.zip}", | 
 |         ":all-modules-system-annotations", | 
 |     ], | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "sdk-annotations-module-lib.zip", | 
 |     defaults: ["sdk-annotations-defaults"], | 
 |     srcs: [ | 
 |         ":android-non-updatable-doc-stubs-module-lib{.annotations.zip}", | 
 |         ":all-modules-module-lib-annotations", | 
 |     ], | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "sdk-annotations-system-server.zip", | 
 |     defaults: ["sdk-annotations-defaults"], | 
 |     srcs: [ | 
 |         ":android-non-updatable-doc-stubs-system-server{.annotations.zip}", | 
 |         ":all-modules-system-server-annotations", | 
 |     ], | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "combined-removed-dex", | 
 |     visibility: [ | 
 |         "//frameworks/base/boot", | 
 |     ], | 
 |     srcs: [ | 
 |         ":frameworks-base-api-removed.txt", | 
 |         ":frameworks-base-api-system-removed.txt", | 
 |         ":android.car-stubs-docs{.removed-api.txt}", | 
 |         ":android.car-system-stubs-docs{.removed-api.txt}", | 
 |     ], | 
 |     tool_files: ["gen_combined_removed_dex.sh"], | 
 |     tools: ["metalava"], | 
 |     out: ["combined-removed-dex.txt"], | 
 |     cmd: "$(location gen_combined_removed_dex.sh) $(location metalava) $(genDir) $(in) > $(out)", | 
 | } | 
 |  | 
 | java_genrule { | 
 |     name: "api_fingerprint", | 
 |     srcs: [ | 
 |         ":frameworks-base-api-current.txt", | 
 |         ":frameworks-base-api-system-current.txt", | 
 |         ":frameworks-base-api-module-lib-current.txt", | 
 |         ":frameworks-base-api-system-server-current.txt", | 
 |     ], | 
 |     out: ["api_fingerprint.txt"], | 
 |     cmd: "cat $(in) | md5sum | cut -d' ' -f1 > $(out)", | 
 | } | 
 |  | 
 | packages_to_document = [ | 
 |     "android", | 
 |     "dalvik", | 
 |     "java", | 
 |     "javax", | 
 |     "junit", | 
 |     "org.apache.http", | 
 |     "org.json", | 
 |     "org.w3c.dom", | 
 |     "org.xml.sax", | 
 |     "org.xmlpull", | 
 | ] | 
 |  | 
 | // Defaults for all stubs that include the non-updatable framework. These defaults do not include | 
 | // module symbols, so will not compile correctly on their own. Users must add module APIs to the | 
 | // classpath (or sources) somehow. | 
 | stubs_defaults { | 
 |     name: "android-non-updatable-stubs-defaults", | 
 |     srcs: [":android-non-updatable-stub-sources"], | 
 |     sdk_version: "none", | 
 |     system_modules: "none", | 
 |     java_version: "1.8", | 
 |     arg_files: [":frameworks-base-core-AndroidManifest.xml"], | 
 |     aidl: { | 
 |         include_dirs: [ | 
 |             "frameworks/av/aidl", | 
 |             "frameworks/base/media/aidl", | 
 |             "frameworks/base/telephony/java", | 
 |             "frameworks/native/libs/permission/aidl", | 
 |             "packages/modules/Bluetooth/framework/aidl-export", | 
 |             "packages/modules/Connectivity/framework/aidl-export", | 
 |             "packages/modules/Media/apex/aidl/stable", | 
 |             "hardware/interfaces/biometrics/common/aidl", | 
 |             "hardware/interfaces/biometrics/fingerprint/aidl", | 
 |             "hardware/interfaces/graphics/common/aidl", | 
 |             "hardware/interfaces/keymaster/aidl", | 
 |             "system/hardware/interfaces/media/aidl", | 
 |         ], | 
 |     }, | 
 |     // These are libs from framework-internal-utils that are required (i.e. being referenced) | 
 |     // from framework-non-updatable-sources. Add more here when there's a need. | 
 |     // DO NOT add the entire framework-internal-utils. It might cause unnecessary circular | 
 |     // dependencies gets bigger. | 
 |     libs: [ | 
 |         "android.hardware.cas-V1.2-java", | 
 |         "android.hardware.health-V1.0-java-constants", | 
 |         "android.hardware.thermal-V1.0-java-constants", | 
 |         "android.hardware.thermal-V2.0-java", | 
 |         "android.hardware.tv.input-V1.0-java-constants", | 
 |         "android.hardware.usb-V1.0-java-constants", | 
 |         "android.hardware.usb-V1.1-java-constants", | 
 |         "android.hardware.usb.gadget-V1.0-java", | 
 |         "android.hardware.vibrator-V1.3-java", | 
 |         "framework-protos", | 
 |     ], | 
 |     flags: [ | 
 |         "--api-lint-ignore-prefix android.icu.", | 
 |         "--api-lint-ignore-prefix java.", | 
 |         "--api-lint-ignore-prefix junit.", | 
 |         "--api-lint-ignore-prefix org.", | 
 |         "--error NoSettingsProvider", | 
 |         "--error UnhiddenSystemApi", | 
 |         "--error UnflaggedApi", | 
 |         "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.*", | 
 |         // Disable CallbackInterface, as Java 8 default interface methods avoid the extensibility | 
 |         // issue interfaces had previously. | 
 |         "--hide CallbackInterface", | 
 |         // Disable HiddenSuperclass, as Metalava handles this fine (it should be hidden by default) | 
 |         "--hide HiddenSuperclass", | 
 |         "--hide-package android.audio.policy.configuration.V7_0", | 
 |         "--hide-package com.android.server", | 
 |         "--manifest $(location :frameworks-base-core-AndroidManifest.xml)", | 
 |     ], | 
 |     filter_packages: packages_to_document, | 
 |     high_mem: true, // Lots of sources => high memory use, see b/170701554 | 
 |     installable: false, | 
 |     annotations_enabled: true, | 
 |     previous_api: ":android.api.public.latest", | 
 |     merge_annotations_dirs: ["metalava-manual"], | 
 |     defaults_visibility: ["//frameworks/base/api"], | 
 |     visibility: ["//frameworks/base/api"], | 
 | } | 
 |  | 
 | // We resolve dependencies on APIs in modules by depending on a prebuilt of the whole | 
 | // platform (sdk_system_current_android). That prebuilt does not include module-lib APIs, | 
 | // so use the prebuilt module-lib stubs for modules that export module-lib stubs that the | 
 | // non-updatable part depends on. | 
 | non_updatable_api_deps_on_modules = [ | 
 |     "sdk_module-lib_current_framework-tethering", | 
 |     "sdk_module-lib_current_framework-connectivity-t", | 
 |     "sdk_system_current_android", | 
 | ] | 
 |  | 
 | // Defaults with module APIs in the classpath (mostly from prebuilts). | 
 | // Suitable for compiling android-non-updatable. | 
 | stubs_defaults { | 
 |     name: "module-classpath-stubs-defaults", | 
 |     aidl: { | 
 |         include_dirs: [ | 
 |             "packages/modules/Bluetooth/framework/aidl-export", | 
 |             "packages/modules/Connectivity/framework/aidl-export", | 
 |             "packages/modules/Media/apex/aidl/stable", | 
 |         ], | 
 |     }, | 
 |     libs: non_updatable_api_deps_on_modules, | 
 | } | 
 |  | 
 | // Defaults for the java_sdk_libraries of unbundled jars from framework. | 
 | // java_sdk_libraries using these defaults should also add themselves to the | 
 | // non_updatable_modules list in frameworks/base/api/api.go | 
 | java_defaults { | 
 |     name: "framework-non-updatable-unbundled-defaults", | 
 |     defaults: [ | 
 |         "framework-non-updatable-lint-defaults", | 
 |         "non-updatable-framework-module-defaults", | 
 |     ], | 
 |     public: { | 
 |         libs: ["android_module_lib_stubs_current"], | 
 |     }, | 
 |     system: { | 
 |         libs: ["android_module_lib_stubs_current"], | 
 |     }, | 
 |     module_lib: { | 
 |         libs: ["android_module_lib_stubs_current"], | 
 |     }, | 
 |     test: { | 
 |         libs: ["android_test_frameworks_core_stubs_current"], | 
 |     }, | 
 |     sdk_version: "core_platform", | 
 |     stub_only_libs: ["framework-protos"], | 
 |     impl_only_libs: ["framework-minus-apex-headers"], // the framework, including hidden API | 
 |     impl_library_visibility: ["//frameworks/base"], | 
 |     defaults_visibility: [ | 
 |         "//frameworks/base/location", | 
 |         "//frameworks/base/nfc", | 
 |     ], | 
 |     plugins: ["error_prone_android_framework"], | 
 |     errorprone: { | 
 |         javacflags: [ | 
 |             "-Xep:AndroidFrameworkCompatChange:ERROR", | 
 |             "-Xep:AndroidFrameworkUid:ERROR", | 
 |         ], | 
 |     }, | 
 |     // Include manual annotations in API txt files | 
 |     merge_annotations_dirs: ["metalava-manual"], | 
 | } | 
 |  | 
 | build = [ | 
 |     "ApiDocs.bp", | 
 |     "StubLibraries.bp", | 
 | ] | 
 |  | 
 | genrule_defaults { | 
 |     name: "flag-api-mapping-generation-defaults", | 
 |     cmd: "$(location extract-flagged-apis) $(in) $(out)", | 
 |     tools: ["extract-flagged-apis"], | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "flag-api-mapping-PublicApi", | 
 |     defaults: ["flag-api-mapping-generation-defaults"], | 
 |     srcs: [":frameworks-base-api-current.txt"], | 
 |     out: ["flag_api_map.textproto"], | 
 |     dist: { | 
 |         targets: ["droid"], | 
 |     }, | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "flag-api-mapping-SystemApi", | 
 |     defaults: ["flag-api-mapping-generation-defaults"], | 
 |     srcs: [":frameworks-base-api-system-current.txt"], | 
 |     out: ["system_flag_api_map.textproto"], | 
 |     dist: { | 
 |         targets: ["droid"], | 
 |     }, | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "flag-api-mapping-ModuleLibApi", | 
 |     defaults: ["flag-api-mapping-generation-defaults"], | 
 |     srcs: [":frameworks-base-api-module-lib-current.txt"], | 
 |     out: ["module_lib_flag_api_map.textproto"], | 
 |     dist: { | 
 |         targets: ["droid"], | 
 |     }, | 
 | } | 
 |  | 
 | genrule { | 
 |     name: "flag-api-mapping-SystemServerApi", | 
 |     defaults: ["flag-api-mapping-generation-defaults"], | 
 |     srcs: [":frameworks-base-api-system-server-current.txt"], | 
 |     out: ["system_server_flag_api_map.textproto"], | 
 |     dist: { | 
 |         targets: ["droid"], | 
 |     }, | 
 | } |