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