1 /* 2 * Copyright (c) 2023 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 #ifndef USB_BUS_EXTENSION_H 17 #define USB_BUS_EXTENSION_H 18 #include <iproxy_broker.h> 19 #include <iremote_object.h> 20 21 #include "ibus_extension.h" 22 #include "usb_dev_subscriber.h" 23 #include "usb_device_info.h" 24 #include "v1_0/iusb_interface.h" 25 #include "v1_0/iusb_ddk.h" 26 27 namespace OHOS { 28 namespace ExternalDeviceManager { 29 using namespace std; 30 using namespace OHOS::HDI::Usb::V1_0; 31 using namespace OHOS::HDI::Usb::Ddk::V1_0; 32 class UsbBusExtension : public IBusExtension { 33 public: 34 UsbBusExtension(); 35 ~UsbBusExtension(); 36 int32_t SetDevChangeCallback(shared_ptr<IDevChangeCallback> callback) override; 37 bool MatchDriver(const DriverInfo &driver, const DeviceInfo &device) override; 38 shared_ptr<DriverInfoExt> ParseDriverInfo(const map<string, string> &metadata) override; 39 shared_ptr<DriverInfoExt> GetNewDriverInfoExtObject() override; 40 void SetUsbInferface(sptr<IUsbInterface> iusb); 41 void SetUsbDdk(sptr<IUsbDdk> iUsbDdk); 42 BusType GetBusType() override; 43 44 private: 45 class UsbdDeathRecipient : public IRemoteObject::DeathRecipient { 46 public: 47 void OnRemoteDied(const wptr<IRemoteObject> &object) override; 48 }; 49 sptr<UsbDevSubscriber> subScriber_ = nullptr; 50 sptr<IUsbInterface> usbInterface_ = nullptr; // in usb HDI; 51 sptr<IUsbDdk> iUsbDdk_ = nullptr; 52 vector<uint16_t> ParseCommaStrToVectorUint16(const string &str); 53 sptr<IRemoteObject::DeathRecipient> recipient_; 54 }; 55 } 56 } 57 #endif