From a5e1d7ace4af6bf9cb997deec8ee226d5a8d2925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Jun 2025 09:59:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication_v2/auth_stages/auth_confirm.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp index 564703c74..e8b0abaa6 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp @@ -668,6 +668,7 @@ int32_t AuthSinkConfirmState::Action(std::shared_ptr context) context->accessee.credTypeList = credTypeNegoResult.Dump(); NegotiateAcl(context, aclNegoResult); context->accessee.aclTypeList = aclNegoResult.Dump(); + context->state = static_cast(GetStateType()); if (credTypeNegoResult.Dump() != context->accesser.credTypeList || aclNegoResult.Dump() != context->accesser.aclTypeList) { LOGE("compability negotiate not match."); -- Gitee From 759b724370454b27af177637d1540442e3609e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Jun 2025 18:14:33 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../implementation/src/authentication_v2/auth_manager.cpp | 5 +++++ .../src/authentication_v2/auth_stages/auth_pin_auth.cpp | 1 + .../src/authentication_v2/dm_auth_message_processor.cpp | 2 ++ .../src/authentication_v2/dm_auth_state_machine.cpp | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index cf5a594b2..cf4d8e6d0 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -231,6 +231,7 @@ int32_t AuthManager::StopAuthenticateDevice(const std::string &pkgName) LOGI("AuthManager::StopAuthenticateDevice start"); context_->reason = STOP_BIND; + context->state = static_cast(GetStateType()); if (context_->direction == DM_AUTH_SOURCE) { context_->authStateMachine->TransitionTo(std::make_shared()); } else { @@ -715,6 +716,7 @@ void AuthSinkManager::OnSessionClosed(int32_t sessionId) { LOGI("AuthSrcManager::OnSessionClosed sessionId = %{public}d", sessionId); context_->reason = ERR_DM_SESSION_CLOSED; + context->state = static_cast(GetStateType()) context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -725,6 +727,7 @@ void AuthSinkManager::OnDataReceived(int32_t sessionId, std::string message) if (ret != DM_OK) { LOGE("OnDataReceived failed, parse input message error."); context_->reason = ERR_DM_PARSE_MESSAGE_FAILED; + context->state = static_cast(GetStateType()) context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -800,6 +803,7 @@ void AuthSrcManager::OnSessionOpened(int32_t sessionId, int32_t sessionSide, int void AuthSrcManager::OnSessionClosed(int32_t sessionId) { LOGI("AuthSrcManager::OnSessionClosed sessionId = %{public}d", sessionId); + context->state = static_cast(GetStateType()); context_->reason = ERR_DM_SESSION_CLOSED; context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -815,6 +819,7 @@ void AuthSrcManager::OnDataReceived(int32_t sessionId, std::string message) int32_t ret = context_->authMessageProcessor->ParseMessage(context_, message); if (ret != DM_OK) { LOGE("OnDataReceived failed, parse input message error."); + context->state = static_cast(GetStateType()); context_->reason = ERR_DM_PARSE_MESSAGE_FAILED; context_->authStateMachine->TransitionTo(std::make_shared()); } diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_pin_auth.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_pin_auth.cpp index 913e6cd11..e86e41297 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_pin_auth.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_pin_auth.cpp @@ -406,6 +406,7 @@ int32_t AuthSrcPinNegotiateStartState::Action(std::shared_ptr con return ProcessPinBind(context); } if (!context->needBind && !context->needAgreeCredential && !context->needAuth) { + context->state = static_cast(GetStateType()); context->reason = ERR_DM_BIND_TRUST_TARGET; context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 043302bf8..93d1e4c0e 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -933,6 +933,7 @@ int32_t DmAuthMessageProcessor::ParseMessageSinkFinish(const JsonObject &jsonObj if (context->reason != DM_OK) { context->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); } + context->state = static_cast(GetStateType()) context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } @@ -953,6 +954,7 @@ int32_t DmAuthMessageProcessor::ParseMessageSrcFinish(const JsonObject &jsonObje if (context->reason != DM_OK) { context->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); } + context->state = static_cast(GetStateType()); context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } diff --git a/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp b/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp index fea412184..113cf3718 100644 --- a/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp @@ -320,7 +320,7 @@ void DmAuthStateMachine::Run(std::shared_ptr context) } // Obtain the status and execute the status action. DmAuthStateType stateType = state.value()->GetStateType(); - context->state = static_cast(stateType); + // context->state = static_cast(stateType); int32_t ret = state.value()->Action(context); if (ret != DM_OK) { LOGE("DmAuthStateMachine::Run err:%{public}d", ret); @@ -329,6 +329,7 @@ void DmAuthStateMachine::Run(std::shared_ptr context) context->reason = ret; } context->successFinished = false; + context->state = static_cast(GetCurState()); if (context->direction == DM_AUTH_SOURCE) { this->TransitionTo(std::make_shared()); } else { -- Gitee From 93161a7bcc01c275814af6074da1c46f8ac3969c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Jun 2025 19:41:49 +0800 Subject: [PATCH 3/6] =?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/src/authentication_v2/auth_manager.cpp | 6 ------ .../src/authentication_v2/dm_auth_message_processor.cpp | 2 -- 2 files changed, 8 deletions(-) diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index cf4d8e6d0..d274b91c4 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -229,9 +229,7 @@ int32_t AuthManager::StopAuthenticateDevice(const std::string &pkgName) { (void)pkgName; LOGI("AuthManager::StopAuthenticateDevice start"); - context_->reason = STOP_BIND; - context->state = static_cast(GetStateType()); if (context_->direction == DM_AUTH_SOURCE) { context_->authStateMachine->TransitionTo(std::make_shared()); } else { @@ -716,7 +714,6 @@ void AuthSinkManager::OnSessionClosed(int32_t sessionId) { LOGI("AuthSrcManager::OnSessionClosed sessionId = %{public}d", sessionId); context_->reason = ERR_DM_SESSION_CLOSED; - context->state = static_cast(GetStateType()) context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -727,7 +724,6 @@ void AuthSinkManager::OnDataReceived(int32_t sessionId, std::string message) if (ret != DM_OK) { LOGE("OnDataReceived failed, parse input message error."); context_->reason = ERR_DM_PARSE_MESSAGE_FAILED; - context->state = static_cast(GetStateType()) context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -803,7 +799,6 @@ void AuthSrcManager::OnSessionOpened(int32_t sessionId, int32_t sessionSide, int void AuthSrcManager::OnSessionClosed(int32_t sessionId) { LOGI("AuthSrcManager::OnSessionClosed sessionId = %{public}d", sessionId); - context->state = static_cast(GetStateType()); context_->reason = ERR_DM_SESSION_CLOSED; context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -819,7 +814,6 @@ void AuthSrcManager::OnDataReceived(int32_t sessionId, std::string message) int32_t ret = context_->authMessageProcessor->ParseMessage(context_, message); if (ret != DM_OK) { LOGE("OnDataReceived failed, parse input message error."); - context->state = static_cast(GetStateType()); context_->reason = ERR_DM_PARSE_MESSAGE_FAILED; context_->authStateMachine->TransitionTo(std::make_shared()); } diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 93d1e4c0e..043302bf8 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -933,7 +933,6 @@ int32_t DmAuthMessageProcessor::ParseMessageSinkFinish(const JsonObject &jsonObj if (context->reason != DM_OK) { context->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); } - context->state = static_cast(GetStateType()) context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } @@ -954,7 +953,6 @@ int32_t DmAuthMessageProcessor::ParseMessageSrcFinish(const JsonObject &jsonObje if (context->reason != DM_OK) { context->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); } - context->state = static_cast(GetStateType()); context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } -- Gitee From be11daadaacf84e7a02e7bc659f5537fb0dc4efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Jun 2025 19:46:47 +0800 Subject: [PATCH 4/6] =?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_v2/auth_manager.cpp | 1 + .../src/authentication_v2/auth_stages/auth_confirm.cpp | 1 - .../src/authentication_v2/dm_auth_state_machine.cpp | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index d274b91c4..cf5a594b2 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -229,6 +229,7 @@ int32_t AuthManager::StopAuthenticateDevice(const std::string &pkgName) { (void)pkgName; LOGI("AuthManager::StopAuthenticateDevice start"); + context_->reason = STOP_BIND; if (context_->direction == DM_AUTH_SOURCE) { context_->authStateMachine->TransitionTo(std::make_shared()); diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp index e8b0abaa6..564703c74 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp @@ -668,7 +668,6 @@ int32_t AuthSinkConfirmState::Action(std::shared_ptr context) context->accessee.credTypeList = credTypeNegoResult.Dump(); NegotiateAcl(context, aclNegoResult); context->accessee.aclTypeList = aclNegoResult.Dump(); - context->state = static_cast(GetStateType()); if (credTypeNegoResult.Dump() != context->accesser.credTypeList || aclNegoResult.Dump() != context->accesser.aclTypeList) { LOGE("compability negotiate not match."); diff --git a/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp b/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp index 113cf3718..aa67b91cf 100644 --- a/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp @@ -320,7 +320,6 @@ void DmAuthStateMachine::Run(std::shared_ptr context) } // Obtain the status and execute the status action. DmAuthStateType stateType = state.value()->GetStateType(); - // context->state = static_cast(stateType); int32_t ret = state.value()->Action(context); if (ret != DM_OK) { LOGE("DmAuthStateMachine::Run err:%{public}d", ret); -- Gitee From f876ae3bb4d6c6cbadb945091a34737aef9bb6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Jun 2025 20:07:35 +0800 Subject: [PATCH 5/6] =?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/src/authentication_v2/auth_manager.cpp | 5 +++++ .../src/authentication_v2/dm_auth_message_processor.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index cf5a594b2..f935ef377 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -231,6 +231,7 @@ int32_t AuthManager::StopAuthenticateDevice(const std::string &pkgName) LOGI("AuthManager::StopAuthenticateDevice start"); context_->reason = STOP_BIND; + context_->state = static_cast(context_->authStateMachine->GetCurState()); if (context_->direction == DM_AUTH_SOURCE) { context_->authStateMachine->TransitionTo(std::make_shared()); } else { @@ -715,6 +716,7 @@ void AuthSinkManager::OnSessionClosed(int32_t sessionId) { LOGI("AuthSrcManager::OnSessionClosed sessionId = %{public}d", sessionId); context_->reason = ERR_DM_SESSION_CLOSED; + context_->state = static_cast(context_->authStateMachine->GetCurState()); context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -725,6 +727,7 @@ void AuthSinkManager::OnDataReceived(int32_t sessionId, std::string message) if (ret != DM_OK) { LOGE("OnDataReceived failed, parse input message error."); context_->reason = ERR_DM_PARSE_MESSAGE_FAILED; + context_->state = static_cast(context_->authStateMachine->GetCurState()); context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -801,6 +804,7 @@ void AuthSrcManager::OnSessionClosed(int32_t sessionId) { LOGI("AuthSrcManager::OnSessionClosed sessionId = %{public}d", sessionId); context_->reason = ERR_DM_SESSION_CLOSED; + context_->state = static_cast(context_->authStateMachine->GetCurState()); context_->authStateMachine->TransitionTo(std::make_shared()); } @@ -816,6 +820,7 @@ void AuthSrcManager::OnDataReceived(int32_t sessionId, std::string message) if (ret != DM_OK) { LOGE("OnDataReceived failed, parse input message error."); context_->reason = ERR_DM_PARSE_MESSAGE_FAILED; + context_->state = static_cast(context_->authStateMachine->GetCurState()); context_->authStateMachine->TransitionTo(std::make_shared()); } diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 043302bf8..341d1519b 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -933,6 +933,7 @@ int32_t DmAuthMessageProcessor::ParseMessageSinkFinish(const JsonObject &jsonObj if (context->reason != DM_OK) { context->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); } + context_->state = static_cast(context_->authStateMachine->GetCurState()); context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } @@ -953,6 +954,7 @@ int32_t DmAuthMessageProcessor::ParseMessageSrcFinish(const JsonObject &jsonObje if (context->reason != DM_OK) { context->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); } + context_->state = static_cast(context_->authStateMachine->GetCurState()); context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } @@ -1293,6 +1295,7 @@ void DmAuthMessageProcessor::CreateAndSendMsg(DmMessageType msgType, std::shared auto message = CreateMessage(msgType, context); int32_t ret = context->softbusConnector->GetSoftbusSession()->SendData(context->sessionId, message); if (ret != DM_OK) { + context_->state = static_cast(context_->authStateMachine->GetCurState()); if (context->direction == DM_AUTH_SOURCE) { context->authStateMachine->TransitionTo(std::make_shared()); } else { -- Gitee From 0d562b019481ef44b845bd71a653f331b3be509d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Wed, 4 Jun 2025 20:13:23 +0800 Subject: [PATCH 6/6] =?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/src/authentication_v2/dm_auth_state.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/implementation/src/authentication_v2/dm_auth_state.cpp b/services/implementation/src/authentication_v2/dm_auth_state.cpp index 3476d8563..7ab8d7a8c 100644 --- a/services/implementation/src/authentication_v2/dm_auth_state.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_state.cpp @@ -111,7 +111,7 @@ bool DmAuthState::IsScreenLocked() void DmAuthState::SourceFinish(std::shared_ptr context) { - LOGI("SourceFinish reason:%{public}d", context->reason); + LOGI("SourceFinish reason:%{public}d, state:%{public}d", context->reason, context->state); context->listener->OnAuthResult(context->processInfo, context->peerTargetId.deviceId, context->accessee.tokenIdHash, GetOutputState(context->state), context->reason); context->listener->OnBindResult(context->processInfo, context->peerTargetId, @@ -147,7 +147,7 @@ void DmAuthState::SourceFinish(std::shared_ptr context) void DmAuthState::SinkFinish(std::shared_ptr context) { - LOGI("SinkFinish reason:%{public}d", context->reason); + LOGI("SinkFinish reason:%{public}d, state:%{public}d", context->reason, context->state); context->processInfo.pkgName = context->accessee.pkgName; context->listener->OnSinkBindResult(context->processInfo, context->peerTargetId, GetOutputReplay(context->accessee.bundleName, context->reason), -- Gitee