• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <hdf_log.h>
17 
18 #include "usbd_wrapper.h"
19 #include "usb_sa_subscriber.h"
20 
21 #define HDF_LOG_TAG UsbSaSubscriber
22 
23 namespace OHOS {
24 namespace HDI {
25 namespace Usb {
26 namespace V1_2 {
27 constexpr int32_t LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 1;
28 UsbdLoadService UsbSaSubscriber::loadUsbService_ = {USB_SYSTEM_ABILITY_ID};
29 UsbdLoadService UsbSaSubscriber::loadHdfEdm_ = {HDF_EXTERNAL_DEVICE_MANAGER_SA_ID};
UsbSaSubscriber()30 UsbSaSubscriber::UsbSaSubscriber() {}
LoadUsbSa(const int32_t & eventId)31 int32_t UsbSaSubscriber::LoadUsbSa(const int32_t &eventId)
32 {
33     if (eventId == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED) {
34         if (loadUsbService_.LoadService() != 0) {
35             HDF_LOGE("loadUsbService_ LoadService error");
36             return HDF_FAILURE;
37         }
38         if (loadHdfEdm_.LoadService() != 0) {
39             HDF_LOGE("loadHdfEdm_ LoadService error");
40             return HDF_FAILURE;
41         }
42     }
43     return HDF_SUCCESS;
44 }
45 } // namespace V1_2
46 } // namespace USB
47 } // namespace HDI
48 } // namespace OHOS
49