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    aidl: {
77        libs: ["bluetooth_constants"],
78    },
79    include_dirs: [
80        "packages/modules/Bluetooth/system",
81        "packages/modules/Bluetooth/system/gd",
82    ],
83    // libbluetooth_jni is the jni lib included in the btservices apex.
84    // As this library is inside an APEX the shared_libs that does not
85    // expose stubs are copied inside it. As a result using those as
86    // shared libraries is less interesting as they are not shared, so we link
87    // them statically to allow the linker to perform more optimisation.
88    //
89    // The only exception to this is libcrypto because the shared version
90    // is required to maintain FIPS compliance.
91    stl: "libc++_static",
92    static_libs: [
93        "aics",
94        "[email protected]",
95        "[email protected]",
96        "[email protected]",
97        "[email protected]",
98        "[email protected]",
99        "android.hardware.common-V2-ndk",
100        "android.hardware.common.fmq-V1-ndk",
101        "android.system.suspend-V1-ndk",
102        "android.system.suspend.control-V1-ndk",
103        "avrcp-target-service",
104        "bluetooth_flags_c_lib",
105        "lib-bt-packets-avrcp",
106        "lib-bt-packets-base",
107        "libFraunhoferAAC",
108        "libaconfig_storage_read_api_cc",
109        "libbase",
110        "libbluetooth",
111        "libbluetooth-types",
112        "libbluetooth_core_rs",
113        "libbluetooth_core_rs_bridge",
114        "libbluetooth_crypto_toolbox",
115        "libbluetooth_gd",
116        "libbluetooth_log",
117        "libbt-audio-asrc",
118        "libbt-audio-hal-interface",
119        "libbt-bta",
120        "libbt-bta-core",
121        "libbt-btu-main-thread",
122        "libbt-common",
123        "libbt-hci",
124        "libbt-jni-thread",
125        "libbt-sbc-decoder",
126        "libbt-sbc-encoder",
127        "libbt-stack",
128        "libbt-stack-core",
129        "libbtcore",
130        "libbtdevice",
131        "libbte",
132        "libbtif",
133        "libbtif-core",
134        "libchrome",
135        "libcutils",
136        "libevent",
137        "libexpresslog",
138        "libflags_rust_cpp_bridge",
139        "libflatbuffers-cpp",
140        "libfmq",
141        "libg722codec",
142        "libhidlbase",
143        "liblc3",
144        "libmodpb64",
145        "libopus",
146        "libosi",
147        "libprotobuf-cpp-lite",
148        "libstatslog_bt",
149        "libstatslog_express",
150        "libtextclassifier_hash_static",
151        "libudrv-uipc",
152        "libutils",
153        "server_configurable_flags",
154    ],
155    shared_libs: [
156        "libaaudio",
157        "libbinder_ndk",
158        "libcrypto",
159        "liblog",
160        "libnativehelper",
161        "libstatssocket",
162        "libvndksupport",
163    ],
164    sanitize: {
165        scs: true,
166    },
167    apex_available: [
168        "com.android.btservices",
169    ],
170    min_sdk_version: "Tiramisu",
171}
172
173cc_library {
174    name: "libbluetooth-core",
175    defaults: ["fluoride_defaults"],
176    header_libs: [
177        "jni_headers",
178        "libbluetooth_headers",
179    ],
180    static_libs: [
181        "lib-bt-packets",
182        "lib-bt-packets-base",
183        "libbt-bta-core",
184        "libbt-common",
185        "libbt-hci",
186        "libbt-stack-core",
187        "libbtcore",
188        "libbtdevice",
189        "libbte",
190        "libbtif-core",
191        "libosi",
192
193        "libbluetooth-types",
194    ],
195    cflags: [
196        // we export all classes, so change default visibility,
197        // instead of having EXPORT_SYMBOL on each class
198        "-fvisibility=default",
199    ],
200    sanitize: {
201        scs: true,
202    },
203    apex_available: [
204        "com.android.btservices",
205    ],
206    host_supported: true,
207    min_sdk_version: "Tiramisu",
208}
209
210// Bluetooth APK
211
212android_app {
213    name: "Bluetooth",
214    defaults: ["bluetooth_framework_errorprone_rules"],
215
216    srcs: [
217        ":statslog-bluetooth-java-gen",
218        ":statslog-bt-restricted-java-gen",
219        ":system-messages-proto-src",
220        "proto/keystore.proto",
221        "src/**/*.java",
222    ],
223    proto: {
224        type: "lite",
225    },
226    aaptflags: [
227        "--custom-package",
228        "com.android.bluetooth",
229    ],
230    certificate: ":com.android.bluetooth.certificate",
231
232    jarjar_rules: ":bluetooth-jarjar-rules",
233    privapp_allowlist: ":privapp_allowlist_com.android.bluetooth.xml",
234
235    jni_uses_platform_apis: true,
236    libs: [
237        "app-compat-annotations",
238        "bluetooth_constants_java",
239        "bluetooth_flags_java_lib",
240        "error_prone_annotations",
241        "framework-annotations-lib",
242        "framework-bluetooth-pre-jarjar",
243        "framework-configinfrastructure.stubs.module_lib",
244        "framework-connectivity.stubs.module_lib",
245        "framework-location.stubs.module_lib",
246        "framework-mediaprovider.stubs.module_lib",
247        "framework-statsd.stubs.module_lib",
248        "framework-tethering.stubs.module_lib",
249        "unsupportedappusage",
250
251        // Need to link the class at runtime
252        "framework-bluetooth.stubs.module_lib",
253    ],
254    static_libs: [
255        "BluetoothApiShims",
256        "android.hardware.radio-V1.0-java",
257        "android.hardware.radio.sap-V1-java",
258        "android.media.audio-aconfig-exported-java",
259        "android.os.flags-aconfig-java-export",
260        "androidx.annotation_annotation",
261        "androidx.core_core",
262        "androidx.lifecycle_lifecycle-livedata",
263        "androidx.media_media",
264        "androidx.room_room-runtime",
265        "bluetooth-proto-enums-java-gen",
266        "bluetooth-protos-lite",
267        "bluetooth.change-ids",
268        "bluetooth.mapsapi",
269        "com.android.obex",
270        "com.android.vcard",
271        "guava",
272        "libprotobuf-java-lite",
273        "mmslib",
274        "modules-utils-backgroundthread",
275        "modules-utils-bytesmatcher",
276        "modules-utils-statemachine",
277        "net-utils-services-common",
278        "networkstack-client",
279        "sap-api-java-static",
280    ],
281
282    plugins: [
283        "androidx.room_room-compiler-plugin",
284    ],
285
286    // Export schemas to the test directory so that we have an history
287    // to be able to test migrations
288    // The following path is absolute because a relative path doesn't work
289    // TODO(b/147596836): Refactor this
290    javacflags: ["-Aroom.schemaLocation=packages/modules/Bluetooth/android/app/tests/unit/src/com/android/bluetooth/btservice/storage/schemas"],
291
292    lint: {
293        error_checks: [
294            "Autofill",
295            "DefaultLocale",
296            "DuplicateDefinition",
297            // "ExportedContentProvider", // TODO: b/289445022 - enable this check
298            // "ExportedReceiver", // TODO: b/289445022 - enable this check
299            // "ExportedService", // TODO: b/289445022 - enable this check
300            "ExtraText",
301            "ExtraTranslation",
302            "GestureBackNavigation",
303            "GetterSetterNullability",
304            "GuardedLogInvocation",
305            "HandlerLeak",
306            "InflateParams",
307            // "InvalidPermission", // TODO: b/289445022 - enable this check
308            "LabelFor",
309            "MissingClass",
310            // "MissingVersion", // TODO: b/289445022 - enable this check
311            "MonochromeLauncherIcon",
312            "NewApi",
313            "ObsoleteSdkInt",
314            // "QueryAllPackagesPermission", // TODO: b/289445022 - enable this check
315            "Recycle",
316            "RtlHardcoded",
317            "RtlSymmetry",
318            "ScrollViewSize",
319            "SetTextI18n",
320            "SimpleDateFormat",
321            "StaticFieldLeak",
322            "StringFormatCount",
323            "StringFormatInvalid",
324            "TextFields",
325            "TypographyEllipsis",
326            "UseSparseArrays",
327            "UseValueOf",
328            "VectorPath",
329            "VisibleForTests",
330            "Wakelock",
331            "WakelockTimeout",
332        ],
333        extra_check_modules: ["BluetoothLintChecker"],
334        baseline_filename: "lint-baseline.xml",
335    },
336
337    optimize: {
338        enabled: true,
339        shrink: true,
340        optimize: false,
341        // TODO(b/289285719): Revisit after resolving mocking issues in testing.
342        proguard_compatibility: true,
343        proguard_flags_files: ["proguard.flags"],
344    },
345    apex_available: [
346        "com.android.btservices",
347    ],
348    min_sdk_version: "Tiramisu",
349    sdk_version: "module_current",
350    updatable: true,
351}
352
353java_library {
354    name: "bluetooth.change-ids",
355    srcs: [
356        "src/com/android/bluetooth/ChangeIds.java",
357    ],
358    libs: [
359        "app-compat-annotations",
360    ],
361    apex_available: [
362        "com.android.btservices",
363    ],
364    min_sdk_version: "Tiramisu",
365    sdk_version: "module_current",
366}
367
368platform_compat_config {
369    name: "bluetoothapk-platform-compat-config",
370    src: ":bluetooth.change-ids",
371}
372
373java_library {
374    name: "bluetooth-proto-enums-java-gen",
375    installable: false,
376    proto: {
377        type: "stream",
378    },
379    srcs: [
380        ":srcs_bluetooth_protos",
381    ],
382    apex_available: [
383        "com.android.btservices",
384    ],
385    min_sdk_version: "Tiramisu",
386    sdk_version: "module_current",
387}
388
389genrule {
390    name: "statslog-bluetooth-java-gen",
391    tools: ["stats-log-api-gen"],
392    cmd: "$(location stats-log-api-gen) --java $(out) --module bluetooth" +
393        " --javaPackage com.android.bluetooth --javaClass BluetoothStatsLog" +
394        " --minApiLevel 33",
395    out: ["com/android/bluetooth/BluetoothStatsLog.java"],
396}
397
398genrule {
399    name: "statslog-bt-restricted-java-gen",
400    tools: ["stats-log-api-gen"],
401    cmd: "$(location stats-log-api-gen) --java $(out) --module bt_restricted" +
402        " --javaPackage com.android.bluetooth --javaClass BtRestrictedStatsLog" +
403        " --minApiLevel 34",
404    out: ["com/android/bluetooth/BtRestrictedStatsLog.java"],
405}
406
407android_app_certificate {
408    name: "com.android.bluetooth.certificate",
409    certificate: "certs/com.android.bluetooth",
410}
411