diff --git a/commondependency/BUILD.gn b/commondependency/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b6cd6ccfe37b8f6657bd55492e352eb287d7d4f4 --- /dev/null +++ b/commondependency/BUILD.gn @@ -0,0 +1,66 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/distributedhardware/device_manager/device_manager.gni") +ohos_shared_library("devicemanagerdependency") { + include_dirs = [ + "include", + "${common_path}/include", + "${innerkits_path}/native_cpp/include", + ] + + if (os_account_part_exists) { + include_dirs += [ + "${os_account_path }/interfaces/innerkits/ohosaccount/native/include", + "${os_account_path }/interfaces/innerkits/osaccount/native/include", + ] + } + + sources = [ + "${common_path}/src/dm_softbus_adapter_crypto.cpp", + "src/deviceprofile_connector.cpp", + "src/multiple_user_connector.cpp", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerdependency\"", + "LOG_DOMAIN=0xD004100", + ] + + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${mbedtls_path}:mbedtls_shared", + ] + + external_deps = [ + "ability_base:want", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + "hilog:libhilog", + "os_account:libaccountkits", + ] + + if (os_account_part_exists) { + defines += [ "OS_ACCOUNT_PART_EXISTS" ] + external_deps += [ + "os_account:libaccountkits", + "os_account:os_account_innerkits", + ] + } + + subsystem_name = "distributedhardware" + + part_name = "device_manager" +} diff --git a/services/implementation/include/dependency/deviceprofile/deviceprofile_connector.h b/commondependency/include/deviceprofile_connector.h similarity index 93% rename from services/implementation/include/dependency/deviceprofile/deviceprofile_connector.h rename to commondependency/include/deviceprofile_connector.h index dd06e376224cedeccef3ea095b1b9601987bc141..a95900b85de417e360879128349c0bd4ddf99e6b 100644 --- a/services/implementation/include/dependency/deviceprofile/deviceprofile_connector.h +++ b/commondependency/include/deviceprofile_connector.h @@ -20,6 +20,7 @@ #include "accesser.h" #include "distributed_device_profile_client.h" #include "distributed_device_profile_enums.h" +#include "single_instance.h" constexpr uint32_t ALLOW_AUTH_ONCE = 1; constexpr uint32_t ALLOW_AUTH_ALWAYS = 2; @@ -28,6 +29,7 @@ constexpr uint32_t INVALIED_TYPE = 0; constexpr uint32_t APP_LEVEL_BIND_TYPE = 1; constexpr uint32_t DEVICE_LEVEL_BIND_TYPE = 2; constexpr uint32_t IDENTICAL_ACCOUNT_TYPE = 3; +constexpr uint32_t DEVICE_PEER_TO_PEER_TYPE = 4; constexpr uint32_t DM_IDENTICAL_ACCOUNT = 1; constexpr uint32_t DM_POINT_TO_POINT = 256; @@ -83,6 +85,7 @@ typedef struct DmOfflineParam { namespace OHOS { namespace DistributedHardware { class DeviceProfileConnector { +DECLARE_SINGLE_INSTANCE_BASE(DeviceProfileConnector); public: DeviceProfileConnector(); ~DeviceProfileConnector(); @@ -102,6 +105,8 @@ public: DmOfflineParam DeleteAccessControlList(std::string pkgName, std::string localDeviceId, std::string remoteDeviceId); std::vector GetPkgNameFromAcl(std::string &localDeviceId, std::string &targetDeviceId); + bool CheckIdenticalAccount(int32_t userId, const std::string &accountId); + int32_t DeleteP2PAccessControlList(int32_t userId, std::string &accountId); }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/include/dependency/multipleuser/multiple_user_connector.h b/commondependency/include/multiple_user_connector.h similarity index 100% rename from services/implementation/include/dependency/multipleuser/multiple_user_connector.h rename to commondependency/include/multiple_user_connector.h diff --git a/services/implementation/src/dependency/deviceprofile/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp similarity index 90% rename from services/implementation/src/dependency/deviceprofile/deviceprofile_connector.cpp rename to commondependency/src/deviceprofile_connector.cpp index 0fdcf3aff83922cfed7626592d7062dc81c63e3c..309efee70bfa713aa12138d6d840ff2b954ab4a3 100644 --- a/services/implementation/src/dependency/deviceprofile/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -25,6 +25,7 @@ using namespace OHOS::DistributedDeviceProfile; namespace OHOS { namespace DistributedHardware { +IMPLEMENT_SINGLE_INSTANCE(DeviceProfileConnector); DeviceProfileConnector::DeviceProfileConnector() { LOGD("DeviceProfileConnector constructor."); @@ -131,7 +132,7 @@ uint32_t DeviceProfileConnector::CheckBindType(std::string trustDeviceId, std::s continue; } uint32_t priority = INVALIED_TYPE; - if (item.GetBindType() == IDENTICAL_ACCOUNT) { + if (item.GetBindType() == DM_IDENTICAL_ACCOUNT) { priority = IDENTICAL_ACCOUNT_TYPE; } else if (item.GetBindLevel() == DEVICE) { priority = DEVICE_LEVEL_BIND_TYPE; @@ -165,7 +166,7 @@ std::vector DeviceProfileConnector::GetBindTypeByPkgName(std::string pk if (trustDeviceIdHash != trustUdidHash || item.GetStatus() == INACTIVE) { continue; } - if (item.GetBindType() == IDENTICAL_ACCOUNT) { + if (item.GetBindType() == DM_IDENTICAL_ACCOUNT) { bindTypeVec.push_back(IDENTICAL_ACCOUNT_TYPE); } else if (item.GetBindLevel() == DEVICE) { bindTypeVec.push_back(DEVICE_LEVEL_BIND_TYPE); @@ -193,7 +194,7 @@ std::vector DeviceProfileConnector::SyncAclByBindType(std::string pkgNa if (profiles[index].GetTrustDeviceId() != targetDeviceId || profiles[index].GetStatus() != ACTIVE) { continue; } - if (profiles[index].GetBindType() == IDENTICAL_ACCOUNT) { + if (profiles[index].GetBindType() == DM_IDENTICAL_ACCOUNT) { sinkBindType.push_back(IDENTICAL_ACCOUNT_TYPE); bindTypeIndex.push_back(index); } else if (profiles[index].GetBindLevel() == DEVICE) { @@ -404,5 +405,46 @@ int32_t DeviceProfileConnector::UpdateAccessControlList(int32_t userId, std::str } return DM_OK; } + +bool DeviceProfileConnector::CheckIdenticalAccount(int32_t userId, const std::string &accountId) +{ + LOGI("DeviceProfileConnector::CheckIdenticalAccount"); + std::vector profiles; + std::map queryParams; + queryParams["userId"] = std::to_string(userId); + queryParams["accountId"] = accountId; + if (DistributedDeviceProfileClient::GetInstance().GetAccessControlProfile(queryParams, profiles) != DM_OK) { + LOGE("DP GetAccessControlProfile failed."); + } + for (auto &item : profiles) { + if (item.GetBindType() == DM_IDENTICAL_ACCOUNT && item.GetStatus() == ACTIVE) { + return true; + } + } + return false; +} +int32_t DeviceProfileConnector::DeleteP2PAccessControlList(int32_t userId, std::string &accountId) +{ + LOGI("DeviceProfileConnector::DeleteP2PAccessControlList"); + std::vector profiles; + std::map queryParams; + queryParams["userId"] = std::to_string(userId); + queryParams["accountId"] = accountId; + if (DistributedDeviceProfileClient::GetInstance().GetAccessControlProfile(queryParams, profiles) != DM_OK) { + LOGE("DP GetAccessControlProfile failed."); + } + for (auto &item : profiles) { + if (item.GetBindType() == DM_IDENTICAL_ACCOUNT || item.GetStatus() != ACTIVE) { + continue; + } + if ((item.GetAccesser().GetAccesserUserId() == userId && + item.GetAccesser().GetAccesserAccountId() == accountId) || + (item.GetAccessee().GetAccesseeUserId() == userId && + item.GetAccessee().GetAccesseeAccountId() == accountId)) { + DistributedDeviceProfileClient::GetInstance().DeleteAccessControlProfile(item.GetAccessControlId()); + } + } + return DM_OK; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/dependency/multipleuser/multiple_user_connector.cpp b/commondependency/src/multiple_user_connector.cpp similarity index 100% rename from services/implementation/src/dependency/multipleuser/multiple_user_connector.cpp rename to commondependency/src/multiple_user_connector.cpp diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 4438e4bf41fb47345c7d74b5fa8d839285448d51..b9176f374a41e4a68b39d621a4f399a8d36a2a5e 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -30,6 +30,7 @@ ohos_shared_library("devicemanagerext_pin_auth") { "include", "include/standard", "${common_path}/include", + "${devicemanager_path}/commondependency/include", "${ext_path}/pin_auth/include/ability", "${servicesimpl_path}/include/dependency/timer", "${servicesimpl_path}/include/config", @@ -75,6 +76,8 @@ ohos_shared_library("devicemanagerext_pin_auth") { "bundle_framework:appexecfwk_core", "c_utils:utils", "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "init:libbegetutil", "ipc:ipc_single", "resource_management:resmgr_napi_core", diff --git a/services/implementation/BUILD.gn b/services/implementation/BUILD.gn index 8bab8a7ac71d4c7559debe40299104bee96863ba..48058f739b4982d91dece08308439c23803aed57 100644 --- a/services/implementation/BUILD.gn +++ b/services/implementation/BUILD.gn @@ -40,6 +40,7 @@ if (!support_jsapi) { "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", + "${devicemanager_path}/commondependency/include", "${devicemanager_path}/radar/include", "${utils_path}/include", "${utils_path}/include/fwkload/standard", @@ -51,13 +52,6 @@ if (!support_jsapi) { "${services_path}/include", "${services_path}/include/ipc/standard", ] - - if (os_account_part_exists) { - include_dirs += [ - "${os_account_path }/interfaces/innerkits/ohosaccount/native/include", - "${os_account_path }/interfaces/innerkits/osaccount/native/include", - ] - } } ohos_shared_library("devicemanagerserviceimpl") { @@ -86,10 +80,8 @@ if (!support_jsapi) { "src/config/dm_config_manager.cpp", "src/credential/dm_credential_manager.cpp", "src/dependency/commonevent/dm_common_event_manager.cpp", - "src/dependency/deviceprofile/deviceprofile_connector.cpp", "src/dependency/hichain/hichain_auth_connector.cpp", "src/dependency/hichain/hichain_connector.cpp", - "src/dependency/multipleuser/multiple_user_connector.cpp", "src/dependency/softbus/softbus_connector.cpp", "src/dependency/softbus/softbus_session.cpp", "src/device_manager_service_impl.cpp", @@ -110,6 +102,7 @@ if (!support_jsapi) { ] deps = [ + "${devicemanager_path}/commondependency:devicemanagerdependency", "${devicemanager_path}/radar:devicemanagerradar", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", @@ -135,14 +128,6 @@ if (!support_jsapi) { "samgr:samgr_proxy", ] - if (os_account_part_exists) { - defines += [ "OS_ACCOUNT_PART_EXISTS" ] - external_deps += [ - "os_account:libaccountkits", - "os_account:os_account_innerkits", - ] - } - subsystem_name = "distributedhardware" part_name = "device_manager" diff --git a/services/implementation/include/authentication/auth_message_processor.h b/services/implementation/include/authentication/auth_message_processor.h index a2ef59016ac20cb1ba878121f33c2e6ce0b01bcb..45cbfbab6d4b82243fb71010baf8be46f9324002 100644 --- a/services/implementation/include/authentication/auth_message_processor.h +++ b/services/implementation/include/authentication/auth_message_processor.h @@ -51,6 +51,21 @@ constexpr const char* QR_CODE_KEY = "qrCode"; constexpr const char* TAG_AUTH_TOKEN = "authToken"; constexpr const char* NFC_CODE_KEY = "nfcCode"; constexpr const char* OLD_VERSION_ACCOUNT = "oldVersionAccount"; + +constexpr const char* TAG_HAVE_CREDENTIAL = "haveCredential"; +constexpr const char* TAG_PUBLICKEY = "publicKey"; +constexpr const char* TAG_SESSIONKEY = "sessionKey"; +constexpr const char* TAG_BIND_LEVEL = "bindLevel"; +constexpr const char* TAG_LOCAL_USERID = "localUserId"; +constexpr const char* TAG_BIND_TYPE_SIZE = "bindTypeSize"; +constexpr const char* TAG_ISONLINE = "isOnline"; +constexpr const char* TAG_AUTHED = "authed"; +constexpr const char* TAG_LOCAL_ACCOUNTID = "localAccountId"; +constexpr const char* TAG_DMVERSION = "dmVersion"; +constexpr const char* TAG_HOST_PKGNAME = "hostPkgname"; +constexpr const char* TAG_TOKENID = "tokenId"; +constexpr const char* TAG_HAVECREDENTIAL = "haveCredential"; +constexpr const char* TAG_CONFIRM_OPERATION = "confirmOperation"; constexpr const char* TAG_DATA = "data"; constexpr const char* TAG_DATA_LEN = "dataLen"; @@ -71,7 +86,9 @@ public: std::shared_ptr GetResponseContext(); std::shared_ptr GetRequestContext(); std::string CreateDeviceAuthMessage(int32_t msgType, const uint8_t *data, uint32_t dataLen); - + void CreateResponseAuthMessageExt(nlohmann::json &json); + void ParseAuthResponseMessageExt(nlohmann::json &json); + private: std::string CreateRequestAuthMessage(nlohmann::json &json); void CreateNegotiateMessage(nlohmann::json &json); @@ -85,6 +102,12 @@ private: void CreateResponseFinishMessage(nlohmann::json &json); void ParseResponseFinishMessage(nlohmann::json &json); void GetAuthReqMessage(nlohmann::json &json); + void ParsePkgNegotiateMessage(const nlohmann::json &json); + void CreatePublicKeyMessageExt(nlohmann::json &json); + void ParsePublicKeyMessageExt(nlohmann::json &json); + void CreateSyncDeleteMessageExt(nlohmann::json &json); + void ParseSyncDeleteMessageExt(nlohmann::json &json); + private: std::weak_ptr authMgr_; std::shared_ptr cryptoAdapter_; diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index c65874e36480fd962b8d79608b701f425cf6fc4b..3ed3b541b4f73f19460fab9305cfda56db9b7913 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -24,6 +24,7 @@ #include "auth_ui_state_manager.h" #include "authentication.h" #include "idevice_manager_service_listener.h" +#include "deviceprofile_connector.h" #include "dm_ability_manager.h" #include "dm_adapter_crypto.h" #include "dm_adapter_manager.h" @@ -44,9 +45,9 @@ typedef enum AuthState { AUTH_REQUEST_REPLY, AUTH_REQUEST_JOIN, AUTH_REQUEST_NETWORK, + AUTH_REQUEST_FINISH, AUTH_REQUEST_CREDENTIAL, AUTH_REQUEST_CREDENTIAL_DONE, - AUTH_REQUEST_FINISH, AUTH_REQUEST_DELETE_INIT, AUTH_REQUEST_SYNCDELETE, AUTH_REQUEST_SYNCDELETE_DONE, @@ -55,8 +56,8 @@ typedef enum AuthState { AUTH_RESPONSE_CONFIRM, AUTH_RESPONSE_GROUP, AUTH_RESPONSE_SHOW, - AUTH_RESPONSE_CREDENTIAL, AUTH_RESPONSE_FINISH, + AUTH_RESPONSE_CREDENTIAL, AUTH_RESPONSE_SYNCDELETE, AUTH_RESPONSE_SYNCDELETE_DONE, } AuthState; @@ -75,12 +76,13 @@ enum DmMsgType : int32_t { MSG_TYPE_SYNC_GROUP = 400, MSG_TYPE_AUTH_BY_PIN = 500, + MSG_TYPE_RESP_AUTH_EXT, MSG_TYPE_REQ_PUBLICKEY, MSG_TYPE_RESP_PUBLICKEY, MSG_TYPE_REQ_SYNC_DELETE, MSG_TYPE_REQ_SYNC_DELETE_DONE, - MSG_TYPE_REQ_AUTH_DEVICE_NEGOTIATE, - MSG_TYPE_RESP_AUTH_DEVICE_NEGOTIATE, + MSG_TYPE_REQ_AUTH_DEVICE_NEGOTIATE = 600, + MSG_TYPE_RESP_AUTH_DEVICE_NEGOTIATE = 700, }; enum DmAuthType : int32_t { @@ -115,6 +117,14 @@ typedef struct DmAuthRequestContext { std::string token; int32_t reason; std::vector syncGroupList; + std::string dmVersion; + int32_t localUserId; + std::string localAccountId; + std::vector bindType; + bool isOnline; + bool authed; + int32_t bindLevel; + int64_t tokenId; } DmAuthRequestContext; typedef struct DmAuthResponseContext { @@ -154,6 +164,15 @@ typedef struct DmAuthResponseContext { bool isOnline; int32_t bindLevel; bool haveCredential; + int32_t confirmOperation; + std::string localAccountId; + int32_t localUserId; + int64_t tokenId; + bool authed; + std::string dmVersion; + std::vector bindType; + std::string remoteAccountId; + int32_t remoteUserId; } DmAuthResponseContext; class AuthMessageProcessor; @@ -458,6 +477,10 @@ private: int32_t ParseConnectAddr(const PeerTargetId &targetId, std::string &deviceId); int32_t ParseAuthType(const std::map &bindParam, int32_t &authType); std::string ParseExtraFromMap(const std::map &bindParam); + void CompatiblePutAcl(); + void ProRespNegotiateExt(const int32_t &sessionId); + void AccountIdLogoutEventCallback(int32_t userId); + void UserChangeEventCallback(int32_t userId); public: void RequestCredential(); @@ -474,8 +497,15 @@ public: void SyncDeleteAclDone(); void AuthDeviceSessionKey(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen); AesGcmCipherKey GetSessionKeyAndLen(); + void CommonEventCallback(int32_t userId); private: int32_t ImportCredential(std::string &deviceId, std::string &publicKey); + void DeleteAllGroup(int32_t userId); + void DeleteP2PGroup(int32_t userId); + void GetAuthParam(const std::string &pkgName, int32_t authType, const std::string &deviceId, + const std::string &extra); + void HandleSyncDeleteTimeout(std::string name); + int32_t DeleteAcl(const std::string &pkgName, const std::string &deviceId); private: std::shared_ptr softbusConnector_; diff --git a/services/implementation/include/dependency/hichain/hichain_auth_connector.h b/services/implementation/include/dependency/hichain/hichain_auth_connector.h index 1e4f5d554d76ea0e8a8f62f8badd4fd1b7bfddaf..2a08896e5d47f5895327dd0d4e358564e1771c68 100644 --- a/services/implementation/include/dependency/hichain/hichain_auth_connector.h +++ b/services/implementation/include/dependency/hichain/hichain_auth_connector.h @@ -54,7 +54,7 @@ public: int32_t GenerateCredential(std::string &localUdid, int32_t osAccountId, std::string &publicKey); bool QueryCredential(std::string &localUdid, int32_t osAccountId); int32_t ImportCredential(int32_t osAccountId, std::string deviceId, std::string publicKey); - int32_t DeleteCredential(std::string &deviceId); + int32_t DeleteCredential(const std::string &deviceId, int32_t userId); int32_t RegisterHiChainAuthCallback(std::shared_ptr callback); int32_t StartAuthDevice(int64_t requestId, const char* authParams, const DeviceAuthCallback* callbak); int32_t ProcessAuthDevice(int64_t requestId, const char* authParams, const DeviceAuthCallback* callbak); diff --git a/services/implementation/include/dependency/softbus/softbus_connector.h b/services/implementation/include/dependency/softbus/softbus_connector.h index 353e021cd08e0603b68841618d97f4243229a949..b8b1873e55121aca96a5a9679773f5168983a1d4 100644 --- a/services/implementation/include/dependency/softbus/softbus_connector.h +++ b/services/implementation/include/dependency/softbus/softbus_connector.h @@ -134,7 +134,9 @@ public: int32_t AddMemberToDiscoverMap(const std::string &deviceId, std::shared_ptr deviceInfo); std::string GetNetworkIdByUdidHash(const std::string &deviceIdHash); void HandleDeviceOnline(std::string &deviceId); + void HandleDeviceOffline(const std::string &deviceId); void SetPkgName(std::string pkgName); + bool CheckIsOnline(const std::string &targetDeviceId); private: static void ConvertDeviceInfoToDmDevice(const DeviceInfo &deviceInfo, DmDeviceInfo &dmDeviceInfo); diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index c108c64d6ea25ad7532f9613a8712803bd1d8c9f..847ec6cb2d3865bdf1b0cabf16162c8f51ea109e 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -112,15 +112,45 @@ std::string AuthMessageProcessor::CreateSimpleMessage(int32_t msgType) case MSG_TYPE_RESP_AUTH: CreateResponseAuthMessage(jsonObj); break; + case MSG_TYPE_RESP_AUTH_EXT: + CreateResponseAuthMessageExt(jsonObj); + break; case MSG_TYPE_REQ_AUTH_TERMINATE: + case MSG_TYPE_REQ_SYNC_DELETE_DONE: CreateResponseFinishMessage(jsonObj); break; + case MSG_TYPE_REQ_PUBLICKEY: + case MSG_TYPE_RESP_PUBLICKEY: + CreatePublicKeyMessageExt(jsonObj); + break; + case MSG_TYPE_REQ_SYNC_DELETE: + CreateSyncDeleteMessageExt(jsonObj); + break; default: break; } return jsonObj.dump(); } +void AuthMessageProcessor::CreateSyncDeleteMessageExt(nlohmann::json &json) +{ + json[TAG_LOCAL_DEVICE_ID] = authResponseContext_->localDeviceId; + json[TAG_HOST_PKGNAME] = authResponseContext_->hostPkgName; +} + +void AuthMessageProcessor::CreatePublicKeyMessageExt(nlohmann::json &json) +{ + json[TAG_PUBLICKEY] = authResponseContext_->publicKey; +} + +void AuthMessageProcessor::CreateResponseAuthMessageExt(nlohmann::json &json) +{ + json[TAG_REPLY] = authResponseContext_->reply; + json[TAG_TOKEN] = authResponseContext_->token; + json[TAG_CONFIRM_OPERATION] = authResponseContext_->confirmOperation; + json[TAG_REQUEST_ID] = authResponseContext_->requestId; +} + void AuthMessageProcessor::CreateNegotiateMessage(nlohmann::json &json) { if (cryptoAdapter_ == nullptr) { @@ -216,15 +246,60 @@ int32_t AuthMessageProcessor::ParseMessage(const std::string &message) case MSG_TYPE_RESP_AUTH: ParseAuthResponseMessage(jsonObject); break; + case MSG_TYPE_RESP_AUTH_EXT: + ParseAuthResponseMessageExt(jsonObject); + break; case MSG_TYPE_REQ_AUTH_TERMINATE: + case MSG_TYPE_REQ_SYNC_DELETE_DONE: ParseResponseFinishMessage(jsonObject); break; + case MSG_TYPE_REQ_PUBLICKEY: + case MSG_TYPE_RESP_PUBLICKEY: + ParsePublicKeyMessageExt(jsonObject); + break; + case MSG_TYPE_REQ_SYNC_DELETE: + ParseSyncDeleteMessageExt(jsonObject); + break; default: break; } return DM_OK; } +void AuthMessageProcessor::ParseSyncDeleteMessageExt(nlohmann::json &json) +{ + if (IsString(json, TAG_LOCAL_DEVICE_ID)) { + authResponseContext_->localDeviceId = json[TAG_LOCAL_DEVICE_ID].get(); + } + if (IsString(json, TAG_HOST_PKGNAME)) { + authResponseContext_->hostPkgName = json[TAG_HOST_PKGNAME].get(); + } +} + +void AuthMessageProcessor::ParsePublicKeyMessageExt(nlohmann::json &json) +{ + if (IsString(json, TAG_PUBLICKEY)) { + authResponseContext_->publicKey = json[TAG_PUBLICKEY].get(); + } +} + +void AuthMessageProcessor::ParseAuthResponseMessageExt(nlohmann::json &json) +{ + LOGI("start ParseAuthResponseMessageExt"); + if (IsInt32(json, TAG_REPLY)) { + authResponseContext_->reply = json[TAG_REPLY].get(); + } + if (IsString(json, TAG_TOKEN)) { + authResponseContext_->token = json[TAG_TOKEN].get(); + } + if (IsInt32(json, TAG_CONFIRM_OPERATION)) { + authResponseContext_->confirmOperation = json[TAG_CONFIRM_OPERATION].get(); + } + if (IsInt64(json, TAG_REQUEST_ID)) { + authResponseContext_->requestId = json[TAG_REQUEST_ID].get(); + } +} + void AuthMessageProcessor::ParseResponseFinishMessage(nlohmann::json &json) { if (IsInt32(json, TAG_REPLY)) { @@ -326,6 +401,46 @@ void AuthMessageProcessor::ParseAuthResponseMessage(nlohmann::json &json) } } +void AuthMessageProcessor::ParsePkgNegotiateMessage(const nlohmann::json &json) +{ + if (IsString(json, TAG_LOCAL_ACCOUNTID)) { + authResponseContext_->localAccountId = json[TAG_LOCAL_ACCOUNTID].get(); + } + if (IsInt32(json, TAG_LOCAL_USERID)) { + authResponseContext_->localUserId = json[TAG_LOCAL_USERID].get(); + } + if (IsBool(json, TAG_ISONLINE)) { + authResponseContext_->isOnline = json[TAG_ISONLINE].get(); + } + if (IsBool(json, TAG_IDENTICAL_ACCOUNT)) { + authResponseContext_->isIdenticalAccount = json[TAG_IDENTICAL_ACCOUNT].get(); + } + if (IsBool(json, TAG_AUTHED)) { + authResponseContext_->authed = json[TAG_AUTHED].get(); + } + if (IsInt64(json, TAG_TOKENID)) { + authResponseContext_->tokenId = json[TAG_TOKENID].get(); + } + if (IsString(json, TAG_DMVERSION)) { + authResponseContext_->dmVersion = json[TAG_DMVERSION].get(); + } else { + authResponseContext_->dmVersion = ""; + } + if (IsBool(json, TAG_HAVECREDENTIAL)) { + authResponseContext_->haveCredential = json[TAG_HAVECREDENTIAL].get(); + } + if (IsInt32(json, TAG_BIND_TYPE_SIZE)) { + int32_t bindTypeSize = json[TAG_BIND_TYPE_SIZE].get(); + authResponseContext_->bindType.clear(); + for (int32_t item = 0; item < bindTypeSize; item++) { + std::string itemStr = std::to_string(item); + if (IsInt32(json, itemStr)) { + authResponseContext_->bindType.push_back(json[itemStr].get()); + } + } + } +} + void AuthMessageProcessor::ParseNegotiateMessage(const nlohmann::json &json) { if (IsBool(json, TAG_CRYPTO_SUPPORT)) { diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 2c076060405d663dba364b648eaf3e056c650a4b..8a6878333e4061d7396ec6fe68c7f29cad9bb74c 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -58,6 +58,7 @@ constexpr const char* TARGET_PKG_NAME_KEY = "targetPkgName"; constexpr const char* CUSTOM_DESCRIPTION_KEY = "customDescription"; constexpr const char* CANCEL_DISPLAY_KEY = "cancelPinCodeDisplay"; const int32_t SESSION_KEY_LENGTH = 16; +constexpr const char* DM_VERSION = "4.1.5.1"; DmAuthManager::DmAuthManager(std::shared_ptr softbusConnector, std::shared_ptr listener, @@ -126,6 +127,53 @@ int32_t DmAuthManager::CheckAuthParamVaild(const std::string &pkgName, int32_t a return DM_OK; } +void DmAuthManager::GetAuthParam(const std::string &pkgName, int32_t authType, + const std::string &deviceId, const std::string &extra) +{ + LOGI("Get auth param."); + char localDeviceId[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); + std::string localUdid = static_cast(localDeviceId); + authRequestContext_->hostPkgName = pkgName; + authRequestContext_->authType = authType; + authRequestContext_->localDeviceName = softbusConnector_->GetLocalDeviceName(); + authRequestContext_->localDeviceTypeId = softbusConnector_->GetLocalDeviceTypeId(); + authRequestContext_->localDeviceId = localUdid; + authRequestContext_->deviceId = deviceId; + authRequestContext_->dmVersion = DM_VERSION; + authRequestContext_->localAccountId = MultipleUserConnector::GetOhosAccountId(); + MultipleUserConnector::SetSwitchOldAccountId(authRequestContext_->localAccountId); + authRequestContext_->localUserId = MultipleUserConnector::GetCurrentAccountUserID(); + MultipleUserConnector::SetSwitchOldUserId(authRequestContext_->localUserId); + authRequestContext_->bindType = + DeviceProfileConnector::GetInstance().GetBindTypeByPkgName(pkgName, localUdid, deviceId); + authRequestContext_->isOnline = softbusConnector_->CheckIsOnline(deviceId); + authRequestContext_->authed = !authRequestContext_->bindType.empty(); + authRequestContext_->bindLevel = DEVICE; + nlohmann::json jsonObject = nlohmann::json::parse(extra, nullptr, false); + if (!jsonObject.is_discarded()) { + if (IsString(jsonObject, TARGET_PKG_NAME_KEY)) { + authRequestContext_->targetPkgName = jsonObject[TARGET_PKG_NAME_KEY].get(); + } + if (IsString(jsonObject, APP_OPERATION_KEY)) { + authRequestContext_->appOperation = jsonObject[APP_OPERATION_KEY].get(); + } + if (IsString(jsonObject, CUSTOM_DESCRIPTION_KEY)) { + authRequestContext_->customDesc = jsonObject[CUSTOM_DESCRIPTION_KEY].get(); + } + if (IsString(jsonObject, APP_THUMBNAIL)) { + authRequestContext_->appThumbnail = jsonObject[APP_THUMBNAIL].get(); + } + if (IsInt64(jsonObject, TAG_TOKENID)) { + authRequestContext_->tokenId = jsonObject[TAG_TOKENID].get(); + } + if (IsInt32(jsonObject, TAG_BIND_LEVEL)) { + authRequestContext_->bindLevel = jsonObject[TAG_BIND_LEVEL].get(); + } + } + authRequestContext_->token = std::to_string(GenRandInt(MIN_PIN_TOKEN, MAX_PIN_TOKEN)); +} + int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra) { @@ -331,6 +379,18 @@ void DmAuthManager::ProcessSourceMsg() authRequestState_->TransitionTo(std::make_shared()); } break; + case MSG_TYPE_RESP_PUBLICKEY: + if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_CREDENTIAL) { + authRequestState_->TransitionTo(std::make_shared()); + } + break; + case MSG_TYPE_REQ_SYNC_DELETE_DONE: + if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_SYNCDELETE) { + timer_->DeleteTimer(std::string(SYNC_DELETE_TIMEOUT_TASK)); + isFinishOfLocal_ = false; + authRequestState_->TransitionTo(std::make_shared()); + } + break; default: break; } @@ -365,6 +425,23 @@ void DmAuthManager::ProcessSinkMsg() authResponseState_->TransitionTo(std::make_shared()); } break; + case MSG_TYPE_REQ_PUBLICKEY: + if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_SHOW) { + authResponseState_->TransitionTo(std::make_shared()); + } + break; + case MSG_TYPE_REQ_SYNC_DELETE: + if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_INIT) { + authResponseState_->TransitionTo(std::make_shared()); + } + break; + case MSG_TYPE_REQ_SYNC_DELETE_DONE: + if (authResponseState_->GetStateType() == AuthState::AUTH_REQUEST_SYNCDELETE) { + timer_->DeleteTimer(std::string(SYNC_DELETE_TIMEOUT_TASK)); + isFinishOfLocal_ = false; + authResponseState_->TransitionTo(std::make_shared()); + } + break; default: break; } @@ -1622,5 +1699,230 @@ AesGcmCipherKey DmAuthManager::GetSessionKeyAndLen() memcpy_s(cipherKey.key, cipherKey.keyLen, sessionKey_, cipherKey.keyLen); return cipherKey; } + +void DmAuthManager::CompatiblePutAcl() +{ + LOGI("DmAuthManager::CompatiblePutAcl"); + char localDeviceId[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); + std::string localUdid = static_cast(localDeviceId); + char mUdidHash[DM_MAX_DEVICE_ID_LEN] = {0}; + DmSoftbusAdapterCrypto::GetUdidHash(localUdid, (uint8_t *)mUdidHash); + std::string localUdidHash = static_cast(mUdidHash); + DmAclInfo aclInfo; + aclInfo.bindLevel = DEVICE; + aclInfo.bindType = DM_POINT_TO_POINT; + aclInfo.trustDeviceId = remoteDeviceId_; + if (action_ == USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS) { + aclInfo.authenticationType = ALLOW_AUTH_ALWAYS; + } else { + aclInfo.authenticationType = ALLOW_AUTH_ONCE; + } + aclInfo.deviceIdHash = localUdidHash; + + DmAccesser accesser; + accesser.requestTokenId = authResponseContext_->tokenId; + accesser.requestBundleName = authResponseContext_->hostPkgName; + if (authRequestState_ != nullptr && authResponseState_ == nullptr) { + accesser.requestUserId = MultipleUserConnector::GetCurrentAccountUserID(); + accesser.requestAccountId = MultipleUserConnector::GetOhosAccountId(); + accesser.requestDeviceId = localUdid; + } else if (authRequestState_ == nullptr && authResponseState_ != nullptr) { + accesser.requestDeviceId = authResponseContext_->localDeviceId; + } + + DmAccessee accessee; + accessee.trustTokenId = authResponseContext_->tokenId; + accessee.trustBundleName = authResponseContext_->hostPkgName; + if (authRequestState_ != nullptr && authResponseState_ == nullptr) { + accessee.trustDeviceId = remoteDeviceId_; + } else if (authRequestState_ == nullptr && authResponseState_ != nullptr) { + accessee.trustUserId = MultipleUserConnector::GetCurrentAccountUserID(); + accessee.trustAccountId = MultipleUserConnector::GetOhosAccountId(); + accessee.trustDeviceId = localUdid; + } + DeviceProfileConnector::GetInstance().PutAccessControlList(aclInfo, accesser, accessee); +} + +void DmAuthManager::CommonEventCallback(int32_t userId) +{ + LOGI("DmAuthManager::CommonEventCallback"); + if (MultipleUserConnector::GetSwitchOldUserId() == userId) { + AccountIdLogoutEventCallback(userId); + } else { + UserSwitchEventCallback(userId); + } +} + +void DmAuthManager::AccountIdLogoutEventCallback(int32_t userId) +{ + LOGI("DmAuthManager::AccountIdLogoutEventCallback"); + std::string oldAccountId = MultipleUserConnector::GetSwitchOldAccountId(); + std::string currentAccountId = MultipleUserConnector::GetOhosAccountId(); + MultipleUserConnector::SetSwitchOldAccountId(currentAccountId); + if (oldAccountId == currentAccountId) { + LOGE("The account logout is error."); + return; + } + if (currentAccountId == "ohosAnonymousUid" && + DeviceProfileConnector::GetInstance().CheckIdenticalAccount(userId, oldAccountId)) { + DeviceProfileConnector::GetInstance().DeleteAccessControlList(userId, oldAccountId); + DeleteAllGroup(userId); + } +} + +void DmAuthManager::DeleteAllGroup(int32_t userId) +{ + LOGI("DmAuthManager::DeleteAllGroup"); + char localDeviceId[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); + std::string localUdid = static_cast(localDeviceId); + std::vector groupList; + hiChainConnector_->GetRelatedGroups(localUdid, groupList); + for (auto &iter : groupList) { + if (hiChainConnector_->DeleteGroup(iter.groupId) != DM_OK) { + LOGE("Delete groupId %s failed.", iter.groupId.c_str()); + } + } +} + +void DmAuthManager::UserChangeEventCallback(int32_t userId) +{ + LOGI("DmAuthManager::UserChangeEventCallback"); + std::string oldAccountId = MultipleUserConnector::GetSwitchOldAccountId(); + int32_t oldUseId = MultipleUserConnector::GetSwitchOldUserId(); + DeviceProfileConnector::GetInstance().DeleteP2PAccessControlList(oldUseId, oldAccountId); + DeviceProfileConnector::GetInstance().DeleteP2PAccessControlList(userId, oldAccountId); + DeleteP2PGroup(userId); +} + +void DmAuthManager::DeleteP2PGroup(int32_t userId) +{ + LOGI("switch user event happen and this user groups will be deleted with userId: %d", userId); + nlohmann::json jsonObj; + jsonObj[FIELD_GROUP_TYPE] = GROUP_TYPE_PEER_TO_PEER_GROUP; + std::string queryParams = jsonObj.dump(); + std::vector groupList; + + int32_t oldUserId = MultipleUserConnector::GetSwitchOldUserId(); + MultipleUserConnector::SetSwitchOldUserId(userId); + if (!hiChainConnector_->GetGroupInfo(oldUserId, queryParams, groupList)) { + LOGE("failed to get the old user id groups"); + return; + } + for (auto iter = groupList.begin(); iter != groupList.end(); iter++) { + int32_t ret = hiChainConnector_->DeleteGroup(oldUserId, iter->groupId); + if (ret != DM_OK) { + LOGE("failed to delete the old user id group"); + } + } + + if (!hiChainConnector_->GetGroupInfo(userId, queryParams, groupList)) { + LOGE("failed to get the user id groups"); + return; + } + for (auto iter = groupList.begin(); iter != groupList.end(); iter++) { + int32_t ret = hiChainConnector_->DeleteGroup(userId, iter->groupId); + if (ret != DM_OK) { + LOGE("failed to delete the user id group"); + } + } +} + +void DmAuthManager::HandleSyncDeleteTimeout(std::string name) +{ + LOGI("DmAuthManager::HandleSyncDeleteTimeout start timer name %s", name.c_str()); + if (authRequestState_ != nullptr && authRequestState_->GetStateType() != AuthState::AUTH_REQUEST_CREDENTIAL_DONE) { + if (authResponseContext_ == nullptr) { + authResponseContext_ = std::make_shared(); + } + authResponseContext_->state = authRequestState_->GetStateType(); + authRequestContext_->reason = ERR_DM_TIME_OUT; + authRequestState_->TransitionTo(std::make_shared()); + } + + if (authResponseState_ != nullptr && + authResponseState_->GetStateType() != AuthState::AUTH_REQUEST_SYNCDELETE_DONE) { + authResponseContext_->state = authResponseState_->GetStateType(); + authResponseContext_->reply = ERR_DM_TIME_OUT; + authResponseState_->TransitionTo(std::make_shared()); + } + LOGI("DmAuthManager::HandleSyncDeleteTimeout start complete"); +} + +int32_t DmAuthManager::DeleteAcl(const std::string &pkgName, const std::string &deviceId) +{ + char localUdid[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localUdid, DEVICE_UUID_LENGTH); + std::string localDeviceId = static_cast(localUdid); + DmOfflineParam offlineParam = + DeviceProfileConnector::GetInstance().DeleteAccessControlList(pkgName, localDeviceId, deviceId); + if (offlineParam.bindType == INVALIED_TYPE) { + LOGE("Acl not contain the pkgName bind data."); + return ERR_DM_FAILED; + } else if (offlineParam.bindType == APP_LEVEL_BIND_TYPE && offlineParam.leftAclNumber != 0) { + LOGI("The pkgName unbind app-level type leftAclNumber not zero."); + softbusConnector_->SetPkgName(pkgName); + softbusConnector_->HandleDeviceOffline(deviceId); + } else if (offlineParam.bindType == APP_LEVEL_BIND_TYPE && offlineParam.leftAclNumber == 0) { + LOGI("The pkgName unbind app-level type leftAclNumber is zero."); + softbusConnector_->SetPkgName(pkgName); + hiChainAuthConnector_->DeleteCredential(deviceId, MultipleUserConnector::GetCurrentAccountUserID()); + } else if (offlineParam.bindType == DEVICE_PEER_TO_PEER_TYPE && offlineParam.leftAclNumber != 0) { + LOGI("Unbind deivce-level, retain identical account bind type."); + } else if (offlineParam.bindType == DEVICE_PEER_TO_PEER_TYPE && offlineParam.leftAclNumber == 0) { + LOGI("Unbind deivce-level, retain null."); + hiChainAuthConnector_->DeleteCredential(deviceId, MultipleUserConnector::GetCurrentAccountUserID()); + } + return DM_OK; +} + +void DmAuthManager::ProRespNegotiateExt(const int32_t &sessionId) +{ + LOGI("DmAuthManager::ProRespNegotiateExt start."); + remoteDeviceId_ = authResponseContext_->localDeviceId; + std::string accountId = MultipleUserConnector::GetOhosAccountId(); + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + MultipleUserConnector::SetSwitchOldAccountId(accountId); + MultipleUserConnector::SetSwitchOldUserId(userId); + authResponseContext_->isIdenticalAccount = false; + if (authResponseContext_->localAccountId == accountId && accountId != "ohosAnonymousUid") { + authResponseContext_->isIdenticalAccount = true; + } + + authResponseContext_->remoteAccountId = authResponseContext_->localAccountId; + authResponseContext_->localAccountId = accountId; + authResponseContext_->remoteUserId = authResponseContext_->localUserId; + authResponseContext_->localUserId = userId; + + char localDeviceId[DEVICE_UUID_LENGTH] = {0}; + GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); + authResponseContext_->deviceId = authResponseContext_->localDeviceId; + authResponseContext_->localDeviceId = static_cast(localDeviceId); + + std::vector bindType = + DeviceProfileConnector::GetInstance().SyncAclByBindType(authResponseContext_->hostPkgName, + authResponseContext_->bindType, authResponseContext_->localDeviceId, authResponseContext_->deviceId); + authResponseContext_->bindType = bindType; + authResponseContext_->authed = !bindType.empty(); + + char udidHash[DM_MAX_DEVICE_ID_LEN] = {0}; + if (DmSoftbusAdapterCrypto::GetUdidHash(remoteDeviceId_, (uint8_t *)udidHash) != DM_OK) { + LOGE("get udidhash by udid: %s failed.", GetAnonyString(udidHash).c_str()); + } + std::string deviceIdHash = static_cast(udidHash); + if (authResponseContext_->isOnline && softbusConnector_->CheckIsOnline(deviceIdHash)) { + authResponseContext_->isOnline = true; + } else { + authResponseContext_->isOnline = false; + } + + authResponseContext_->haveCredential = + hiChainAuthConnector_->QueryCredential(authResponseContext_->deviceId, authResponseContext_->localUserId); + + AbilityNegotiate(); + std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_RESP_NEGOTIATE); + softbusConnector_->GetSoftbusSession()->SendData(sessionId, message); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index 0b6bede47c35d8be35217c86179c8d8eee652c72..73b812724e2a7cc6e5a9097139b4db1beaa25594 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -277,12 +277,13 @@ int32_t HiChainAuthConnector::ImportCredential(int32_t osAccountId, std::string return DM_OK; } -int32_t HiChainAuthConnector::DeleteCredential(std::string &deviceId) +int32_t HiChainAuthConnector::DeleteCredential(const std::string &deviceId, int32_t userId) { LOGI("DeleteCredential start."); nlohmann::json jsonObj; jsonObj["deviceId"] = deviceId; jsonObj["acquireType"] = P2P_BIND; + jsonObj["osAccountId"] = userId; char *requestParam = strdup(jsonObj.dump().c_str()); char *returnData = nullptr; if (ProcessCredential(CRED_OP_DELETE, requestParam, &returnData) != HC_SUCCESS) { diff --git a/services/implementation/src/dependency/softbus/softbus_connector.cpp b/services/implementation/src/dependency/softbus/softbus_connector.cpp index ee3866473c64752f4ebd0200d0ad55e0c643218b..874cb5d8682a266bee0ed020cc5f5126f0b362df 100644 --- a/services/implementation/src/dependency/softbus/softbus_connector.cpp +++ b/services/implementation/src/dependency/softbus/softbus_connector.cpp @@ -651,5 +651,43 @@ void SoftbusConnector::HandleDeviceOnline(std::string &deviceId) LOGI("SoftbusConnector::HandleDeviceOnline"); return; } + +void SoftbusConnector::HandleDeviceOffline(const std::string &deviceId) +{ + LOGI("SoftbusConnector::HandleDeviceOnline"); + return; +} + +bool SoftbusConnector::CheckIsOnline(const std::string &targetDeviceId) +{ + LOGI("Check the device is online."); + int32_t deviceCount = 0; + NodeBasicInfo *nodeInfo = nullptr; + if (GetAllNodeDeviceInfo(DM_PKG_NAME, &nodeInfo, &deviceCount) != DM_OK) { + LOGE("[SOFTBUS]GetAllNodeDeviceInfo failed."); + return ERR_DM_FAILED; + } + for (int32_t i = 0; i < deviceCount; ++i) { + NodeBasicInfo *nodeBasicInfo = nodeInfo + i; + uint8_t mUdid[UDID_BUF_LEN] = {0}; + if (GetNodeKeyInfo(DM_PKG_NAME, reinterpret_cast(nodeBasicInfo->networkId), + NodeDeviceInfoKey::NODE_KEY_UDID, mUdid, sizeof(mUdid)) != DM_OK) { + LOGE("[SOFTBUS]GetNodeKeyInfo failed."); + } + std::string udid = reinterpret_cast(mUdid); + char mUdidHash[DM_MAX_DEVICE_ID_LEN] = {0}; + if (DmSoftbusAdapterCrypto::GetUdidHash(udid, (uint8_t *)mUdidHash) != DM_OK) { + LOGE("get mUdidHash by udid: %s failed.", GetAnonyString(udid).c_str()); + } + std::string udidHash = static_cast(mUdidHash); + if (udidHash == targetDeviceId) { + LOGI("The device is online."); + return true; + } + } + LOGI("The device is not online."); + return false; +} + } // namespace DistributedHardware } // namespace OHOS diff --git a/services/service/include/softbus/softbus_adapter.h b/services/service/include/softbus/softbus_adapter.h new file mode 100644 index 0000000000000000000000000000000000000000..3850ecb28e91fb5a82e1719eebef5fa8db72b834 --- /dev/null +++ b/services/service/include/softbus/softbus_adapter.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_SOFTBUS_ADAPTER +#define OHOS_SOFTBUS_ADAPTER + +#include +#include +#include + +#include "session.h" +#include "single_instance.h" + +#include "dm_constants.h" +#include "dm_device_info.h" +#include "dm_log.h" +namespace OHOS { +namespace DistributedHardware { +class SoftbusAdapter { + DECLARE_SINGLE_INSTANCE_BASE(SoftbusAdapter); +public: + SoftbusAdapter(); + ~SoftbusAdapter(); + int32_t CreateSoftbusSessionServer(const std::string &pkgname, const std::string &sessionName); + int32_t RemoveSoftbusSessionServer(const std::string &pkgname, const std::string &sessionName); + + void OnSoftbusSessionOpened(int32_t sessionId, int32_t result); + void OnSoftbusSessionClosed(int32_t sessionId); + void OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen); + void OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, + const StreamFrameInfo *frameInfo); + void OnMessageReceived(int sessionId, const void *data, unsigned int dataLen) const; + void OnQosEvent(int sessionId, int eventId, int tvCount, const QosTv *tvList) const; + +private: + ISessionListener sessListener_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/service/src/softbus/softbus_adapte.cpp b/services/service/src/softbus/softbus_adapte.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cb3022e704c934bdd18510d10958232ddb3da9a8 --- /dev/null +++ b/services/service/src/softbus/softbus_adapte.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "softbus_adapter.h" + +#include +#include + +#include "softbus_bus_center.h" +#include "softbus_common.h" +#include "device_manager_service.h" +namespace OHOS { +namespace DistributedHardware { +IMPLEMENT_SINGLE_INSTANCE(SoftbusAdapter); +static int32_t DmOnSoftbusSessionOpened(int32_t sessionId, int32_t result) +{ + SoftbusAdapter::GetInstance().OnSoftbusSessionOpened(sessionId, result); + return DM_OK; +} + +static void DmOnSoftbusSessionClosed(int32_t sessionId) +{ + SoftbusAdapter::GetInstance().OnSoftbusSessionClosed(sessionId); +} + +static void DmOnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) +{ + SoftbusAdapter::GetInstance().OnBytesReceived(sessionId, data, dataLen); +} + +static void DmOnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, + const StreamFrameInfo *frameInfo) +{ + SoftbusAdapter::GetInstance().OnStreamReceived(sessionId, data, ext, frameInfo); +} + +static void DmOnMessageReceived(int sessionId, const void *data, unsigned int dataLen) +{ + SoftbusAdapter::GetInstance().OnMessageReceived(sessionId, data, dataLen); +} + +static void DmOnQosEvent(int sessionId, int eventId, int tvCount, const QosTv *tvList) +{ + SoftbusAdapter::GetInstance().OnQosEvent(sessionId, eventId, tvCount, tvList); +} + +SoftbusAdapter::SoftbusAdapter() +{ + LOGI("SoftbusAdapter"); + sessListener_.OnSessionOpened = DmOnSoftbusSessionOpened; + sessListener_.OnSessionClosed = DmOnSoftbusSessionClosed; + sessListener_.OnBytesReceived = DmOnBytesReceived; + sessListener_.OnStreamReceived = DmOnStreamReceived; + sessListener_.OnMessageReceived = DmOnMessageReceived; + sessListener_.OnQosEvent = DmOnQosEvent; +} + +SoftbusAdapter::~SoftbusAdapter() +{ + LOGI("~SoftbusAdapter"); +} + +int32_t SoftbusAdapter::CreateSoftbusSessionServer(const std::string &pkgname, const std::string &sessionName) +{ + LOGI("SoftbusAdapter::CreateSoftbusSessionServer."); + if (CreateSessionServer(pkgname.c_str(), sessionName.c_str(), &sessListener_) != DM_OK) { + LOGE("CreateSoftbusSessionServer failed."); + return ERR_DM_FAILED; + } + LOGI("SoftbusAdapter::CreateSoftbusSessionServer success."); + return DM_OK; +} + +int32_t SoftbusAdapter::RemoveSoftbusSessionServer(const std::string &pkgname, const std::string &sessionName) +{ + LOGI("SoftbusAdapter::RemoveSoftbusSessionServer"); + if (RemoveSessionServer(pkgname.c_str(), sessionName.c_str()) != DM_OK) { + LOGE("RemoveSoftbusSessionServer failed."); + return ERR_DM_FAILED; + } + LOGI("SoftbusAdapter::RemoveSoftbusSessionServer success."); + return DM_OK; +} + +void SoftbusAdapter::OnSoftbusSessionOpened(int32_t sessionId, int32_t result) +{ + LOGI("SoftbusAdapter::OnSoftbusSessionOpened"); + DeviceManagerService::GetInstance().OnUnbindSessionOpened(sessionId, result); +} + +void SoftbusAdapter::OnSoftbusSessionClosed(int32_t sessionId) +{ + LOGI("SoftbusAdapter::OnSoftbusSessionClosed"); + DeviceManagerService::GetInstance().OnUnbindSessionCloseed(sessionId); +} + +void SoftbusAdapter::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) +{ + LOGI("SoftbusAdapter::OnBytesReceived"); + DeviceManagerService::GetInstance().OnUnbindBytesReceived(sessionId, data, dataLen); +} + +void SoftbusAdapter::OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, + const StreamFrameInfo *frameInfo) +{ + (void)data; + (void)ext; + (void)frameInfo; + LOGI("SoftbusAdapter::OnStreamReceived, sessionId:%d", sessionId); +} + +void SoftbusAdapter::OnMessageReceived(int sessionId, const void *data, unsigned int dataLen) const +{ + (void)data; + (void)dataLen; + LOGI("SoftbusAdapter::OnMessageReceived, sessionId:%d", sessionId); +} + +void SoftbusAdapter::OnQosEvent(int sessionId, int eventId, int tvCount, const QosTv *tvList) const +{ + (void)eventId; + (void)tvCount; + (void)tvList; + LOGI("SoftbusAdapter::OnQosEvent, sessionId:%d", sessionId); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn b/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn index d229aa4ed9636c05bd6ab19468ec7c456d53e5bf..dca46d5b28b69468ddda42ca4e2adedc651f5224 100644 --- a/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn +++ b/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn @@ -48,6 +48,8 @@ ohos_fuzztest("DmAuthManagerFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "ipc:ipc_single", "safwk:system_ability_fwk", ] diff --git a/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn b/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn index 69a53b07e58981e37cde9f20c9615bd44adfbcff..75c554288c63f267663d124b604a005fd5e7a823 100644 --- a/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn +++ b/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn @@ -48,6 +48,8 @@ ohos_fuzztest("OnDataReceivedFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "ipc:ipc_single", "safwk:system_ability_fwk", ] diff --git a/test/commonfuzztest/onerror_fuzzer/BUILD.gn b/test/commonfuzztest/onerror_fuzzer/BUILD.gn index 3fa62d9a89c1ce06c7efa8465c8c17fcfbe58c94..10263c5e8b0761a2e9b6828b1b79e9092e2071ba 100644 --- a/test/commonfuzztest/onerror_fuzzer/BUILD.gn +++ b/test/commonfuzztest/onerror_fuzzer/BUILD.gn @@ -47,6 +47,8 @@ ohos_fuzztest("OnErrorFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "ipc:ipc_single", "safwk:system_ability_fwk", ] diff --git a/test/commonfuzztest/onfinish_fuzzer/BUILD.gn b/test/commonfuzztest/onfinish_fuzzer/BUILD.gn index 4eeba7e5be32ba9370fa02447bfc4a6e499b9f6f..650d6df487602bc881642aa5a6925fbddf439efe 100644 --- a/test/commonfuzztest/onfinish_fuzzer/BUILD.gn +++ b/test/commonfuzztest/onfinish_fuzzer/BUILD.gn @@ -47,6 +47,8 @@ ohos_fuzztest("OnFinishFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "ipc:ipc_single", "safwk:system_ability_fwk", ] diff --git a/test/commonfuzztest/onrequest_fuzzer/BUILD.gn b/test/commonfuzztest/onrequest_fuzzer/BUILD.gn index aeed88085373c13690463ed00dad03b4d3a73f22..2b7280f47340bbfd91678581da80548a7edd8488 100644 --- a/test/commonfuzztest/onrequest_fuzzer/BUILD.gn +++ b/test/commonfuzztest/onrequest_fuzzer/BUILD.gn @@ -48,6 +48,8 @@ ohos_fuzztest("OnRequestFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "ipc:ipc_single", "safwk:system_ability_fwk", ] diff --git a/test/commonfuzztest/pinauth_fuzzer/BUILD.gn b/test/commonfuzztest/pinauth_fuzzer/BUILD.gn index e480b5eb0e999a687c55811029252e8ebef28284..f2fdefdd70527e85ada6586b519a26ed81a67dcd 100644 --- a/test/commonfuzztest/pinauth_fuzzer/BUILD.gn +++ b/test/commonfuzztest/pinauth_fuzzer/BUILD.gn @@ -84,6 +84,8 @@ ohos_fuzztest("PinAuthFuzzTest") { "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "init:libbegetutil", "ipc:ipc_single", "resource_management:resmgr_napi_core", diff --git a/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn b/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn index f9ec729780b024101ddc592734ff4847597c5690..74ff4aa767317c0db9c8d4ba081d94bac6eaada8 100644 --- a/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn +++ b/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn @@ -85,6 +85,8 @@ ohos_fuzztest("PinAuthUiFuzzTest") { "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "init:libbegetutil", "resource_management:resmgr_napi_core", "safwk:system_ability_fwk", diff --git a/test/commonfuzztest/pinholder_fuzzer/BUILD.gn b/test/commonfuzztest/pinholder_fuzzer/BUILD.gn index 88f51c6b69dd87fb45e7a957e719d7d3dd43ff39..68c1ecff41c51edb4bdd5c7304f804d9b6604135 100644 --- a/test/commonfuzztest/pinholder_fuzzer/BUILD.gn +++ b/test/commonfuzztest/pinholder_fuzzer/BUILD.gn @@ -85,6 +85,8 @@ ohos_fuzztest("PinHolderFuzzTest") { "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "init:libbegetutil", "resource_management:resmgr_napi_core", "safwk:system_ability_fwk", diff --git a/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn b/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn index fcc9d785de9c598163f58e91430d5fb289e70e01..46d57ce733d212892984f3b56710d1d70fd0c3a9 100644 --- a/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn @@ -56,6 +56,8 @@ ohos_fuzztest("OnBytesReceivedFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "safwk:system_ability_fwk", ] diff --git a/test/softbusfuzztest/onsessionopened_fuzzer/BUILD.gn b/test/softbusfuzztest/onsessionopened_fuzzer/BUILD.gn index f69ace34795489be5183f7463dc1e5d9b878aca8..ea33bf09f7064032ef7c5409671fc8dc8abd6f38 100644 --- a/test/softbusfuzztest/onsessionopened_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsessionopened_fuzzer/BUILD.gn @@ -56,6 +56,8 @@ ohos_fuzztest("OnSessionOpenedFuzzTest") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "safwk:system_ability_fwk", ] diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 71b3662626eddb144abf80c9d45d85972daa825a..d15cf399b1ff66dabb4c1314db16dcc59476e789 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -74,7 +74,11 @@ ohos_unittest("UTTest_pin_auth") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UnitTest UTTest_pin_auth }}} @@ -93,7 +97,11 @@ ohos_unittest("UTTest_pin_auth_ui") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UnitTest UTTest_pin_auth_ui }}} @@ -186,7 +194,11 @@ ohos_unittest("UTTest_device_manager_service") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UnitTest UTTest_device_manager_service }}} @@ -203,7 +215,11 @@ ohos_unittest("UTTest_hichain_connector") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UnitTest UTTest_hichain_connector }}} @@ -215,6 +231,7 @@ ohos_unittest("UTTest_softbus_connector") { include_dirs = [ "${devicemanager_path}/test/softbusunittest" ] sources = [ + "${devicemanager_path}/commondependency/src/multiple_user_connector.cpp", "${devicemanager_path}/test/softbusunittest/UTTest_softbus_connector.cpp", "${devicemanager_path}/test/unittest/mock/ipc_server_listener.cpp", "${devicemanager_path}/test/unittest/mock/parameter.cpp", @@ -224,7 +241,6 @@ ohos_unittest("UTTest_softbus_connector") { "${servicesimpl_path}/src/adapter/standard/dm_adapter_manager.cpp", "${servicesimpl_path}/src/config/dm_config_manager.cpp", "${servicesimpl_path}/src/dependency/hichain/hichain_connector.cpp", - "${servicesimpl_path}/src/dependency/multipleuser/multiple_user_connector.cpp", "${servicesimpl_path}/src/dependency/softbus/softbus_connector.cpp", "${servicesimpl_path}/src/dependency/softbus/softbus_session.cpp", "${servicesimpl_path}/src/devicestate/dm_device_state_manager.cpp", @@ -237,8 +253,11 @@ ohos_unittest("UTTest_softbus_connector") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "os_account:libaccountkits", ] } @@ -258,6 +277,8 @@ ohos_unittest("UTTest_softbus_listener") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "hisysevent:libhisysevent", "hitrace:hitrace_meter", ] @@ -279,6 +300,8 @@ ohos_unittest("UTTest_softbus_session") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "hisysevent:libhisysevent", "hitrace:hitrace_meter", ] @@ -446,11 +469,18 @@ ohos_unittest("UTTest_multiple_user_connector") { include_dirs = [ "${devicemanager_path}/test/commonunittest" ] - sources = [ "${devicemanager_path}/test/commonunittest/UTTest_multiple_user_connector.cpp" ] + sources = [ + "${devicemanager_path}/commondependency/src/multiple_user_connector.cpp", + "${devicemanager_path}/test/commonunittest/UTTest_multiple_user_connector.cpp", + ] deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "os_account:libaccountkits", + "os_account:os_account_innerkits", + ] } ## UnitTest UTTest_multiple_user_connector }}} @@ -551,7 +581,11 @@ ohos_unittest("UTTest_dm_discovery_filter") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UnitTest UTTest_dm_discovery_filter }}} @@ -560,14 +594,26 @@ ohos_unittest("UTTest_dm_discovery_filter") { ohos_unittest("UTTest_device_manager_service_impl") { module_out_path = module_out_path + include_dirs = [ + "${os_account_path }/interfaces/innerkits/ohosaccount/native/include", + "${os_account_path }/interfaces/innerkits/osaccount/native/include", + ] + sources = [ + "${devicemanager_path}/commondependency/src/multiple_user_connector.cpp", "${servicesimpl_path}/src/device_manager_service_impl.cpp", "UTTest_device_manager_service_impl.cpp", ] deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + "os_account:libaccountkits", + "os_account:os_account_innerkits", + ] } ## UnitTest UTTest_device_manager_service_impl }}} @@ -584,7 +630,11 @@ ohos_unittest("UTTest_device_manager_service_listener") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UnitTest UTTest_device_manager_service_listener }}} @@ -597,7 +647,11 @@ ohos_unittest("UTTest_auth_message_processor") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UTTest_auth_message_processor }}} @@ -610,7 +664,11 @@ ohos_unittest("UTTest_auth_response_state") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UTTest_auth_response_state }}} @@ -623,7 +681,11 @@ ohos_unittest("UTTest_auth_request_state") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UTTest_auth_request_state }}} @@ -652,7 +714,11 @@ ohos_unittest("UTTest_dm_auth_manager") { deps = [ ":device_manager_test_common" ] - external_deps = [ "device_auth:deviceauth_sdk" ] + external_deps = [ + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] } ## UTTest_dm_auth_manager }}} @@ -701,6 +767,8 @@ ohos_unittest("UTTest_dm_discovery_manager") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "hitrace:hitrace_meter", ] } @@ -729,6 +797,8 @@ ohos_unittest("UTTest_dm_publish_manager") { external_deps = [ "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", "hitrace:hitrace_meter", ] }