diff --git a/commondependency/src/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp index b22354b8d6f48bd02ad4bfd8c31582982d6affd3..e81ec4c19108665ee5d8f79a0cc6c530c535e938 100644 --- a/commondependency/src/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -37,6 +37,9 @@ const uint32_t IDENTICAL_ACCOUNT_TYPE = 6; const uint32_t SERVICE_PEER_TO_PEER_TYPE = 7; const uint32_t SERVICE_ACROSS_ACCOUNT_TYPE = 8; +const int32_t USLEEP_TIME_US_120000 = 120000; // 120ms +constexpr uint32_t RETRY_TIMES = 3; + const uint32_t DM_INVALIED_TYPE = 2048; const uint32_t SERVICE = 2; const uint32_t APP = 3; @@ -2109,18 +2112,34 @@ DmOfflineParam DeviceProfileConnector::HandleServiceUnBindEvent(int32_t remoteUs DM_EXPORT std::vector DeviceProfileConnector::GetAllAccessControlProfile() { std::vector profiles; - if (DistributedDeviceProfileClient::GetInstance().GetAllAccessControlProfile(profiles) != DM_OK) { - LOGE("DP failed."); - } + int32_t ret; + uint32_t retryTimes = 0; + do { + ret = DistributedDeviceProfileClient::GetInstance().GetAllAccessControlProfile(profiles); + if (ret != DM_OK) { + ++retryTimes; + LOGE("DP failed."); + usleep(USLEEP_TIME_US_120000); + } + } while (ret != DM_OK && retryTimes < RETRY_TIMES); + return profiles; } DM_EXPORT std::vector DeviceProfileConnector::GetAllAclIncludeLnnAcl() { std::vector profiles; - if (DistributedDeviceProfileClient::GetInstance().GetAllAclIncludeLnnAcl(profiles) != DM_OK) { - LOGE("DP failed."); - } + int32_t ret; + uint32_t retryTimes = 0; + do { + ret = DistributedDeviceProfileClient::GetInstance().GetAllAclIncludeLnnAcl(profiles); + if (ret != DM_OK) { + ++retryTimes; + LOGE("DP failed."); + usleep(USLEEP_TIME_US_120000); + } + } while (ret != DM_OK && retryTimes < RETRY_TIMES); + return profiles; } diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 8073d714bffc4030b2df5cb64540bfb054630204..085c919cc8d090cc5483bb3eb2fbeb4b8cd08abe 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -1176,6 +1176,8 @@ bool DmAuthManager::IsAuthFinish() int32_t DmAuthManager::ConfirmProcess(const int32_t &action) { LOGI("ConfirmProcess start."); + CHECK_NULL_RETURN(authResponseContext_, ERR_DM_POINT_NULL); + authResponseContext_->confirmOperation = action; if (action_ == USER_OPERATION_TYPE_ALLOW_AUTH || action_ == USER_OPERATION_TYPE_ALLOW_AUTH_ALWAYS) { authResponseContext_->reply = USER_OPERATION_TYPE_ALLOW_AUTH; } else { @@ -2409,6 +2411,11 @@ void DmAuthManager::AuthDeviceFinish(int64_t requestId) void DmAuthManager::AuthDeviceError(int64_t requestId, int32_t errorCode) { LOGI("AuthDeviceError start."); + CHECK_NULL_VOID(authResponseContext_); + if (requestId != authResponseContext_->requestId) { + LOGE("reqId: %{public}" PRId64", RespReqId: %{public}" PRId64".", requestId, authResponseContext_->requestId); + return; + } isAuthDevice_ = false; if (authRequestState_ == nullptr || authResponseState_ != nullptr) { if (CheckNeedShowAuthInfoDialog(errorCode)) { @@ -2425,10 +2432,6 @@ void DmAuthManager::AuthDeviceError(int64_t requestId, int32_t errorCode) return; } if (authResponseContext_->authType == AUTH_TYPE_IMPORT_AUTH_CODE) { - if (requestId != authResponseContext_->requestId) { - LOGE("DmAuthManager::AuthDeviceError requestId %{public}" PRId64 "is error.", requestId); - return; - } authResponseContext_->state = AuthState::AUTH_REQUEST_JOIN; authRequestContext_->reason = ERR_DM_AUTH_CODE_INCORRECT; authResponseContext_->reply = ERR_DM_AUTH_CODE_INCORRECT; diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index 97f29240d6040ed719920d5d3d70a9cfd518f349..6fcc9545f28b03e9f558b40367aba5836bc7e799 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -839,6 +839,11 @@ int32_t AuthSrcManager::OnUserOperation(int32_t action, const std::string ¶m void AuthSrcManager::AuthDeviceError(int64_t requestId, int32_t errorCode) { LOGI("AuthSrcManager::AuthDeviceError start."); + CHECK_NULL_VOID(context_); + if (requestId != context_->requestId) { + LOGE("requestId: %{public}" PRId64", context_->requestId: %{public}" PRId64".", requestId, context_->requestId); + return; + } auto curState = context_->authStateMachine->GetCurState(); if (curState == DmAuthStateType::AUTH_SRC_PIN_AUTH_START_STATE || curState == DmAuthStateType::AUTH_SRC_PIN_AUTH_MSG_NEGOTIATE_STATE ||