1// MAP API module
2
3package {
4    default_applicable_licenses: ["packages_apps_Bluetooth_license"],
5}
6
7// Added automatically by a large-scale-change that took the approach of
8// 'apply every license found to every target'. While this makes sure we respect
9// every license restriction, it may not be entirely correct.
10//
11// e.g. GPL in an MIT project might only apply to the contrib/ directory.
12//
13// Please consider splitting the single license below into multiple licenses,
14// taking care not to lose any license_kind information, and overriding the
15// default license using the 'licenses: [...]' property on targets as needed.
16//
17// For unused files, consider creating a 'fileGroup' with "//visibility:private"
18// to attach the license to, and including a comment whether the files may be
19// used in the current project.
20// See: http://go/android-license-faq
21license {
22    name: "packages_apps_Bluetooth_license",
23    visibility: [":__subpackages__"],
24    license_kinds: [
25        "SPDX-license-identifier-Apache-2.0",
26        "SPDX-license-identifier-BSD",
27    ],
28    // large-scale-change unable to identify any license_text files
29}
30
31java_library {
32    name: "bluetooth.mapsapi",
33
34    srcs: ["lib/mapapi/**/*.java"],
35    apex_available: [
36        "com.android.btservices",
37    ],
38    min_sdk_version: "Tiramisu",
39    sdk_version: "module_current",
40    lint: {
41        baseline_filename: "lint-baseline.xml",
42    },
43}
44
45java_library {
46    name: "mmslib",
47
48    srcs: [":framework-mms-shared-srcs"],
49    libs: ["unsupportedappusage"],
50    apex_available: [
51        "com.android.btservices",
52    ],
53    min_sdk_version: "Tiramisu",
54    sdk_version: "module_current",
55    lint: {
56        baseline_filename: "lint-baseline.xml",
57    },
58}
59
60// Bluetooth JNI
61
62cc_library_shared {
63    name: "libbluetooth_jni",
64    defaults: [
65        "fluoride_defaults",
66        "latest_android_hardware_audio_common_ndk_static",
67        "latest_android_hardware_bluetooth_audio_ndk_static",
68        "latest_android_media_audio_common_types_ndk_static",
69    ],
70    srcs: ["jni/**/*.cpp"],
71    version_script: "libbluetooth_jni.map",
72    header_libs: [
73        "jni_headers",
74        "libbluetooth_headers",
75    ],
76    include_dirs: [
77        "packages/modules/Bluetooth/system",
78        "packages/modules/Bluetooth/system/gd",
79        "packages/modules/Bluetooth/system/types",
80    ],
81    // libbluetooth_jni is the jni lib included in the btservices apex.
82    // As this library is inside an APEX the shared_libs that does not
83    // expose stubs are copied inside it. As a result using those as
84    // shared libraries is less interesting as they are not shared, so we link
85    // them statically to allow the linker to perform more optimisation.
86    //
87    // The only exception to this is libcrypto because the shared version
88    // is required to maintain FIPS compliance.
89    stl: "libc++_static",
90    static_libs: [
91        "android.hardware.audio.common@5.0",
92        "android.hardware.bluetooth.audio@2.0",
93        "android.hardware.bluetooth.audio@2.1",
94        "android.hardware.bluetooth@1.0",
95        "android.hardware.bluetooth@1.1",
96        "android.hardware.common-V2-ndk",
97        "android.hardware.common.fmq-V1-ndk",
98        "android.system.suspend-V1-ndk",
99        "android.system.suspend.control-V1-ndk",
100        "avrcp-target-service",
101        "lib-bt-packets-avrcp",
102        "lib-bt-packets-base",
103        "libFraunhoferAAC",
104        "libaconfig_storage_read_api_cc",
105        "libaudio-a2dp-hw-utils",
106        "libbase",
107        "libbluetooth",
108        "libbluetooth-dumpsys",
109        "libbluetooth-gdx",
110        "libbluetooth-types",
111        "libbluetooth_core_rs",
112        "libbluetooth_core_rs_bridge",
113        "libbluetooth_crypto_toolbox",
114        "libbluetooth_gd",
115        "libbluetooth_log",
116        "libbt-audio-asrc",
117        "libbt-audio-hal-interface",
118        "libbt-bta",
119        "libbt-bta-core",
120        "libbt-btu-main-thread",
121        "libbt-common",
122        "libbt-hci",
123        "libbt-jni-thread",
124        "libbt-sbc-decoder",
125        "libbt-sbc-encoder",
126        "libbt-stack",
127        "libbt-stack-core",
128        "libbt_shim_bridge",
129        "libbtcore",
130        "libbtdevice",
131        "libbte",
132        "libbtif",
133        "libbtif-core",
134        "libchrome",
135        "libcutils",
136        "libevent",
137        "libflatbuffers-cpp",
138        "libfmq",
139        "libg722codec",
140        "libhidlbase",
141        "liblc3",
142        "libmodpb64",
143        "libopus",
144        "libosi",
145        "libprotobuf-cpp-lite",
146        "libstatslog_bt",
147        "libudrv-uipc",
148        "libutils",
149        "server_configurable_flags",
150    ],
151    shared_libs: [
152        "libaaudio",
153        "libbinder_ndk",
154        "libcrypto",
155        "liblog",
156        "libnativehelper",
157        "libstatssocket",
158        "libvndksupport",
159    ],
160    sanitize: {
161        scs: true,
162    },
163    apex_available: [
164        "com.android.btservices",
165    ],
166    min_sdk_version: "Tiramisu",
167    ldflags: ["-Wl,--allow-multiple-definition"],
168
169    // TODO(b/346919576) Workaround LTO build breakage.
170    lto_O0: true,
171}
172
173cc_library {
174    name: "libbluetooth-core",
175    defaults: ["fluoride_defaults"],
176    header_libs: [
177        "jni_headers",
178        "libbluetooth_headers",
179    ],
180    include_dirs: [
181        "packages/modules/Bluetooth/system/types",
182    ],
183    static_libs: [
184        "lib-bt-packets",
185        "lib-bt-packets-base",
186        "libbt-bta-core",
187        "libbt-common",
188        "libbt-hci",
189        "libbt-stack-core",
190        "libbtcore",
191        "libbtdevice",
192        "libbte",
193        "libbtif-core",
194        "libosi",
195
196        "libbluetooth-types",
197    ],
198    cflags: [
199        /* we export all classes, so change default visibility, instead of having EXPORT_SYMBOL on each class*/
200        "-Wall",
201        "-Werror",
202        "-Wextra",
203        "-Wno-unused-parameter",
204        "-fvisibility=default",
205    ],
206    sanitize: {
207        scs: true,
208    },
209    apex_available: [
210        "com.android.btservices",
211    ],
212    host_supported: true,
213    min_sdk_version: "Tiramisu",
214}
215
216// Bluetooth APK
217
218android_app {
219    name: "Bluetooth",
220
221    srcs: [
222        ":statslog-bluetooth-java-gen",
223        ":statslog-bt-restricted-java-gen",
224        ":system-messages-proto-src",
225        "proto/keystore.proto",
226        "src/**/*.java",
227    ],
228    proto: {
229        type: "lite",
230    },
231    aaptflags: [
232        "--custom-package",
233        "com.android.bluetooth",
234    ],
235    certificate: ":com.android.bluetooth.certificate",
236
237    jarjar_rules: ":bluetooth-jarjar-rules",
238    privapp_allowlist: ":privapp_allowlist_com.android.bluetooth.xml",
239
240    jni_uses_platform_apis: true,
241    libs: [
242        "app-compat-annotations",
243        "bluetooth_flags_java_lib",
244        "error_prone_annotations",
245        "framework-annotations-lib",
246        "framework-bluetooth-pre-jarjar",
247        "framework-configinfrastructure",
248        "framework-connectivity.stubs.module_lib",
249        "framework-location.stubs.module_lib",
250        "framework-mediaprovider",
251        "framework-statsd.stubs.module_lib",
252        "framework-tethering.stubs.module_lib",
253        "unsupportedappusage",
254
255        // Need to link the class at runtime
256        "framework-bluetooth",
257    ],
258    static_libs: [
259        "BluetoothApiShims",
260        "android.hardware.radio-V1.0-java",
261        "android.hardware.radio.sap-V1-java",
262        "androidx.annotation_annotation",
263        "androidx.core_core",
264        "androidx.lifecycle_lifecycle-livedata",
265        "androidx.media_media",
266        "androidx.room_room-runtime",
267        "bluetooth-proto-enums-java-gen",
268        "bluetooth-protos-lite",
269        "bluetooth.change-ids",
270        "bluetooth.mapsapi",
271        "com.android.obex",
272        "com.android.vcard",
273        "guava",
274        "libprotobuf-java-lite",
275        "mmslib",
276        "modules-utils-backgroundthread",
277        "modules-utils-bytesmatcher",
278        "modules-utils-statemachine",
279        "net-utils-services-common",
280        "networkstack-client",
281        "sap-api-java-static",
282    ],
283
284    plugins: [
285        "androidx.room_room-compiler-plugin",
286    ],
287
288    // Export schemas to the test directory so that we have an history
289    // to be able to test migrations
290    // The following path is absolute because a relative path doesn't work
291    // TODO(b/147596836): Refactor this
292    javacflags: ["-Aroom.schemaLocation=packages/modules/Bluetooth/android/app/tests/unit/src/com/android/bluetooth/btservice/storage/schemas"],
293
294    lint: {
295        // TODO(b/318814235): Add back ObsoleteSdkInt to this list.
296        error_checks: [
297            "ExtraText",
298            "MissingClass",
299            "NewApi",
300            "Recycle",
301            "RtlHardcoded",
302            "UseSparseArrays",
303            "UseValueOf",
304        ],
305        extra_check_modules: ["BluetoothLintChecker"],
306        baseline_filename: "lint-baseline.xml",
307    },
308
309    optimize: {
310        enabled: true,
311        shrink: true,
312        optimize: false,
313        // TODO(b/289285719): Revisit after resolving mocking issues in testing.
314        proguard_compatibility: true,
315        proguard_flags_files: ["proguard.flags"],
316    },
317    apex_available: [
318        "com.android.btservices",
319    ],
320    errorprone: {
321        enabled: true,
322        javacflags: [
323            // "-Xep:AndroidFrameworkRequiresPermission:ERROR",
324            "-Xep:AlmostJavadoc:ERROR",
325            "-Xep:BadImport:ERROR",
326            "-Xep:ClassCanBeStatic:ERROR",
327            "-Xep:EmptyBlockTag:ERROR",
328            "-Xep:InlineMeInliner:ERROR",
329            "-Xep:InvalidBlockTag:ERROR",
330            "-Xep:InvalidParam:ERROR",
331            "-Xep:MockNotUsedInProduction:ERROR",
332            "-Xep:NonCanonicalType:ERROR",
333            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
334            "-Xep:UnusedMethod:ERROR",
335            "-Xep:UnusedVariable:ERROR",
336            "-XepExcludedPaths:.*/srcjars/.*", // Exclude generated files
337        ],
338    },
339    min_sdk_version: "Tiramisu",
340    sdk_version: "module_current",
341}
342
343java_library {
344    name: "bluetooth.change-ids",
345    srcs: [
346        "src/com/android/bluetooth/ChangeIds.java",
347    ],
348    libs: [
349        "app-compat-annotations",
350    ],
351    apex_available: [
352        "com.android.btservices",
353    ],
354    min_sdk_version: "Tiramisu",
355    sdk_version: "module_current",
356}
357
358platform_compat_config {
359    name: "bluetoothapk-platform-compat-config",
360    src: ":bluetooth.change-ids",
361}
362
363java_library {
364    name: "bluetooth-proto-enums-java-gen",
365    installable: false,
366    proto: {
367        type: "stream",
368    },
369    srcs: [
370        ":srcs_bluetooth_protos",
371    ],
372    apex_available: [
373        "com.android.btservices",
374    ],
375    min_sdk_version: "Tiramisu",
376    sdk_version: "module_current",
377}
378
379genrule {
380    name: "statslog-bluetooth-java-gen",
381    tools: ["stats-log-api-gen"],
382    cmd: "$(location stats-log-api-gen) --java $(out) --module bluetooth" +
383        " --javaPackage com.android.bluetooth --javaClass BluetoothStatsLog" +
384        " --minApiLevel 33",
385    out: ["com/android/bluetooth/BluetoothStatsLog.java"],
386}
387
388genrule {
389    name: "statslog-bt-restricted-java-gen",
390    tools: ["stats-log-api-gen"],
391    cmd: "$(location stats-log-api-gen) --java $(out) --module bt_restricted" +
392        " --javaPackage com.android.bluetooth --javaClass BtRestrictedStatsLog" +
393        " --minApiLevel 34",
394    out: ["com/android/bluetooth/BtRestrictedStatsLog.java"],
395}
396
397android_app_certificate {
398    name: "com.android.bluetooth.certificate",
399    certificate: "certs/com.android.bluetooth",
400}
401