diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 15c52772ca41c5f8de857b05d52db09ebfe4d026..5ed774e88f3ed672729e94a1d1d54166276c99b4 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 359721a012625694e3d529ffe5d02a4862b7e301..de940a62a4e95852c5a24a853c86228377715b19 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: