From 8f16fd6607067f7bb09f09fbbcaf21082d24457b Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Thu, 26 May 2022 23:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=A8=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E4=B8=ADpin=E7=A0=81=E6=98=8E=E6=96=87?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E5=AF=BC=E8=87=B4=E7=9A=84=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20Signed-off-by:=20renguang1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/include/dm_constants.h | 1 + .../dialog_ui/js/pages/index/index.js | 5 ++--- ext/pin_auth/src/standard/pin_auth_ui.cpp | 22 +++++++++++++------ test/unittest/UTTest_auth_request_state.cpp | 2 ++ test/unittest/UTTest_auth_response_state.cpp | 4 ++++ 5 files changed, 24 insertions(+), 10 deletions(-) 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";