From fbeb6e7accd3ea97f736fc62624fc06843445565 Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 9 Apr 2024 21:40:44 +0800 Subject: [PATCH] fix autofill unfocus problems Signed-off-by: xinking129 --- .../include/auto_fill_extension_callback.h | 5 +++- .../src/auto_fill_extension_callback.cpp | 25 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h index 34954261c1..9d2a78309d 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h @@ -69,8 +69,11 @@ private: AbilityBase::ViewData viewData_; bool isReloadInModal_ = false; bool isSmartAutoFill_ = false; + bool isOnResult_ = false; + AAFwk::Want want_; + int32_t errCode_ = 0; AbilityBase::AutoFillType autoFillType_ = AbilityBase::AutoFillType::UNSPECIFIED; }; } // AbilityRuntime } // OHOS -#endif // OHOS_ABILITY_RUNTIME_AUTO_FILL_EXTENSION_CALLBACK_H \ No newline at end of file +#endif // OHOS_ABILITY_RUNTIME_AUTO_FILL_EXTENSION_CALLBACK_H diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp index 26e247ba46..f27204b85c 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp @@ -33,14 +33,10 @@ void AutoFillExtensionCallback::OnResult(int32_t errCode, const AAFwk::Want &wan TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called, result code is %{public}d.", errCode); AutoFillManager::GetInstance().RemoveEvent(eventId_); CloseModalUIExtension(); - - if (errCode == AutoFill::AUTO_FILL_SUCCESS) { - SendAutoFillSucess(want); - } else { - auto resultCode = (errCode == AutoFill::AUTO_FILL_CANCEL) ? - AutoFill::AUTO_FILL_CANCEL : AutoFill::AUTO_FILL_FAILED; - SendAutoFillFailed(resultCode); - } + + isOnResult_ = true; + want_ = want; + errCode_ = errCode; } void AutoFillExtensionCallback::OnRelease(int32_t errCode) @@ -128,6 +124,17 @@ void AutoFillExtensionCallback::onDestroy() isReloadInModal_ = false; return; } + if (isOnResult_) { + isOnResult_ = false; + if (errCode_ == AutoFill::AUTO_FILL_SUCCESS) { + SendAutoFillSucess(want_); + } else { + auto resultCode = (errCode_ == AutoFill::AUTO_FILL_CANCEL) ? + AutoFill::AUTO_FILL_CANCEL : AutoFill::AUTO_FILL_FAILED; + SendAutoFillFailed(resultCode); + } + return; + } SendAutoFillFailed(AutoFill::AUTO_FILL_CANCEL); CloseModalUIExtension(); } @@ -233,4 +240,4 @@ void AutoFillExtensionCallback::CloseModalUIExtension() uiContent_ = nullptr; } } // namespace AbilityRuntime -} // namespace OHOS \ No newline at end of file +} // namespace OHOS