diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index c9716d65a4bb94719c11bfa0ab41aca040f4fea7..34350a38c61d31b63f14b2e195841f8fa98d91c3 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -519,6 +519,7 @@ private: void PutAccessControlList(); void SinkAuthenticateFinish(); void SrcAuthenticateFinish(); + static void OpenAuthSession(); std::string GetBundleLable(const std::string &bundleName); bool IsScreenLocked(); std::string ConvertSrcVersion(const std::string &version, const std::string &edition); @@ -530,6 +531,7 @@ private: void DeleteOffLineTimer(int32_t sessionId); private: + static std::shared_ptr sessionState_; std::shared_ptr softbusConnector_; std::shared_ptr hiChainConnector_; 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 f5fb9c185b0b12f21024cdbd78d71e83d6a9ba00..603e8e809e847b2edf9f1f6b25547f2b67c16a08 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "bundle_mgr_interface.h" #include "iservice_registry.h" @@ -94,6 +95,8 @@ constexpr const char* CANCEL_DISPLAY_KEY = "cancelPinCodeDisplay"; 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"; +constexpr const char* DM_OPEN_AUTH_SESSION = "dmOpenAuthSession"; +std::shared_ptr DmAuthManager::sessionState_ = nullptr; std::mutex g_authFinishLock; DmAuthManager::DmAuthManager(std::shared_ptr softbusConnector, @@ -233,10 +236,21 @@ void DmAuthManager::InitAuthState(const std::string &pkgName, int32_t authType, if (!DmRadarHelper::GetInstance().ReportAuthStart(peerTargetId_.deviceId, pkgName)) { LOGE("ReportAuthStart failed"); } - authRequestState_->Enter(); + sessionState_ = authRequestState_; + std::thread openAuthSession(OpenAuthSession); + if (pthread_setname_np(openAuthSession.native_handle(), DM_OPEN_AUTH_SESSION) != DM_OK) { + LOGE("OpenAuthSession setname failed."); + } + openAuthSession.detach(); LOGI("DmAuthManager::AuthenticateDevice complete"); } +void DmAuthManager::OpenAuthSession() +{ + LOGI("DmAuthManager::OpenAuthSession, state %d.", sessionState_->GetStateType()); + sessionState_->Enter(); +} + int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra) { @@ -1245,6 +1259,7 @@ void DmAuthManager::AuthenticateFinish() authResponseContext_ = nullptr; authMessageProcessor_ = nullptr; authPtr_ = nullptr; + sessionState_ = nullptr; LOGI("DmAuthManager::AuthenticateFinish complete"); }