• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021-2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//foundation/communication/bluetooth_service/bluetooth.gni")
16
17SUBSYSTEM_DIR = "//foundation/communication"
18PART_DIR = "$SUBSYSTEM_DIR/bluetooth_service/services/bluetooth"
19BT_SERVICE_DIR = "$PART_DIR/service"
20
21declare_args() {
22  bluetooth_service_avrcp_avsession = false
23}
24
25ServiceBleScanFilter = [ "src/ble/ble_scan_filter/src/ble_scan_filter_lsf.cpp" ]
26
27ServiceBleSrc = [
28  "src/ble/ble_adapter.cpp",
29  "src/ble/ble_advertiser_impl.cpp",
30  "src/ble/ble_central_manager_impl.cpp",
31  "src/ble/ble_config.cpp",
32  "src/ble/ble_properties.cpp",
33  "src/ble/ble_security.cpp",
34  "src/ble/ble_utils.cpp",
35]
36
37ServiceClassicSrc = [
38  "src/classic/classic_adapter_properties.cpp",
39  "src/classic/classic_adapter.cpp",
40  "src/classic/classic_battery_observer.cpp",
41  "src/classic/classic_bluetooth_data.cpp",
42  "src/classic/classic_config.cpp",
43  "src/classic/classic_data_structure.cpp",
44  "src/classic/classic_remote_device.cpp",
45  "src/classic/classic_utils.cpp",
46]
47
48ServiceCommonSrc = [
49  "src/common/adapter_config.cpp",
50  "src/common/adapter_device_config.cpp",
51  "src/common/adapter_device_info.cpp",
52  "src/common/adapter_manager.cpp",
53  "src/common/adapter_state_machine.cpp",
54  "src/common/class_creator.cpp",
55  "src/common/compat.cpp",
56  "src/common/power_device.cpp",
57  "src/common/power_manager.cpp",
58  "src/common/power_spec.cpp",
59  "src/common/power_state_machine.cpp",
60  "src/common/profile_config.cpp",
61  "src/common/profile_info.cpp",
62  "src/common/profile_service_manager.cpp",
63  "src/common/sys_state_machine.cpp",
64]
65
66ServiceDialogSrc = [
67  "src/dialog/bluetooth_ability_connection.cpp",
68  "src/dialog/bluetooth_dialog.cpp",
69  "src/dialog/dialog_pair.cpp",
70  "src/dialog/dialog_switch.cpp",
71]
72
73ServiceGattSrc = [
74  "src/gatt/gatt_cache.cpp",
75  "src/gatt/gatt_client_profile.cpp",
76  "src/gatt/gatt_client_service.cpp",
77  "src/gatt/gatt_connection_manager.cpp",
78  "src/gatt/gatt_database.cpp",
79  "src/gatt/gatt_server_profile.cpp",
80  "src/gatt/gatt_server_service.cpp",
81  "src/gatt/gatt_service_base.cpp",
82  "src/gatt/gatt_based_services_manager.cpp",
83  "src/gatt/dis/device_information_service.cpp",
84  "src/gatt/gas/generic_access_service.cpp",
85  "src/gatt/gatts/gatt_service_over_bredr.cpp",
86  "src/gatt/gatts/generic_attribute_service.cpp",
87]
88
89ServiceGavdpSrc = [
90  "src/gavdp/a2dp_avdtp.cpp",
91  "src/gavdp/a2dp_codec_thread.cpp",
92  "src/gavdp/a2dp_profile_peer.cpp",
93  "src/gavdp/a2dp_profile.cpp",
94  "src/gavdp/a2dp_sdp.cpp",
95  "src/gavdp/a2dp_service_connection.cpp",
96  "src/gavdp/a2dp_service_device.cpp",
97  "src/gavdp/a2dp_service_state_machine.cpp",
98  "src/gavdp/a2dp_service.cpp",
99  "src/gavdp/a2dp_sink.cpp",
100  "src/gavdp/a2dp_source.cpp",
101  "src/gavdp/a2dp_state_machine.cpp",
102  "src/gavdp/a2dp_codec/a2dp_aac_param_ctrl.cpp",
103  "src/gavdp/a2dp_codec/a2dp_codec_config.cpp",
104  "src/gavdp/a2dp_codec/a2dp_codec_factory.cpp",
105  "src/gavdp/a2dp_codec/a2dp_sbc_param_ctrl.cpp",
106  "src/gavdp/a2dp_codec/sbccodecctrl/src/a2dp_decoder_sbc.cpp",
107  "src/gavdp/a2dp_codec/sbccodecctrl/src/a2dp_encoder_sbc.cpp",
108  "src/gavdp/a2dp_codec/sbccodecctrl/src/a2dp_sbc_dynamic_lib_ctrl.cpp",
109  "src/gavdp/a2dp_shared_buffer.cpp",
110]
111
112ServiceObexSrc = [
113  "src/obex/obex_body.cpp",
114  "src/obex/obex_client.cpp",
115  "src/obex/obex_headers.cpp",
116  "src/obex/obex_mp_client.cpp",
117  "src/obex/obex_mp_server.cpp",
118  "src/obex/obex_server.cpp",
119  "src/obex/obex_session.cpp",
120  "src/obex/obex_socket_transport.cpp",
121  "src/obex/obex_transport.cpp",
122  "src/obex/obex_utils.cpp",
123]
124
125ServiceSockSrc = [
126  "src/sock/socket.cpp",
127  "src/sock/socket_gap_client.cpp",
128  "src/sock/socket_gap_server.cpp",
129  "src/sock/socket_sdp_client.cpp",
130  "src/sock/socket_sdp_server.cpp",
131  "src/sock/socket_service.cpp",
132  "src/sock/socket_listener.cpp",
133  "src/sock/socket_util.cpp",
134]
135
136ServiceTransportSrc = [
137  "src/transport/transport_factory.cpp",
138  "src/transport/transport_l2cap.cpp",
139  "src/transport/transport_rfcomm.cpp",
140]
141
142ServiceUtilSrc = [
143  "src/util/bluetooth_common_event_helper.cpp",
144  "src/util/dispatcher.cpp",
145  "src/util/semaphore_utils.cpp",
146  "src/util/state_machine.cpp",
147  "src/util/timer.cpp",
148  "src/util/xml_parse.cpp",
149  "src/util/log_util.cpp",
150]
151
152ServicePermissionSrc = [
153  "src/permission/auth_center.cpp",
154  "src/permission/permission_helper.cpp",
155  "src/permission/permission_manager.cpp",
156  "src/permission/permission_utils.cpp",
157]
158
159config("btservice_public_config") {
160  include_dirs = [
161    "include",
162    "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include",
163    "$SUBSYSTEM_DIR/bluetooth/frameworks/inner/include",
164  ]
165}
166
167config("btservice_config") {
168  include_dirs = [
169    "$BT_SERVICE_DIR/src",
170    "$BT_SERVICE_DIR/src/base",
171    "$BT_SERVICE_DIR/src/common",
172    "$BT_SERVICE_DIR/src/permission",
173    "$BT_SERVICE_DIR/src/util",
174    "$BT_SERVICE_DIR/src/ble/ble_scan_filter",
175    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/aaccodecctrl_l2/include",
176    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbccodecctrl/include",
177    "$PART_DIR/common",
178  ]
179
180  cflags_cc = [
181    "-fPIC",
182    "-fexceptions",
183    "-Wno-pessimizing-move",
184    "-Wno-unused-parameter",
185    "-Wunused-variable",
186    "-Wreorder",
187    "-Wmissing-braces",
188    "-Wimplicit-fallthrough",
189    "-Wunused-private-field",
190    "-Wlogical-op-parentheses",
191    "-Wmissing-field-initializers",
192    "-Wparentheses-equality",
193    "-Wparentheses",
194    "-Wdelete-non-abstract-non-virtual-dtor",
195    "-Wignored-qualifiers",
196    "-Wdelete-abstract-non-virtual-dtor",
197    "-Wuninitialized",
198    "-Woverloaded-virtual",
199    "-Wdangling-else",
200    "-Woverloaded-virtual",
201    "-Wno-non-c-typedef-for-linkage",
202    "-Wno-unused-but-set-variable",
203    "-Wno-array-parameter",
204  ]
205}
206
207ohos_shared_library("btservice") {
208  # sanitize = {
209  #   cfi = true
210  #   blocklist = "./bluetooth_service_blocklist.txt"
211  # }
212  stack_protector_ret = true
213  configs = [ ":btservice_config" ]
214  public_configs = [ ":btservice_public_config" ]
215
216  if (bluetooth_service_avrcp_avsession) {
217    defines = [ "AVRCP_AVSESSION" ]
218  }
219
220  sources = ServiceCommonSrc + ServiceUtilSrc
221  sources += ServiceBleScanFilter
222  sources += ServiceBleSrc
223  sources += ServiceClassicSrc
224  sources += ServiceDialogSrc
225  sources += ServiceGattSrc
226  sources += ServiceGavdpSrc
227  sources += ServiceObexSrc
228  sources += ServiceSockSrc
229  sources += ServiceTransportSrc
230  sources += ServicePermissionSrc
231
232  if (bluetooth_service_a2dp_sink_feature) {
233    sources += [ "src/a2dp_snk/a2dp_snk_service.cpp" ]
234  }
235
236  if (bluetooth_service_a2dp_source_feature) {
237    sources += [ "src/a2dp_src/a2dp_src_service.cpp" ]
238  }
239
240  if (bluetooth_service_avrcp_ct_feature) {
241    sources += [
242      "src/avrcp_ct/avrcp_ct_browse.cpp",
243      "src/avrcp_ct/avrcp_ct_connection.cpp",
244      "src/avrcp_ct/avrcp_ct_gap.cpp",
245      "src/avrcp_ct/avrcp_ct_notification.cpp",
246      "src/avrcp_ct/avrcp_ct_packet.cpp",
247      "src/avrcp_ct/avrcp_ct_pass_through.cpp",
248      "src/avrcp_ct/avrcp_ct_profile.cpp",
249      "src/avrcp_ct/avrcp_ct_sdp.cpp",
250      "src/avrcp_ct/avrcp_ct_service.cpp",
251      "src/avrcp_ct/avrcp_ct_state_machine.cpp",
252      "src/avrcp_ct/avrcp_ct_sub_unit_info.cpp",
253      "src/avrcp_ct/avrcp_ct_unit_info.cpp",
254      "src/avrcp_ct/avrcp_ct_vendor.cpp",
255    ]
256  }
257
258  if (bluetooth_service_avrcp_tg_feature) {
259    sources += [
260      "src/avrcp_tg/avrcp_tg_browse.cpp",
261      "src/avrcp_tg/avrcp_tg_connection.cpp",
262      "src/avrcp_tg/avrcp_tg_gap.cpp",
263      "src/avrcp_tg/avrcp_tg_notification.cpp",
264      "src/avrcp_tg/avrcp_tg_packet.cpp",
265      "src/avrcp_tg/avrcp_tg_pass_through.cpp",
266      "src/avrcp_tg/avrcp_tg_profile.cpp",
267      "src/avrcp_tg/avrcp_tg_sdp.cpp",
268      "src/avrcp_tg/avrcp_tg_service.cpp",
269      "src/avrcp_tg/avrcp_tg_state_machine.cpp",
270      "src/avrcp_tg/avrcp_tg_sub_unit_info.cpp",
271      "src/avrcp_tg/avrcp_tg_unit_info.cpp",
272      "src/avrcp_tg/avrcp_tg_vendor.cpp",
273    ]
274  }
275
276  if (bluetooth_service_hfp_ag_feature) {
277    sources += [
278      "src/hfp_ag/hfp_ag_audio_connection.cpp",
279      "src/hfp_ag/hfp_ag_command_parser.cpp",
280      "src/hfp_ag/hfp_ag_command_processor.cpp",
281      "src/hfp_ag/hfp_ag_data_connection.cpp",
282      "src/hfp_ag/hfp_ag_data_connection_server.cpp",
283      "src/hfp_ag/hfp_ag_gap_client.cpp",
284      "src/hfp_ag/hfp_ag_gap_server.cpp",
285      "src/hfp_ag/hfp_ag_profile.cpp",
286      "src/hfp_ag/hfp_ag_profile_event_sender.cpp",
287      "src/hfp_ag/hfp_ag_rfcomm_connection.cpp",
288      "src/hfp_ag/hfp_ag_rfcomm_connection_server.cpp",
289      "src/hfp_ag/hfp_ag_sdp_client.cpp",
290      "src/hfp_ag/hfp_ag_sdp_server.cpp",
291      "src/hfp_ag/hfp_ag_service.cpp",
292      "src/hfp_ag/hfp_ag_statemachine.cpp",
293      "src/hfp_ag/hfp_ag_system_event_processer.cpp",
294      "src/hfp_ag/hfp_ag_system_interface.cpp",
295    ]
296  }
297
298  if (bluetooth_service_hfp_hf_feature) {
299    sources += [
300      "src/hfp_hf/hfp_hf_audio_connection.cpp",
301      "src/hfp_hf/hfp_hf_call_manager.cpp",
302      "src/hfp_hf/hfp_hf_command_parser.cpp",
303      "src/hfp_hf/hfp_hf_command_processor.cpp",
304      "src/hfp_hf/hfp_hf_data_connection.cpp",
305      "src/hfp_hf/hfp_hf_data_connection_server.cpp",
306      "src/hfp_hf/hfp_hf_gap_client.cpp",
307      "src/hfp_hf/hfp_hf_gap_server.cpp",
308      "src/hfp_hf/hfp_hf_profile.cpp",
309      "src/hfp_hf/hfp_hf_profile_event_sender.cpp",
310      "src/hfp_hf/hfp_hf_rfcomm_connection.cpp",
311      "src/hfp_hf/hfp_hf_rfcomm_connection_server.cpp",
312      "src/hfp_hf/hfp_hf_sdp_client.cpp",
313      "src/hfp_hf/hfp_hf_sdp_server.cpp",
314      "src/hfp_hf/hfp_hf_service.cpp",
315      "src/hfp_hf/hfp_hf_statemachine.cpp",
316    ]
317  }
318
319  if (bluetooth_service_hid_host_feature) {
320    sources += [
321      "src/hid_host/hid_host_hogp.cpp",
322      "src/hid_host/hid_host_l2cap_connection.cpp",
323      "src/hid_host/hid_host_sdp_client.cpp",
324      "src/hid_host/hid_host_service.cpp",
325      "src/hid_host/hid_host_statemachine.cpp",
326      "src/hid_host/hid_host_uhid.cpp",
327    ]
328  }
329
330  if (bluetooth_service_pan_feature) {
331    sources += [
332      "src/pan/pan_bnep.cpp",
333      "src/pan/pan_network.cpp",
334      "src/pan/pan_sdp.cpp",
335      "src/pan/pan_service.cpp",
336      "src/pan/pan_statemachine.cpp",
337    ]
338  }
339
340  deps = [
341    "$PART_DIR/external:btdummy",
342    "$PART_DIR/stack:btstack",
343    "//third_party/bounds_checking_function:libsec_shared",
344    "//third_party/libxml2:xml2",
345    "//third_party/openssl:libcrypto_shared",
346  ]
347
348  external_deps = [
349    "ability_base:want",
350    "ability_runtime:ability_connect_callback_stub",
351    "ability_runtime:extension_manager",
352    "access_token:libaccesstoken_sdk",
353    "access_token:libtokenid_sdk",
354    "audio_framework:audio_client",
355    "bluetooth:btcommon",
356    "c_utils:utils",
357    "common_event_service:cesfwk_innerkits",
358    "hdf_core:libhdi",
359    "hilog:libhilog",
360    "hisysevent:libhisysevent",
361    "ipc:ipc_core",
362    "jsoncpp:jsoncpp",
363    "samgr:samgr_proxy",
364  ]
365
366  if (bluetooth_service_hfp_ag_feature) {
367    external_deps += [
368      "call_manager:tel_call_manager_api",
369      "core_service:tel_core_service_api",
370      "state_registry:tel_state_registry_api",
371    ]
372  }
373
374  if (bluetooth_service_avrcp_avsession) {
375    external_deps += [
376      "ability_runtime:wantagent_innerkits",
377      "av_session:avsession_client",
378      "input:libmmi-client",
379      "multimedia_image_framework:image_native",
380    ]
381  }
382
383  subsystem_name = "communication"
384  part_name = "bluetooth_service"
385}
386
387SBC_CODEC_DIR = "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbclib"
388ohos_shared_library("btsbc") {
389  # sanitize = {
390  #   cfi = true
391  # }
392  stack_protector_ret = true
393  include_dirs = [ "$PART_DIR/common" ]
394  sources = [
395    "$SBC_CODEC_DIR/src/sbc_decoder.cpp",
396    "$SBC_CODEC_DIR/src/sbc_encoder.cpp",
397    "$SBC_CODEC_DIR/src/sbc_frame.cpp",
398  ]
399
400  deps = [
401    "$PART_DIR/external:btdummy",
402    "//third_party/bounds_checking_function:libsec_shared",
403  ]
404
405  external_deps = [ "hilog:libhilog" ]
406
407  cflags = [ "-Wno-array-bounds" ]
408  subsystem_name = "communication"
409  part_name = "bluetooth_service"
410}
411