diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 5053b051295b754d2e02c15a9273b5aeb307b03e..2615f88a794d0b085c3e2453e87c4a3a19507c5a 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -230,6 +230,7 @@ constexpr const char* PARAM_KEY_CONN_ADDR_TYPE = "CONN_ADDR_TYPE"; constexpr const char* PARAM_KEY_PUBLISH_ID = "PUBLISH_ID"; constexpr const char* PARAM_KEY_SUBSCRIBE_ID = "SUBSCRIBE_ID"; constexpr const char* PARAM_KEY_TARGET_PKG_NAME = "TARGET_PKG_NAME"; +constexpr const char* PARAM_KEY_PEER_BUNDLE_NAME = "PEER_BUNDLE_NAME"; constexpr const char* PARAM_KEY_DISC_FREQ = "DISC_FREQ"; constexpr const char* PARAM_KEY_DISC_MEDIUM = "DISC_MEDIUM"; constexpr const char* PARAM_KEY_DISC_CAPABILITY = "DISC_CAPABILITY"; diff --git a/common/include/ipc/model/ipc_unbind_device_req.h b/common/include/ipc/model/ipc_unbind_device_req.h index 0777c871e2b9463c9606f7cb90c82931949a8558..7700d47e16d210cc6b1625f279542c858a53b549 100644 --- a/common/include/ipc/model/ipc_unbind_device_req.h +++ b/common/include/ipc/model/ipc_unbind_device_req.h @@ -44,8 +44,19 @@ public: deviceId_ = deviceId; } + const std::string &GetExtraInfo() const + { + return extra_; + } + + void SetExtraInfo(const std::string &extra) + { + extra_ = extra; + } + private: std::string deviceId_; + std::string extra_ = ""; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/commondependency/include/deviceprofile_connector.h b/commondependency/include/deviceprofile_connector.h index 7b746adc91fd4672e0d2638e6f373600f62952aa..793d0e7cbbe368fe9a910dbfdf2f22e0449745f2 100644 --- a/commondependency/include/deviceprofile_connector.h +++ b/commondependency/include/deviceprofile_connector.h @@ -107,6 +107,7 @@ public: const std::string &deviceId); std::vector GetBindTypeByPkgName(std::string pkgName, std::string requestDeviceId, std::string trustUdid); + uint64_t GetTokenIdByNameAndDeviceId(std::string pkgName, std::string requestDeviceId); std::vector SyncAclByBindType(std::string pkgName, std::vector bindTypeVec, std::string localDeviceId, std::string targetDeviceId); int32_t GetDeviceAclParam(DmDiscoveryInfo discoveryInfo, bool &isOnline, int32_t &authForm); @@ -114,7 +115,7 @@ public: const std::string &peerUdid, int32_t peerUserId); void DeleteAclForUserRemoved(std::string localUdid, int32_t userId); DmOfflineParam DeleteAccessControlList(const std::string &pkgName, const std::string &localDeviceId, - const std::string &remoteDeviceId, int32_t bindLevel); + const std::string &remoteDeviceId, int32_t bindLevel, const std::string &extra); std::vector GetProcessInfoFromAclByUserId(const std::string &localDeviceId, const std::string &targetDeviceId, int32_t userId); bool CheckIdenticalAccount(int32_t userId, const std::string &accountId); @@ -141,6 +142,8 @@ public: int32_t HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, const std::string &localUdid); OHOS::DistributedHardware::ProcessInfo HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, int32_t tokenId, const std::string &localUdid); + OHOS::DistributedHardware::ProcessInfo HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, + int32_t tokenId, const std::string &localUdid, int32_t peerTokenId); std::vector GetAllAccessControlProfile(); void DeleteAccessControlById(int64_t accessControlId); int32_t HandleUserSwitched(const std::string &localUdid, const std::vector &deviceVec, @@ -166,10 +169,11 @@ public: private: int32_t HandleDmAuthForm(DistributedDeviceProfile::AccessControlProfile profiles, DmDiscoveryInfo discoveryInfo); - void GetParamBindTypeVec(DistributedDeviceProfile::AccessControlProfile profiles, std::string pkgName, - std::string requestDeviceId, std::vector &bindTypeVec); - void ProcessBindType(DistributedDeviceProfile::AccessControlProfile profiles, DmDiscoveryInfo paramInfo, - std::vector &sinkBindType, std::vector &bindTypeIndex, uint32_t index); + void GetParamBindTypeVec(DistributedDeviceProfile::AccessControlProfile profiles, std::string requestDeviceId, + std::vector &bindTypeVec, std::string trustUdid); + void ProcessBindType(DistributedDeviceProfile::AccessControlProfile profiles, std::string localDeviceId, + std::vector &sinkBindType, std::vector &bindTypeIndex, + uint32_t index, std::string targetDeviceId); int32_t GetAuthForm(DistributedDeviceProfile::AccessControlProfile profiles, const std::string &trustDev, const std::string &reqDev); int32_t CheckAuthForm(DmAuthForm form, DistributedDeviceProfile::AccessControlProfile profiles, @@ -179,6 +183,9 @@ private: void DeleteAppBindLevel(DmOfflineParam &offlineParam, const std::string &pkgName, const std::vector &profiles, const std::string &localUdid, const std::string &remoteUdid); + void DeleteAppBindLevel(DmOfflineParam &offlineParam, const std::string &pkgName, + const std::vector &profiles, const std::string &localUdid, + const std::string &remoteUdid, const std::string &extra); void DeleteDeviceBindLevel(DmOfflineParam &offlineParam, const std::vector &profiles, const std::string &localUdid, const std::string &remoteUdid); diff --git a/commondependency/src/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp index e5cb7d3e132d2dc70b563fb2f965d1a3135887ff..806d77066b67dc13532ac02681bfc9f252e09433 100644 --- a/commondependency/src/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -258,13 +258,32 @@ std::vector DeviceProfileConnector::GetBindTypeByPkgName(std::string pk if (trustUdid != item.GetTrustDeviceId() || item.GetStatus() != ACTIVE) { continue; } - GetParamBindTypeVec(item, pkgName, requestDeviceId, bindTypeVec); + GetParamBindTypeVec(item, requestDeviceId, bindTypeVec, trustUdid); } return bindTypeVec; } -void DeviceProfileConnector::GetParamBindTypeVec(AccessControlProfile profiles, std::string pkgName, - std::string requestDeviceId, std::vector &bindTypeVec) +uint64_t DeviceProfileConnector::GetTokenIdByNameAndDeviceId(std::string pkgName, std::string requestDeviceId) +{ + std::vector profiles = GetAccessControlProfile(); + uint64_t peerTokenId = 0; + for (auto &item : profiles) { + if (item.GetAccesser().GetAccesserBundleName() == pkgName && + item.GetAccesser().GetAccesserDeviceId() == requestDeviceId) { + peerTokenId = static_cast(item.GetAccesser().GetAccesserTokenId()); + break; + } + if (item.GetAccessee().GetAccesseeBundleName() == pkgName && + item.GetAccessee().GetAccesseeDeviceId() == requestDeviceId) { + peerTokenId = static_cast(item.GetAccessee().GetAccesseeTokenId()); + break; + } + } + return peerTokenId; +} + +void DeviceProfileConnector::GetParamBindTypeVec(AccessControlProfile profiles, std::string requestDeviceId, + std::vector &bindTypeVec, std::string trustUdid) { if (profiles.GetBindType() == DM_IDENTICAL_ACCOUNT) { bindTypeVec.push_back(IDENTICAL_ACCOUNT_TYPE); @@ -274,12 +293,12 @@ void DeviceProfileConnector::GetParamBindTypeVec(AccessControlProfile profiles, bindTypeVec.push_back(DEVICE_PEER_TO_PEER_TYPE); } if (profiles.GetBindLevel() == APP) { - if (profiles.GetAccesser().GetAccesserBundleName() == pkgName && - profiles.GetAccesser().GetAccesserDeviceId() == requestDeviceId) { + if (profiles.GetAccesser().GetAccesserDeviceId() == trustUdid && + profiles.GetAccessee().GetAccesseeDeviceId() == requestDeviceId) { bindTypeVec.push_back(APP_PEER_TO_PEER_TYPE); } - if ((profiles.GetAccessee().GetAccesseeBundleName() == pkgName && - profiles.GetAccessee().GetAccesseeDeviceId() == requestDeviceId)) { + if (profiles.GetAccessee().GetAccesseeDeviceId() == trustUdid && + profiles.GetAccesser().GetAccesserDeviceId() == requestDeviceId) { bindTypeVec.push_back(APP_PEER_TO_PEER_TYPE); } } @@ -289,12 +308,12 @@ void DeviceProfileConnector::GetParamBindTypeVec(AccessControlProfile profiles, bindTypeVec.push_back(DEVICE_ACROSS_ACCOUNT_TYPE); } if (profiles.GetBindLevel() == APP) { - if (profiles.GetAccesser().GetAccesserBundleName() == pkgName && - profiles.GetAccesser().GetAccesserDeviceId() == requestDeviceId) { + if (profiles.GetAccesser().GetAccesserDeviceId() == trustUdid && + profiles.GetAccessee().GetAccesseeDeviceId() == requestDeviceId) { bindTypeVec.push_back(APP_ACROSS_ACCOUNT_TYPE); } - if ((profiles.GetAccessee().GetAccesseeBundleName() == pkgName && - profiles.GetAccessee().GetAccesseeDeviceId() == requestDeviceId)) { + if (profiles.GetAccessee().GetAccesseeDeviceId() == trustUdid && + profiles.GetAccesser().GetAccesserDeviceId() == requestDeviceId) { bindTypeVec.push_back(APP_ACROSS_ACCOUNT_TYPE); } } @@ -313,13 +332,13 @@ std::vector DeviceProfileConnector::CompareBindType(std::vector &sinkBindType, std::vector &bindTypeIndex, uint32_t index) +void DeviceProfileConnector::ProcessBindType(AccessControlProfile profiles, std::string localDeviceId, + std::vector &sinkBindType, std::vector &bindTypeIndex, uint32_t index, std::string targetDeviceId) { if (profiles.GetBindType() == DM_IDENTICAL_ACCOUNT) { sinkBindType.push_back(IDENTICAL_ACCOUNT_TYPE); @@ -331,13 +350,13 @@ void DeviceProfileConnector::ProcessBindType(AccessControlProfile profiles, DmDi bindTypeIndex.push_back(index); } if (profiles.GetBindLevel() == APP) { - if (profiles.GetAccesser().GetAccesserBundleName() == paramInfo.pkgname && - profiles.GetAccesser().GetAccesserDeviceId() == paramInfo.localDeviceId) { + if (profiles.GetAccesser().GetAccesserDeviceId() == targetDeviceId && + profiles.GetAccessee().GetAccesseeDeviceId() == localDeviceId) { sinkBindType.push_back(APP_PEER_TO_PEER_TYPE); bindTypeIndex.push_back(index); } - if (profiles.GetAccessee().GetAccesseeBundleName() == paramInfo.pkgname && - profiles.GetAccessee().GetAccesseeDeviceId() == paramInfo.localDeviceId) { + if (profiles.GetAccessee().GetAccesseeDeviceId() == targetDeviceId && + profiles.GetAccesser().GetAccesserDeviceId() == localDeviceId) { sinkBindType.push_back(APP_PEER_TO_PEER_TYPE); bindTypeIndex.push_back(index); } @@ -349,13 +368,13 @@ void DeviceProfileConnector::ProcessBindType(AccessControlProfile profiles, DmDi bindTypeIndex.push_back(index); } if (profiles.GetBindLevel() == APP) { - if (profiles.GetAccesser().GetAccesserBundleName() == paramInfo.pkgname && - profiles.GetAccesser().GetAccesserDeviceId() == paramInfo.localDeviceId) { + if (profiles.GetAccesser().GetAccesserDeviceId() == targetDeviceId && + profiles.GetAccessee().GetAccesseeDeviceId() == localDeviceId) { sinkBindType.push_back(APP_ACROSS_ACCOUNT_TYPE); bindTypeIndex.push_back(index); } - if (profiles.GetAccessee().GetAccesseeBundleName() == paramInfo.pkgname && - profiles.GetAccessee().GetAccesseeDeviceId() == paramInfo.localDeviceId) { + if (profiles.GetAccessee().GetAccesseeDeviceId() == targetDeviceId && + profiles.GetAccesser().GetAccesserDeviceId() == localDeviceId) { sinkBindType.push_back(APP_ACROSS_ACCOUNT_TYPE); bindTypeIndex.push_back(index); } @@ -373,6 +392,7 @@ std::vector DeviceProfileConnector::SyncAclByBindType(std::string pkgNa std::vector bindType; std::vector bindTypeIndex = CompareBindType(profiles, pkgName, sinkBindType, localDeviceId, targetDeviceId); + LOGI("SyncAclByBindType sinkBindType size is %{public}zu", sinkBindType.size()); for (uint32_t sinkIndex = 0; sinkIndex < sinkBindType.size(); sinkIndex++) { bool deleteAclFlag = true; for (uint32_t srcIndex = 0; srcIndex < bindTypeVec.size(); srcIndex++) { @@ -384,6 +404,7 @@ std::vector DeviceProfileConnector::SyncAclByBindType(std::string pkgNa if (deleteAclFlag) { int32_t deleteIndex = profiles[bindTypeIndex[sinkIndex]].GetAccessControlId(); DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(deleteIndex); + LOGI("SyncAclByBindType deleteAcl index is %{public}d", deleteIndex); } } return bindType; @@ -529,7 +550,8 @@ void DeviceProfileConnector::DeleteAccessControlList(const std::string &udid) } DmOfflineParam DeviceProfileConnector::DeleteAccessControlList(const std::string &pkgName, - const std::string &localDeviceId, const std::string &remoteDeviceId, int32_t bindLevel) + const std::string &localDeviceId, const std::string &remoteDeviceId, + int32_t bindLevel, const std::string &extra) { LOGI("pkgName %{public}s, localDeviceId %{public}s, remoteDeviceId %{public}s, bindLevel %{public}d.", pkgName.c_str(), GetAnonyString(localDeviceId).c_str(), GetAnonyString(remoteDeviceId).c_str(), bindLevel); @@ -546,7 +568,11 @@ DmOfflineParam DeviceProfileConnector::DeleteAccessControlList(const std::string } switch (bindLevel) { case APP: - DeleteAppBindLevel(offlineParam, pkgName, profiles, localDeviceId, remoteDeviceId); + if (extra == "") { + DeleteAppBindLevel(offlineParam, pkgName, profiles, localDeviceId, remoteDeviceId); + } else { + DeleteAppBindLevel(offlineParam, pkgName, profiles, localDeviceId, remoteDeviceId, extra); + } break; case SERVICE: DeleteServiceBindLevel(offlineParam, pkgName, profiles, localDeviceId, remoteDeviceId); @@ -605,6 +631,56 @@ void DeviceProfileConnector::DeleteAppBindLevel(DmOfflineParam &offlineParam, co offlineParam.leftAclNumber = bindNums - deleteNums; } +void DeviceProfileConnector::DeleteAppBindLevel(DmOfflineParam &offlineParam, const std::string &pkgName, + const std::vector &profiles, const std::string &localUdid, + const std::string &remoteUdid, const std::string &extra) +{ + LOGI("DeviceProfileConnector::DeleteAppBindLevel extra %{public}s", extra.c_str()); + int32_t bindNums = 0; + int32_t deleteNums = 0; + std::string peerBundleName = extra; + for (auto &item : profiles) { + if (item.GetTrustDeviceId() != remoteUdid || item.GetBindType() == DM_IDENTICAL_ACCOUNT || + item.GetBindLevel() != APP) { + continue; + } + bindNums++; + if (item.GetAccesser().GetAccesserBundleName() == pkgName && + item.GetAccessee().GetAccesseeBundleName() == peerBundleName && + item.GetAccesser().GetAccesserDeviceId() == localUdid && + item.GetAccessee().GetAccesseeDeviceId() == remoteUdid) { + DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(item.GetAccessControlId()); + deleteNums++; + offlineParam.bindType = APP; + ProcessInfo processInfo; + processInfo.pkgName = item.GetAccesser().GetAccesserBundleName(); + processInfo.userId = item.GetAccesser().GetAccesserUserId(); + offlineParam.processVec.push_back(processInfo); + LOGI("Src delete acl pkgName %{public}s, bindType %{public}d, localUdid %{public}s, remoteUdid %{public}s", + pkgName.c_str(), item.GetBindType(), GetAnonyString(localUdid).c_str(), + GetAnonyString(remoteUdid).c_str()); + continue; + } + if (item.GetAccessee().GetAccesseeBundleName() == pkgName && + item.GetAccesser().GetAccesserBundleName() == peerBundleName && + item.GetAccessee().GetAccesseeDeviceId() == localUdid && + item.GetAccesser().GetAccesserDeviceId() == remoteUdid) { + DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(item.GetAccessControlId()); + deleteNums++; + offlineParam.bindType = APP; + ProcessInfo processInfo; + processInfo.pkgName = item.GetAccessee().GetAccesseeBundleName(); + processInfo.userId = item.GetAccessee().GetAccesseeUserId(); + offlineParam.processVec.push_back(processInfo); + LOGI("Sink delete acl pkgName %{public}s, bindType %{public}d, localUdid %{public}s, remoteUdid %{public}s", + pkgName.c_str(), item.GetBindType(), GetAnonyString(localUdid).c_str(), + GetAnonyString(remoteUdid).c_str()); + continue; + } + } + offlineParam.leftAclNumber = bindNums - deleteNums; +} + void DeviceProfileConnector::DeleteDeviceBindLevel(DmOfflineParam &offlineParam, const std::vector &profiles, const std::string &localUdid, const std::string &remoteUdid) { @@ -869,7 +945,8 @@ bool DeviceProfileConnector::SingleUserProcess(const DistributedDeviceProfile::A if (profile.GetBindLevel() == DEVICE || profile.GetBindLevel() == SERVICE) { ret = true; } else if (profile.GetBindLevel() == APP && - profile.GetAccesser().GetAccesserBundleName() == caller.pkgName) { + (profile.GetAccesser().GetAccesserBundleName() == caller.pkgName || + profile.GetAccessee().GetAccesseeBundleName() == caller.pkgName)) { ret = true; } break; @@ -877,7 +954,8 @@ bool DeviceProfileConnector::SingleUserProcess(const DistributedDeviceProfile::A if (profile.GetBindLevel() == DEVICE || profile.GetBindLevel() == SERVICE) { ret = true; } else if (profile.GetBindLevel() == APP && - profile.GetAccesser().GetAccesserBundleName() == caller.pkgName) { + (profile.GetAccesser().GetAccesserBundleName() == caller.pkgName || + profile.GetAccessee().GetAccesseeBundleName() == caller.pkgName)) { ret = true; } break; @@ -1100,6 +1178,44 @@ OHOS::DistributedHardware::ProcessInfo DeviceProfileConnector::HandleAppUnBindEv return processInfo; } +OHOS::DistributedHardware::ProcessInfo DeviceProfileConnector::HandleAppUnBindEvent(int32_t remoteUserId, + const std::string &remoteUdid, int32_t tokenId, const std::string &localUdid, int32_t peerTokenId) +{ + LOGI("RemoteUserId %{public}d, remoteUdid %{public}s, tokenId %{public}d, localUdid %{public}s.", + remoteUserId, GetAnonyString(remoteUdid).c_str(), tokenId, GetAnonyString(localUdid).c_str()); + std::vector profiles = GetAccessControlProfile(); + ProcessInfo processInfo; + for (const auto &item : profiles) { + if (item.GetTrustDeviceId() != remoteUdid || item.GetBindType() == DM_IDENTICAL_ACCOUNT || + item.GetBindLevel() != APP) { + continue; + } + if (item.GetAccesser().GetAccesserUserId() == remoteUserId && + item.GetAccesser().GetAccesserDeviceId() == remoteUdid && + static_cast(item.GetAccesser().GetAccesserTokenId()) == tokenId && + static_cast(item.GetAccessee().GetAccesseeTokenId()) == peerTokenId && + item.GetAccessee().GetAccesseeDeviceId() == localUdid) { + LOGI("Src device unbind."); + DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(item.GetAccessControlId()); + processInfo.pkgName = item.GetAccessee().GetAccesseeBundleName(); + processInfo.userId = item.GetAccessee().GetAccesseeUserId(); + continue; + } + if (item.GetAccessee().GetAccesseeUserId() == remoteUserId && + item.GetAccessee().GetAccesseeDeviceId() == remoteUdid && + static_cast(item.GetAccessee().GetAccesseeTokenId()) == tokenId && + static_cast(item.GetAccesser().GetAccesserTokenId()) == peerTokenId && + item.GetAccesser().GetAccesserDeviceId() == localUdid) { + LOGI("Sink device unbind."); + DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(item.GetAccessControlId()); + processInfo.pkgName = item.GetAccesser().GetAccesserBundleName(); + processInfo.userId = item.GetAccesser().GetAccesserUserId(); + continue; + } + } + return processInfo; +} + std::vector DeviceProfileConnector::GetAllAccessControlProfile() { std::vector profiles; diff --git a/interfaces/inner_kits/native_cpp/include/device_manager.h b/interfaces/inner_kits/native_cpp/include/device_manager.h index d9abc735104daff6b9afb11265bfab7d3f80b8b3..bcb32dad31fc94082a07ff949ca9e2708244c0d7 100644 --- a/interfaces/inner_kits/native_cpp/include/device_manager.h +++ b/interfaces/inner_kits/native_cpp/include/device_manager.h @@ -393,6 +393,8 @@ public: */ virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &deviceId) = 0; + virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &deviceId, const std::string &extra) = 0; + virtual int32_t CheckNewAPIAccessPermission() = 0; /** diff --git a/interfaces/inner_kits/native_cpp/include/device_manager_impl.h b/interfaces/inner_kits/native_cpp/include/device_manager_impl.h index cf09515130bdf0ff34450eef5c437eb45e408dc3..26886b6d1de7c40f5be96d26340f89c5400901c1 100644 --- a/interfaces/inner_kits/native_cpp/include/device_manager_impl.h +++ b/interfaces/inner_kits/native_cpp/include/device_manager_impl.h @@ -336,6 +336,8 @@ public: virtual int32_t BindDevice(const std::string &pkgName, int32_t bindType, const std::string &deviceId, const std::string &extra, std::shared_ptr callback) override; virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &deviceId) override; + virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &deviceId, + const std::string &extra) override; virtual int32_t GetNetworkTypeByNetworkId(const std::string &pkgName, const std::string &netWorkId, int32_t &netWorkType) override; virtual int32_t ImportAuthCode(const std::string &pkgName, const std::string &authCode) override; diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index a799d988f43cbb2c2afdab60ff5f69d2140d035c..2432a0d476830e3b414e42230baa3013ecc30b0b 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -1539,6 +1539,36 @@ int32_t DeviceManagerImpl::UnBindDevice(const std::string &pkgName, const std::s return DM_OK; } +int32_t DeviceManagerImpl::UnBindDevice(const std::string &pkgName, const std::string &deviceId, + const std::string &extra) +{ + if (pkgName.empty() || deviceId.empty()) { + LOGE("UnBindDevice error: Invalid para. pkgName %{public}s", pkgName.c_str()); + return ERR_DM_INPUT_PARA_INVALID; + } + LOGI("Start, pkgName: %{public}s, deviceId: %{public}s", pkgName.c_str(), + GetAnonyString(std::string(deviceId)).c_str()); + std::shared_ptr req = std::make_shared(); + std::shared_ptr rsp = std::make_shared(); + req->SetPkgName(pkgName); + req->SetDeviceId(deviceId); + req->SetExtraInfo(extra); + LOGI("DeviceManagerImpl::UnBindDevice extra: %{public}s.", extra.c_str()); + int32_t ret = ipcClientProxy_->SendRequest(UNBIND_DEVICE, req, rsp); + if (ret != DM_OK) { + LOGE("UnBindDevice error: Send Request failed ret: %{public}d", ret); + return ERR_DM_IPC_SEND_REQUEST_FAILED; + } + ret = rsp->GetErrCode(); + if (ret != DM_OK) { + LOGE("UnBindDevice error: Failed with ret %{public}d", ret); + return ret; + } + + LOGI("End"); + return DM_OK; +} + int32_t DeviceManagerImpl::GetNetworkTypeByNetworkId(const std::string &pkgName, const std::string &netWorkId, int32_t &netWorkType) { diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index e6b1082fe913e97ed0a2baa55850f5311db702f2..159883adb364e1010684d1185aa536793122fd94 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -1028,6 +1028,7 @@ ON_IPC_SET_REQUEST(UNBIND_DEVICE, std::shared_ptr pBaseReq, MessageParce std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); std::string deviceId = pReq->GetDeviceId(); + std::string extra = pReq->GetExtraInfo(); if (!data.WriteString(pkgName)) { LOGE("write pkgName failed"); @@ -1037,6 +1038,9 @@ ON_IPC_SET_REQUEST(UNBIND_DEVICE, std::shared_ptr pBaseReq, MessageParce LOGE("write deviceId failed"); return ERR_DM_IPC_WRITE_FAILED; } + if (!data.WriteString(extra)) { + LOGE("write extra failed"); + } return DM_OK; } diff --git a/interfaces/kits/js4.0/src/dm_native_util.cpp b/interfaces/kits/js4.0/src/dm_native_util.cpp index a3b0eb5c89dd848f077c41ea7b223f35d0590d56..a7af920e798ee866a98e508cec36f235e3999bb2 100644 --- a/interfaces/kits/js4.0/src/dm_native_util.cpp +++ b/interfaces/kits/js4.0/src/dm_native_util.cpp @@ -299,6 +299,8 @@ void JsToBindParam(const napi_env &env, const napi_value &object, std::string &b JsObjectToString(env, object, "targetPkgName", targetPkgName, sizeof(targetPkgName)); char metaType[DM_NAPI_BUF_LENGTH] = ""; JsObjectToString(env, object, "metaType", metaType, sizeof(metaType)); + char peerBundleName[DM_NAPI_BUF_LENGTH] = ""; + JsObjectToString(env, object, "peerBundleName", peerBundleName, sizeof(peerBundleName)); std::string metaTypeStr = metaType; isMetaType = !metaTypeStr.empty(); @@ -324,6 +326,7 @@ void JsToBindParam(const napi_env &env, const napi_value &object, std::string &b jsonObj[CUSTOM_DESCRIPTION] = std::string(customDescription); jsonObj[PARAM_KEY_TARGET_PKG_NAME] = std::string(targetPkgName); jsonObj[PARAM_KEY_META_TYPE] = metaTypeStr; + jsonObj[PARAM_KEY_PEER_BUNDLE_NAME] = std::string(peerBundleName); jsonObj[PARAM_KEY_PIN_CODE] = std::string(pinCode); jsonObj[PARAM_KEY_AUTH_TOKEN] = std::string(authToken); jsonObj[PARAM_KEY_BR_MAC] = std::string(brMac); diff --git a/services/implementation/include/authentication/auth_message_processor.h b/services/implementation/include/authentication/auth_message_processor.h index a987e0dc94ac7b720857444ff773e63b516ce14d..b23468ec55810a8413baf0e40ed771aa34827fc3 100644 --- a/services/implementation/include/authentication/auth_message_processor.h +++ b/services/implementation/include/authentication/auth_message_processor.h @@ -76,6 +76,7 @@ constexpr const char* TAG_HOST_PKGLABEL = "hostPkgLabel"; constexpr const char* TAG_EDITION = "edition"; constexpr const char* TAG_BUNDLE_NAME = "bundleName"; constexpr const char* TAG_CRYPTIC_MSG = "encryptMsg"; +constexpr const char* TAG_PEER_BUNDLE_NAME = "PEER_BUNDLE_NAME"; class DmAuthManager; struct DmAuthRequestContext; diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 4a4fafbaa08ad949ed4bfb00ec11c79e82d4636f..3d0a431728cf5ec6e785c1d59fcabd95a845ba50 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -111,6 +111,7 @@ typedef struct DmAuthRequestContext { std::string hostPkgName; std::string targetPkgName; std::string bundleName; + std::string peerBundleName; std::string appOperation; std::string appDesc; std::string appName; @@ -155,6 +156,7 @@ typedef struct DmAuthResponseContext { std::string hostPkgName; std::string targetPkgName; std::string bundleName; + std::string peerBundleName; std::string appOperation; std::string appDesc; std::string customDesc; @@ -223,7 +225,8 @@ public: * @param deviceId device id. * @return Return 0 if success. */ - int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel); + int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra); /** * @tc.name: DmAuthManager::OnSessionOpened @@ -517,8 +520,9 @@ private: int32_t ImportCredential(std::string &deviceId, std::string &publicKey); void GetAuthParam(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra); + void parseJsonObject(nlohmann::json jsonObject); int32_t DeleteAcl(const std::string &pkgName, const std::string &localUdid, const std::string &remoteUdid, - int32_t bindLevel); + int32_t bindLevel, const std::string &extra); void ProcessAuthRequestExt(const int32_t &sessionId); bool IsAuthFinish(); void ProcessAuthRequest(const int32_t &sessionId); diff --git a/services/implementation/include/device_manager_service_impl.h b/services/implementation/include/device_manager_service_impl.h index 4414b5bd9e4d40e4aef6f1b2538f9895bc79da0b..42bf914d3997d917a241261cb94cbcaaba039193 100644 --- a/services/implementation/include/device_manager_service_impl.h +++ b/services/implementation/include/device_manager_service_impl.h @@ -47,6 +47,9 @@ public: int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel); + int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra); + int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms); void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo); @@ -107,6 +110,7 @@ public: int32_t DpAclAdd(const std::string &udid); int32_t IsSameAccount(const std::string &udid); + uint64_t GetTokenIdByNameAndDeviceId(std::string pkgName, std::string requestDeviceId); void ScreenCommonEventCallback(std::string commonEventType); int32_t CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); @@ -141,6 +145,8 @@ private: const std::string &remoteUdid); void HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid); void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, int32_t tokenId); + void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, + int32_t tokenId, int32_t peerTokenId); void HandleUserRemoved(int32_t preUserId); void HandleRemoteUserRemoved(int32_t preUserId, const std::string &remoteUdid); DmAuthForm ConvertBindTypeToAuthForm(int32_t bindType); diff --git a/services/implementation/include/device_manager_service_impl_lite.h b/services/implementation/include/device_manager_service_impl_lite.h index 46bcc11ac7492d6664b79a18a95f4a5bf65ef7d2..212146f8f0fc691d8a69461835ed433b303d76ca 100644 --- a/services/implementation/include/device_manager_service_impl_lite.h +++ b/services/implementation/include/device_manager_service_impl_lite.h @@ -54,6 +54,9 @@ public: int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel); + int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra); + int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms); void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo); @@ -119,6 +122,7 @@ public: int32_t DpAclAdd(const std::string &udid); int32_t IsSameAccount(const std::string &udid); + uint64_t GetTokenIdByNameAndDeviceId(std::string pkgName, std::string requestDeviceId); void ScreenCommonEventCallback(std::string commonEventType); int32_t CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid); @@ -132,6 +136,8 @@ public: const std::string &remoteUdid); void HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid); void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, int32_t tokenId); + void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, + int32_t tokenId, int32_t peerTokenId); void HandleIdentAccountLogout(const std::string &localUdid, int32_t localUserId, const std::string &peerUdid, int32_t peerUserId); void HandleUserRemoved(int32_t preUserId); diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index b463cdf39995e028fba4271e16cc1dccb1b4d7aa..e847a79398871ca691536f4127bd35e1564610ae 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -207,6 +207,7 @@ void AuthMessageProcessor::CreateNegotiateMessage(nlohmann::json &json) json[TAG_DMVERSION] = authResponseContext_->dmVersion; json[TAG_HOST] = authResponseContext_->hostPkgName; json[TAG_BUNDLE_NAME] = authResponseContext_->bundleName; + json[TAG_PEER_BUNDLE_NAME] = authResponseContext_->peerBundleName; json[TAG_TOKENID] = authResponseContext_->tokenId; json[TAG_IDENTICAL_ACCOUNT] = authResponseContext_->isIdenticalAccount; json[TAG_HAVE_CREDENTIAL] = authResponseContext_->haveCredential; @@ -589,6 +590,11 @@ void AuthMessageProcessor::ParseNegotiateMessage(const nlohmann::json &json) if (IsString(json, TAG_BUNDLE_NAME)) { authResponseContext_->bundleName = json[TAG_BUNDLE_NAME].get(); } + if (IsString(json, TAG_PEER_BUNDLE_NAME)) { + authResponseContext_->peerBundleName = json[TAG_PEER_BUNDLE_NAME].get(); + } else { + authResponseContext_->peerBundleName = authResponseContext_->hostPkgName; + } ParsePkgNegotiateMessage(json); } diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index a721ec7258ac54eeeee2d3b91d611060d958a2ae..069c253d71296ff1126ca51c917264b51bdcad7f 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -216,6 +216,12 @@ void DmAuthManager::GetAuthParam(const std::string &pkgName, int32_t authType, authRequestContext_->authed = !authRequestContext_->bindType.empty(); authRequestContext_->bindLevel = INVALIED_TYPE; nlohmann::json jsonObject = nlohmann::json::parse(extra, nullptr, false); + parseJsonObject(jsonObject); + authRequestContext_->token = std::to_string(GenRandInt(MIN_PIN_TOKEN, MAX_PIN_TOKEN)); +} + +void DmAuthManager::parseJsonObject(nlohmann::json jsonObject) +{ if (!jsonObject.is_discarded()) { if (IsString(jsonObject, TARGET_PKG_NAME_KEY)) { authRequestContext_->targetPkgName = jsonObject[TARGET_PKG_NAME_KEY].get(); @@ -238,9 +244,13 @@ void DmAuthManager::GetAuthParam(const std::string &pkgName, int32_t authType, authRequestContext_->closeSessionDelaySeconds = GetCloseSessionDelaySeconds(delaySecondsStr); } authRequestContext_->bindLevel = GetBindLevel(authRequestContext_->bindLevel); + if (IsString(jsonObject, TAG_PEER_BUNDLE_NAME)) { + authRequestContext_->peerBundleName = jsonObject[TAG_PEER_BUNDLE_NAME].get(); + } else { + authRequestContext_->peerBundleName = authRequestContext_->hostPkgName; + } } authRequestContext_->bundleName = GetBundleName(jsonObject); - authRequestContext_->token = std::to_string(GenRandInt(MIN_PIN_TOKEN, MAX_PIN_TOKEN)); } int32_t DmAuthManager::GetCloseSessionDelaySeconds(std::string &delaySecondsStr) @@ -339,7 +349,8 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st if (bindLevel == DEVICE) { DeleteGroup(pkgName, udid); } - return DeleteAcl(pkgName, std::string(localDeviceId), udid, bindLevel); + std::string extra = ""; + return DeleteAcl(pkgName, std::string(localDeviceId), udid, bindLevel, extra); } int32_t DmAuthManager::StopAuthenticateDevice(const std::string &pkgName) @@ -361,12 +372,12 @@ int32_t DmAuthManager::StopAuthenticateDevice(const std::string &pkgName) } int32_t DmAuthManager::DeleteAcl(const std::string &pkgName, const std::string &localUdid, - const std::string &remoteUdid, int32_t bindLevel) + const std::string &remoteUdid, int32_t bindLevel, const std::string &extra) { LOGI("DeleteAcl pkgName %{public}s, localUdid %{public}s, remoteUdid %{public}s, bindLevel %{public}d.", pkgName.c_str(), GetAnonyString(localUdid).c_str(), GetAnonyString(remoteUdid).c_str(), bindLevel); DmOfflineParam offlineParam = - DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localUdid, remoteUdid, bindLevel); + DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localUdid, remoteUdid, bindLevel, extra); if (offlineParam.bindType == INVALIED_TYPE) { LOGE("Acl not contain the pkgname bind data."); return ERR_DM_FAILED; @@ -400,7 +411,8 @@ int32_t DmAuthManager::DeleteAcl(const std::string &pkgName, const std::string & return ERR_DM_FAILED; } -int32_t DmAuthManager::UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel) +int32_t DmAuthManager::UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra) { if (pkgName.empty()) { LOGE("Invalid parameter, pkgName is empty."); @@ -411,7 +423,7 @@ int32_t DmAuthManager::UnBindDevice(const std::string &pkgName, const std::strin if (bindLevel == DEVICE) { DeleteGroup(pkgName, udid); } - return DeleteAcl(pkgName, std::string(localDeviceId), udid, bindLevel); + return DeleteAcl(pkgName, std::string(localDeviceId), udid, bindLevel, extra); } void DmAuthManager::GetPeerUdidHash(int32_t sessionId, std::string &peerUdidHash) @@ -794,6 +806,7 @@ void DmAuthManager::StartNegotiate(const int32_t &sessionId) authResponseContext_->accountGroupIdHash = GetAccountGroupIdHash(); authResponseContext_->hostPkgName = authRequestContext_->hostPkgName; authResponseContext_->bundleName = authRequestContext_->bundleName; + authResponseContext_->peerBundleName = authRequestContext_->peerBundleName; authResponseContext_->hostPkgLabel = authRequestContext_->hostPkgLabel; authResponseContext_->tokenId = authRequestContext_->tokenId; authResponseContext_->bindLevel = authRequestContext_->bindLevel; @@ -1037,14 +1050,6 @@ bool DmAuthManager::IsAuthFinish() return true; } - if (authResponseContext_->isOnline && authResponseContext_->authed) { - authRequestContext_->reason = DM_OK; - authResponseContext_->reply = DM_OK; - authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; - authRequestState_->TransitionTo(std::make_shared()); - return true; - } - if ((authResponseContext_->isIdenticalAccount && !authResponseContext_->authed) || (authResponseContext_->authed && !authResponseContext_->isOnline)) { softbusConnector_->JoinLnn(authRequestContext_->addr); @@ -1274,7 +1279,7 @@ int32_t DmAuthManager::JoinNetwork() void DmAuthManager::SinkAuthenticateFinish() { LOGI("DmAuthManager::SinkAuthenticateFinish, isFinishOfLocal: %{public}d", isFinishOfLocal_); - processInfo_.pkgName = authResponseContext_->hostPkgName; + processInfo_.pkgName = authResponseContext_->peerBundleName; listener_->OnSinkBindResult(processInfo_, peerTargetId_, authResponseContext_->reply, authResponseContext_->state, GenerateBindResultContent()); if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH && authPtr_ != nullptr) { @@ -1487,7 +1492,7 @@ void DmAuthManager::ShowConfigDialog() char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); std::string localUdid = static_cast(localDeviceId); - DeviceProfileConnector::GetInstance().SyncAclByBindType(authResponseContext_->hostPkgName, + DeviceProfileConnector::GetInstance().SyncAclByBindType(authResponseContext_->peerBundleName, authResponseContext_->bindType, localUdid, remoteDeviceId_); DmDialogManager::GetInstance().ShowConfirmDialog(params); struct RadarInfo info = { @@ -2407,7 +2412,7 @@ void DmAuthManager::PutAccessControlList() DmAccesser accesser; accesser.requestBundleName = authResponseContext_->hostPkgName; DmAccessee accessee; - accessee.trustBundleName = authResponseContext_->hostPkgName; + accessee.trustBundleName = authResponseContext_->peerBundleName; if (authRequestState_ != nullptr && authResponseState_ == nullptr) { accesser.requestTokenId = static_cast(authResponseContext_->tokenId); accesser.requestUserId = authRequestContext_->localUserId; @@ -2683,7 +2688,8 @@ int32_t DmAuthManager::GetBinderInfo() return DM_OK; } ret = AppManager::GetInstance().GetHapTokenIdByName(authResponseContext_->localUserId, - authResponseContext_->bundleName, 0, authResponseContext_->tokenId); + authResponseContext_->peerBundleName, 0, authResponseContext_->tokenId); + LOGI("GetBinderInfo sink tokenId = %{public}llu", authResponseContext_->tokenId); if (ret != DM_OK) { LOGI("get tokenId by bundleName failed %{public}s", GetAnonyString(authResponseContext_->bundleName).c_str()); authResponseContext_->tokenId = authResponseContext_->remoteTokenId; @@ -2696,8 +2702,15 @@ void DmAuthManager::SetProcessInfo() CHECK_NULL_VOID(authResponseContext_); ProcessInfo processInfo; if (authResponseContext_->bindLevel == APP) { - processInfo.pkgName = authResponseContext_->hostPkgName; - processInfo.userId = authResponseContext_->localUserId; + if ((authRequestState_ != nullptr) && (authResponseState_ == nullptr)) { + processInfo.pkgName = authResponseContext_->hostPkgName; + processInfo.userId = authResponseContext_->localUserId; + } else if ((authRequestState_ == nullptr) && (authResponseState_ != nullptr)) { + processInfo.pkgName = authResponseContext_->peerBundleName; + processInfo.userId = authResponseContext_->localUserId; + } else { + LOGE("DMAuthManager::SetProcessInfo failed, state is invalid."); + } } else if (authResponseContext_->bindLevel == DEVICE || authResponseContext_->bindLevel == INVALIED_TYPE) { processInfo.pkgName = std::string(DM_PKG_NAME); processInfo.userId = authResponseContext_->localUserId; diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 46fc347427cce6669bf75b84e4b482382b3d7187..877306b234de05ba93a5ea48b12612d862873e3e 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -129,7 +129,19 @@ int32_t DeviceManagerServiceImpl::UnBindDevice(const std::string &pkgName, const pkgName.c_str(), GetAnonyString(udid).c_str()); return ERR_DM_INPUT_PARA_INVALID; } - return authMgr_->UnBindDevice(pkgName, udid, bindLevel); + std::string extra = ""; + return authMgr_->UnBindDevice(pkgName, udid, bindLevel, extra); +} + +int32_t DeviceManagerServiceImpl::UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra) +{ + if (pkgName.empty() || udid.empty()) { + LOGE("DeviceManagerServiceImpl::UnBindDevice failed, pkgName is %{public}s, udid is %{public}s", + pkgName.c_str(), GetAnonyString(udid).c_str()); + return ERR_DM_INPUT_PARA_INVALID; + } + return authMgr_->UnBindDevice(pkgName, udid, bindLevel, extra); } int32_t DeviceManagerServiceImpl::SetUserOperation(std::string &pkgName, int32_t action, @@ -626,6 +638,22 @@ int32_t DeviceManagerServiceImpl::IsSameAccount(const std::string &udid) return DeviceProfileConnector::GetInstance().IsSameAccount(udid); } +uint64_t DeviceManagerServiceImpl::GetTokenIdByNameAndDeviceId(std::string pkgName, + std::string requestDeviceId) +{ + if (pkgName.empty()) { + LOGE("DeviceManagerServiceImpl::GetTokenIdByNameAndDeviceId error: pkgName."); + return ERR_DM_INPUT_PARA_INVALID; + } + + if (requestDeviceId.empty()) { + LOGE("DeviceManagerServiceImpl::GetTokenIdByNameAndDeviceId error: requestDeviceId."); + return ERR_DM_INPUT_PARA_INVALID; + } + + return DeviceProfileConnector::GetInstance().GetTokenIdByNameAndDeviceId(pkgName, requestDeviceId); +} + std::unordered_map DeviceManagerServiceImpl::GetAppTrustDeviceIdList( std::string pkgname) { @@ -821,6 +849,25 @@ void DeviceManagerServiceImpl::HandleAppUnBindEvent(int32_t remoteUserId, const softbusConnector_->HandleDeviceOffline(remoteUdid); } +void DeviceManagerServiceImpl::HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, + int32_t tokenId, int32_t peerTokenId) +{ + LOGI("HandleAppUnBindEvent peerTokenId = %{public}d.", peerTokenId); + char localUdidTemp[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localUdidTemp, DEVICE_UUID_LENGTH); + std::string localUdid = std::string(localUdidTemp); + ProcessInfo processInfo = + DeviceProfileConnector::GetInstance().HandleAppUnBindEvent(remoteUserId, remoteUdid, + tokenId, localUdid, peerTokenId); + if (processInfo.pkgName.empty()) { + LOGE("Pkgname is empty."); + return; + } + CHECK_NULL_VOID(softbusConnector_); + softbusConnector_->SetProcessInfo(processInfo); + softbusConnector_->HandleDeviceOffline(remoteUdid); +} + void DeviceManagerServiceImpl::HandleSyncUserIdEvent(const std::vector &foregroundUserIds, const std::vector &backgroundUserIds, const std::string &remoteUdid) { diff --git a/services/implementation/src/device_manager_service_impl_lite.cpp b/services/implementation/src/device_manager_service_impl_lite.cpp index cd7d6f40e0f087f9d8bdda4b8a65870dff4d0818..e14fde93b19079771a581dc73140851d4ea55577 100644 --- a/services/implementation/src/device_manager_service_impl_lite.cpp +++ b/services/implementation/src/device_manager_service_impl_lite.cpp @@ -69,6 +69,7 @@ void DeviceManagerServiceImpl::Release() softbusConnector_ = nullptr; hiChainConnector_ = nullptr; mineHiChainConnector_ = nullptr; + return; } int32_t DeviceManagerServiceImpl::UnAuthenticateDevice(const std::string &pkgName, const std::string &udid, @@ -89,6 +90,16 @@ int32_t DeviceManagerServiceImpl::UnBindDevice(const std::string &pkgName, const return DM_OK; } +int32_t DeviceManagerServiceImpl::UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra) +{ + (void)pkgName; + (void)udid; + (void)bindLevel; + (void)extra; + return DM_OK; +} + int32_t DeviceManagerServiceImpl::SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms) { @@ -109,6 +120,7 @@ void DeviceManagerServiceImpl::HandleDeviceStatusChange(DmDeviceState devState, LOGE("get deviceId: %{public}s failed", GetAnonyString(deviceId).c_str()); } deviceStateMgr_->HandleDeviceStatusChange(devState, devInfo); + return; } std::string DeviceManagerServiceImpl::GetUdidHashByNetworkId(const std::string &networkId) @@ -136,6 +148,7 @@ int DeviceManagerServiceImpl::OnSessionOpened(int sessionId, int result) void DeviceManagerServiceImpl::OnSessionClosed(int sessionId) { (void)sessionId; + return; } void DeviceManagerServiceImpl::OnBytesReceived(int sessionId, const void *data, unsigned int dataLen) @@ -143,6 +156,7 @@ void DeviceManagerServiceImpl::OnBytesReceived(int sessionId, const void *data, (void)sessionId; (void)data; (void)dataLen; + return; } int DeviceManagerServiceImpl::OnPinHolderSessionOpened(int sessionId, int result) @@ -155,6 +169,7 @@ int DeviceManagerServiceImpl::OnPinHolderSessionOpened(int sessionId, int result void DeviceManagerServiceImpl::OnPinHolderSessionClosed(int sessionId) { (void)sessionId; + return; } void DeviceManagerServiceImpl::OnPinHolderBytesReceived(int sessionId, const void *data, unsigned int dataLen) @@ -162,6 +177,7 @@ void DeviceManagerServiceImpl::OnPinHolderBytesReceived(int sessionId, const voi (void)sessionId; (void)data; (void)dataLen; + return; } int32_t DeviceManagerServiceImpl::RequestCredential(const std::string &reqJsonStr, std::string &returnJsonStr) @@ -364,6 +380,7 @@ std::unordered_map DeviceManagerServiceImpl::GetAppTrus void DeviceManagerServiceImpl::LoadHardwareFwkService() { + return; } int32_t DeviceManagerServiceImpl::DpAclAdd(const std::string &udid) @@ -378,9 +395,18 @@ int32_t DeviceManagerServiceImpl::IsSameAccount(const std::string &udid) return DM_OK; } +uint64_t DeviceManagerServiceImpl::GetTokenIdByNameAndDeviceId(std::string pkgName, + std::string requestDeviceId) +{ + (void)pkgName; + (void)requestDeviceId; + return 0; +} + void DeviceManagerServiceImpl::ScreenCommonEventCallback(std::string commonEventType) { (void)commonEventType; + return; } int32_t DeviceManagerServiceImpl::CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, @@ -452,6 +478,16 @@ void DeviceManagerServiceImpl::HandleAppUnBindEvent(int32_t remoteUserId, const return; } +void DeviceManagerServiceImpl::HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, + int32_t tokenId, int32_t peerTokenId) +{ + (void)remoteUserId; + (void)remoteUdid; + (void)tokenId; + (void)peerTokenId; + return; +} + void DeviceManagerServiceImpl::HandleIdentAccountLogout(const std::string &localUdid, int32_t localUserId, const std::string &peerUdid, int32_t peerUserId) { @@ -511,23 +547,26 @@ void DeviceManagerServiceImpl::HandleSyncUserIdEvent(const std::vector (void)foregroundUserIds; (void)backgroundUserIds; (void)remoteUdid; + return; } void HandleRemoteUserRemoved(int32_t preUserId, const std::string &remoteUdid) { (void)preUserId; (void)remoteUdid; + return; } std::map DeviceManagerServiceImpl::GetDeviceIdAndBindLevel(int32_t userId) { (void)userId; + return std::map {}; } std::multimap DeviceManagerServiceImpl::GetDeviceIdAndUserId(int32_t localUserId) { (void)localUserId; - return {}; + return std::multimap {}; } int32_t DeviceManagerServiceImpl::SaveOnlineDeviceInfo(const std::vector &deviceList) diff --git a/services/service/include/device_manager_service.h b/services/service/include/device_manager_service.h index 4cf68d0facbfcddf52ba7e67457ac4c7f06ca766..513197c21c9b4c32ce2f2a72e031eb7dffa6628e 100644 --- a/services/service/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -98,6 +98,8 @@ public: int32_t UnBindDevice(const std::string &pkgName, const std::string &udidHash); + int32_t UnBindDevice(const std::string &pkgName, const std::string &udidHash, const std::string &extra); + int32_t SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms); void HandleDeviceStatusChange(DmDeviceState devState, DmDeviceInfo &devInfo); @@ -220,8 +222,12 @@ private: void UnloadDMServiceAdapterResident(); void SendUnBindBroadCast(const std::vector &peerUdids, int32_t userId, uint64_t tokenId, int32_t bindLevel); + void SendUnBindBroadCast(const std::vector &peerUdids, int32_t userId, uint64_t tokenId, + int32_t bindLevel, uint64_t peerTokenId); void SendDeviceUnBindBroadCast(const std::vector &peerUdids, int32_t userId); void SendAppUnBindBroadCast(const std::vector &peerUdids, int32_t userId, uint64_t tokenId); + void SendAppUnBindBroadCast(const std::vector &peerUdids, int32_t userId, + uint64_t tokenId, uint64_t peerTokenId); void SendServiceUnBindBroadCast(const std::vector &peerUdids, int32_t userId, uint64_t tokenId); void SendAccountLogoutBroadCast(const std::vector &peerUdids, const std::string &accountId, const std::string &accountName, int32_t userId); diff --git a/services/service/include/idevice_manager_service_impl.h b/services/service/include/idevice_manager_service_impl.h index 0e5f16bb292b1da514a198dd20edcd576bc51a6c..8335e13feb49f6ffa6fbb17321fe46e1c1f74810 100644 --- a/services/service/include/idevice_manager_service_impl.h +++ b/services/service/include/idevice_manager_service_impl.h @@ -59,6 +59,9 @@ public: */ virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel) = 0; + virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, + int32_t bindLevel, const std::string &extra) = 0; + /** * @tc.name: IDeviceManagerServiceImpl::SetUserOperation * @tc.desc: Se tUser Operation of device manager service impl @@ -218,6 +221,7 @@ public: virtual std::unordered_map GetAppTrustDeviceIdList(std::string pkgname) = 0; virtual int32_t DpAclAdd(const std::string &udid) = 0; virtual int32_t IsSameAccount(const std::string &udid) = 0; + virtual uint64_t GetTokenIdByNameAndDeviceId(std::string pkgName, std::string requestDeviceId) = 0; virtual void ScreenCommonEventCallback(std::string commonEventType) = 0; virtual int32_t CheckIsSameAccount(const DmAccessCaller &caller, const std::string &srcUdid, const DmAccessCallee &callee, const std::string &sinkUdid) = 0; @@ -230,6 +234,8 @@ public: const std::string &remoteUdid) = 0; virtual void HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid) = 0; virtual void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, int32_t tokenId) = 0; + virtual void HandleAppUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid, + int32_t tokenId, int32_t peerTokenId) = 0; virtual int32_t GetBindLevel(const std::string &pkgName, const std::string &localUdid, const std::string &udid, uint64_t &tokenId) = 0; virtual void HandleIdentAccountLogout(const std::string &localUdid, int32_t localUserId, diff --git a/services/service/include/relationshipsyncmgr/relationship_sync_mgr.h b/services/service/include/relationshipsyncmgr/relationship_sync_mgr.h index f64c1af30c15db5c06c449fcce749501282ff65f..22d74af970e0e1b694362373fe3f28cd708e3cf4 100644 --- a/services/service/include/relationshipsyncmgr/relationship_sync_mgr.h +++ b/services/service/include/relationshipsyncmgr/relationship_sync_mgr.h @@ -49,6 +49,7 @@ struct RelationShipChangeMsg { uint32_t userId; std::string accountId; uint64_t tokenId; + uint64_t peerTokenId = 0; // The broadcast need send to these devices with the udids std::vector peerUdids; // The broadcast from which device with the udid. diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index 0868ce035f396a02f7f5021d85e784b1774b8543..49ed6a71317be4b3dcf5710af40e25256e5de045 100755 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -664,6 +664,57 @@ int32_t DeviceManagerService::UnBindDevice(const std::string &pkgName, const std return DM_OK; } +int32_t DeviceManagerService::UnBindDevice(const std::string &pkgName, const std::string &udidHash, + const std::string &extra) +{ + if (!PermissionManager::GetInstance().CheckNewPermission()) { + LOGE("The caller does not have permission to call UnBindDevice."); + return ERR_DM_NO_PERMISSION; + } + LOGI("Begin for pkgName = %{public}s, udidHash = %{public}s", pkgName.c_str(), GetAnonyString(udidHash).c_str()); + if (pkgName.empty() || udidHash.empty()) { + LOGE("DeviceManagerService::UnBindDevice error: Invalid parameter, pkgName: %{public}s", pkgName.c_str()); + return ERR_DM_INPUT_PARA_INVALID; + } + if (!IsDMServiceImplReady()) { + LOGE("UnBindDevice failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + std::string realDeviceId = udidHash; +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + std::string udidHashTemp = ""; + if (GetUdidHashByAnoyDeviceId(udidHash, udidHashTemp) == DM_OK) { + realDeviceId = udidHashTemp; + } +#endif + std::string udid = ""; + if (SoftbusCache::GetInstance().GetUdidByUdidHash(realDeviceId, udid) != DM_OK) { + LOGE("Get udid by udidhash failed."); + return ERR_DM_FAILED; + } + char localUdid[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localUdid, DEVICE_UUID_LENGTH); + uint64_t tokenId = 0; + int32_t bindLevel = dmServiceImpl_->GetBindLevel(pkgName, std::string(localUdid), udid, tokenId); + LOGI("UnAuthenticateDevice get bindlevel %{public}d.", bindLevel); + if (bindLevel == INVALIED_BIND_LEVEL) { + LOGE("UnAuthenticateDevice failed, Acl not contain the bindLevel %{public}d.", bindLevel); + return ERR_DM_FAILED; + } + uint64_t peerTokenId = dmServiceImpl_->GetTokenIdByNameAndDeviceId(extra, udid); + if (dmServiceImpl_->UnBindDevice(pkgName, udid, bindLevel, extra) != DM_OK) { + LOGE("dmServiceImpl_ UnBindDevice failed."); + return ERR_DM_FAILED; + } +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + std::vector peerUdids; + peerUdids.emplace_back(udid); + SendUnBindBroadCast(peerUdids, MultipleUserConnector::GetCurrentAccountUserID(), tokenId, + bindLevel, peerTokenId); +#endif + return DM_OK; +} + int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t action, const std::string ¶ms) { if (!PermissionManager::GetInstance().CheckPermission()) { @@ -2062,6 +2113,23 @@ void DeviceManagerService::SendUnBindBroadCast(const std::vector &p } } +void DeviceManagerService::SendUnBindBroadCast(const std::vector &peerUdids, int32_t userId, + uint64_t tokenId, int32_t bindLevel, uint64_t peerTokenId) +{ + if (bindLevel == DEVICE) { + SendDeviceUnBindBroadCast(peerUdids, userId); + return; + } + if (bindLevel == APP) { + SendAppUnBindBroadCast(peerUdids, userId, tokenId, peerTokenId); + return; + } + if (bindLevel == SERVICE) { + SendServiceUnBindBroadCast(peerUdids, userId, tokenId); + return; + } +} + void DeviceManagerService::SendDeviceUnBindBroadCast(const std::vector &peerUdids, int32_t userId) { RelationShipChangeMsg msg; @@ -2086,6 +2154,21 @@ void DeviceManagerService::SendAppUnBindBroadCast(const std::vector softbusListener_->SendAclChangedBroadcast(broadCastMsg); } +void DeviceManagerService::SendAppUnBindBroadCast(const std::vector &peerUdids, int32_t userId, + uint64_t tokenId, uint64_t peerTokenId) +{ + RelationShipChangeMsg msg; + msg.type = RelationShipChangeType::APP_UNBIND; + msg.userId = static_cast(userId); + msg.peerUdids = peerUdids; + msg.tokenId = tokenId; + msg.peerTokenId = peerTokenId; + LOGI("SendAppUnBindBroadCast msg.peerTokenId = %{public}llu.", msg.peerTokenId); + std::string broadCastMsg = ReleationShipSyncMgr::GetInstance().SyncTrustRelationShip(msg); + CHECK_NULL_VOID(softbusListener_); + softbusListener_->SendAclChangedBroadcast(broadCastMsg); +} + void DeviceManagerService::SendServiceUnBindBroadCast(const std::vector &peerUdids, int32_t userId, uint64_t tokenId) { @@ -2121,8 +2204,14 @@ void DeviceManagerService::HandleDeviceTrustedChange(const std::string &msg) dmServiceImpl_->HandleDevUnBindEvent(relationShipMsg.userId, relationShipMsg.peerUdid); break; case RelationShipChangeType::APP_UNBIND: - dmServiceImpl_->HandleAppUnBindEvent(relationShipMsg.userId, relationShipMsg.peerUdid, - static_cast(relationShipMsg.tokenId)); + if (relationShipMsg.peerTokenId != 0) { + dmServiceImpl_->HandleAppUnBindEvent(relationShipMsg.userId, relationShipMsg.peerUdid, + static_cast(relationShipMsg.tokenId), + static_cast(relationShipMsg.peerTokenId)); + } else { + dmServiceImpl_->HandleAppUnBindEvent(relationShipMsg.userId, relationShipMsg.peerUdid, + static_cast(relationShipMsg.tokenId)); + } break; case RelationShipChangeType::SYNC_USERID: HandleUserIdsBroadCast(relationShipMsg.userIdInfos, diff --git a/services/service/src/ipc/standard/ipc_cmd_parser.cpp b/services/service/src/ipc/standard/ipc_cmd_parser.cpp index 4c40447b67de8913ed5f9ba119e30d3505d7031f..bc75ba3eba5072deaa64eab02bac2b16739d76a8 100644 --- a/services/service/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/service/src/ipc/standard/ipc_cmd_parser.cpp @@ -829,7 +829,13 @@ ON_IPC_CMD(UNBIND_DEVICE, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); std::string deviceId = data.ReadString(); - int32_t result = DeviceManagerService::GetInstance().UnBindDevice(pkgName, deviceId); + std::string extra = data.ReadString(); + int32_t result = 0; + if (extra == "") { + result = DeviceManagerService::GetInstance().UnBindDevice(pkgName, deviceId); + } else { + result = DeviceManagerService::GetInstance().UnBindDevice(pkgName, deviceId, extra); + } if (!reply.WriteInt32(result)) { LOGE("write result failed"); return ERR_DM_IPC_WRITE_FAILED; diff --git a/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp b/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp index 2a7ddb86f17833a031be083fd3c613449a5f521c..47d1def3a1ee35259645deaf537da97d373b5a66 100644 --- a/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp +++ b/services/service/src/relationshipsyncmgr/relationship_sync_mgr.cpp @@ -43,7 +43,7 @@ namespace { * | 2 bytes | 4 bytes | * | userid lower 2 bytes | token id lower 4 bytes | */ - const int32_t APP_UNBIND_PAYLOAD_LEN = 6; + const int32_t APP_UNBIND_PAYLOAD_LEN = 10; /** * @brief delete user payload length 2 bytes * | 2 bytes | @@ -55,6 +55,7 @@ namespace { * */ const int32_t USERID_PAYLOAD_LEN = 2; + const int32_t TOKENID_PAYLOAD_LEN = 6; const int32_t ACCOUNTID_PAYLOAD_LEN = 6; const int32_t SYNC_FRONT_OR_BACK_USERID_PAYLOAD_MAX_LEN = 11; const int32_t SYNC_FRONT_OR_BACK_USERID_PAYLOAD_MIN_LEN = 3; @@ -66,6 +67,7 @@ namespace { const char * const MSG_VALUE = "VALUE"; const char * const MSG_PEER_UDID = "PEER_UDID"; const char * const MSG_ACCOUNTID = "ACCOUNTID"; + const char * const MSG_PEER_TOKENID = "PEER_TOKENID"; // The need response mask offset, the 8th bit. const int32_t NEED_RSP_MASK_OFFSET = 7; @@ -242,10 +244,14 @@ void RelationShipChangeMsg::ToAppUnbindPayLoad(uint8_t *&msg, uint32_t &len) con msg[i] |= (userId >> (i * BITS_PER_BYTE)) & 0xFF; } - for (int i = USERID_PAYLOAD_LEN; i < APP_UNBIND_PAYLOAD_LEN; i++) { + for (int i = USERID_PAYLOAD_LEN; i < TOKENID_PAYLOAD_LEN; i++) { msg[i] |= (tokenId >> ((i - USERID_PAYLOAD_LEN) * BITS_PER_BYTE)) & 0xFF; } + for (int i = TOKENID_PAYLOAD_LEN; i < APP_UNBIND_PAYLOAD_LEN; i++) { + msg[i] |= (peerTokenId >> ((i - TOKENID_PAYLOAD_LEN) * BITS_PER_BYTE)) & 0xFF; + } + len = APP_UNBIND_PAYLOAD_LEN; } @@ -365,13 +371,21 @@ bool RelationShipChangeMsg::FromAppUnbindPayLoad(const cJSON *payloadJson) } } tokenId = 0; - for (uint32_t j = USERID_PAYLOAD_LEN; j < APP_UNBIND_PAYLOAD_LEN; j++) { + for (uint32_t j = USERID_PAYLOAD_LEN; j < TOKENID_PAYLOAD_LEN; j++) { cJSON *payloadItem = cJSON_GetArrayItem(payloadJson, j); CHECK_NULL_RETURN(payloadItem, false); if (cJSON_IsNumber(payloadItem)) { tokenId |= (static_cast(payloadItem->valueint)) << ((j - USERID_PAYLOAD_LEN) * BITS_PER_BYTE); } } + peerTokenId = 0; + for (uint32_t j = TOKENID_PAYLOAD_LEN; j < APP_UNBIND_PAYLOAD_LEN; j++) { + cJSON *payloadItem = cJSON_GetArrayItem(payloadJson, j); + if (cJSON_IsNumber(payloadItem)) { + peerTokenId |= (static_cast(payloadItem->valueint)) << + ((j - TOKENID_PAYLOAD_LEN) * BITS_PER_BYTE); + } + } return true; } diff --git a/test/commonfuzztest/dmauthmanager_fuzzer/dm_auth_manager_fuzzer.cpp b/test/commonfuzztest/dmauthmanager_fuzzer/dm_auth_manager_fuzzer.cpp index 881aeb081268dbb2a17e51b9b5dfcf56477b8296..403ca99f6c3862303b4d24614f73e9dc23b2ecef 100644 --- a/test/commonfuzztest/dmauthmanager_fuzzer/dm_auth_manager_fuzzer.cpp +++ b/test/commonfuzztest/dmauthmanager_fuzzer/dm_auth_manager_fuzzer.cpp @@ -106,7 +106,7 @@ void DmAuthManagerFuzzTest(const uint8_t* data, size_t size) g_authManager->RegisterUiStateCallback(str); g_authManager->UnRegisterUiStateCallback(str); g_authManager->UnAuthenticateDevice(str, str, bindLevel); - g_authManager->UnBindDevice(str, str, bindLevel); + g_authManager->UnBindDevice(str, str, bindLevel, str); } } } diff --git a/test/commonunittest/UTTest_dm_auth_manager_first.cpp b/test/commonunittest/UTTest_dm_auth_manager_first.cpp index 2306830dc425c1ffb4f820403e5b79c6b1c89048..f5633e787395009f74d47d92f61eda64291f78f4 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_first.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_first.cpp @@ -561,23 +561,24 @@ HWTEST_F(DmAuthManagerTest, UnAuthenticateDevice_001, testing::ext::TestSize.Lev HWTEST_F(DmAuthManagerTest, UnBindDevice_001, testing::ext::TestSize.Level0) { std::string pkgName; - std::string udid = "UnAuthenticateDevice_001"; + std::string udid = "UnBindDevice_001"; int32_t bindLevel = DEVICE; - int32_t ret = authManager_->UnBindDevice(pkgName, udid, bindLevel); + std::string extra = "extraTest"; + int32_t ret = authManager_->UnBindDevice(pkgName, udid, bindLevel, extra); EXPECT_NE(ret, DM_OK); pkgName = "com.ohos.test"; authManager_->isAuthenticateDevice_ = false; - ret = authManager_->UnBindDevice(pkgName, udid, bindLevel); + ret = authManager_->UnBindDevice(pkgName, udid, bindLevel, extra); EXPECT_NE(ret, DM_OK); authManager_->authRequestState_ = nullptr; authManager_->authResponseContext_ = nullptr; - ret = authManager_->UnBindDevice(pkgName, udid, bindLevel); + ret = authManager_->UnBindDevice(pkgName, udid, bindLevel, extra); EXPECT_NE(ret, DM_OK); bindLevel = 0; - ret = authManager_->UnBindDevice(pkgName, udid, bindLevel); + ret = authManager_->UnBindDevice(pkgName, udid, bindLevel, extra); EXPECT_NE(ret, DM_OK); } diff --git a/test/commonunittest/UTTest_dm_auth_manager_third.cpp b/test/commonunittest/UTTest_dm_auth_manager_third.cpp index d4c1150f5dc245dbca8fa0065594057ea4643d31..29c5f1b0bdf7604785d0a4177e342c1889041282 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_third.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_third.cpp @@ -69,15 +69,6 @@ bool SoftbusConnector::CheckIsOnline(const std::string &targetDeviceId) return g_checkIsOnlineReturnBoolValue; } -DmOfflineParam DeviceProfileConnector::DeleteAccessControlList(const std::string &pkgName, - const std::string &localDeviceId, const std::string &remoteDeviceId, int32_t bindLevel) -{ - DmOfflineParam offlineParam; - offlineParam.bindType = g_bindType; - offlineParam.leftAclNumber = g_leftAclNumber; - return offlineParam; -} - bool DmRadarHelper::ReportAuthConfirmBox(struct RadarInfo &info) { return g_reportAuthConfirmBoxReturnBoolValue; @@ -225,37 +216,38 @@ HWTEST_F(DmAuthManagerTest, DeleteAcl001, testing::ext::TestSize.Level0) std::string pkgName = "pkgName"; std::string localUdid = "localUdid"; std::string remoteUdid = "remoteUdid"; + std::string extra = "extraTest"; int32_t sessionId = 0; int32_t bindLevel = APP; g_bindType = INVALIED_TYPE; - int32_t ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel); + int32_t ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel, extra); EXPECT_EQ(ret, ERR_DM_FAILED); bindLevel = APP; g_bindType = APP_PEER_TO_PEER_TYPE; g_leftAclNumber = 1; authManager_->softbusConnector_->deviceStateManagerCallback_ = std::make_shared(); - ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel); + ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel, extra); EXPECT_EQ(ret, DM_OK); g_leftAclNumber = 0; - ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel); + ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel, extra); EXPECT_EQ(ret, DM_OK); bindLevel = DEVICE; - ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel); + ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel, extra); EXPECT_EQ(ret, DM_OK); g_leftAclNumber = 1; g_peerUdidHash = "test"; authManager_->DeleteOffLineTimer(sessionId); - ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel); + ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel, extra); EXPECT_EQ(ret, DM_OK); authManager_->softbusConnector_ = nullptr; authManager_->DeleteOffLineTimer(sessionId); bindLevel = 0; - ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel); + ret = authManager_->DeleteAcl(pkgName, localUdid, remoteUdid, bindLevel, extra); EXPECT_EQ(ret, ERR_DM_FAILED); } @@ -319,6 +311,63 @@ HWTEST_F(DmAuthManagerTest, ShowStartAuthDialog001, testing::ext::TestSize.Level ASSERT_EQ(authManager_->authResponseContext_->targetDeviceName, DmDialogManager::GetInstance().targetDeviceName_); } +HWTEST_F(DmAuthManagerTest, DeleteAccessControlList001, testing::ext::TestSize.Level0) +{ + std::string pkgName = "pkgName"; + std::string localDeviceId = "localDeviceId"; + std::string remoteDeviceId = "remoteDeviceId"; + int32_t bindLevel = APP; + std::string extra = ""; + auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, + remoteDeviceId, bindLevel, extra); + EXPECT_EQ(APP, ret.bindType); +} + +HWTEST_F(DmAuthManagerTest, DeleteAccessControlList002, testing::ext::TestSize.Level0) +{ + DmOfflineParam offlineParam; + offlineParam.leftAclNumber = 1; + std::string pkgName = "pkgName"; + std::string localDeviceId = "localDeviceId"; + std::string remoteDeviceId = "remoteDeviceId"; + int32_t bindLevel = APP; + std::string extra = "extratest"; + auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, + remoteDeviceId, bindLevel, extra); + EXPECT_EQ(APP, ret.bindType); + EXPECT_EQ(0, ret.leftAclNumber); +} + +HWTEST_F(DmAuthManagerTest, DeleteAccessControlList003, testing::ext::TestSize.Level0) +{ + DmOfflineParam offlineParam; + offlineParam.leftAclNumber = 1; + std::string pkgName = "pkgName"; + std::string localDeviceId = "localDeviceId"; + std::string remoteDeviceId = "remoteDeviceId"; + int32_t bindLevel = SERVICE; + std::string extra = "extratest"; + auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, + remoteDeviceId, bindLevel, extra); + EXPECT_EQ(SERVICE, ret.bindType); + EXPECT_EQ(0, ret.leftAclNumber); +} + +HWTEST_F(DmAuthManagerTest, DeleteAccessControlList004, testing::ext::TestSize.Level0) +{ + DmOfflineParam offlineParam; + offlineParam.leftAclNumber = 1; + std::string pkgName = "pkgName"; + std::string localDeviceId = "localDeviceId"; + std::string remoteDeviceId = "remoteDeviceId"; + int32_t bindLevel = DEVICE; + std::string extra = ""; + auto ret = DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, + remoteDeviceId, bindLevel, extra); + EXPECT_EQ(DEVICE, ret.bindType); + EXPECT_EQ(0, ret.leftAclNumber); +} + HWTEST_F(DmAuthManagerTest, OnUserOperation001, testing::ext::TestSize.Level0) { int32_t action = USER_OPERATION_TYPE_AUTH_CONFIRM_TIMEOUT; diff --git a/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp b/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp index 5e8c831ac7babced02336c82731928db7754c915..cfe3f14a6f39ec88dd9399233714ad3a3fcead66 100644 --- a/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp +++ b/test/commonunittest/UTTest_dm_deviceprofile_connector.cpp @@ -709,11 +709,11 @@ HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_001, testing::ext::Test { DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_IDENTICAL_ACCOUNT); - std::string pkgName; - std::string requestDeviceId; + std::string requestDeviceId = "requestDeviceId"; + std::string trustUdid = "trustUdid"; std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); + DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid); + EXPECT_EQ(bindTypeVec, std::vector({IDENTICAL_ACCOUNT_TYPE})); } HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_002, testing::ext::TestSize.Level0) @@ -721,11 +721,11 @@ HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_002, testing::ext::Test DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_POINT_TO_POINT); profiles.SetBindLevel(DEVICE); - std::string pkgName; - std::string requestDeviceId; + std::string requestDeviceId = "requestDeviceId"; + std::string trustUdid = "trustUdid"; std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); + DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid); + EXPECT_EQ(bindTypeVec, std::vector({DEVICE_PEER_TO_PEER_TYPE})); } HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_003, testing::ext::TestSize.Level0) @@ -733,67 +733,39 @@ HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_003, testing::ext::Test DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_POINT_TO_POINT); profiles.SetBindLevel(APP); - profiles.accesser_.SetAccesserBundleName("pkgName"); - profiles.accesser_.SetAccesserDeviceId("localDeviceId"); - std::string pkgName = "pkgName"; - std::string requestDeviceId = "localDeviceId"; + std::string requestDeviceId = "requestDeviceId"; + std::string trustUdid = "trustUdid"; + profiles.GetAccesser().SetAccesserDeviceId(trustUdid); + profiles.GetAccessee().SetAccesseeDeviceId(requestDeviceId); std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); + DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid); + EXPECT_EQ(bindTypeVec, std::vector({APP_PEER_TO_PEER_TYPE})); } HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_004, testing::ext::TestSize.Level0) -{ - DistributedDeviceProfile::AccessControlProfile profiles; - profiles.SetBindType(DM_POINT_TO_POINT); - profiles.SetBindLevel(APP); - profiles.accessee_.SetAccesseeBundleName("pkgName"); - profiles.accessee_.SetAccesseeDeviceId("localDeviceId"); - std::string pkgName = "pkgName"; - std::string requestDeviceId = "localDeviceId"; - std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); -} - -HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_005, testing::ext::TestSize.Level0) { DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_ACROSS_ACCOUNT); profiles.SetBindLevel(DEVICE); - std::string pkgName; - std::string requestDeviceId; - std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); -} - -HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_006, testing::ext::TestSize.Level0) -{ - DistributedDeviceProfile::AccessControlProfile profiles; - profiles.SetBindType(DM_ACROSS_ACCOUNT); - profiles.SetBindLevel(APP); - profiles.accesser_.SetAccesserBundleName("pkgName"); - profiles.accesser_.SetAccesserDeviceId("localDeviceId"); - std::string pkgName = "pkgName"; - std::string requestDeviceId = "localDeviceId"; + std::string requestDeviceId = "requestDeviceId"; + std::string trustUdid = "trustUdid"; std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); + DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid); + EXPECT_EQ(bindTypeVec, std::vector({DEVICE_ACROSS_ACCOUNT_TYPE})); } -HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_007, testing::ext::TestSize.Level0) +HWTEST_F(DeviceProfileConnectorTest, GetParamBindTypeVec_005, testing::ext::TestSize.Level0) { DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_ACROSS_ACCOUNT); profiles.SetBindLevel(APP); - profiles.accessee_.SetAccesseeBundleName("pkgName"); - profiles.accessee_.SetAccesseeDeviceId("localDeviceId"); - std::string pkgName = "pkgName"; - std::string requestDeviceId = "localDeviceId"; + std::string requestDeviceId = "requestDeviceId"; + std::string trustUdid = "trustUdid"; + profiles.GetAccesser().SetAccesserDeviceId(trustUdid); + profiles.GetAccessee().SetAccesseeDeviceId(requestDeviceId); std::vector bindTypeVec; - DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, pkgName, requestDeviceId, bindTypeVec); - EXPECT_EQ(bindTypeVec.empty(), false); + DeviceProfileConnector::GetInstance().GetParamBindTypeVec(profiles, requestDeviceId, bindTypeVec, trustUdid); + EXPECT_EQ(bindTypeVec, std::vector({APP_ACROSS_ACCOUNT_TYPE})); } HWTEST_F(DeviceProfileConnectorTest, CompareBindType_001, testing::ext::TestSize.Level0) @@ -848,106 +820,45 @@ HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_001, testing::ext::TestSize { DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_IDENTICAL_ACCOUNT); - DmDiscoveryInfo paramInfo; - std::vector sinkBindType; - std::vector bindTypeIndex; + vector sinkBindType; + vector bindTypeIndex; + string localDeviceId = "localDeviceId"; + string targetDeviceId = "targetDeviceId"; uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); + DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, + sinkBindType, bindTypeIndex, index, targetDeviceId); + EXPECT_EQ(sinkBindType, vector({IDENTICAL_ACCOUNT_TYPE})); + EXPECT_EQ(bindTypeIndex, vector({0})); } HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_002, testing::ext::TestSize.Level0) { DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_POINT_TO_POINT); - profiles.SetBindLevel(DEVICE); - DmDiscoveryInfo paramInfo; - std::vector sinkBindType; - std::vector bindTypeIndex; + vector sinkBindType; + vector bindTypeIndex; + string localDeviceId = "localDeviceId"; + string targetDeviceId = "targetDeviceId"; uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); + DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, + sinkBindType, bindTypeIndex, index, targetDeviceId); + EXPECT_EQ(sinkBindType, vector({DEVICE_PEER_TO_PEER_TYPE})); + EXPECT_EQ(bindTypeIndex, vector({0})); } HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_003, testing::ext::TestSize.Level0) -{ - DistributedDeviceProfile::AccessControlProfile profiles; - profiles.SetBindType(DM_POINT_TO_POINT); - profiles.SetBindLevel(APP); - profiles.accesser_.SetAccesserBundleName("pkgName"); - profiles.accesser_.SetAccesserDeviceId("localDeviceId"); - DmDiscoveryInfo paramInfo; - paramInfo.pkgname = "pkgName"; - paramInfo.localDeviceId = "localDeviceId"; - std::vector sinkBindType; - std::vector bindTypeIndex; - uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); -} - -HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_004, testing::ext::TestSize.Level0) -{ - DistributedDeviceProfile::AccessControlProfile profiles; - profiles.SetBindType(DM_POINT_TO_POINT); - profiles.SetBindLevel(APP); - profiles.accessee_.SetAccesseeBundleName("pkgName"); - profiles.accessee_.SetAccesseeDeviceId("localDeviceId"); - DmDiscoveryInfo paramInfo; - paramInfo.pkgname = "pkgName"; - paramInfo.localDeviceId = "localDeviceId"; - std::vector sinkBindType; - std::vector bindTypeIndex; - uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); -} - -HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_005, testing::ext::TestSize.Level0) -{ - DistributedDeviceProfile::AccessControlProfile profiles; - profiles.SetBindType(DM_ACROSS_ACCOUNT); - profiles.SetBindLevel(DEVICE); - DmDiscoveryInfo paramInfo; - std::vector sinkBindType; - std::vector bindTypeIndex; - uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); -} - -HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_006, testing::ext::TestSize.Level0) { DistributedDeviceProfile::AccessControlProfile profiles; profiles.SetBindType(DM_ACROSS_ACCOUNT); - profiles.SetBindLevel(APP); - profiles.accesser_.SetAccesserBundleName("pkgName"); - profiles.accesser_.SetAccesserDeviceId("localDeviceId"); - DmDiscoveryInfo paramInfo; - paramInfo.pkgname = "pkgName"; - paramInfo.localDeviceId = "localDeviceId"; - std::vector sinkBindType; - std::vector bindTypeIndex; - uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); -} - -HWTEST_F(DeviceProfileConnectorTest, ProcessBindType_007, testing::ext::TestSize.Level0) -{ - DistributedDeviceProfile::AccessControlProfile profiles; - profiles.SetBindType(DM_ACROSS_ACCOUNT); - profiles.SetBindLevel(APP); - profiles.accessee_.SetAccesseeBundleName("pkgName"); - profiles.accessee_.SetAccesseeDeviceId("localDeviceId"); - DmDiscoveryInfo paramInfo; - paramInfo.pkgname = "pkgName"; - paramInfo.localDeviceId = "localDeviceId"; - std::vector sinkBindType; - std::vector bindTypeIndex; + vector sinkBindType; + vector bindTypeIndex; + string localDeviceId = "localDeviceId"; + string targetDeviceId = "targetDeviceId"; uint32_t index = 0; - DeviceProfileConnector::GetInstance().ProcessBindType(profiles, paramInfo, sinkBindType, bindTypeIndex, index); - EXPECT_EQ(sinkBindType.empty(), false); + DeviceProfileConnector::GetInstance().ProcessBindType(profiles, localDeviceId, + sinkBindType, bindTypeIndex, index, targetDeviceId); + EXPECT_EQ(sinkBindType, vector({DEVICE_ACROSS_ACCOUNT_TYPE})); + EXPECT_EQ(bindTypeIndex, vector({0})); } HWTEST_F(DeviceProfileConnectorTest, SyncAclByBindType_001, testing::ext::TestSize.Level0) @@ -1200,11 +1111,10 @@ HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_001, testing::ext:: std::string pkgName = "bundleName"; std::string localDeviceId = "localDeviceId"; std::string remoteDeviceId = "remoteDeviceId"; + std::string extra = "extraTest"; int32_t bindLevel = INVALIED_TYPE; - DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance() - .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel); - + .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel, extra); EXPECT_EQ(offlineParam.bindType, INVALIED_TYPE); } @@ -1213,11 +1123,10 @@ HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_002, testing::ext:: std::string pkgName = "bundleName"; std::string localDeviceId = "localDeviceId"; std::string remoteDeviceId = "remoteDeviceId"; + std::string extra = "extraTest"; int32_t bindLevel = APP; - DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance() - .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel); - + .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel, extra); EXPECT_EQ(offlineParam.bindType, APP); } @@ -1226,11 +1135,10 @@ HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_003, testing::ext:: std::string pkgName = "bundleName"; std::string localDeviceId = "localDeviceId"; std::string remoteDeviceId = "remoteDeviceId"; + std::string extra = "extraTest"; int32_t bindLevel = SERVICE; - DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance() - .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel); - + .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel, extra); EXPECT_EQ(offlineParam.bindType, SERVICE); } @@ -1239,11 +1147,10 @@ HWTEST_F(DeviceProfileConnectorTest, DeleteAccessControlList_004, testing::ext:: std::string pkgName = "bundleName"; std::string localDeviceId = "localDeviceId"; std::string remoteDeviceId = "remoteDeviceId"; + std::string extra = "extraTest"; int32_t bindLevel = DEVICE; - DmOfflineParam offlineParam = DeviceProfileConnector::GetInstance() - .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel); - + .DeleteAccessControlList(pkgName, localDeviceId, remoteDeviceId, bindLevel, extra); EXPECT_EQ(offlineParam.bindType, DEVICE); } diff --git a/test/servicesfuzztest/deviceprofileconnector_fuzzer/device_profile_connector_fuzzer.cpp b/test/servicesfuzztest/deviceprofileconnector_fuzzer/device_profile_connector_fuzzer.cpp index 112f21058b650fcc52c0b9e8ae8b9391f90ebde3..f0ef6424f9cf73124504e9f008aae88581054b0d 100644 --- a/test/servicesfuzztest/deviceprofileconnector_fuzzer/device_profile_connector_fuzzer.cpp +++ b/test/servicesfuzztest/deviceprofileconnector_fuzzer/device_profile_connector_fuzzer.cpp @@ -35,11 +35,13 @@ void DeviceProfileConnectorFuzzTest(const uint8_t* data, size_t size) std::string requestDeviceId(reinterpret_cast(data), size); std::string pkgName(reinterpret_cast(data), size); std::string trustUdid(reinterpret_cast(data), size); + std::string extra(reinterpret_cast(data), size); std::string localDeviceId(reinterpret_cast(data), size); std::string targetDeviceId(reinterpret_cast(data), size); std::string requestAccountId(reinterpret_cast(data), size); std::string deviceIdHash(reinterpret_cast(data), size); std::string trustBundleName(reinterpret_cast(data), size); + int32_t bindLevel = 1; DmAclInfo aclInfo; aclInfo.bindType = fdp.ConsumeIntegral(); aclInfo.bindLevel = fdp.ConsumeIntegral(); @@ -56,12 +58,12 @@ void DeviceProfileConnectorFuzzTest(const uint8_t* data, size_t size) dmAccessee.trustBundleName = trustBundleName; int32_t userId = fdp.ConsumeIntegral(); std::string accountId(reinterpret_cast(data), size); - int32_t bindLevel = fdp.ConsumeIntegral(); DeviceProfileConnector::GetInstance().CheckBindType(trustDeviceId, requestDeviceId); DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, requestDeviceId, trustUdid); DeviceProfileConnector::GetInstance().GetProcessInfoFromAclByUserId(localDeviceId, targetDeviceId, userId); DeviceProfileConnector::GetInstance().PutAccessControlList(aclInfo, dmAccesser, dmAccessee); - DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, requestDeviceId, bindLevel); + DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, + requestDeviceId, bindLevel, extra); DeviceProfileConnector::GetInstance().UpdateAccessControlList(userId, accountId, accountId); DeviceProfileConnector::GetInstance().CheckIdenticalAccount(userId, accountId); DeviceProfileConnector::GetInstance().CheckDevIdInAclForDevBind(pkgName, localDeviceId);