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); 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(); 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); 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); 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); 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); 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); 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); 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); 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); 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); 113 114 /** 115 * @tc.name: IDeviceManagerServiceImpl::VerifyAuthentication 116 * @tc.desc: Verify Authentication of the device manager service impl 117 * @tc.type: FUNC 118 */ 119 virtual int32_t VerifyAuthentication(const std::string &authParam); 120 121 /** 122 * @tc.name: IDeviceManagerServiceImpl::GetFaParam 123 * @tc.desc: Get FaParam of the device manager service impl 124 * @tc.type: FUNC 125 */ 126 virtual int32_t GetFaParam(std::string &pkgName, DmAuthParam &authParam); 127 128 /** 129 * @tc.name: IDeviceManagerServiceImpl::SetUserOperation 130 * @tc.desc: Se tUser Operation of device manager service impl 131 * @tc.type: FUNC 132 */ 133 virtual int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms); 134 135 /** 136 * @tc.name: IDeviceManagerServiceImpl::RegisterDevStateCallback 137 * @tc.desc: Register Device State Callback to device manager service impl 138 * @tc.type: FUNC 139 */ 140 virtual int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra); 141 142 /** 143 * @tc.name: IDeviceManagerServiceImpl::UnRegisterDevStateCallback 144 * @tc.desc: UnRegister Device State Callback to device manager service impl 145 * @tc.type: FUNC 146 */ 147 virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra); 148 149 /** 150 * @tc.name: IDeviceManagerServiceImpl::HandleDeviceOnline 151 * @tc.desc: Handle Device Online to the device manager service impl 152 * @tc.type: FUNC 153 */ 154 virtual void HandleDeviceOnline(DmDeviceInfo &info); 155 156 /** 157 * @tc.name: IDeviceManagerServiceImpl::HandleDeviceOffline 158 * @tc.desc: Handle Device Offline to the device manager service impl 159 * @tc.type: FUNC 160 */ 161 virtual void HandleDeviceOffline(DmDeviceInfo &info); 162 163 /** 164 * @tc.name: IDeviceManagerServiceImpl::HandleDeviceNameChange 165 * @tc.desc: Handle Device Name Change to the device manager service impl 166 * @tc.type: FUNC 167 */ 168 virtual void HandleDeviceNameChange(DmDeviceInfo &info); 169 /** 170 * @tc.name: IDeviceManagerServiceImpl::OnSessionOpened 171 * @tc.desc: Send Session Opened event to the device manager service impl 172 * @tc.type: FUNC 173 */ 174 virtual int OnSessionOpened(int sessionId, int result); 175 176 /** 177 * @tc.name: IDeviceManagerServiceImpl::OnSessionClosed 178 * @tc.desc: Send Session Closed event to the device manager service impl 179 * @tc.type: FUNC 180 */ 181 virtual void OnSessionClosed(int sessionId); 182 183 /** 184 * @tc.name: IDeviceManagerServiceImpl::OnBytesReceived 185 * @tc.desc: Send Bytes Received event to the device manager service impl 186 * @tc.type: FUNC 187 */ 188 virtual void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen); 189 190 /** 191 * @tc.name: DeviceManagerService::RequestCredential 192 * @tc.desc: RequestCredential of the Device Manager Service 193 * @tc.type: FUNC 194 */ 195 virtual int32_t RequestCredential(const std::string &reqJsonStr, std::string &returnJsonStr); 196 /** 197 * @tc.name: DeviceManagerService::ImportCredential 198 * @tc.desc: ImportCredential of the Device Manager Service 199 * @tc.type: FUNC 200 */ 201 virtual int32_t ImportCredential(const std::string &pkgName, const std::string &credentialInfo); 202 /** 203 * @tc.name: DeviceManagerService::DeleteCredential 204 * @tc.desc: DeleteCredential of the Device Manager Service 205 * @tc.type: FUNC 206 */ 207 virtual int32_t DeleteCredential(const std::string &pkgName, const std::string &deleteInfo); 208 /** 209 * @tc.name: DeviceManagerService::RegisterCredentialCallback 210 * @tc.desc: RegisterCredentialCallback 211 * @tc.type: FUNC 212 */ 213 virtual int32_t RegisterCredentialCallback(const std::string &pkgName); 214 /** 215 * @tc.name: DeviceManagerService::UnRegisterCredentialCallback 216 * @tc.desc: UnRegisterCredentialCallback 217 * @tc.type: FUNC 218 */ 219 virtual int32_t UnRegisterCredentialCallback(const std::string &pkgName); 220 221 /** 222 * @tc.name: DeviceManagerService::NotifyEvent 223 * @tc.desc: NotifyEvent 224 * @tc.type: FUNC 225 */ 226 virtual int32_t NotifyEvent(const std::string &pkgName, const int32_t eventId, const std::string &event); 227 228 /** 229 * @tc.name: DeviceManagerService::GetGroupType 230 * @tc.desc: GetGroupType 231 * @tc.type: FUNC 232 */ 233 virtual int32_t GetGroupType(std::vector<DmDeviceInfo> &deviceList); 234 235 /** 236 * @tc.name: DeviceManagerService::GetUdidHashByNetWorkId 237 * @tc.desc: GetUdidHashByNetWorkId 238 * @tc.type: FUNC 239 */ 240 virtual int32_t GetUdidHashByNetWorkId(const char *networkId, std::string &deviceId); 241 242 /** 243 * @tc.name: DeviceManagerService::LoadHardwareFwkService 244 * @tc.desc: LoadHardwareFwkService 245 * @tc.type: FUNC 246 */ 247 virtual void LoadHardwareFwkService(); 248 virtual int32_t RegisterUiStateCallback(const std::string &pkgName); 249 virtual int32_t UnRegisterUiStateCallback(const std::string &pkgName); 250 251 /** 252 * @tc.name: DeviceManagerService::GetEncryptedUuidByNetworkId 253 * @tc.desc: GenerateEncryptedUuid 254 * @tc.type: FUNC 255 */ 256 virtual int32_t GetEncryptedUuidByNetworkId(const std::string &pkgName, const std::string &networkId, 257 std::string &uuid); 258 259 /** 260 * @tc.name: DeviceManagerService::GenerateEncryptedUuid 261 * @tc.desc: GenerateEncryptedUuid 262 * @tc.type: FUNC 263 */ 264 virtual int32_t GenerateEncryptedUuid(const std::string &pkgName, const std::string &uuid, 265 const std::string &appId, std::string &encryptedUuid); 266 }; 267 268 using CreateDMServiceFuncPtr = IDeviceManagerServiceImpl *(*)(void); 269 } // namespace DistributedHardware 270 } // namespace OHOS 271 #endif // OHOS_I_DM_SERVICE_IMPL_H 272