• 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 = true
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  ]
163}
164
165config("btservice_config") {
166  include_dirs = [
167    "$BT_SERVICE_DIR/src",
168    "$BT_SERVICE_DIR/src/base",
169    "$BT_SERVICE_DIR/src/common",
170    "$BT_SERVICE_DIR/src/permission",
171    "$BT_SERVICE_DIR/src/util",
172    "$BT_SERVICE_DIR/src/ble/ble_scan_filter",
173    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/aaccodecctrl_l2/include",
174    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbccodecctrl/include",
175    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbccodecctrl",
176    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec",
177    "$BT_SERVICE_DIR/src/gavdp",
178    "$BT_SERVICE_DIR/src/gatt",
179    "$PART_DIR/common",
180    "$PART_DIR",
181  ]
182
183  cflags_cc = [
184    "-fPIC",
185    "-fexceptions",
186    "-Wno-pessimizing-move",
187    "-Wno-unused-parameter",
188    "-Wunused-variable",
189    "-Wreorder",
190    "-Wmissing-braces",
191    "-Wimplicit-fallthrough",
192    "-Wunused-private-field",
193    "-Wlogical-op-parentheses",
194    "-Wmissing-field-initializers",
195    "-Wparentheses-equality",
196    "-Wparentheses",
197    "-Wdelete-non-abstract-non-virtual-dtor",
198    "-Wignored-qualifiers",
199    "-Wdelete-abstract-non-virtual-dtor",
200    "-Wuninitialized",
201    "-Woverloaded-virtual",
202    "-Wdangling-else",
203    "-Woverloaded-virtual",
204    "-Wno-non-c-typedef-for-linkage",
205    "-Wno-unused-but-set-variable",
206    "-Wno-array-parameter",
207  ]
208}
209
210ohos_shared_library("btservice") {
211  # sanitize = {
212  #   cfi = true
213  #   blocklist = "./bluetooth_service_blocklist.txt"
214  # }
215  stack_protector_ret = true
216  configs = [ ":btservice_config" ]
217  public_configs = [ ":btservice_public_config" ]
218
219  if (bluetooth_service_avrcp_avsession) {
220    defines = [ "AVRCP_AVSESSION" ]
221  }
222
223  sources = ServiceCommonSrc + ServiceUtilSrc
224  sources += ServiceBleScanFilter
225  sources += ServiceBleSrc
226  sources += ServiceClassicSrc
227  sources += ServiceDialogSrc
228  sources += ServiceGattSrc
229  sources += ServiceGavdpSrc
230  sources += ServiceObexSrc
231  sources += ServiceSockSrc
232  sources += ServiceTransportSrc
233  sources += ServicePermissionSrc
234
235  if (bluetooth_service_a2dp_sink_feature) {
236    sources += [ "src/a2dp_snk/a2dp_snk_service.cpp" ]
237  }
238
239  if (bluetooth_service_a2dp_source_feature) {
240    sources += [ "src/a2dp_src/a2dp_src_service.cpp" ]
241  }
242
243  if (bluetooth_service_avrcp_ct_feature) {
244    sources += [
245      "src/avrcp_ct/avrcp_ct_browse.cpp",
246      "src/avrcp_ct/avrcp_ct_connection.cpp",
247      "src/avrcp_ct/avrcp_ct_gap.cpp",
248      "src/avrcp_ct/avrcp_ct_notification.cpp",
249      "src/avrcp_ct/avrcp_ct_packet.cpp",
250      "src/avrcp_ct/avrcp_ct_pass_through.cpp",
251      "src/avrcp_ct/avrcp_ct_profile.cpp",
252      "src/avrcp_ct/avrcp_ct_sdp.cpp",
253      "src/avrcp_ct/avrcp_ct_service.cpp",
254      "src/avrcp_ct/avrcp_ct_state_machine.cpp",
255      "src/avrcp_ct/avrcp_ct_sub_unit_info.cpp",
256      "src/avrcp_ct/avrcp_ct_unit_info.cpp",
257      "src/avrcp_ct/avrcp_ct_vendor.cpp",
258    ]
259  }
260
261  if (bluetooth_service_avrcp_tg_feature) {
262    sources += [
263      "src/avrcp_tg/avrcp_tg_browse.cpp",
264      "src/avrcp_tg/avrcp_tg_connection.cpp",
265      "src/avrcp_tg/avrcp_tg_gap.cpp",
266      "src/avrcp_tg/avrcp_tg_notification.cpp",
267      "src/avrcp_tg/avrcp_tg_packet.cpp",
268      "src/avrcp_tg/avrcp_tg_pass_through.cpp",
269      "src/avrcp_tg/avrcp_tg_profile.cpp",
270      "src/avrcp_tg/avrcp_tg_sdp.cpp",
271      "src/avrcp_tg/avrcp_tg_service.cpp",
272      "src/avrcp_tg/avrcp_tg_state_machine.cpp",
273      "src/avrcp_tg/avrcp_tg_sub_unit_info.cpp",
274      "src/avrcp_tg/avrcp_tg_unit_info.cpp",
275      "src/avrcp_tg/avrcp_tg_vendor.cpp",
276    ]
277  }
278
279  if (bluetooth_service_hfp_ag_feature) {
280    sources += [
281      "src/hfp_ag/hfp_ag_audio_connection.cpp",
282      "src/hfp_ag/hfp_ag_command_parser.cpp",
283      "src/hfp_ag/hfp_ag_command_processor.cpp",
284      "src/hfp_ag/hfp_ag_data_connection.cpp",
285      "src/hfp_ag/hfp_ag_data_connection_server.cpp",
286      "src/hfp_ag/hfp_ag_gap_client.cpp",
287      "src/hfp_ag/hfp_ag_gap_server.cpp",
288      "src/hfp_ag/hfp_ag_profile.cpp",
289      "src/hfp_ag/hfp_ag_profile_event_sender.cpp",
290      "src/hfp_ag/hfp_ag_rfcomm_connection.cpp",
291      "src/hfp_ag/hfp_ag_rfcomm_connection_server.cpp",
292      "src/hfp_ag/hfp_ag_sdp_client.cpp",
293      "src/hfp_ag/hfp_ag_sdp_server.cpp",
294      "src/hfp_ag/hfp_ag_service.cpp",
295      "src/hfp_ag/hfp_ag_statemachine.cpp",
296      "src/hfp_ag/hfp_ag_system_event_processer.cpp",
297      "src/hfp_ag/hfp_ag_system_interface.cpp",
298    ]
299  }
300
301  if (bluetooth_service_hfp_hf_feature) {
302    sources += [
303      "src/hfp_hf/hfp_hf_audio_connection.cpp",
304      "src/hfp_hf/hfp_hf_call_manager.cpp",
305      "src/hfp_hf/hfp_hf_command_parser.cpp",
306      "src/hfp_hf/hfp_hf_command_processor.cpp",
307      "src/hfp_hf/hfp_hf_data_connection.cpp",
308      "src/hfp_hf/hfp_hf_data_connection_server.cpp",
309      "src/hfp_hf/hfp_hf_gap_client.cpp",
310      "src/hfp_hf/hfp_hf_gap_server.cpp",
311      "src/hfp_hf/hfp_hf_profile.cpp",
312      "src/hfp_hf/hfp_hf_profile_event_sender.cpp",
313      "src/hfp_hf/hfp_hf_rfcomm_connection.cpp",
314      "src/hfp_hf/hfp_hf_rfcomm_connection_server.cpp",
315      "src/hfp_hf/hfp_hf_sdp_client.cpp",
316      "src/hfp_hf/hfp_hf_sdp_server.cpp",
317      "src/hfp_hf/hfp_hf_service.cpp",
318      "src/hfp_hf/hfp_hf_statemachine.cpp",
319    ]
320  }
321
322  if (bluetooth_service_hid_host_feature) {
323    sources += [
324      "src/hid_host/hid_host_hogp.cpp",
325      "src/hid_host/hid_host_l2cap_connection.cpp",
326      "src/hid_host/hid_host_sdp_client.cpp",
327      "src/hid_host/hid_host_service.cpp",
328      "src/hid_host/hid_host_statemachine.cpp",
329      "src/hid_host/hid_host_uhid.cpp",
330    ]
331  }
332
333  if (bluetooth_service_pan_feature) {
334    sources += [
335      "src/pan/pan_bnep.cpp",
336      "src/pan/pan_network.cpp",
337      "src/pan/pan_sdp.cpp",
338      "src/pan/pan_service.cpp",
339      "src/pan/pan_statemachine.cpp",
340    ]
341  }
342
343  deps = [
344    "$PART_DIR/external:btdummy",
345    "$PART_DIR/stack:btstack",
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    "c_utils:utils",
356    "common_event_service:cesfwk_innerkits",
357    "hdf_core:libhdi",
358    "hilog:libhilog",
359    "hisysevent:libhisysevent",
360    "ipc:ipc_core",
361    "jsoncpp:jsoncpp",
362    "samgr:samgr_proxy",
363    "bounds_checking_function:libsec_shared",
364    "libxml2:libxml2",
365    "openssl:libcrypto_shared",
366    "bluetooth:btframework",
367    "bluetooth:btcommon",
368    "bundle_framework:appexecfwk_core",
369    "hitrace:hitrace_dump",
370  ]
371
372  if (bluetooth_service_hfp_ag_feature) {
373    external_deps += [
374      "call_manager:tel_call_manager_api",
375      "core_service:tel_core_service_api",
376      "state_registry:tel_state_registry_api",
377    ]
378  }
379
380  if (bluetooth_service_avrcp_avsession) {
381    external_deps += [
382      "ability_runtime:wantagent_innerkits",
383      "av_session:avsession_client",
384      "image_framework:image_native",
385      "input:libmmi-client",
386    ]
387  }
388
389  subsystem_name = "communication"
390  part_name = "bluetooth_service"
391}
392
393SBC_CODEC_DIR = "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbclib"
394ohos_shared_library("btsbc") {
395  # sanitize = {
396  #   cfi = true
397  # }
398  stack_protector_ret = true
399  include_dirs = [
400    "$PART_DIR/common",
401    "$SBC_CODEC_DIR",
402    ]
403  sources = [
404    "$SBC_CODEC_DIR/src/sbc_decoder.cpp",
405    "$SBC_CODEC_DIR/src/sbc_encoder.cpp",
406    "$SBC_CODEC_DIR/src/sbc_frame.cpp",
407  ]
408
409  deps = [
410    "$PART_DIR/external:btdummy",
411  ]
412
413  external_deps = [
414    "hilog:libhilog",
415    "bounds_checking_function:libsec_shared",
416    ]
417
418  cflags = [ "-Wno-array-bounds" ]
419  subsystem_name = "communication"
420  part_name = "bluetooth_service"
421}
422