1 /* 2 * Copyright (c) 2023-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 #ifndef OHOS_DM_DEVICEPROFILE_CONNECTOR_H 16 #define OHOS_DM_DEVICEPROFILE_CONNECTOR_H 17 #include <algorithm> 18 #include <string> 19 #include <unordered_set> 20 #include "access_control_profile.h" 21 #include "dm_device_info.h" 22 #include "dm_single_instance.h" 23 #include "i_dp_inited_callback.h" 24 #include "local_service_info.h" 25 #include "parameter.h" 26 #include "trusted_device_info.h" 27 #include "json_object.h" 28 29 enum AllowAuthType { 30 ALLOW_AUTH_ONCE = 1, 31 ALLOW_AUTH_ALWAYS = 2 32 }; 33 34 DM_EXPORT extern const uint32_t INVALIED_TYPE; 35 DM_EXPORT extern const uint32_t APP_PEER_TO_PEER_TYPE; 36 DM_EXPORT extern const uint32_t APP_ACROSS_ACCOUNT_TYPE; 37 DM_EXPORT extern const uint32_t SHARE_TYPE; 38 DM_EXPORT extern const uint32_t DEVICE_PEER_TO_PEER_TYPE; 39 DM_EXPORT extern const uint32_t DEVICE_ACROSS_ACCOUNT_TYPE; 40 DM_EXPORT extern const uint32_t IDENTICAL_ACCOUNT_TYPE; 41 DM_EXPORT extern const uint32_t SERVICE_PEER_TO_PEER_TYPE; 42 DM_EXPORT extern const uint32_t SERVICE_ACROSS_ACCOUNT_TYPE; 43 44 DM_EXPORT extern const uint32_t DM_INVALIED_TYPE; 45 DM_EXPORT extern const uint32_t USER; 46 DM_EXPORT extern const uint32_t SERVICE; 47 DM_EXPORT extern const uint32_t APP; 48 49 extern const char* TAG_PEER_BUNDLE_NAME; 50 DM_EXPORT extern const char* TAG_PEER_TOKENID; 51 52 const uint32_t DM_IDENTICAL_ACCOUNT = 1; 53 const uint32_t DM_SHARE = 2; 54 const uint32_t DM_LNN = 3; 55 const uint32_t DM_POINT_TO_POINT = 256; 56 const uint32_t DM_ACROSS_ACCOUNT = 1282; 57 const int32_t DM_VERSION_INT_5_1_0 = 510; 58 59 enum ProfileState { 60 INACTIVE = 0, 61 ACTIVE = 1 62 }; 63 64 typedef struct DmDiscoveryInfo { 65 std::string pkgname; 66 std::string localDeviceId; 67 int32_t userId; 68 std::string remoteDeviceIdHash; 69 } DmDiscoveryInfo; 70 71 typedef struct DmAclInfo { 72 std::string sessionKey; 73 int32_t bindType; 74 int32_t state; 75 std::string trustDeviceId; 76 int32_t bindLevel; 77 int32_t authenticationType; 78 std::string deviceIdHash; 79 } DmAclInfo; 80 81 typedef struct DmAccesser { 82 uint64_t requestTokenId; 83 std::string requestBundleName; 84 int32_t requestUserId; 85 std::string requestAccountId; 86 std::string requestDeviceId; 87 int32_t requestTargetClass; 88 std::string requestDeviceName; 89 } DmAccesser; 90 91 typedef struct DmAccessee { 92 uint64_t trustTokenId; 93 std::string trustBundleName; 94 int32_t trustUserId; 95 std::string trustAccountId; 96 std::string trustDeviceId; 97 int32_t trustTargetClass; 98 std::string trustDeviceName; 99 } DmAccessee; 100 101 typedef struct DmAclIdParam { 102 std::string udid; 103 int32_t userId; 104 int64_t accessControlId; 105 int32_t skId; 106 std::string credId; 107 } DmAclIdParam; 108 109 typedef struct DmOfflineParam { 110 uint32_t bindType; 111 std::vector<OHOS::DistributedHardware::ProcessInfo> processVec; 112 std::vector<std::string> credIdVec; 113 std::vector<int32_t> skIdVec; 114 int32_t leftAclNumber; 115 int32_t peerUserId; 116 bool hasLnnAcl = false; 117 int64_t accessControlId; 118 // save the need unbind acl info 119 std::vector<DmAclIdParam> needDelAclInfos; 120 // save all the lnn acl between localdevid/localuserId -> remotedevid 121 std::vector<DmAclIdParam> allLnnAclInfos; 122 // save all the app or service acl between localdevid/localuserId -> remotedevid except the need del ones 123 std::vector<DmAclIdParam> allLeftAppOrSvrAclInfos; 124 // save all the user acl between localdevid/localuserId -> remotedevid 125 std::vector<DmAclIdParam> allUserAclInfos; 126 } DmOfflineParam; 127 128 struct AclHashItem { 129 std::string version; 130 std::vector<std::string> aclHashList; 131 }; 132 133 namespace OHOS { 134 namespace DistributedHardware { 135 class IDeviceProfileConnector { 136 public: ~IDeviceProfileConnector()137 virtual ~IDeviceProfileConnector() {} 138 virtual int32_t GetDeviceAclParam(DmDiscoveryInfo discoveryInfo, bool &isOnline, int32_t &authForm) = 0; 139 virtual std::map<std::string, int32_t> GetDeviceIdAndBindLevel(std::vector<int32_t> userIds, 140 const std::string &localUdid) = 0; 141 virtual int32_t HandleUserSwitched(const std::string &localUdid, const std::vector<std::string> &deviceVec, 142 const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds) = 0; 143 virtual bool CheckAclStatusAndForegroundNotMatch(const std::string &localUdid, 144 const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds) = 0; 145 virtual int32_t HandleUserStop(int32_t stopUserId, const std::string &stopEventUdid) = 0; 146 virtual int32_t HandleUserStop(int32_t stopUserId, const std::string &localUdid, 147 const std::vector<std::string> &acceptEventUdids) = 0; 148 virtual int32_t HandleAccountCommonEvent(const std::string &localUdid, const std::vector<std::string> &deviceVec, 149 const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds) = 0; 150 }; 151 152 class DeviceProfileConnector : public IDeviceProfileConnector { 153 DM_DECLARE_SINGLE_INSTANCE(DeviceProfileConnector); 154 public: 155 DM_EXPORT DmOfflineParam FilterNeedDeleteACL(const std::string &localDeviceId, uint32_t localTokenId, 156 const std::string &remoteDeviceId, const std::string &extra); 157 DM_EXPORT std::vector<DistributedDeviceProfile::AccessControlProfile> 158 GetAccessControlProfile(); 159 DM_EXPORT DmOfflineParam HandleServiceUnBindEvent(int32_t remoteUserId, 160 const std::string &remoteUdid, const std::string &localUdid, int32_t tokenId); 161 std::vector<DistributedDeviceProfile::AccessControlProfile> GetAccessControlProfileByUserId(int32_t userId); 162 std::vector<DistributedDeviceProfile::AccessControlProfile> GetAclProfileByDeviceIdAndUserId( 163 const std::string &deviceId, int32_t userId); 164 DM_EXPORT uint32_t CheckBindType(std::string peerUdid, std::string localUdid); 165 DM_EXPORT int32_t PutAccessControlList(DmAclInfo aclInfo, DmAccesser dmAccesser, 166 DmAccessee dmAccessee); 167 int32_t UpdateAccessControlList(int32_t userId, std::string &oldAccountId, std::string &newAccountId); 168 DM_EXPORT std::unordered_map<std::string, DmAuthForm> GetAppTrustDeviceList( 169 const std::string &pkgName, const std::string &deviceId); 170 DM_EXPORT std::vector<int32_t> GetBindTypeByPkgName(std::string pkgName, 171 std::string requestDeviceId, std::string trustUdid); 172 DM_EXPORT uint64_t GetTokenIdByNameAndDeviceId(std::string extra, std::string requestDeviceId); 173 DM_EXPORT std::vector<int32_t> SyncAclByBindType(std::string pkgName, 174 std::vector<int32_t> bindTypeVec, std::string localDeviceId, std::string targetDeviceId); 175 int32_t GetDeviceAclParam(DmDiscoveryInfo discoveryInfo, bool &isOnline, int32_t &authForm); 176 177 DM_EXPORT bool DeleteAclForAccountLogOut(const DMAclQuadInfo &info, const std::string &accountId, 178 DmOfflineParam &offlineParam); 179 DM_EXPORT bool DeleteAclByActhash(const DMAclQuadInfo &info, const std::string &accountIdHash, 180 DmOfflineParam &offlineParam); 181 DM_EXPORT void CacheOfflineParam(const DistributedDeviceProfile::AccessControlProfile &profile, 182 const DMAclQuadInfo &info, const std::string &accountIdHash, DmOfflineParam &offlineParam, 183 bool ¬ifyOffline); 184 DM_EXPORT void DeleteAclForUserRemoved(std::string localUdid, int32_t userId, std::vector<std::string> peerUdids, 185 std::multimap<std::string, int32_t> &peerUserIdMap, DmOfflineParam &offlineParam); 186 DM_EXPORT void DeleteAclForRemoteUserRemoved(std::string peerUdid, 187 int32_t peerUserId, std::vector<int32_t> &userIds, DmOfflineParam &offlineParam); 188 DM_EXPORT DmOfflineParam DeleteAccessControlList(const std::string &pkgName, 189 const std::string &localDeviceId, const std::string &remoteDeviceId, int32_t bindLevel, 190 const std::string &extra); 191 DM_EXPORT std::vector<OHOS::DistributedHardware::ProcessInfo> 192 GetProcessInfoFromAclByUserId(const std::string &localDeviceId, const std::string &targetDeviceId, 193 int32_t userId); 194 DM_EXPORT DistributedDeviceProfile::AccessControlProfile GetAccessControlProfileByAccessControlId( 195 int64_t accessControlId); 196 DM_EXPORT std::vector<std::pair<int64_t, int64_t>> GetAgentToProxyVecFromAclByUserId( 197 const std::string &localDeviceId, const std::string &targetDeviceId, int32_t userId); 198 DM_EXPORT bool CheckSrcDevIdInAclForDevBind(const std::string &pkgName, 199 const std::string &deviceId); 200 DM_EXPORT bool CheckSinkDevIdInAclForDevBind(const std::string &pkgName, 201 const std::string &deviceId); 202 203 DM_EXPORT uint32_t DeleteTimeOutAcl(const std::string &deviceId, DmOfflineParam &offlineParam); 204 DM_EXPORT int32_t GetTrustNumber(const std::string &deviceId); 205 bool CheckDevIdInAclForDevBind(const std::string &pkgName, const std::string &deviceId); 206 std::vector<int32_t> CompareBindType(std::vector<DistributedDeviceProfile::AccessControlProfile> profiles, 207 std::string pkgName, std::vector<int32_t> &sinkBindType, std::string localDeviceId, std::string targetDeviceId); 208 DM_EXPORT int32_t IsSameAccount(const std::string &udid); 209 DM_EXPORT bool CheckAccessControl(const DmAccessCaller &caller, 210 const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); 211 DM_EXPORT bool CheckIsSameAccount(const DmAccessCaller &caller, 212 const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); 213 DM_EXPORT void DeleteAccessControlList(const std::string &udid); 214 DM_EXPORT int32_t GetBindLevel(const std::string &pkgName, 215 const std::string &localUdid, const std::string &udid, uint64_t &tokenId); 216 std::map<std::string, int32_t> GetDeviceIdAndBindLevel(std::vector<int32_t> userIds, const std::string &localUdid); 217 DM_EXPORT std::vector<std::string> GetDeviceIdAndUdidListByTokenId(const std::vector<int32_t> &userIds, 218 const std::string &localUdid, int32_t tokenId); 219 DM_EXPORT std::multimap<std::string, int32_t> GetDeviceIdAndUserId( 220 int32_t userId, const std::string &accountId, const std::string &localUdid); 221 int32_t HandleAccountLogoutEvent(int32_t remoteUserId, const std::string &remoteAccountHash, 222 const std::string &remoteUdid, const std::string &localUdid); 223 224 DM_EXPORT int32_t HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, 225 const std::string &localUdid, DmOfflineParam &offlineParam); 226 DM_EXPORT DmOfflineParam HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, 227 int32_t tokenId, const std::string &localUdid); 228 DM_EXPORT DmOfflineParam HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, 229 int32_t tokenId, const std::string &localUdid, int32_t peerTokenId); 230 DM_EXPORT std::vector<DistributedDeviceProfile::AccessControlProfile> 231 GetAllAccessControlProfile(); 232 DM_EXPORT std::vector<DistributedDeviceProfile::AccessControlProfile> GetAllAclIncludeLnnAcl(); 233 DM_EXPORT void DeleteAccessControlById(int64_t accessControlId); 234 DM_EXPORT int32_t HandleUserSwitched(const std::string &localUdid, 235 const std::vector<std::string> &deviceVec, int32_t currentUserId, int32_t beforeUserId); 236 DM_EXPORT int32_t HandleUserSwitched(const std::string &localUdid, 237 const std::vector<std::string> &deviceVec, const std::vector<int32_t> &foregroundUserIds, 238 const std::vector<int32_t> &backgroundUserIds); 239 bool CheckAclStatusAndForegroundNotMatch(const std::string &localUdid, 240 const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds); 241 DM_EXPORT void HandleUserSwitched( 242 const std::vector<DistributedDeviceProfile::AccessControlProfile> &activeProfiles, 243 const std::vector<DistributedDeviceProfile::AccessControlProfile> &inActiveProfiles); 244 DM_EXPORT void HandleSyncForegroundUserIdEvent( 245 const std::vector<int32_t> &remoteUserIds, const std::string &remoteUdid, 246 const std::vector<int32_t> &localUserIds, std::string &localUdid); 247 std::vector<ProcessInfo> GetOfflineProcessInfo(std::string &localUdid, const std::vector<int32_t> &localUserIds, 248 const std::string &remoteUdid, const std::vector<int32_t> &remoteUserIds); 249 DM_EXPORT std::map<int32_t, int32_t> GetUserIdAndBindLevel( 250 const std::string &localUdid, const std::string &peerUdid); 251 DM_EXPORT void UpdateACL(std::string &localUdid, const std::vector<int32_t> &localUserIds, 252 const std::string &remoteUdid, const std::vector<int32_t> &remoteFrontUserIds, 253 const std::vector<int32_t> &remoteBackUserIds, DmOfflineParam &offlineParam); 254 DM_EXPORT std::multimap<std::string, int32_t> GetDevIdAndUserIdByActHash( 255 const std::string &localUdid, const std::string &peerUdid, int32_t peerUserId, 256 const std::string &peerAccountHash); 257 DM_EXPORT std::multimap<std::string, int32_t> GetDeviceIdAndUserId( 258 const std::string &localUdid, int32_t localUserId); 259 DM_EXPORT void HandleSyncBackgroundUserIdEvent( 260 const std::vector<int32_t> &remoteUserIds, const std::string &remoteUdid, 261 const std::vector<int32_t> &localUserIds, std::string &localUdid); 262 DM_EXPORT void HandleDeviceUnBind(int32_t bindType, const std::string &peerUdid, 263 const std::string &localUdid, int32_t localUserId, const std::string &localAccountId); 264 265 DM_EXPORT int32_t DeleteSessionKey(int32_t userId, int32_t sessionKeyId); 266 DM_EXPORT int32_t GetSessionKey(int32_t userId, int32_t sessionKeyId, 267 std::vector<unsigned char> &sessionKeyArray); 268 DM_EXPORT int32_t SubscribeDeviceProfileInited( 269 sptr<DistributedDeviceProfile::IDpInitedCallback> dpInitedCallback); 270 DM_EXPORT int32_t UnSubscribeDeviceProfileInited(); 271 DM_EXPORT int32_t PutAllTrustedDevices( 272 const std::vector<DistributedDeviceProfile::TrustedDeviceInfo> &deviceInfos); 273 DM_EXPORT int32_t CheckDeviceInfoPermission(const std::string &localUdid, 274 const std::string &peerDeviceId); 275 DM_EXPORT int32_t UpdateAclDeviceName(const std::string &udid, 276 const std::string &newDeviceName); 277 DM_EXPORT int32_t PutLocalServiceInfo( 278 const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo); 279 DM_EXPORT int32_t DeleteLocalServiceInfo(const std::string &bundleName, 280 int32_t pinExchangeType); 281 DM_EXPORT int32_t UpdateLocalServiceInfo( 282 const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo); 283 DM_EXPORT int32_t GetLocalServiceInfoByBundleNameAndPinExchangeType( 284 const std::string &bundleName, int32_t pinExchangeType, 285 DistributedDeviceProfile::LocalServiceInfo &localServiceInfo); 286 DM_EXPORT int32_t PutSessionKey(int32_t userId, const std::vector<unsigned char> &sessionKeyArray, 287 int32_t &sessionKeyId); 288 int32_t HandleUserStop(int32_t stopUserId, const std::string &stopEventUdid); 289 int32_t HandleUserStop(int32_t stopUserId, const std::string &localUdid, 290 const std::vector<std::string> &acceptEventUdids); 291 DM_EXPORT std::string IsAuthNewVersion(int32_t bindLevel, std::string localUdid, std::string remoteUdid, 292 int32_t tokenId, int32_t userId); 293 std::vector<DistributedDeviceProfile::AccessControlProfile> GetAclProfileByDeviceIdAndUserId( 294 const std::string &deviceId, int32_t userId, const std::string &remoteDeviceId); 295 DM_EXPORT std::vector<DistributedDeviceProfile::AccessControlProfile> GetAclList(const std::string localUdid, 296 int32_t localUserId, const std::string remoteUdid, int32_t remoteUserId); 297 DM_EXPORT bool ChecksumAcl(DistributedDeviceProfile::AccessControlProfile &acl, 298 std::vector<std::string> &acLStrList); 299 DM_EXPORT std::string AccessToStr(DistributedDeviceProfile::AccessControlProfile acl); 300 DM_EXPORT int32_t GetVersionByExtra(std::string &extraInfo, std::string &dmVersion); 301 DM_EXPORT void GetAllVerionAclMap(DistributedDeviceProfile::AccessControlProfile &acl, 302 std::map<std::string, std::vector<std::string>> &aclMap, std::string dmVersion = ""); 303 void GenerateAclHash(DistributedDeviceProfile::AccessControlProfile &acl, 304 std::map<std::string, std::vector<std::string>> &aclMap, const std::string &dmVersion); 305 DM_EXPORT int32_t CheckIsSameAccountByUdidHash(const std::string &udidHash); 306 DM_EXPORT int32_t GetAclListHashStr(const DevUserInfo &localDevUserInfo, 307 const DevUserInfo &remoteDevUserInfo, std::string &aclListHash, std::string dmVersion = ""); 308 DM_EXPORT bool IsLnnAcl(const DistributedDeviceProfile::AccessControlProfile &profile); 309 DM_EXPORT void CacheAcerAclId(const DistributedDeviceProfile::AccessControlProfile &profile, 310 std::vector<DmAclIdParam> &aclInfos); 311 DM_EXPORT void CacheAceeAclId(const DistributedDeviceProfile::AccessControlProfile &profile, 312 std::vector<DmAclIdParam> &aclInfos); 313 DM_EXPORT void AclHashItemToJson(JsonItemObject &itemObject, const AclHashItem &value); 314 DM_EXPORT void AclHashVecToJson(JsonItemObject &itemObject, const std::vector<AclHashItem> &values); 315 DM_EXPORT void AclHashItemFromJson(const JsonItemObject &itemObject, AclHashItem &value); 316 DM_EXPORT void AclHashVecFromJson(const JsonItemObject &itemObject, std::vector<AclHashItem> &values); 317 void DeleteCacheAcl(std::vector<int64_t> delAclIdVec, 318 std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles); 319 DM_EXPORT int32_t HandleAccountCommonEvent(const std::string &localUdid, const std::vector<std::string> &deviceVec, 320 const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds); 321 DM_EXPORT bool CheckSrcAccessControl(const DmAccessCaller &caller, const std::string &srcUdid, 322 const DmAccessCallee &callee, const std::string &sinkUdid); 323 DM_EXPORT bool CheckSinkAccessControl(const DmAccessCaller &caller, const std::string &srcUdid, 324 const DmAccessCallee &callee, const std::string &sinkUdid); 325 DM_EXPORT bool CheckSrcIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, 326 const DmAccessCallee &callee, const std::string &sinkUdid); 327 DM_EXPORT bool CheckSinkIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, 328 const DmAccessCallee &callee, const std::string &sinkUdid); 329 DM_EXPORT void DeleteHoDevice(const std::string &peerUdid, const std::vector<int32_t> &foreGroundUserIds, 330 const std::vector<int32_t> &backGroundUserIds); 331 DM_EXPORT bool IsAllowAuthAlways(const std::string &localUdid, int32_t userId, const std::string &peerUdid, 332 const std::string &pkgName, int64_t tokenId); 333 334 private: 335 int32_t HandleDmAuthForm(DistributedDeviceProfile::AccessControlProfile profiles, DmDiscoveryInfo discoveryInfo); 336 void GetParamBindTypeVec(DistributedDeviceProfile::AccessControlProfile profiles, std::string requestDeviceId, 337 std::vector<int32_t> &bindTypeVec, std::string trustUdid); 338 void ProcessBindType(DistributedDeviceProfile::AccessControlProfile profiles, std::string localDeviceId, 339 std::vector<int32_t> &sinkBindType, std::vector<int32_t> &bindTypeIndex, 340 uint32_t index, std::string targetDeviceId); 341 bool CheckAppLevelAccess(const DistributedDeviceProfile::AccessControlProfile &profile, 342 const DmAccessCaller &caller, const DmAccessCallee &callee); 343 bool CheckSinkShareType(const DistributedDeviceProfile::AccessControlProfile &profile, 344 const int32_t &userId, const std::string &deviceId, const std::string &trustDeviceId, const int32_t &bindType); 345 std::unordered_map<std::string, DmAuthForm> GetAuthFormMap(const std::string &pkgName, const std::string &deviceId, 346 const std::vector<DistributedDeviceProfile::AccessControlProfile> &profilesFilter, const int32_t &userId); 347 int32_t GetAuthForm(DistributedDeviceProfile::AccessControlProfile profiles, const std::string &trustDev, 348 const std::string &reqDev); 349 bool CheckAuthFormProxyTokenId(const std::string pkgName, const std::string &extraStr); 350 int32_t CheckAuthForm(DmAuthForm form, DistributedDeviceProfile::AccessControlProfile profiles, 351 DmDiscoveryInfo discoveryInfo); 352 bool SingleUserProcess(const DistributedDeviceProfile::AccessControlProfile &profile, const DmAccessCaller &caller, 353 const DmAccessCallee &callee); 354 void DeleteAppBindLevel(DmOfflineParam &offlineParam, const std::string &pkgName, 355 const std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles, const std::string &localUdid, 356 const std::string &remoteUdid); 357 void DeleteAppBindLevel(DmOfflineParam &offlineParam, const std::string &pkgName, 358 const std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles, const std::string &localUdid, 359 const std::string &remoteUdid, const std::string &extra); 360 void DeleteDeviceBindLevel(DmOfflineParam &offlineParam, 361 const std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles, const std::string &localUdid, 362 const std::string &remoteUdid); 363 void DeleteServiceBindLevel(DmOfflineParam &offlineParam, const std::string &pkgName, 364 const std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles, const std::string &localUdid, 365 const std::string &remoteUdid); 366 void UpdateBindType(const std::string &udid, int32_t compareParam, std::map<std::string, int32_t> &deviceMap); 367 std::vector<DistributedDeviceProfile::AccessControlProfile> GetAclProfileByUserId(const std::string &localUdid, 368 int32_t userId, const std::string &remoteUdid); 369 void DeleteSigTrustACL(DistributedDeviceProfile::AccessControlProfile profile, const std::string &remoteUdid, 370 const std::vector<int32_t> &remoteFrontUserIds, const std::vector<int32_t> &remoteBackUserIds, 371 DmOfflineParam &offlineParam); 372 void UpdatePeerUserId(DistributedDeviceProfile::AccessControlProfile profile, std::string &localUdid, 373 const std::vector<int32_t> &localUserIds, const std::string &remoteUdid, 374 const std::vector<int32_t> &remoteFrontUserIds); 375 void SetProcessInfoPkgName(const DistributedDeviceProfile::AccessControlProfile &acl, ProcessInfo &processInfo); 376 bool CheckAclStatusNotMatch(const DistributedDeviceProfile::AccessControlProfile &profile, 377 const std::string &localUdid, const std::vector<int32_t> &foregroundUserIds, 378 const std::vector<int32_t> &backgroundUserIds); 379 380 void FilterNeedDeleteACLInfos(std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles, 381 const std::string &localUdid, const uint32_t localTokenId, 382 const std::string &remoteUdid, const std::string &extra, DmOfflineParam &offlineParam); 383 bool FindLeftAcl(const DistributedDeviceProfile::AccessControlProfile &acl, 384 const std::string &localUdid, const std::string &remoteUdid, DmOfflineParam &offlineParam); 385 bool FindUserAcl(const DistributedDeviceProfile::AccessControlProfile &acl, 386 const std::string &localUdid, const std::string &remoteUdid, DmOfflineParam &offlineParam); 387 bool FindLnnAcl(const DistributedDeviceProfile::AccessControlProfile &acl, 388 const std::string &localUdid, const std::string &remoteUdid, DmOfflineParam &offlineParam); 389 bool FindTargetAcl(const DistributedDeviceProfile::AccessControlProfile &acl, 390 const std::string &localUdid, const uint32_t localTokenId, 391 const std::string &remoteUdid, const uint32_t peerTokenId, 392 DmOfflineParam &offlineParam); 393 bool FindTargetAcl(const DistributedDeviceProfile::AccessControlProfile &acl, 394 const std::string &localUdid, const int32_t remoteUserId, const std::string &remoteUdid, 395 const int32_t tokenId, const int32_t peerTokenId, DmOfflineParam &offlineParam); 396 bool FindTargetAcl(const DistributedDeviceProfile::AccessControlProfile &acl, 397 const std::string &localUdid, const int32_t remoteUserId, const std::string &remoteUdid, 398 const int32_t remoteTokenId, DmOfflineParam &offlineParam); 399 400 std::string GetAppServiceAuthVersionInfo(std::string localUdid, std::string remoteUdid, int32_t tokenId, 401 int32_t userId, std::vector<DistributedDeviceProfile::AccessControlProfile> profiles); 402 std::string GetDeviceAuthVersionInfo(std::string localUdid, std::string remoteUdid, 403 std::vector<DistributedDeviceProfile::AccessControlProfile> profiles); 404 405 bool CacheLnnAcl(DistributedDeviceProfile::AccessControlProfile profile, const std::string &localUdid, 406 DmAclIdParam &dmAclIdParam); 407 void CheckLastLnnAcl(const std::string &localDeviceId, int32_t userId, const std::string &remoteDeviceId, 408 DmOfflineParam &offlineParam, std::vector<DistributedDeviceProfile::AccessControlProfile> &profiles); 409 bool CheckSrcAcuntAccessControl(const DistributedDeviceProfile::AccessControlProfile &profile, 410 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 411 const std::string &sinkUdid); 412 bool CheckSinkAcuntAccessControl(const DistributedDeviceProfile::AccessControlProfile &profile, 413 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 414 const std::string &sinkUdid); 415 bool CheckSrcShareAccessControl(const DistributedDeviceProfile::AccessControlProfile &profile, 416 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 417 const std::string &sinkUdid); 418 bool CheckSinkShareAccessControl(const DistributedDeviceProfile::AccessControlProfile &profile, 419 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 420 const std::string &sinkUdid); 421 bool CheckSrcP2PAccessControl(const DistributedDeviceProfile::AccessControlProfile &profile, 422 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 423 const std::string &sinkUdid); 424 bool CheckSinkP2PAccessControl(const DistributedDeviceProfile::AccessControlProfile &profile, 425 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 426 const std::string &sinkUdid); 427 bool CheckSinkUserP2PAcl(const DistributedDeviceProfile::AccessControlProfile &profile, 428 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 429 const std::string &sinkUdid); 430 bool CheckSinkAppOrServiceP2PAcl(const DistributedDeviceProfile::AccessControlProfile &profile, 431 const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, 432 const std::string &sinkUdid); 433 bool CheckExtWhiteList(const std::string &bundleName); 434 }; 435 436 extern "C" IDeviceProfileConnector *CreateDpConnectorInstance(); 437 using CreateDpConnectorFuncPtr = IDeviceProfileConnector *(*)(void); 438 } // namespace DistributedHardware 439 } // namespace OHOS 440 #endif // OHOS_DM_DEVICEPROFILE_CONNECTOR_H 441