• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 OHOS_DEVICE_MANAGER_IMPL_H
17 #define OHOS_DEVICE_MANAGER_IMPL_H
18 
19 #include "device_manager.h"
20 #if !defined(__LITEOS_M__)
21 #include "ipc_client_manager.h"
22 #include "ipc_client_proxy.h"
23 #endif
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 class DeviceManagerImpl : public DeviceManager {
28 public:
29     static DeviceManagerImpl &GetInstance();
30 
31 public:
32     /**
33      * @tc.name: DeviceManagerImpl::InitDeviceManager
34      * @tc.desc: Initialize DeviceManager
35      * @tc.type: FUNC
36      */
37     virtual int32_t InitDeviceManager(const std::string &pkgName,
38                                       std::shared_ptr<DmInitCallback> dmInitCallback) override;
39     /**
40      * @tc.name: DeviceManagerImpl::UnInitDeviceManager
41      * @tc.desc: UnInitialize DeviceManager
42      * @tc.type: FUNC
43      */
44     virtual int32_t UnInitDeviceManager(const std::string &pkgName) override;
45     /**
46      * @tc.name: DeviceManagerImpl::GetTrustedDeviceList
47      * @tc.desc: Get device list of trusted devices
48      * @tc.type: FUNC
49      */
50     virtual int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra,
51                                          std::vector<DmDeviceInfo> &deviceList) override;
52     /**
53      * @tc.name: DeviceManagerImpl::GetLocalDeviceInfo
54      * @tc.desc: Get local device information
55      * @tc.type: FUNC
56      */
57     virtual int32_t GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &deviceInfo) override;
58     /**
59      * @tc.name: DeviceManagerImpl::RegisterDevStateCallback
60      * @tc.desc: Register device development status callback
61      * @tc.type: FUNC
62      */
63     virtual int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra,
64                                              std::shared_ptr<DeviceStateCallback> callback) override;
65     /**
66      * @tc.name: DeviceManagerImpl::UnRegisterDevStateCallback
67      * @tc.desc: UnRegister device development status callback
68      * @tc.type: FUNC
69      */
70     virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName) override;
71     /**
72      * @tc.name: DeviceManagerImpl::StartDeviceDiscovery
73      * @tc.desc: Initiate device discovery
74      * @tc.type: FUNC
75      */
76     virtual int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo,
77                                          const std::string &extra,
78                                          std::shared_ptr<DiscoveryCallback> callback) override;
79     /**
80      * @tc.name: DeviceManagerImpl::StopDeviceDiscovery
81      * @tc.desc: Stop device discovery
82      * @tc.type: FUNC
83      */
84     virtual int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) override;
85     /**
86      * @tc.name: DeviceManagerImpl::PublishDeviceDiscovery
87      * @tc.desc: Publish device discovery
88      * @tc.type: FUNC
89      */
90     virtual int32_t PublishDeviceDiscovery(const std::string &pkgName, const DmPublishInfo &publishInfo,
91         std::shared_ptr<PublishCallback> callback) override;
92     /**
93      * @tc.name: DeviceManagerImpl::UnPublishDeviceDiscovery
94      * @tc.desc: UnPublish device discovery
95      * @tc.type: FUNC
96      */
97     virtual int32_t UnPublishDeviceDiscovery(const std::string &pkgName, int32_t publishId) override;
98     /**
99      * @tc.name: DeviceManagerImpl::AuthenticateDevice
100      * @tc.desc: Complete verifying the device
101      * @tc.type: FUNC
102      */
103     virtual int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const DmDeviceInfo &deviceInfo,
104                                        const std::string &extra,
105                                        std::shared_ptr<AuthenticateCallback> callback) override;
106     /**
107      * @tc.name: DeviceManagerImpl::UnAuthenticateDevice
108      * @tc.desc: Cancel complete verification of device
109      * @tc.type: FUNC
110      */
111     virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const DmDeviceInfo &deviceInfo) override;
112     /**
113      * @tc.name: DeviceManagerImpl::VerifyAuthentication
114      * @tc.desc: Verify device authentication
115      * @tc.type: FUNC
116      */
117     virtual int32_t VerifyAuthentication(const std::string &pkgName, const std::string &authPara,
118                                          std::shared_ptr<VerifyAuthCallback> callback) override;
119     /**
120      * @tc.name: DeviceManagerImpl::RegisterDeviceManagerFaCallback
121      * @tc.desc: Register Fa callback for device manager
122      * @tc.type: FUNC
123      */
124     virtual int32_t RegisterDeviceManagerFaCallback(const std::string &packageName,
125                                                     std::shared_ptr<DeviceManagerUiCallback> callback) override;
126     /**
127      * @tc.name: DeviceManagerImpl::UnRegisterDeviceManagerFaCallback
128      * @tc.desc: Unregister Fa callback for device manager
129      * @tc.type: FUNC
130      */
131     virtual int32_t UnRegisterDeviceManagerFaCallback(const std::string &pkgName) override;
132     /**
133      * @tc.name: DeviceManagerImpl::GetFaParam
134      * @tc.desc: Get Fa Param
135      * @tc.type: FUNC
136      */
137     virtual int32_t GetFaParam(const std::string &pkgName, DmAuthParam &faParam) override;
138     /**
139      * @tc.name: DeviceManagerImpl::SetUserOperation
140      * @tc.desc: Set User Actions
141      * @tc.type: FUNC
142      */
143     virtual int32_t SetUserOperation(const std::string &pkgName, int32_t action, const std::string &params) override;
144     /**
145      * @tc.name: DeviceManagerImpl::GetUdidByNetworkId
146      * @tc.desc: Get Udid by NetworkId
147      * @tc.type: FUNC
148      */
149     virtual int32_t GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId,
150                                        std::string &udid) override;
151     /**
152      * @tc.name: DeviceManagerImpl::GetUuidByNetworkId
153      * @tc.desc: Get Uuid by NetworkId
154      * @tc.type: FUNC
155      */
156     virtual int32_t GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId,
157                                        std::string &uuid) override;
158     /**
159      * @tc.name: DeviceManagerImpl::RegisterDevStateCallback
160      * @tc.desc: Register development status callback
161      * @tc.type: FUNC
162      */
163     virtual int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra) override;
164     /**
165      * @tc.name: DeviceManagerImpl::UnRegisterDevStateCallback
166      * @tc.desc: Unregister development status callback
167      * @tc.type: FUNC
168      */
169     virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra) override;
170     /**
171      * @tc.name: DeviceManagerImpl::RequestCredential
172      * @tc.desc: RequestCredential
173      * @tc.type: FUNC
174      */
175     virtual int32_t RequestCredential(const std::string &pkgName, const std::string &reqJsonStr,
176         std::string &returnJsonStr) override;
177     /**
178      * @tc.name: DeviceManagerImpl::ImportCredential
179      * @tc.desc: ImportCredential
180      * @tc.type: FUNC
181      */
182     virtual int32_t ImportCredential(const std::string &pkgName, const std::string &credentialInfo) override;
183     /**
184      * @tc.name: DeviceManagerImpl::DeleteCredential
185      * @tc.desc: DeleteCredential
186      * @tc.type: FUNC
187      */
188     virtual int32_t DeleteCredential(const std::string &pkgName, const std::string &deleteInfo) override;
189     /**
190      * @tc.name: DeviceManagerImpl::RegisterCredentialCallback
191      * @tc.desc: RegisterCredentialCallback
192      * @tc.type: FUNC
193      */
194     virtual int32_t RegisterCredentialCallback(const std::string &pkgName,
195         std::shared_ptr<CredentialCallback> callback) override;
196     /**
197      * @tc.name: DeviceManagerImpl::UnRegisterCredentialCallback
198      * @tc.desc: UnRegisterCredentialCallback
199      * @tc.type: FUNC
200      */
201     virtual int32_t UnRegisterCredentialCallback(const std::string &pkgName) override;
202 
203     /**
204      * @tc.name: DeviceManagerImpl::NotifyEvent
205      * @tc.desc: NotifyEvent
206      * @tc.type: FUNC
207      */
208     virtual int32_t NotifyEvent(const std::string &pkgName, const int32_t eventId, const std::string &event) override;
209 
210     int32_t OnDmServiceDied();
211 private:
212     DeviceManagerImpl() = default;
213     ~DeviceManagerImpl() = default;
214     DeviceManagerImpl(const DeviceManagerImpl &) = delete;
215     DeviceManagerImpl &operator=(const DeviceManagerImpl &) = delete;
216     DeviceManagerImpl(DeviceManagerImpl &&) = delete;
217     DeviceManagerImpl &operator=(DeviceManagerImpl &&) = delete;
218 
219 private:
220 #if !defined(__LITEOS_M__)
221     std::shared_ptr<IpcClientProxy> ipcClientProxy_ =
222         std::make_shared<IpcClientProxy>(std::make_shared<IpcClientManager>());
223 #endif
224 };
225 } // namespace DistributedHardware
226 } // namespace OHOS
227 #endif // OHOS_DEVICE_MANAGER_IMPL_H
228