From d9f821aca49508bd23dc9854e70bdf3bac4a6fdb Mon Sep 17 00:00:00 2001 From: wangbaidong Date: Wed, 11 Jun 2025 21:31:03 +0800 Subject: [PATCH] add isNeedJoinLnn Signed-off-by: wangbaidong --- .../include/authentication/dm_auth_manager.h | 1 + .../include/authentication_v2/dm_auth_context.h | 1 + .../src/authentication/dm_auth_manager.cpp | 11 ++++++++++- .../src/authentication_v2/auth_manager.cpp | 9 ++++++--- .../src/authentication_v2/auth_stages/auth_acl.cpp | 4 +++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 509cb730b..3080fff94 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -626,6 +626,7 @@ private: std::string dmVersion_ = ""; bool isAuthDevice_ = false; bool isAuthenticateDevice_ = false; + bool isNeedJoinLnn_ = true; int32_t authForm_ = DmAuthForm::ACROSS_ACCOUNT; std::string remoteVersion_ = ""; std::atomic authType_ = AUTH_TYPE_UNKNOW; diff --git a/services/implementation/include/authentication_v2/dm_auth_context.h b/services/implementation/include/authentication_v2/dm_auth_context.h index faf47baa2..c007f4ae5 100644 --- a/services/implementation/include/authentication_v2/dm_auth_context.h +++ b/services/implementation/include/authentication_v2/dm_auth_context.h @@ -219,6 +219,7 @@ struct DmAuthContext { DmAccess accesser; DmAccess accessee; std::multimap proxy; // Multimap where the key is the accessor and the value is the accesssee + bool isNeedJoinLnn{true}; std::shared_ptr authStateMachine; std::shared_ptr authUiStateMgr; diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 4bef5ffdc..26d07d2d1 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -64,6 +64,7 @@ const int32_t ALREADY_BIND = 1; const int32_t STRTOLL_BASE_10 = 10; const int32_t MAX_PUT_SESSIONKEY_TIMEOUT = 100; //ms const int32_t SESSION_CLOSE_TIMEOUT = 2; +const char* IS_NEED_JOIN_LNN = "IsNeedJoinLnn"; // clone task timeout map const std::map TASK_TIME_OUT_MAP = { @@ -1495,6 +1496,7 @@ void DmAuthManager::AuthenticateFinish() isAddingMember_ = false; isAuthenticateDevice_ = false; isAuthDevice_ = false; + isNeedJoinLnn_ = true; if (DeviceProfileConnector::GetInstance().GetTrustNumber(remoteDeviceId_) >= 1 && CompareVersion(remoteVersion_, std::string(DM_VERSION_4_1_5_1)) && softbusConnector_->CheckIsOnline(remoteDeviceId_) && authResponseContext_->isFinish) { @@ -2040,6 +2042,10 @@ int32_t DmAuthManager::BindTarget(const std::string &pkgName, const PeerTargetId if (!DmRadarHelper::GetInstance().ReportDiscoverUserRes(info)) { LOGE("ReportDiscoverUserRes failed"); } + if (bindParam.find(IS_NEED_JOIN_LNN) != bindParam.end()) { + std::string isNeedJoinLnnStr = bindParam.at(IS_NEED_JOIN_LNN); + isNeedJoinLnn_ = std::atoi(isNeedJoinLnnStr.c_str()); + } if (pkgName.empty()) { LOGE("DmAuthManager::BindTarget failed, pkgName is empty."); return ERR_DM_INPUT_PARA_INVALID; @@ -3256,7 +3262,10 @@ void DmAuthManager::JoinLnn(const std::string &deviceId, bool isForceJoin) authResponseContext_->remoteSessionKeyId); return; } - softbusConnector_->JoinLnn(deviceId, isForceJoin); + if (isNeedJoinLnn_) { + LOGI("isNeedJoinLnn %{public}d", isNeedJoinLnn_); + softbusConnector_->JoinLnn(deviceId, isForceJoin); + } } int32_t DmAuthManager::GetTokenIdByBundleName(int32_t userId, std::string &bundleName, int64_t &tokenId) diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index cf5a594b2..61c40a1b6 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -47,6 +47,7 @@ constexpr int32_t MIN_PIN_CODE = 100000; constexpr int32_t MAX_PIN_CODE = 999999; constexpr int32_t DM_ULTRASONIC_FORWARD = 0; constexpr int32_t DM_ULTRASONIC_REVERSE = 1; +const char* IS_NEED_JOIN_LNN = "IsNeedJoinLnn"; int32_t GetCloseSessionDelaySeconds(std::string &delaySecondsStr) { @@ -661,6 +662,10 @@ int32_t AuthManager::BindTarget(const std::string &pkgName, const PeerTargetId & if (!DmRadarHelper::GetInstance().ReportDiscoverUserRes(info)) { LOGE("ReportDiscoverUserRes failed"); } + if (bindParam.find(IS_NEED_JOIN_LNN) != bindParam.end()) { + std::string isNeedJoinLnnStr = bindParam.at(IS_NEED_JOIN_LNN); + context_->isNeedJoinLnn = std::atoi(isNeedJoinLnnStr.c_str()); + } if (pkgName.empty()) { LOGE("AuthManager::BindTarget failed, pkgName is empty."); return ERR_DM_INPUT_PARA_INVALID; @@ -677,9 +682,7 @@ int32_t AuthManager::BindTarget(const std::string &pkgName, const PeerTargetId & } if (!targetId.deviceId.empty()) { ret = AuthenticateDevice(pkgName, authType, targetId.deviceId, ParseExtraFromMap(bindParam)); - if (ret != DM_OK) { - return ret; - } + if (ret != DM_OK) { return ret; } } else { LOGE("AuthManager::BindTarget failed, targetId is error."); return ERR_DM_INPUT_PARA_INVALID; diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp index 73dedccd0..d79687789 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_acl.cpp @@ -77,7 +77,7 @@ int32_t AuthSrcDataSyncState::Action(std::shared_ptr context) } bool isNeedJoinLnn = context->softbusConnector->CheckIsNeedJoinLnn(peerDeviceId, context->accessee.addr); // Trigger networking - if (!context->accesser.isOnline || isNeedJoinLnn) { + if ((!context->accesser.isOnline || isNeedJoinLnn) && context->isNeedJoinLnn) { if (context->connSessionType == CONN_SESSION_TYPE_HML) { context->softbusConnector->JoinLnnByHml(context->sessionId, context->accesser.transmitSessionKeyId, context->accessee.transmitSessionKeyId); @@ -123,6 +123,7 @@ int32_t AuthSinkFinishState::Action(std::shared_ptr context) context->accessee.deviceType); LOGI("UpdateFreezeData ret: %{public}d", ret); } + context->isNeedJoinLnn = true; SinkFinish(context); LOGI("AuthSinkFinishState::Action ok"); if (context->cleanNotifyCallback != nullptr) { @@ -146,6 +147,7 @@ int32_t AuthSrcFinishState::Action(std::shared_ptr context) } else { context->state = static_cast(GetStateType()); } + context->isNeedJoinLnn = true; SourceFinish(context); LOGI("AuthSrcFinishState::Action ok"); std::shared_ptr tempContext = context; -- Gitee