diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index cf5a594b28f2402dcf4b1f6264e2e2cd5fc7b0b9..f935ef377a62eacd6c0fc76c8cec915ad1b8b276 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/auth_stages/auth_pin_auth.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_pin_auth.cpp index 913e6cd117655c1a3789eaa0c8bbc73f315ecbcd..e86e41297a8e18063b6faf133e8d31a59a4ba198 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 043302bf8374c79955eafed7cfcc7b5bd48afc6d..341d1519bb4f7d2a8e3fd8865fc91fd83b3ce0b3 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 { diff --git a/services/implementation/src/authentication_v2/dm_auth_state.cpp b/services/implementation/src/authentication_v2/dm_auth_state.cpp index 3476d8563f4de95e73ece17fa2da260fc51a2d2a..7ab8d7a8cda4cca04c3270a42e9d0aef58bf54ed 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), 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 fea4121847bb63a0245eee0c5ca6d1c5c0744134..aa67b91cf100db0978f1b6c60610e08de013cfea 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); @@ -329,6 +328,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 {