diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 5f1d0250..58c26ce3 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -143,6 +143,7 @@ const int32_t AUTH_TYPE_SCAN = 2; const int32_t AUTH_TYPE_TOUCH = 3; const int32_t DEFAULT_PIN_CODE = 0; const int32_t DEFAULT_PIN_TOKEN = 0; +const int32_t DEFAULT_PIN_CODE_LENGTH = 6; // Softbus const int32_t SOFTBUS_CHECK_INTERVAL = 100000; // 100ms diff --git a/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js index 2fee82db..c897f879 100644 --- a/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js +++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js @@ -31,16 +31,15 @@ export default { onInit() { callNativeHandler(EVENT_INIT, EVENT_INIT_CODE); }, - onChange(e){ + onChange(e){ inputValue = e.value; - }, + }, onConfirm() { if ((inputValue == null) || (inputValue == "")) { return; } this.isTimes--; callNativeHandler(EVENT_CONFIRM, inputValue); - inputValue = ""; }, onCancel() { console.info('click cancel'); diff --git a/ext/pin_auth/src/standard/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp index 4cf7d399..d702ca37 100644 --- a/ext/pin_auth/src/standard/pin_auth_ui.cpp +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -76,13 +76,21 @@ int32_t PinAuthUi::InputPinDialog(std::shared_ptr authManager) OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, [authManager](int32_t id, const std::string& event, const std::string& params) { - if (event == EVENT_INIT) { - authManager->SetPageId(id); - } else if (event == EVENT_CONFIRM) { - LOGI("On confirm event for page id:%d, parms:%s", id, params.c_str()); - authManager->AddMember(std::stoi(params)); - } else { - authManager->SetReasonAndFinish(ERR_DM_AUTH_INPUT_PARAMETER_FAILED, AuthState::AUTH_REQUEST_JOIN); + switch (event) { + case EVENT_INIT: + authManager->SetPageId(id); + break; + case EVENT_CONFIRM: + LOGI("On confirm event for page id:%d, parms:%s", id, params.c_str()); + if (params.length() == DEFAULT_PIN_CODE_LENGTH) { + authManager->AddMember(std::stoi(params)); + } else { + UpdatePinDialog(id); + } + break; + default: + authManager->SetReasonAndFinish(ERR_DM_AUTH_INPUT_PARAMETER_FAILED, AuthState::AUTH_REQUEST_JOIN); + break; } }); LOGI("ShowConfigDialog end"); diff --git a/test/unittest/UTTest_auth_request_state.cpp b/test/unittest/UTTest_auth_request_state.cpp index 65bcc212..9d0b6b0d 100644 --- a/test/unittest/UTTest_auth_request_state.cpp +++ b/test/unittest/UTTest_auth_request_state.cpp @@ -487,6 +487,7 @@ HWTEST_F(AuthRequestStateTest, Enter_012, testing::ext::TestSize.Level0) authManager->authRequestContext_ = std::make_shared(); authManager->authMessageProcessor_ = std::make_shared(authManager); authManager->authResponseContext_ = std::make_shared(); + authManager->authPtr_ = authManager->authenticationMap_[1]; authManager->authResponseContext_->groupId = "111"; authManager->authResponseContext_->groupName = "222"; authManager->authResponseContext_->code = 123; @@ -609,6 +610,7 @@ HWTEST_F(AuthRequestStateTest, Enter_016, testing::ext::TestSize.Level0) std::make_shared(softbusConnector, listener, hiChainConnector); std::shared_ptr authRequestState = std::make_shared(); authManager->timer_ = std::make_shared(); + authManager->authPtr_ = authManager->authenticationMap_[1]; authManager->authMessageProcessor_ = std::make_shared(authManager); authManager->authResponseContext_ = std::make_shared(); authManager->authRequestContext_ = std::make_shared(); diff --git a/test/unittest/UTTest_auth_response_state.cpp b/test/unittest/UTTest_auth_response_state.cpp index 9ddcb2be..51ef19ee 100644 --- a/test/unittest/UTTest_auth_response_state.cpp +++ b/test/unittest/UTTest_auth_response_state.cpp @@ -235,6 +235,7 @@ HWTEST_F(AuthResponseStateTest, Enter_003, testing::ext::TestSize.Level0) authManager->authRequestState_ = std::make_shared(); authManager->authResponseContext_->deviceId = "111"; authManager->authResponseContext_->localDeviceId = "222"; + authManager->authPtr_ = authManager->authenticationMap_[1]; authManager->authMessageProcessor_->SetResponseContext(authManager->authResponseContext_); authManager->authMessageProcessor_->SetRequestContext(authManager->authRequestContext_); authManager->softbusConnector_->GetSoftbusSession()->RegisterSessionCallback(authManager); @@ -397,6 +398,8 @@ HWTEST_F(AuthResponseStateTest, Enter_009, testing::ext::TestSize.Level0) std::make_shared(softbusConnector, listener, hiChainConnector); authManager->authResponseContext_ = std::make_shared(); std::shared_ptr authResponseState = std::make_shared(); + authManager->authPtr_ = authManager->authenticationMap_[1]; + authManager->authResponseContext_->code = 123456; authResponseState->SetAuthManager(authManager); int32_t ret = authResponseState->Enter(); ASSERT_EQ(ret, DM_OK); @@ -453,6 +456,7 @@ HWTEST_F(AuthResponseStateTest, Enter_011, testing::ext::TestSize.Level0) authManager->authRequestContext_ = std::make_shared(); authManager->authMessageProcessor_ = std::make_shared(authManager); authManager->listener_ = std::make_shared(); + authManager->authPtr_ = authManager->authenticationMap_[1]; authManager->authResponseContext_->sessionId = 1; authManager->authRequestContext_->deviceId = "2"; authManager->authRequestContext_->hostPkgName = "3";