From 433eb3f3a5e86f12cc1a2e8f202df81f7e392c9c Mon Sep 17 00:00:00 2001 From: pang-wenbin2 Date: Wed, 15 Jun 2022 12:43:30 +0800 Subject: [PATCH 1/2] Modify the function of GetPincode. Signed-off-by: pang-wenbin2 --- .../src/authentication/dm_auth_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 450829e4e..18587c573 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -670,7 +670,11 @@ int32_t DmAuthManager::SetAuthResponseState(std::shared_ptr a int32_t DmAuthManager::GetPinCode() { - LOGI("ShowConfigDialog start add member pin code %d", authResponseContext_->code); + LOGI("ShowConfigDialog start add member pin code."); + if (authResponseContext_ == nullptr) { + LOGE("authResponseContext_ is nullptr."); + return ERR_DM_AUTH_NOT_START; + } return authResponseContext_->code; } -- Gitee From 9e25efd738805fc676fc59042779aedb430a4a06 Mon Sep 17 00:00:00 2001 From: pang-wenbin2 Date: Wed, 15 Jun 2022 16:53:59 +0800 Subject: [PATCH 2/2] Add the Code of empty_judgment Signed-off-by: pang-wenbin2 --- .../src/authentication/dm_auth_manager.cpp | 67 +++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 18587c573..50386a0a6 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -310,11 +310,15 @@ void DmAuthManager::OnDataReceived(const int32_t sessionId, const std::string me void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId) { - LOGI("DmAuthManager::OnGroupCreated start group id %s", groupId.c_str()); + if (authResponseContext_ == nullptr) { + LOGE("failed to OnGroupCreated"); + return; + } if (authResponseState_ == nullptr) { LOGE("DmAuthManager::AuthenticateDevice end"); return; } + LOGI("DmAuthManager::OnGroupCreated start group id %s", groupId.c_str()); if (groupId == "{}") { authResponseContext_->reply = ERR_DM_CREATE_GROUP_FAILED; authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -340,6 +344,10 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId void DmAuthManager::OnMemberJoin(int64_t requestId, int32_t status) { + if (authResponseContext_ == nullptr) { + LOGE("failed to OnMemberJoin"); + return; + } LOGI("DmAuthManager OnMemberJoin start authTimes %d", authTimes_); if (authRequestState_ != nullptr) { authTimes_++; @@ -397,6 +405,10 @@ int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) void DmAuthManager::StartNegotiate(const int32_t &sessionId) { + if (authResponseContext_ == nullptr) { + LOGE("failed to StartNegotiate"); + return; + } LOGI("DmAuthManager::EstablishAuthChannel session id is %d", sessionId); char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); @@ -415,6 +427,10 @@ void DmAuthManager::StartNegotiate(const int32_t &sessionId) void DmAuthManager::RespNegotiate(const int32_t &sessionId) { + if (authResponseContext_ == nullptr) { + LOGE("failed to RespNegotiate"); + return; + } LOGI("DmAuthManager::EstablishAuthChannel session id is %d", sessionId); char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); @@ -459,6 +475,10 @@ void DmAuthManager::RespNegotiate(const int32_t &sessionId) void DmAuthManager::SendAuthRequest(const int32_t &sessionId) { + if (authResponseContext_ == nullptr) { + LOGE("failed to SendAuthRequest"); + return; + } LOGI("DmAuthManager::EstablishAuthChannel session id"); timer_->DeleteTimer(NEGOTIATE_TIMEOUT_TASK); if (authResponseContext_->cryptoSupport) { @@ -480,12 +500,11 @@ void DmAuthManager::SendAuthRequest(const int32_t &sessionId) int32_t DmAuthManager::StartAuthProcess(const int32_t &action) { - LOGI("DmAuthManager:: StartAuthProcess"); if (authResponseContext_ == nullptr) { LOGI("Authenticate is not start"); return ERR_DM_AUTH_NOT_START; } - + LOGI("DmAuthManager:: StartAuthProcess"); authResponseContext_->reply = action; if (authResponseContext_->reply == USER_OPERATION_TYPE_ALLOW_AUTH && authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_CONFIRM) { @@ -500,6 +519,10 @@ int32_t DmAuthManager::StartAuthProcess(const int32_t &action) void DmAuthManager::StartRespAuthProcess() { + if (authResponseContext_ == nullptr) { + LOGE("failed to StartRespAuthProcess"); + return; + } LOGI("DmAuthManager::StartRespAuthProcess", authResponseContext_->sessionId); timer_->DeleteTimer(CONFIRM_TIMEOUT_TASK); if (authResponseContext_->reply == USER_OPERATION_TYPE_ALLOW_AUTH) { @@ -518,7 +541,11 @@ void DmAuthManager::StartRespAuthProcess() int32_t DmAuthManager::CreateGroup() { - LOGI("DmAuthManager:: CreateGroup"); + if (authResponseContext_ == nullptr) { + LOGE("failed to CreateGroup"); + return ERR_DM_FAILED; + } + LOGI("DmAuthManager:: CreateGroup start"); authResponseContext_->groupName = GenerateGroupName(); authResponseContext_->requestId = GenRandLongLong(MIN_REQUEST_ID, MAX_REQUEST_ID); hiChainConnector_->CreateGroup(authResponseContext_->requestId, authResponseContext_->groupName); @@ -527,6 +554,10 @@ int32_t DmAuthManager::CreateGroup() int32_t DmAuthManager::AddMember(int32_t pinCode) { + if (authResponseContext_ == nullptr) { + LOGE("failed to AddMember"); + return ERR_DM_FAILED; + } LOGI("DmAuthManager::AddMember start group id %s", authResponseContext_->groupId.c_str()); timer_->DeleteTimer(INPUT_TIMEOUT_TASK); nlohmann::json jsonObject; @@ -557,6 +588,10 @@ std::string DmAuthManager::GetConnectAddr(std::string deviceId) int32_t DmAuthManager::JoinNetwork() { + if (authResponseContext_ == nullptr) { + LOGE("failed to JoinNeWork"); + return ERR_DM_FAILED; + } LOGI("DmAuthManager JoinNetwork start"); timer_->DeleteTimer(AUTHENTICATE_TIMEOUT_TASK); authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; @@ -567,6 +602,10 @@ int32_t DmAuthManager::JoinNetwork() void DmAuthManager::AuthenticateFinish() { + if (authResponseContext_ == nullptr) { + LOGE("authResponseContext_ is nullptr"); + return; + } LOGI("DmAuthManager::AuthenticateFinish start"); if (authResponseState_ != nullptr) { if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) { @@ -627,6 +666,10 @@ int32_t DmAuthManager::GeneratePincode() std::string DmAuthManager::GenerateGroupName() { + if (authResponseContext_ == nullptr) { + LOGE("failed to get the authResponseContext_ of targetPkgName."); + return ""; + } char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); std::string sLocalDeviceId = localDeviceId; @@ -670,16 +713,20 @@ int32_t DmAuthManager::SetAuthResponseState(std::shared_ptr a int32_t DmAuthManager::GetPinCode() { - LOGI("ShowConfigDialog start add member pin code."); if (authResponseContext_ == nullptr) { - LOGE("authResponseContext_ is nullptr."); + LOGE("failed to get the authResponseContext_ of pin code"); return ERR_DM_AUTH_NOT_START; } + LOGI("ShowConfigDialog start add member pin code."); return authResponseContext_->code; } void DmAuthManager::ShowConfigDialog() { + if (authResponseContext_ == nullptr) { + LOGI("failed to get the authResponseContext_ of content"); + return; + } LOGI("ShowConfigDialog start"); dmAbilityMgr_ = std::make_shared(); nlohmann::json jsonObj; @@ -695,6 +742,10 @@ void DmAuthManager::ShowConfigDialog() void DmAuthManager::ShowAuthInfoDialog() { + if (authResponseContext_ == nullptr) { + LOGI("failed to get the authResponseContext_ of code"); + return; + } LOGI("DmAuthManager::ShowAuthInfoDialog start %d", authResponseContext_->code); nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = authResponseContext_->code; @@ -704,6 +755,10 @@ void DmAuthManager::ShowAuthInfoDialog() void DmAuthManager::ShowStartAuthDialog() { + if (authResponseContext_ == nullptr) { + LOGI("failed to get the authResponseContext_ of authToken"); + return; + } LOGI("DmAuthManager::ShowStartAuthDialog start"); authPtr_->StartAuth(authResponseContext_->authToken, shared_from_this()); } -- Gitee