1 /* 2 * Copyright (c) 2022-2025 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::UnAuthenticateDevice 51 * @tc.desc: UnAuthenticate Device of the device manager service impl 52 * @tc.type: FUNC 53 */ 54 virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel) = 0; 55 /** 56 * @tc.name: IDeviceManagerServiceImpl::UnBindDevice 57 * @tc.desc: UnBindDevice Device of the device manager service impl 58 * @tc.type: FUNC 59 */ 60 virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel) = 0; 61 62 virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, 63 int32_t bindLevel, const std::string &extra) = 0; 64 65 /** 66 * @tc.name: IDeviceManagerServiceImpl::SetUserOperation 67 * @tc.desc: Se tUser Operation of device manager service impl 68 * @tc.type: FUNC 69 */ 70 virtual int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms) = 0; 71 72 /** 73 * @tc.name: IDeviceManagerServiceImpl::HandleDeviceStatusChange 74 * @tc.desc: Handle Device Status Event to the device manager service impl 75 * @tc.type: FUNC 76 */ 77 virtual void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo) = 0; 78 /** 79 * @tc.name: IDeviceManagerServiceImpl::OnSessionOpened 80 * @tc.desc: Send Session Opened event to the device manager service impl 81 * @tc.type: FUNC 82 */ 83 virtual int OnSessionOpened(int sessionId, int result) = 0; 84 85 /** 86 * @tc.name: IDeviceManagerServiceImpl::OnSessionClosed 87 * @tc.desc: Send Session Closed event to the device manager service impl 88 * @tc.type: FUNC 89 */ 90 virtual void OnSessionClosed(int sessionId) = 0; 91 92 /** 93 * @tc.name: IDeviceManagerServiceImpl::OnBytesReceived 94 * @tc.desc: Send Bytes Received event to the device manager service impl 95 * @tc.type: FUNC 96 */ 97 virtual void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen) = 0; 98 99 /** 100 * @tc.name: IDeviceManagerServiceImpl::RequestCredential 101 * @tc.desc: RequestCredential of the Device Manager Service 102 * @tc.type: FUNC 103 */ 104 virtual int32_t RequestCredential(const std::string &reqJsonStr, std::string &returnJsonStr) = 0; 105 /** 106 * @tc.name: IDeviceManagerServiceImpl::ImportCredential 107 * @tc.desc: ImportCredential of the Device Manager Service 108 * @tc.type: FUNC 109 */ 110 virtual int32_t ImportCredential(const std::string &pkgName, const std::string &credentialInfo) = 0; 111 /** 112 * @tc.name: IDeviceManagerServiceImpl::DeleteCredential 113 * @tc.desc: DeleteCredential of the Device Manager Service 114 * @tc.type: FUNC 115 */ 116 virtual int32_t DeleteCredential(const std::string &pkgName, const std::string &deleteInfo) = 0; 117 /** 118 * @tc.name: IDeviceManagerServiceImpl::MineRequestCredential 119 * @tc.desc: MineRequestCredential of the Device Manager Service 120 * @tc.type: FUNC 121 */ 122 virtual int32_t MineRequestCredential(const std::string &pkgName, std::string &returnJsonStr) = 0; 123 /** 124 * @tc.name: IDeviceManagerServiceImpl::CheckCredential 125 * @tc.desc: CheckCredential of the Device Manager Service 126 * @tc.type: FUNC 127 */ 128 virtual int32_t CheckCredential(const std::string &pkgName, const std::string &reqJsonStr, 129 std::string &returnJsonStr) = 0; 130 /** 131 * @tc.name: IDeviceManagerServiceImpl::ImportCredential 132 * @tc.desc: ImportCredential of the Device Manager Service 133 * @tc.type: FUNC 134 */ 135 virtual int32_t ImportCredential(const std::string &pkgName, const std::string &reqJsonStr, 136 std::string &returnJsonStr) = 0; 137 /** 138 * @tc.name: IDeviceManagerServiceImpl::DeleteCredential 139 * @tc.desc: DeleteCredential of the Device Manager Service 140 * @tc.type: FUNC 141 */ 142 virtual int32_t DeleteCredential(const std::string &pkgName, const std::string &reqJsonStr, 143 std::string &returnJsonStr) = 0; 144 /** 145 * @tc.name: IDeviceManagerServiceImpl::RegisterCredentialCallback 146 * @tc.desc: RegisterCredentialCallback 147 * @tc.type: FUNC 148 */ 149 virtual int32_t RegisterCredentialCallback(const std::string &pkgName) = 0; 150 /** 151 * @tc.name: IDeviceManagerServiceImpl::UnRegisterCredentialCallback 152 * @tc.desc: UnRegisterCredentialCallback 153 * @tc.type: FUNC 154 */ 155 virtual int32_t UnRegisterCredentialCallback(const std::string &pkgName) = 0; 156 157 /** 158 * @tc.name: IDeviceManagerServiceImpl::NotifyEvent 159 * @tc.desc: NotifyEvent 160 * @tc.type: FUNC 161 */ 162 virtual int32_t NotifyEvent(const std::string &pkgName, const int32_t eventId, const std::string &event) = 0; 163 164 /** 165 * @tc.name: IDeviceManagerServiceImpl::GetGroupType 166 * @tc.desc: GetGroupType 167 * @tc.type: FUNC 168 */ 169 virtual int32_t GetGroupType(std::vector<DmDeviceInfo> &deviceList) = 0; 170 171 /** 172 * @tc.name: IDeviceManagerServiceImpl::GetUdidHashByNetWorkId 173 * @tc.desc: GetUdidHashByNetWorkId 174 * @tc.type: FUNC 175 */ 176 virtual int32_t GetUdidHashByNetWorkId(const char *networkId, std::string &deviceId) = 0; 177 178 /** 179 * @tc.name: IDeviceManagerServiceImpl::ImportAuthCode 180 * @tc.desc: ImportAuthCode 181 * @tc.type: FUNC 182 */ 183 virtual int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode) = 0; 184 185 /** 186 * @tc.name: IDeviceManagerServiceImpl::ExportAuthCode 187 * @tc.desc: ExportAuthCode 188 * @tc.type: FUNC 189 */ 190 virtual int32_t ExportAuthCode(std::string &authCode) = 0; 191 192 /** 193 * @tc.name: IDeviceManagerServiceImpl::BindTarget 194 * @tc.desc: BindTarget 195 * @tc.type: FUNC 196 */ 197 virtual int32_t BindTarget(const std::string &pkgName, const PeerTargetId &targetId, 198 const std::map<std::string, std::string> &bindParam) = 0; 199 200 /** 201 * @tc.name: IDeviceManagerServiceImpl::LoadHardwareFwkService 202 * @tc.desc: LoadHardwareFwkService 203 * @tc.type: FUNC 204 */ 205 virtual void LoadHardwareFwkService() = 0; 206 207 /** 208 * @tc.name: IDeviceManagerServiceImpl::RegisterUiStateCallback 209 * @tc.desc: RegisterUiStateCallback 210 * @tc.type: FUNC 211 */ 212 virtual int32_t RegisterUiStateCallback(const std::string &pkgName) = 0; 213 214 /** 215 * @tc.name: IDeviceManagerServiceImpl::UnRegisterUiStateCallback 216 * @tc.desc: UnRegisterUiStateCallback 217 * @tc.type: FUNC 218 */ 219 virtual int32_t UnRegisterUiStateCallback(const std::string &pkgName) = 0; 220 221 virtual std::unordered_map<std::string, DmAuthForm> GetAppTrustDeviceIdList(std::string pkgname) = 0; 222 virtual int32_t DpAclAdd(const std::string &udid) = 0; 223 virtual int32_t IsSameAccount(const std::string &udid) = 0; 224 virtual uint64_t GetTokenIdByNameAndDeviceId(std::string pkgName, std::string requestDeviceId) = 0; 225 virtual void ScreenCommonEventCallback(std::string commonEventType) = 0; 226 virtual int32_t CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, 227 const DmAccessCallee &callee, const std::string &sinkUdid) = 0; 228 virtual int32_t CheckAccessControl(const DmAccessCaller &caller, const std::string &srcUdid, 229 const DmAccessCallee &callee, const std::string &sinkUdid) = 0; 230 virtual void HandleDeviceNotTrust(const std::string &udid) = 0; 231 virtual std::multimap<std::string, int32_t> GetDeviceIdAndUserId(int32_t userId, 232 const std::string &accountId) = 0; 233 virtual void HandleAccountLogoutEvent(int32_t remoteUserId, const std::string &remoteAccountHash, 234 const std::string &remoteUdid) = 0; 235 virtual void HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid) = 0; 236 virtual void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, int32_t tokenId) = 0; 237 virtual void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, 238 int32_t tokenId, int32_t peerTokenId) = 0; 239 virtual int32_t GetBindLevel(const std::string &pkgName, const std::string &localUdid, 240 const std::string &udid, uint64_t &tokenId) = 0; 241 virtual void HandleIdentAccountLogout(const std::string &localUdid, int32_t localUserId, 242 const std::string &peerUdid, int32_t peerUserId) = 0; 243 virtual void HandleUserRemoved(int32_t preUserId) = 0; 244 virtual void HandleDeviceScreenStatusChange(DmDeviceInfo &devInfo) = 0; 245 virtual void HandleUserSwitched(const std::vector<std::string> &deviceVec, int32_t currentUserId, 246 int32_t beforeUserId) = 0; 247 virtual int32_t StopAuthenticateDevice(const std::string &pkgName) = 0; 248 virtual void HandleCredentialAuthStatus(const std::string &deviceList, uint16_t deviceTypeId, 249 int32_t errcode) = 0; 250 virtual int32_t ProcessAppUnintall(const std::string &appId, int32_t accessTokenId) = 0; 251 virtual void HandleSyncUserIdEvent(const std::vector<uint32_t> &foregroundUserIds, 252 const std::vector<uint32_t> &backgroundUserIds, const std::string &remoteUdid, bool isCheckUserStatus) = 0; 253 virtual void HandleRemoteUserRemoved(int32_t userId, const std::string &remoteUdid) = 0; 254 virtual std::map<std::string, int32_t> GetDeviceIdAndBindLevel(int32_t userId) = 0; 255 virtual std::multimap<std::string, int32_t> GetDeviceIdAndUserId(int32_t localUserId) = 0; 256 virtual int32_t SaveOnlineDeviceInfo(const std::vector<DmDeviceInfo> &deviceList) = 0; 257 virtual void HandleDeviceUnBind(int32_t bindType, const std::string &peerUdid, 258 const std::string &localUdid, int32_t localUserId, const std::string &localAccountId) = 0; 259 virtual int32_t RegisterAuthenticationType(int32_t authenticationType) = 0; 260 virtual void DeleteAlwaysAllowTimeOut() = 0; 261 virtual void CheckDeleteCredential(const std::string &remoteUdid) = 0; 262 virtual int32_t CheckDeviceInfoPermission(const std::string &localUdid, const std::string &peerDeviceId) = 0; 263 }; 264 265 using CreateDMServiceFuncPtr = IDeviceManagerServiceImpl *(*)(void); 266 } // namespace DistributedHardware 267 } // namespace OHOS 268 #endif // OHOS_I_DM_SERVICE_IMPL_H 269