• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 USBD_SUBSCRIBER_H
17 #define USBD_SUBSCRIBER_H
18 
19 #include "ipc_object_stub.h"
20 #include "usb_info.h"
21 #include "usbd_type.h"
22 
23 namespace OHOS {
24 namespace USB {
25 class UsbdSubscriber : public IPCObjectStub {
26 public:
UsbdSubscriber()27     explicit UsbdSubscriber() : IPCObjectStub(u"ohos.usb.IUsbManagerSubscriber") {};
28     virtual ~UsbdSubscriber() = default;
29     virtual int32_t DeviceEvent(const UsbInfo &info) = 0;
30     virtual int32_t PortChangedEvent(int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode) = 0;
31     int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
32 
33 private:
34     static int32_t ParserUsbInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info);
35     static int32_t ParserPortInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info);
36     static inline const std::u16string metaDescriptor_ = u"hdf.usb.usbdsubscriber";
GetDescriptor()37     static inline const std::u16string &GetDescriptor()
38     {
39         return metaDescriptor_;
40     }
41 };
42 } // namespace USB
43 } // namespace OHOS
44 #endif // USBD_SUBSCRIBER_H
45