1# Copyright (c) 2021-2023 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("./../usbmgr.gni") 15 16config("usbsrv_private_config") { 17 include_dirs = [ "${usb_manager_path}/interfaces/innerkits/native/include" ] 18} 19 20config("usbsrv_public_config") { 21 include_dirs = [ 22 "native/include", 23 "${usb_manager_path}/utils/native/include", 24 ] 25} 26 27ohos_shared_library("usbservice") { 28 sanitize = { 29 integer_overflow = true 30 ubsan = true 31 boundary_sanitize = true 32 cfi = true 33 cfi_cross_dso = true 34 debug = false 35 } 36 branch_protector_ret = "pac_ret" 37 38 install_enable = true 39 sources = [ 40 "${utils_path}/native/src/usb_settings_datashare.cpp", 41 "native/src/serial_manager.cpp", 42 "native/src/usb_connection_notifier.cpp", 43 "native/src/usb_report_sys_event.cpp", 44 "native/src/usb_right_database.cpp", 45 "native/src/usb_right_db_helper.cpp", 46 "native/src/usb_right_manager.cpp", 47 "native/src/usb_service.cpp", 48 "native/src/usb_service_subscriber.cpp", 49 "native/src/usb_timer_wraper.cpp", 50 ] 51 52 configs = [ 53 "${utils_path}:utils_config", 54 ":usbsrv_private_config", 55 ] 56 57 public_configs = [ ":usbsrv_public_config" ] 58 deps = [ "${usb_manager_path}/interfaces/innerkits:usb_server_stub" ] 59 defines = [] 60 if (usb_manager_pass_through) { 61 defines += [ 62 "USB_MANAGER_PASS_THROUGH", 63 "USB_MANAGER_V2_0", 64 ] 65 sources += [ "native/src/usb_manager_subscriber.cpp" ] 66 } 67 if (usb_manager_feature_host) { 68 defines += [ "USB_MANAGER_FEATURE_HOST" ] 69 sources += [ 70 "${utils_path}/native/src/struct_parcel.cpp", 71 "native/src/usb_descriptor_parser.cpp", 72 "native/src/usb_host_manager.cpp", 73 "native/src/usb_serial_reader.cpp", 74 "native/src/usbd_bulkcallback_impl.cpp", 75 "native/src/usbd_transfer_callback_impl.cpp", 76 ] 77 if (usb_manager_pass_through) { 78 sources += [ 79 "native/src/usb_bulkcallback_impl.cpp", 80 "native/src/usb_transfer_callback_impl.cpp", 81 ] 82 } 83 } 84 if (usb_manager_feature_device) { 85 defines += [ "USB_MANAGER_FEATURE_DEVICE" ] 86 sources += [ 87 "native/src/usb_accessory_manager.cpp", 88 "native/src/usb_device_manager.cpp", 89 "native/src/usb_function_switch_window.cpp", 90 ] 91 } 92 if (usb_manager_feature_port) { 93 defines += [ "USB_MANAGER_FEATURE_PORT" ] 94 sources += [ "native/src/usb_port_manager.cpp" ] 95 } 96 97 external_deps = [ 98 "ability_base:base", 99 "ability_base:want", 100 "ability_runtime:ability_connect_callback_stub", 101 "ability_runtime:ability_manager", 102 "ability_runtime:wantagent_innerkits", 103 "access_token:libaccesstoken_sdk", 104 "access_token:libtokenid_sdk", 105 "bundle_framework:appexecfwk_base", 106 "bundle_framework:appexecfwk_core", 107 "cJSON:cjson", 108 "c_utils:utils", 109 "common_event_service:cesfwk_innerkits", 110 "drivers_interface_usb:libserial_proxy_1.0", 111 "drivers_interface_usb:libserial_stub_1.0", 112 "hilog:libhilog", 113 "hisysevent:libhisysevent", 114 "hitrace:hitrace_meter", 115 "i18n:intl_util", 116 "data_share:datashare_common", 117 "data_share:datashare_consumer", 118 "init:libbeget_proxy", 119 "init:libbegetutil", 120 "ipc:ipc_single", 121 "memmgr:memmgrclient", 122 "napi:ace_napi", 123 "os_account:os_account_innerkits", 124 "relational_store:native_rdb", 125 "safwk:system_ability_fwk", 126 "samgr:samgr_proxy", 127 "hdf_core:libhdf_utils", 128 ] 129 130 if (usb_manager_peripheral_fault_notifier) { 131 external_deps += [ "external_device_manager:driver_ext_mgr_client" ] 132 defines += [ "USB_PERIPHERAL_FAULT_NOTIFY" ] 133 } 134 135 if (true) { 136 external_deps += [ "distributed_notification_service:ans_innerkits" ] 137 } 138 if (usb_manager_pass_through) { 139 external_deps += [ "drivers_interface_usb:libusb_proxy_2.0" ] 140 } else { 141 external_deps += [ 142 "drivers_interface_usb:libusb_proxy_1.1", 143 "drivers_interface_usb:libusb_proxy_1.2", 144 ] 145 } 146 147 if (usb_manager_feature_pop_up_func_switch_model) { 148 defines += [ "USB_FUNC_SWITCH_MODE" ] 149 } 150 shlib_type = "sa" 151 version_script = "usbservice.map" 152 subsystem_name = "usb" 153 part_name = "usb_manager" 154} 155 156ohos_prebuilt_etc("usb_service.init") { 157 source = "usb_service.cfg" 158 relative_install_dir = "init" 159 subsystem_name = "usb" 160 part_name = "usb_manager" 161} 162