From f075080a9d5cd924cc60b241dfac6aa3eab9b868 Mon Sep 17 00:00:00 2001 From: "xiaocong.ran" Date: Tue, 8 Mar 2022 20:55:47 +0800 Subject: [PATCH] bug Signed-off-by: xiaocong.ran Change-Id: I8db85608de6739d3d6d92e4e04452fce40403fd7 --- ext/pin_auth/src/pin_auth.cpp | 1 + .../src/authentication/dm_auth_manager.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 15c52772c..5ed774e88 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -26,6 +26,7 @@ namespace DistributedHardware { const int32_t MAX_VERIFY_TIMES = 3; PinAuth::PinAuth() { + pinAuthUi_ = std::make_shared(); LOGI("PinAuth constructor"); } diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 359721a01..de940a62a 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -175,6 +175,10 @@ int32_t DmAuthManager::UnAuthenticateDevice(const std::string &pkgName, const st int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam) { LOGI("DmAuthManager::VerifyAuthentication"); + if (authResponseContext_ == nullptr) { + LOGI("authResponseContext_ is not init"); + return DM_FAILED; + } std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end() || timerMap_.find(INPUT_TIMEOUT_TASK) == timerMap_.end()) { @@ -749,7 +753,7 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) authParam.authType = AUTH_TYPE_PIN; authParam.authToken = authResponseContext_->token; - if (role == AbilityRole::ABILITY_ROLE_PASSIVE) { + if (role == AbilityRole::ABILITY_ROLE_PASSIVE && authResponseContext_ != nullptr) { authResponseContext_->code = GeneratePincode(); authParam.packageName = authResponseContext_->targetPkgName; authParam.appName = authResponseContext_->appName; @@ -762,6 +766,10 @@ int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) int32_t DmAuthManager::OnUserOperation(int32_t action) { + if (authResponseContext_ == nullptr) { + LOGI("authResponseContext_ is not init"); + return DM_FAILED; + } switch (action) { case USER_OPERATION_TYPE_ALLOW_AUTH: case USER_OPERATION_TYPE_CANCEL_AUTH: -- Gitee