• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 OHOS_I_DM_SERVICE_IMPL_H
17 #define OHOS_I_DM_SERVICE_IMPL_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "idevice_manager_service_listener.h"
23 #include "dm_device_info.h"
24 #include "dm_publish_info.h"
25 #include "dm_subscribe_info.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class IDeviceManagerServiceImpl {
30 public:
~IDeviceManagerServiceImpl()31     virtual ~IDeviceManagerServiceImpl() {}
32 
33     /**
34      * @tc.name: IDeviceManagerServiceImpl::Initialize
35      * @tc.desc: Initialize the device manager service impl
36      * @tc.type: FUNC
37      */
38     virtual int32_t Initialize(const std::shared_ptr<IDeviceManagerServiceListener> &listener) = 0;
39 
40     /**
41      * @tc.name: IDeviceManagerServiceImpl::Release
42      * @tc.desc: Release the device manager service impl
43      * @tc.type: FUNC
44      */
45     virtual void Release() = 0;
46 
47     /**
48      * @tc.name: IDeviceManagerServiceImpl::StartDeviceDiscovery
49      * @tc.desc: Start Device Discovery of the device manager service impl
50      * @tc.type: FUNC
51      */
52     virtual int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo,
53                                          const std::string &extra) = 0;
54 
55     /**
56      * @tc.name: IDeviceManagerServiceImpl::StartDeviceDiscovery
57      * @tc.desc: Start Device Discovery of the device manager service impl
58      * @tc.type: FUNC
59      */
60     virtual int32_t StartDeviceDiscovery(const std::string &pkgName, const uint16_t subscribeId,
61                                  const std::string &filterOptions) = 0;
62 
63    /**
64      * @tc.name: IDeviceManagerServiceImpl::StopDeviceDiscovery
65      * @tc.desc: Stop Device Discovery of the device manager service impl
66      * @tc.type: FUNC
67      */
68     virtual int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) = 0;
69 
70    /**
71      * @tc.name: IDeviceManagerServiceImpl::PublishDeviceDiscovery
72      * @tc.desc: Publish Device Discovery of the device manager service impl
73      * @tc.type: FUNC
74      */
75     virtual int32_t PublishDeviceDiscovery(const std::string &pkgName, const DmPublishInfo &publishInfo) = 0;
76 
77     /**
78      * @tc.name: IDeviceManagerServiceImpl::UnPublishDeviceDiscovery
79      * @tc.desc: UnPublish Device Discovery of the device manager service impl
80      * @tc.type: FUNC
81      */
82     virtual int32_t UnPublishDeviceDiscovery(const std::string &pkgName, int32_t publishId) = 0;
83 
84     /**
85      * @tc.name: IDeviceManagerServiceImpl::AuthenticateDevice
86      * @tc.desc: Authenticate Device of the device manager service impl
87      * @tc.type: FUNC
88      */
89     virtual int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
90                                        const std::string &extra) = 0;
91 
92     /**
93      * @tc.name: IDeviceManagerServiceImpl::UnAuthenticateDevice
94      * @tc.desc: UnAuthenticate Device of the device manager service impl
95      * @tc.type: FUNC
96      */
97     virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &networkId) = 0;
98 
99     /**
100      * @tc.name: IDeviceManagerServiceImpl::BindDevice
101      * @tc.desc: Bind Device of the device manager service impl
102      * @tc.type: FUNC
103      */
104     virtual int32_t BindDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
105         const std::string &bindParam) = 0;
106 
107     /**
108      * @tc.name: IDeviceManagerServiceImpl::UnBindDevice
109      * @tc.desc: UnBindDevice Device of the device manager service impl
110      * @tc.type: FUNC
111      */
112     virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &deviceId) = 0;
113 
114     /**
115      * @tc.name: IDeviceManagerServiceImpl::SetUserOperation
116      * @tc.desc: Se tUser Operation of device manager service impl
117      * @tc.type: FUNC
118      */
119     virtual int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string &params) = 0;
120 
121     /**
122      * @tc.name: IDeviceManagerServiceImpl::HandleDeviceStatusChange
123      * @tc.desc: Handle Device Status Event to the device manager service impl
124      * @tc.type: FUNC
125      */
126     virtual void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo) = 0;
127     /**
128      * @tc.name: IDeviceManagerServiceImpl::OnSessionOpened
129      * @tc.desc: Send Session Opened event to the device manager service impl
130      * @tc.type: FUNC
131      */
132     virtual int OnSessionOpened(int sessionId, int result) = 0;
133 
134     /**
135      * @tc.name: IDeviceManagerServiceImpl::OnSessionClosed
136      * @tc.desc: Send Session Closed event to the device manager service impl
137      * @tc.type: FUNC
138      */
139     virtual void OnSessionClosed(int sessionId) = 0;
140 
141     /**
142      * @tc.name: IDeviceManagerServiceImpl::OnBytesReceived
143      * @tc.desc: Send Bytes Received event to the device manager service impl
144      * @tc.type: FUNC
145      */
146     virtual void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen) = 0;
147 
148     /**
149      * @tc.name: IDeviceManagerServiceImpl::RequestCredential
150      * @tc.desc: RequestCredential of the Device Manager Service
151      * @tc.type: FUNC
152      */
153     virtual int32_t RequestCredential(const std::string &reqJsonStr, std::string &returnJsonStr) = 0;
154     /**
155      * @tc.name: IDeviceManagerServiceImpl::ImportCredential
156      * @tc.desc: ImportCredential of the Device Manager Service
157      * @tc.type: FUNC
158      */
159     virtual int32_t ImportCredential(const std::string &pkgName, const std::string &credentialInfo) = 0;
160     /**
161      * @tc.name: IDeviceManagerServiceImpl::DeleteCredential
162      * @tc.desc: DeleteCredential of the Device Manager Service
163      * @tc.type: FUNC
164      */
165     virtual int32_t DeleteCredential(const std::string &pkgName, const std::string &deleteInfo) = 0;
166     /**
167      * @tc.name: IDeviceManagerServiceImpl::MineRequestCredential
168      * @tc.desc: MineRequestCredential of the Device Manager Service
169      * @tc.type: FUNC
170      */
171     virtual int32_t MineRequestCredential(const std::string &pkgName, std::string &returnJsonStr) = 0;
172     /**
173      * @tc.name: IDeviceManagerServiceImpl::CheckCredential
174      * @tc.desc: CheckCredential of the Device Manager Service
175      * @tc.type: FUNC
176      */
177     virtual int32_t CheckCredential(const std::string &pkgName, const std::string &reqJsonStr,
178         std::string &returnJsonStr) = 0;
179     /**
180      * @tc.name: IDeviceManagerServiceImpl::ImportCredential
181      * @tc.desc: ImportCredential of the Device Manager Service
182      * @tc.type: FUNC
183      */
184     virtual int32_t ImportCredential(const std::string &pkgName, const std::string &reqJsonStr,
185         std::string &returnJsonStr) = 0;
186     /**
187      * @tc.name: IDeviceManagerServiceImpl::DeleteCredential
188      * @tc.desc: DeleteCredential of the Device Manager Service
189      * @tc.type: FUNC
190      */
191     virtual int32_t DeleteCredential(const std::string &pkgName, const std::string &reqJsonStr,
192         std::string &returnJsonStr) = 0;
193     /**
194      * @tc.name: IDeviceManagerServiceImpl::RegisterCredentialCallback
195      * @tc.desc: RegisterCredentialCallback
196      * @tc.type: FUNC
197      */
198     virtual int32_t RegisterCredentialCallback(const std::string &pkgName) = 0;
199     /**
200      * @tc.name: IDeviceManagerServiceImpl::UnRegisterCredentialCallback
201      * @tc.desc: UnRegisterCredentialCallback
202      * @tc.type: FUNC
203      */
204     virtual int32_t UnRegisterCredentialCallback(const std::string &pkgName) = 0;
205 
206     /**
207      * @tc.name: IDeviceManagerServiceImpl::NotifyEvent
208      * @tc.desc: NotifyEvent
209      * @tc.type: FUNC
210      */
211     virtual int32_t NotifyEvent(const std::string &pkgName, const int32_t eventId, const std::string &event) = 0;
212 
213     /**
214      * @tc.name: IDeviceManagerServiceImpl::GetGroupType
215      * @tc.desc: GetGroupType
216      * @tc.type: FUNC
217      */
218     virtual int32_t GetGroupType(std::vector<DmDeviceInfo> &deviceList) = 0;
219 
220     /**
221      * @tc.name: IDeviceManagerServiceImpl::GetUdidHashByNetWorkId
222      * @tc.desc: GetUdidHashByNetWorkId
223      * @tc.type: FUNC
224      */
225     virtual int32_t GetUdidHashByNetWorkId(const char *networkId, std::string &deviceId) = 0;
226 
227     /**
228      * @tc.name: IDeviceManagerServiceImpl::ImportAuthCode
229      * @tc.desc: ImportAuthCode
230      * @tc.type: FUNC
231      */
232     virtual int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode) = 0;
233 
234     /**
235      * @tc.name: IDeviceManagerServiceImpl::ExportAuthCode
236      * @tc.desc: ExportAuthCode
237      * @tc.type: FUNC
238      */
239     virtual int32_t ExportAuthCode(std::string &authCode) = 0;
240 
241     /**
242      * @tc.name: IDeviceManagerServiceImpl::BindTarget
243      * @tc.desc: BindTarget
244      * @tc.type: FUNC
245      */
246     virtual int32_t BindTarget(const std::string &pkgName, const PeerTargetId &targetId,
247         const std::map<std::string, std::string> &bindParam) = 0;
248 
249     /**
250      * @tc.name: IDeviceManagerServiceImpl::LoadHardwareFwkService
251      * @tc.desc: LoadHardwareFwkService
252      * @tc.type: FUNC
253      */
254     virtual void LoadHardwareFwkService() = 0;
255 
256     /**
257      * @tc.name: IDeviceManagerServiceImpl::RegisterUiStateCallback
258      * @tc.desc: RegisterUiStateCallback
259      * @tc.type: FUNC
260      */
261     virtual int32_t RegisterUiStateCallback(const std::string &pkgName) = 0;
262 
263     /**
264      * @tc.name: IDeviceManagerServiceImpl::UnRegisterUiStateCallback
265      * @tc.desc: UnRegisterUiStateCallback
266      * @tc.type: FUNC
267      */
268     virtual int32_t UnRegisterUiStateCallback(const std::string &pkgName) = 0;
269 
270     virtual std::map<std::string, DmAuthForm> GetAppTrustDeviceIdList(std::string pkgname) = 0;
271     virtual void OnUnbindSessionOpened(int32_t sessionId, int32_t result) = 0;
272     virtual void OnUnbindSessionCloseed(int32_t sessionId) = 0;
273     virtual void OnUnbindBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) = 0;
274     virtual int32_t DpAclAdd(const std::string &udid) = 0;
275 };
276 
277 using CreateDMServiceFuncPtr = IDeviceManagerServiceImpl *(*)(void);
278 } // namespace DistributedHardware
279 } // namespace OHOS
280 #endif // OHOS_I_DM_SERVICE_IMPL_H
281