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