From 747e35478682fc74edb518375b6904cd8086dabf Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 18 Jun 2024 00:24:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=89=E8=B5=B7=E8=87=AA=E5=8A=A8=E5=A1=AB?= =?UTF-8?q?=E5=85=85=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xinking129 --- .../include/auto_fill_manager.h | 5 +- .../src/auto_fill_manager.cpp | 46 ++++++++++++++++--- .../auto_fill_manager_test.cpp | 5 +- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h index d781ee7648e..e6eab205706 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h @@ -110,9 +110,10 @@ private: const std::shared_ptr &extensionCallback, Ace::ModalUIExtensionCallbacks &callback); void SetTimeOutEvent(uint32_t eventId); - AutoFill::AutoFillWindowType ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, - bool &isSmartAutoFill); + bool ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, + bool &isSmartAutoFill, AutoFill::AutoFillWindowType &autoFillWindowType); bool IsPreviousRequestFinished(Ace::UIContent *uiContent); + bool IsNeed2SaveRequest(const AbilityBase::ViewData &viewData, bool &isSmartAutoFill); std::mutex extensionCallbacksMutex_; std::mutex modalProxyMapMutex_; diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp index 696bcee9ac2..6a276e0c890 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp @@ -118,7 +118,13 @@ int32_t AutoFillManager::HandleRequestExecuteInner( BindModalUIExtensionCallback(extensionCallback, callback); bool isSmartAutoFill = false; - auto autoFillWindowType = ConvertAutoFillWindowType(request, isSmartAutoFill); + AutoFill::AutoFillWindowType autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; + if (!ConvertAutoFillWindowType(request, isSmartAutoFill, autoFillWindowType)) { + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Convert auto fill type failed."); + RemoveEvent(eventId_); + return AutoFill::AUTO_FILL_CREATE_MODULE_UI_EXTENSION_FAILED; + } + isPopup = autoFillWindowType == AutoFill::AutoFillWindowType::POPUP_WINDOW ? true : false; auto sessionId = CreateAutoFillExtension(uiContent, request, callback, autoFillWindowType, isSmartAutoFill); if (sessionId == AUTO_FILL_UI_EXTENSION_SESSION_ID_INVALID) { @@ -307,10 +313,34 @@ int32_t AutoFillManager::CreateAutoFillExtension(Ace::UIContent *uiContent, return sessionId; } -AutoFill::AutoFillWindowType AutoFillManager::ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, - bool &isSmartAutoFill) +bool AutoFillManager::IsNeed2SaveRequest(const AbilityBase::ViewData& viewData, bool& isSmartAutoFill) { - AutoFill::AutoFillWindowType autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; + bool ret = false; + for (auto it = viewData.nodes.begin(); it != viewData.nodes.end(); ++it) { + if ((it->autoFillType == AbilityBase::AutoFillType::PASSWORD || + it->autoFillType == AbilityBase::AutoFillType::USER_NAME || + it->autoFillType == AbilityBase::AutoFillType::NEW_PASSWORD) && + it->enableAutoFill && !it->value.empty()) { + isSmartAutoFill = false; + return true; + } + if (AbilityBase::AutoFillType::FULL_STREET_ADDRESS <= it->autoFillType && + it->autoFillType <= AbilityBase::AutoFillType::FORMAT_ADDRESS && + it->enableAutoFill && !it->value.empty()) { + { + isSmartAutoFill = false; + ret = true; + } + } + } + return ret; +} + +bool AutoFillManager::ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, + bool &isSmartAutoFill, AutoFill::AutoFillWindowType &autoFillWindowType) +{ + bool ret = true; + autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; AbilityBase::AutoFillType autoFillType = request.autoFillType; if (autoFillType >= AbilityBase::AutoFillType::FULL_STREET_ADDRESS && autoFillType <= AbilityBase::AutoFillType::FORMAT_ADDRESS) { @@ -327,9 +357,11 @@ AutoFill::AutoFillWindowType AutoFillManager::ConvertAutoFillWindowType(const Au isSmartAutoFill = false; } - autoFillWindowType = request.autoFillCommand == AutoFill::AutoFillCommand::SAVE ? - AutoFill::AutoFillWindowType::MODAL_WINDOW : autoFillWindowType; - return autoFillWindowType; + if (request.autoFillCommand == AutoFill::AutoFillCommand::SAVE) { + ret = IsNeed2SaveRequest(request.viewData, isSmartAutoFill); + autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; + } + return ret; } void AutoFillManager::SetTimeOutEvent(uint32_t eventId) diff --git a/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp b/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp index e9d895fff3b..cc88fead412 100644 --- a/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp +++ b/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp @@ -317,12 +317,13 @@ HWTEST_F(AutoFillManagerTest, ConvertAutoFillWindowType_0100, TestSize.Level1) autoFillRequest.autoFillType = AbilityBase::AutoFillType::PASSWORD; auto &manager = AbilityRuntime::AutoFillManager::GetInstance(); bool isSmartAutoFill = false; - auto autoFillWindowType = manager.ConvertAutoFillWindowType(autoFillRequest, isSmartAutoFill); + AutoFill::AutoFillWindowType autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; + manager.ConvertAutoFillWindowType(autoFillRequest, isSmartAutoFill, autoFillWindowType); EXPECT_EQ(isSmartAutoFill, false); autoFillRequest.autoFillCommand = AbilityRuntime::AutoFill::AutoFillCommand::SAVE; autoFillRequest.autoFillType = AbilityBase::AutoFillType::PERSON_FULL_NAME; - autoFillWindowType = manager.ConvertAutoFillWindowType(autoFillRequest, isSmartAutoFill); + manager.ConvertAutoFillWindowType(autoFillRequest, isSmartAutoFill, autoFillWindowType); EXPECT_EQ(isSmartAutoFill, true); EXPECT_EQ(autoFillWindowType, AbilityRuntime::AutoFill::AutoFillWindowType::MODAL_WINDOW); } -- Gitee From d9e47b4ed051c70218009e0cfaaba2a718a8aa59 Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 18 Jun 2024 10:37:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=8F=8A=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xinking129 --- .../inner_api/auto_fill_manager/src/auto_fill_manager.cpp | 6 ++---- .../auto_fill_manager_test/auto_fill_manager_test.cpp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp index 6a276e0c890..fb01a22929a 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp @@ -327,10 +327,8 @@ bool AutoFillManager::IsNeed2SaveRequest(const AbilityBase::ViewData& viewData, if (AbilityBase::AutoFillType::FULL_STREET_ADDRESS <= it->autoFillType && it->autoFillType <= AbilityBase::AutoFillType::FORMAT_ADDRESS && it->enableAutoFill && !it->value.empty()) { - { - isSmartAutoFill = false; - ret = true; - } + isSmartAutoFill = true; + ret = true; } } return ret; diff --git a/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp b/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp index cc88fead412..5648d7829e1 100644 --- a/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp +++ b/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp @@ -317,7 +317,8 @@ HWTEST_F(AutoFillManagerTest, ConvertAutoFillWindowType_0100, TestSize.Level1) autoFillRequest.autoFillType = AbilityBase::AutoFillType::PASSWORD; auto &manager = AbilityRuntime::AutoFillManager::GetInstance(); bool isSmartAutoFill = false; - AutoFill::AutoFillWindowType autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; + AbilityRuntime::AutoFill::AutoFillWindowType autoFillWindowType + = AbilityRuntime::AutoFill::AutoFillWindowType::MODAL_WINDOW; manager.ConvertAutoFillWindowType(autoFillRequest, isSmartAutoFill, autoFillWindowType); EXPECT_EQ(isSmartAutoFill, false); -- Gitee From 35fb8e263e495b784d1997d3ebeb74e01ee15a68 Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 18 Jun 2024 13:02:03 +0800 Subject: [PATCH 3/3] fixed CodeCheck issues Signed-off-by: xinking129 --- .../inner_api/auto_fill_manager/src/auto_fill_manager.cpp | 2 +- test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp index fb01a22929a..3f468888699 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp @@ -335,7 +335,7 @@ bool AutoFillManager::IsNeed2SaveRequest(const AbilityBase::ViewData& viewData, } bool AutoFillManager::ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, - bool &isSmartAutoFill, AutoFill::AutoFillWindowType &autoFillWindowType) + bool &isSmartAutoFill, AutoFill::AutoFillWindowType &autoFillWindowType) { bool ret = true; autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; diff --git a/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp b/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp index 5648d7829e1..026ea6ead2b 100644 --- a/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp +++ b/test/unittest/auto_fill_manager_test/auto_fill_manager_test.cpp @@ -317,7 +317,7 @@ HWTEST_F(AutoFillManagerTest, ConvertAutoFillWindowType_0100, TestSize.Level1) autoFillRequest.autoFillType = AbilityBase::AutoFillType::PASSWORD; auto &manager = AbilityRuntime::AutoFillManager::GetInstance(); bool isSmartAutoFill = false; - AbilityRuntime::AutoFill::AutoFillWindowType autoFillWindowType + AbilityRuntime::AutoFill::AutoFillWindowType autoFillWindowType = AbilityRuntime::AutoFill::AutoFillWindowType::MODAL_WINDOW; manager.ConvertAutoFillWindowType(autoFillRequest, isSmartAutoFill, autoFillWindowType); EXPECT_EQ(isSmartAutoFill, false); -- Gitee