• 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
66ServiceGattSrc = [
67  "src/gatt/gatt_cache.cpp",
68  "src/gatt/gatt_client_profile.cpp",
69  "src/gatt/gatt_client_service.cpp",
70  "src/gatt/gatt_connection_manager.cpp",
71  "src/gatt/gatt_database.cpp",
72  "src/gatt/gatt_server_profile.cpp",
73  "src/gatt/gatt_server_service.cpp",
74  "src/gatt/gatt_service_base.cpp",
75  "src/gatt/gatt_based_services_manager.cpp",
76  "src/gatt/dis/device_information_service.cpp",
77  "src/gatt/gas/generic_access_service.cpp",
78  "src/gatt/gatts/gatt_service_over_bredr.cpp",
79  "src/gatt/gatts/generic_attribute_service.cpp",
80]
81
82ServiceGavdpSrc = [
83  "src/gavdp/a2dp_avdtp.cpp",
84  "src/gavdp/a2dp_codec_thread.cpp",
85  "src/gavdp/a2dp_profile_peer.cpp",
86  "src/gavdp/a2dp_profile.cpp",
87  "src/gavdp/a2dp_sdp.cpp",
88  "src/gavdp/a2dp_service_connection.cpp",
89  "src/gavdp/a2dp_service_device.cpp",
90  "src/gavdp/a2dp_service_state_machine.cpp",
91  "src/gavdp/a2dp_service.cpp",
92  "src/gavdp/a2dp_sink.cpp",
93  "src/gavdp/a2dp_source.cpp",
94  "src/gavdp/a2dp_state_machine.cpp",
95  "src/gavdp/a2dp_codec/a2dp_aac_param_ctrl.cpp",
96  "src/gavdp/a2dp_codec/a2dp_codec_config.cpp",
97  "src/gavdp/a2dp_codec/a2dp_codec_factory.cpp",
98  "src/gavdp/a2dp_codec/a2dp_sbc_param_ctrl.cpp",
99  "src/gavdp/a2dp_codec/sbccodecctrl/src/a2dp_decoder_sbc.cpp",
100  "src/gavdp/a2dp_codec/sbccodecctrl/src/a2dp_encoder_sbc.cpp",
101  "src/gavdp/a2dp_codec/sbccodecctrl/src/a2dp_sbc_dynamic_lib_ctrl.cpp",
102  "src/gavdp/a2dp_shared_buffer.cpp",
103]
104
105ServiceObexSrc = [
106  "src/obex/obex_body.cpp",
107  "src/obex/obex_client.cpp",
108  "src/obex/obex_headers.cpp",
109  "src/obex/obex_mp_client.cpp",
110  "src/obex/obex_mp_server.cpp",
111  "src/obex/obex_server.cpp",
112  "src/obex/obex_session.cpp",
113  "src/obex/obex_socket_transport.cpp",
114  "src/obex/obex_transport.cpp",
115  "src/obex/obex_utils.cpp",
116]
117
118ServiceSockSrc = [
119  "src/sock/socket.cpp",
120  "src/sock/socket_gap_client.cpp",
121  "src/sock/socket_gap_server.cpp",
122  "src/sock/socket_sdp_client.cpp",
123  "src/sock/socket_sdp_server.cpp",
124  "src/sock/socket_service.cpp",
125  "src/sock/socket_listener.cpp",
126  "src/sock/socket_util.cpp",
127]
128
129ServiceTransportSrc = [
130  "src/transport/transport_factory.cpp",
131  "src/transport/transport_l2cap.cpp",
132  "src/transport/transport_rfcomm.cpp",
133]
134
135ServiceUtilSrc = [
136  "src/util/bluetooth_common_event_helper.cpp",
137  "src/util/dispatcher.cpp",
138  "src/util/semaphore_utils.cpp",
139  "src/util/state_machine.cpp",
140  "src/util/timer.cpp",
141  "src/util/xml_parse.cpp",
142  "src/util/log_util.cpp",
143]
144
145ServicePermissionSrc = [
146  "src/permission/auth_center.cpp",
147  "src/permission/permission_helper.cpp",
148  "src/permission/permission_utils.cpp",
149]
150
151config("btservice_public_config") {
152  include_dirs = [
153    "include",
154    "$SUBSYSTEM_DIR/bluetooth/interfaces/inner_api/include",
155    "$SUBSYSTEM_DIR/bluetooth/frameworks/inner/include",
156    "//third_party/bounds_checking_function/include",
157  ]
158}
159
160config("btservice_config") {
161  include_dirs = [
162    "$BT_SERVICE_DIR/src",
163    "$BT_SERVICE_DIR/src/base",
164    "$BT_SERVICE_DIR/src/common",
165    "$BT_SERVICE_DIR/src/permission",
166    "$BT_SERVICE_DIR/src/util",
167    "$BT_SERVICE_DIR/src/ble/ble_scan_filter",
168    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/aaccodecctrl_l2/include",
169    "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbccodecctrl/include",
170    "//base/telephony/state_registry/frameworks/native/observer/include",
171    "//foundation/multimedia/audio_framework/interfaces/inner_api/native/audiocommon/include",
172    "//foundation/multimedia/audio_framework/interfaces/inner_api/native/audiomanager/include",
173    "$PART_DIR/common",
174  ]
175
176  cflags_cc = [
177    "-fPIC",
178    "-fexceptions",
179    "-Wno-pessimizing-move",
180    "-Wno-unused-parameter",
181    "-Wunused-variable",
182    "-Wreorder",
183    "-Wmissing-braces",
184    "-Wimplicit-fallthrough",
185    "-Wunused-private-field",
186    "-Wlogical-op-parentheses",
187    "-Wmissing-field-initializers",
188    "-Wparentheses-equality",
189    "-Wparentheses",
190    "-Wdelete-non-abstract-non-virtual-dtor",
191    "-Wignored-qualifiers",
192    "-Wdelete-abstract-non-virtual-dtor",
193    "-Wuninitialized",
194    "-Woverloaded-virtual",
195    "-Wdangling-else",
196    "-Woverloaded-virtual",
197    "-Wno-non-c-typedef-for-linkage",
198    "-Wno-unused-but-set-variable",
199    "-Wno-array-parameter",
200  ]
201}
202
203ohos_shared_library("btservice") {
204  # sanitize = {
205  #   cfi = true
206  #   blocklist = "./bluetooth_service_blocklist.txt"
207  # }
208  stack_protector_ret = true
209  configs = [ ":btservice_config" ]
210  public_configs = [ ":btservice_public_config" ]
211
212  if (bluetooth_service_avrcp_avsession) {
213    defines = [ "AVRCP_AVSESSION" ]
214  }
215
216  sources = ServiceCommonSrc + ServiceUtilSrc
217  sources += ServiceBleScanFilter
218  sources += ServiceBleSrc
219  sources += ServiceClassicSrc
220  sources += ServiceGattSrc
221  sources += ServiceGavdpSrc
222  sources += ServiceObexSrc
223  sources += ServiceSockSrc
224  sources += ServiceTransportSrc
225  sources += ServicePermissionSrc
226
227  if (bluetooth_service_a2dp_sink_feature) {
228    sources += [ "src/a2dp_snk/a2dp_snk_service.cpp" ]
229  }
230
231  if (bluetooth_service_a2dp_source_feature) {
232    sources += [ "src/a2dp_src/a2dp_src_service.cpp" ]
233  }
234
235  if (bluetooth_service_avrcp_ct_feature) {
236    sources += [
237      "src/avrcp_ct/avrcp_ct_browse.cpp",
238      "src/avrcp_ct/avrcp_ct_connection.cpp",
239      "src/avrcp_ct/avrcp_ct_gap.cpp",
240      "src/avrcp_ct/avrcp_ct_notification.cpp",
241      "src/avrcp_ct/avrcp_ct_packet.cpp",
242      "src/avrcp_ct/avrcp_ct_pass_through.cpp",
243      "src/avrcp_ct/avrcp_ct_profile.cpp",
244      "src/avrcp_ct/avrcp_ct_sdp.cpp",
245      "src/avrcp_ct/avrcp_ct_service.cpp",
246      "src/avrcp_ct/avrcp_ct_state_machine.cpp",
247      "src/avrcp_ct/avrcp_ct_sub_unit_info.cpp",
248      "src/avrcp_ct/avrcp_ct_unit_info.cpp",
249      "src/avrcp_ct/avrcp_ct_vendor.cpp",
250    ]
251  }
252
253  if (bluetooth_service_avrcp_tg_feature) {
254    sources += [
255      "src/avrcp_tg/avrcp_tg_browse.cpp",
256      "src/avrcp_tg/avrcp_tg_connection.cpp",
257      "src/avrcp_tg/avrcp_tg_gap.cpp",
258      "src/avrcp_tg/avrcp_tg_notification.cpp",
259      "src/avrcp_tg/avrcp_tg_packet.cpp",
260      "src/avrcp_tg/avrcp_tg_pass_through.cpp",
261      "src/avrcp_tg/avrcp_tg_profile.cpp",
262      "src/avrcp_tg/avrcp_tg_sdp.cpp",
263      "src/avrcp_tg/avrcp_tg_service.cpp",
264      "src/avrcp_tg/avrcp_tg_state_machine.cpp",
265      "src/avrcp_tg/avrcp_tg_sub_unit_info.cpp",
266      "src/avrcp_tg/avrcp_tg_unit_info.cpp",
267      "src/avrcp_tg/avrcp_tg_vendor.cpp",
268    ]
269  }
270
271  if (bluetooth_service_hfp_ag_feature) {
272    sources += [
273      "src/hfp_ag/hfp_ag_audio_connection.cpp",
274      "src/hfp_ag/hfp_ag_command_parser.cpp",
275      "src/hfp_ag/hfp_ag_command_processor.cpp",
276      "src/hfp_ag/hfp_ag_data_connection.cpp",
277      "src/hfp_ag/hfp_ag_data_connection_server.cpp",
278      "src/hfp_ag/hfp_ag_gap_client.cpp",
279      "src/hfp_ag/hfp_ag_gap_server.cpp",
280      "src/hfp_ag/hfp_ag_profile.cpp",
281      "src/hfp_ag/hfp_ag_profile_event_sender.cpp",
282      "src/hfp_ag/hfp_ag_rfcomm_connection.cpp",
283      "src/hfp_ag/hfp_ag_rfcomm_connection_server.cpp",
284      "src/hfp_ag/hfp_ag_sdp_client.cpp",
285      "src/hfp_ag/hfp_ag_sdp_server.cpp",
286      "src/hfp_ag/hfp_ag_service.cpp",
287      "src/hfp_ag/hfp_ag_statemachine.cpp",
288      "src/hfp_ag/hfp_ag_system_event_processer.cpp",
289      "src/hfp_ag/hfp_ag_system_interface.cpp",
290    ]
291  }
292
293  if (bluetooth_service_hfp_hf_feature) {
294    sources += [
295      "src/hfp_hf/hfp_hf_audio_connection.cpp",
296      "src/hfp_hf/hfp_hf_call_manager.cpp",
297      "src/hfp_hf/hfp_hf_command_parser.cpp",
298      "src/hfp_hf/hfp_hf_command_processor.cpp",
299      "src/hfp_hf/hfp_hf_data_connection.cpp",
300      "src/hfp_hf/hfp_hf_data_connection_server.cpp",
301      "src/hfp_hf/hfp_hf_gap_client.cpp",
302      "src/hfp_hf/hfp_hf_gap_server.cpp",
303      "src/hfp_hf/hfp_hf_profile.cpp",
304      "src/hfp_hf/hfp_hf_profile_event_sender.cpp",
305      "src/hfp_hf/hfp_hf_rfcomm_connection.cpp",
306      "src/hfp_hf/hfp_hf_rfcomm_connection_server.cpp",
307      "src/hfp_hf/hfp_hf_sdp_client.cpp",
308      "src/hfp_hf/hfp_hf_sdp_server.cpp",
309      "src/hfp_hf/hfp_hf_service.cpp",
310      "src/hfp_hf/hfp_hf_statemachine.cpp",
311    ]
312  }
313
314  if (bluetooth_service_hid_host_feature) {
315    sources += [
316      "src/hid_host/hid_host_hogp.cpp",
317      "src/hid_host/hid_host_l2cap_connection.cpp",
318      "src/hid_host/hid_host_sdp_client.cpp",
319      "src/hid_host/hid_host_service.cpp",
320      "src/hid_host/hid_host_statemachine.cpp",
321      "src/hid_host/hid_host_uhid.cpp",
322    ]
323  }
324
325  if (bluetooth_service_pan_feature) {
326    sources += [
327      "src/pan/pan_bnep.cpp",
328      "src/pan/pan_network.cpp",
329      "src/pan/pan_sdp.cpp",
330      "src/pan/pan_service.cpp",
331      "src/pan/pan_statemachine.cpp",
332    ]
333  }
334
335  deps = [
336    "$PART_DIR/external:btdummy",
337    "$PART_DIR/stack:btstack",
338    "//third_party/bounds_checking_function:libsec_shared",
339    "//third_party/libxml2:xml2",
340    "//third_party/openssl:libcrypto_shared",
341  ]
342
343  external_deps = [
344    "ability_base:want",
345    "access_token:libaccesstoken_sdk",
346    "access_token:libtokenid_sdk",
347    "audio_framework:audio_client",
348    "bluetooth:btcommon",
349    "c_utils:utils",
350    "call_manager:tel_call_manager_api",
351    "common_event_service:cesfwk_innerkits",
352    "core_service:tel_core_service_api",
353    "hdf_core:libhdi",
354    "hilog:libhilog",
355    "hisysevent:libhisysevent",
356    "ipc:ipc_core",
357    "samgr:samgr_proxy",
358    "state_registry:tel_state_registry_api",
359  ]
360
361  if (bluetooth_service_avrcp_avsession) {
362    external_deps += [
363      "ability_runtime:wantagent_innerkits",
364      "av_session:avsession_client",
365      "input:libmmi-client",
366      "multimedia_image_framework:image_native",
367    ]
368  }
369
370  subsystem_name = "communication"
371  part_name = "bluetooth_service"
372}
373
374SBC_CODEC_DIR = "$BT_SERVICE_DIR/src/gavdp/a2dp_codec/sbclib"
375ohos_shared_library("btsbc") {
376  # sanitize = {
377  #   cfi = true
378  # }
379  stack_protector_ret = true
380  include_dirs = [ "$PART_DIR/common" ]
381  sources = [
382    "$SBC_CODEC_DIR/src/sbc_decoder.cpp",
383    "$SBC_CODEC_DIR/src/sbc_encoder.cpp",
384    "$SBC_CODEC_DIR/src/sbc_frame.cpp",
385  ]
386
387  deps = [
388    "$PART_DIR/external:btdummy",
389    "//third_party/bounds_checking_function:libsec_shared",
390  ]
391
392  external_deps = [ "hilog:libhilog" ]
393
394  cflags = [ "-Wno-array-bounds" ]
395  subsystem_name = "communication"
396  part_name = "bluetooth_service"
397}
398