From 3cab4d3e3d1674897259c296f8de267982c1fbff Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 10 Mar 2025 10:53:23 +0800 Subject: [PATCH] fix quick mirrow bug, refactor pincode and skipconfirm Signed-off-by: zhuzhihui7 Change-Id: I0d6dab1ec86a8546375acd905a33457305a14bca --- .../authentication/auth_message_processor.cpp | 2 +- .../src/authentication/dm_auth_manager.cpp | 16 ++++++---------- services/service/src/device_manager_service.cpp | 2 +- .../UTTest_dm_auth_manager_first.cpp | 7 ++++++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/services/implementation/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp index b0a52f004..f31dc440a 100644 --- a/services/implementation/src/authentication/auth_message_processor.cpp +++ b/services/implementation/src/authentication/auth_message_processor.cpp @@ -438,7 +438,7 @@ void AuthMessageProcessor::ParsePublicKeyMessageExt(nlohmann::json &json) } if (IsInt32(jsonObject, TAG_SESSIONKEY_ID)) { authResponseContext_->remoteSessionKeyId = jsonObject[TAG_SESSIONKEY_ID].get(); - LOGI("got remoteSessionKeyId"); + LOGI("get remoteSessionKeyId"); } return; } diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 772980d26..a157ce5a3 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -1580,8 +1580,7 @@ bool DmAuthManager::IsPinCodeValid(int32_t numpin) bool DmAuthManager::CanUsePincodeFromDp() { CHECK_NULL_RETURN(authResponseContext_, false); - return (authResponseContext_->authType == AUTH_TYPE_NFC && - IsPinCodeValid(serviceInfoProfile_.GetPinCode()) && + return (IsPinCodeValid(serviceInfoProfile_.GetPinCode()) && serviceInfoProfile_.GetPinExchangeType() == (int32_t)DMLocalServiceInfoPinExchangeType::FROMDP); } @@ -1628,10 +1627,6 @@ bool DmAuthManager::IsLocalServiceInfoValid(const DistributedDeviceProfile::Loca LOGE("PinExchangeType not valid, %{public}d", localServiceInfo.GetPinExchangeType()); return false; } - if (!IsPinCodeValid(localServiceInfo.GetPinCode())) { - LOGE("pincode not valid"); - return false; - } return true; } @@ -1714,7 +1709,7 @@ void DmAuthManager::ShowConfigDialog() LOGE("failed to ShowConfigDialog because authResponseContext_ is nullptr"); return; } - if (CanUsePincodeFromDp() && + if (authResponseContext_->authType == AUTH_TYPE_NFC && serviceInfoProfile_.GetAuthBoxType() == (int32_t)DMLocalServiceInfoAuthBoxType::SKIP_CONFIRM) { LOGI("no need confirm dialog"); StartAuthProcess(serviceInfoProfile_.GetAuthType()); @@ -1820,10 +1815,11 @@ void DmAuthManager::ShowStartAuthDialog() GetAuthCode(authResponseContext_->hostPkgName, pincode) == DM_OK) { LOGI("already has pin code"); ProcessPincode(pincode); - } else { - pincodeDialogEverShown_ = true; - DmDialogManager::GetInstance().ShowInputDialog(authResponseContext_->targetDeviceName); + return; } + + pincodeDialogEverShown_ = true; + DmDialogManager::GetInstance().ShowInputDialog(authResponseContext_->targetDeviceName); } int32_t DmAuthManager::ProcessPincode(int32_t pinCode) diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index ccd96186e..d5f706844 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -3004,7 +3004,7 @@ void DeviceManagerService::AddHmlInfoToBindParam(int32_t actionId, std::string & } } cJSON_AddStringToObject(bindParamObj, PARAM_KEY_CONN_SESSIONTYPE, CONN_SESSION_TYPE_HML); - cJSON_AddNumberToObject(bindParamObj, PARAM_KEY_HML_ACTIONID, actionId); + cJSON_AddStringToObject(bindParamObj, PARAM_KEY_HML_ACTIONID, std::to_string(actionId).c_str()); char *str = cJSON_PrintUnformatted(bindParamObj); if (str == nullptr) { cJSON_Delete(bindParamObj); diff --git a/test/commonunittest/UTTest_dm_auth_manager_first.cpp b/test/commonunittest/UTTest_dm_auth_manager_first.cpp index 450babef2..3f46ba091 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_first.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_first.cpp @@ -2136,7 +2136,7 @@ HWTEST_F(DmAuthManagerTest, IsLocalServiceInfoValid_001, testing::ext::TestSize. profile.SetPinExchangeType(static_cast(DMLocalServiceInfoPinExchangeType::FROMDP)); profile.SetPinCode(""); - ASSERT_FALSE(authManager_->IsLocalServiceInfoValid(profile)); + ASSERT_TRUE(authManager_->IsLocalServiceInfoValid(profile)); profile.SetPinCode(std::to_string(PINCODE)); ASSERT_TRUE(authManager_->IsLocalServiceInfoValid(profile)); @@ -2176,6 +2176,11 @@ HWTEST_F(DmAuthManagerTest, CheckAuthParamVaildExtra_002, testing::ext::TestSize ASSERT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); jsonObject[PARAM_KEY_HML_ACTIONID] = 1; + strExtra = jsonObject.dump(); + ret = authManager_->CheckAuthParamVaildExtra(strExtra, deviceId); + ASSERT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); + + jsonObject[PARAM_KEY_HML_ACTIONID] = "1"; jsonObject[TAG_BIND_LEVEL] = 1; strExtra = jsonObject.dump(); EXPECT_CALL(*appManagerMock_, IsSystemSA()).WillOnce(Return(true)); -- Gitee