From ba58532458dc7e0031bbb0fa294cf2cb63dabe13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 30 Nov 2024 11:29:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=BF=87=E7=A8=8B?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=BC=82=E6=AD=A5=E8=B0=83=E7=94=A8openAuthe?= =?UTF-8?q?ssion=E5=BB=BA=E7=AB=8B=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../include/authentication/dm_auth_manager.h | 2 ++ .../src/authentication/dm_auth_manager.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 38ebf8607..f637598da 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -532,6 +532,7 @@ private: std::string GetBundleName(nlohmann::json &jsonObject); int32_t GetBinderInfo(); void SetProcessInfo(); + void OpenAuthSession(); private: std::shared_ptr softbusConnector_; @@ -568,6 +569,7 @@ private: std::atomic authType_ = AUTH_TYPE_UNKNOW; std::string remoteUdidHash_ = ""; ProcessInfo processInfo_; + static std::shared_ptr sessionState_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 651ddc55e..c90966ebb 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -39,6 +39,7 @@ #include "dm_log.h" #include "dm_radar_helper.h" #include "dm_random.h" +#include "ffrt.h" #include "multiple_user_connector.h" #include "nlohmann/json.hpp" #include "parameter.h" @@ -99,6 +100,7 @@ constexpr const char* DM_VERSION_4_1_5_1 = "4.1.5.1"; constexpr const char* DM_VERSION_5_0_1 = "5.0.1"; constexpr const char* DM_VERSION_5_0_2 = "5.0.2"; std::mutex g_authFinishLock; +std::shared_ptr DmAuthManager::sessionState_ = nullptr; DmAuthManager::DmAuthManager(std::shared_ptr softbusConnector, std::shared_ptr hiChainConnector, @@ -262,9 +264,17 @@ void DmAuthManager::InitAuthState(const std::string &pkgName, int32_t authType, LOGE("ReportAuthStart failed"); } authRequestState_->Enter(); + sessionState_ = authRequestState_; + ffrt::submit([=]() { OpenAuthSession(); }); LOGI("DmAuthManager::AuthenticateDevice complete"); } +void DmAuthManager::OpenAuthSession() +{ + LOGI("state %{public}d", sessionState_->GetStateType()); + sessionState_->Enter(); +} + int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra) { @@ -1283,6 +1293,7 @@ void DmAuthManager::SrcAuthenticateFinish() authRequestContext_ = nullptr; authRequestState_ = nullptr; authTimes_ = 0; + sessionState_ = nullptr; } void DmAuthManager::AuthenticateFinish() -- Gitee From d8cbb6807a0bf115ceb83ab9489cc61a1f450c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Dec 2024 16:27:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- services/implementation/src/authentication/dm_auth_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index c90966ebb..4a076d35e 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -263,7 +263,6 @@ void DmAuthManager::InitAuthState(const std::string &pkgName, int32_t authType, if (!DmRadarHelper::GetInstance().ReportAuthStart(peerTargetId_.deviceId, pkgName)) { LOGE("ReportAuthStart failed"); } - authRequestState_->Enter(); sessionState_ = authRequestState_; ffrt::submit([=]() { OpenAuthSession(); }); LOGI("DmAuthManager::AuthenticateDevice complete"); -- Gitee From b398e009f8549f2bce11e358dd1299b4367aca56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Dec 2024 16:37:57 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../implementation/include/authentication/dm_auth_manager.h | 2 +- services/implementation/src/authentication/dm_auth_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index f637598da..b51251cd1 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -569,7 +569,7 @@ private: std::atomic authType_ = AUTH_TYPE_UNKNOW; std::string remoteUdidHash_ = ""; ProcessInfo processInfo_; - static std::shared_ptr sessionState_; + std::shared_ptr sessionState_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 4a076d35e..d76cf277b 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -100,7 +100,6 @@ constexpr const char* DM_VERSION_4_1_5_1 = "4.1.5.1"; constexpr const char* DM_VERSION_5_0_1 = "5.0.1"; constexpr const char* DM_VERSION_5_0_2 = "5.0.2"; std::mutex g_authFinishLock; -std::shared_ptr DmAuthManager::sessionState_ = nullptr; DmAuthManager::DmAuthManager(std::shared_ptr softbusConnector, std::shared_ptr hiChainConnector, @@ -270,6 +269,7 @@ void DmAuthManager::InitAuthState(const std::string &pkgName, int32_t authType, void DmAuthManager::OpenAuthSession() { + CHECK_NULL_VOID(sessionState_); LOGI("state %{public}d", sessionState_->GetStateType()); sessionState_->Enter(); } -- Gitee From 630aac0337338c5a093814283700348430b2256e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 9 Dec 2024 14:09:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../include/authentication/dm_auth_manager.h | 1 - .../implementation/src/authentication/dm_auth_manager.cpp | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index b51251cd1..820169b41 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -569,7 +569,6 @@ private: std::atomic authType_ = AUTH_TYPE_UNKNOW; std::string remoteUdidHash_ = ""; ProcessInfo processInfo_; - std::shared_ptr sessionState_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index d76cf277b..1a588c3b5 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -262,16 +262,15 @@ void DmAuthManager::InitAuthState(const std::string &pkgName, int32_t authType, if (!DmRadarHelper::GetInstance().ReportAuthStart(peerTargetId_.deviceId, pkgName)) { LOGE("ReportAuthStart failed"); } - sessionState_ = authRequestState_; ffrt::submit([=]() { OpenAuthSession(); }); LOGI("DmAuthManager::AuthenticateDevice complete"); } void DmAuthManager::OpenAuthSession() { - CHECK_NULL_VOID(sessionState_); - LOGI("state %{public}d", sessionState_->GetStateType()); - sessionState_->Enter(); + CHECK_NULL_VOID(authRequestState_); + LOGI("state %{public}d", authRequestState_->GetStateType()); + authRequestState_->Enter(); } int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t authType, @@ -1292,7 +1291,6 @@ void DmAuthManager::SrcAuthenticateFinish() authRequestContext_ = nullptr; authRequestState_ = nullptr; authTimes_ = 0; - sessionState_ = nullptr; } void DmAuthManager::AuthenticateFinish() -- Gitee