diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 509cb730bc8386fb3cb33fe971c6527a78053cfa..3080fff94f003b8cf27635d4894a7f009cfd729b 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 faf47baa267731adacb7dbbfd59fdeaf9bfebff6..c007f4ae5cd81da2bd556b707612e9c9411f0d7c 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 4bef5ffdc0e753cefb79e083f35561c1f6b27782..26d07d2d13363c110fcea2d0d21574680345584b 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 cf5a594b28f2402dcf4b1f6264e2e2cd5fc7b0b9..61c40a1b6e727b0bb36057c1f2b9d7411f7f2557 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 73dedccd089963445303624090f8489e53df2147..d79687789b4b8162574c06be60f294250f7fd5ed 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;