From 122a0480811c187b15f029d5f9b717d3cca37866 Mon Sep 17 00:00:00 2001 From: ZhangYu Date: Mon, 18 Mar 2024 08:06:40 +0000 Subject: [PATCH] lifecycle timeout Signed-off-by: ZhangYu Change-Id: I239f27b311a7f4e6ffd03d063e634e190bc3aaba --- frameworks/base/error/error_code.h | 2 ++ .../pattern/ui_extension/session_wrapper.h | 1 + .../ui_extension/session_wrapper_impl.cpp | 25 +++++++++++++++++-- .../ui_extension/session_wrapper_impl.h | 3 ++- .../window_scene/scene/window_pattern.cpp | 2 ++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/frameworks/base/error/error_code.h b/frameworks/base/error/error_code.h index d18faba20c3..7be46c581dd 100644 --- a/frameworks/base/error/error_code.h +++ b/frameworks/base/error/error_code.h @@ -45,6 +45,8 @@ constexpr int32_t ERROR_CODE_UIEXTENSION_TRANSFER_DATA_FAILED = 100012; constexpr int32_t ERROR_CODE_UIEXTENSION_FORBID_CASCADE = 100013; // The uiextension provider exited abnormally. constexpr int32_t ERROR_CODE_UIEXTENSION_EXITED_ABNORMALLY = 100014; +// The lifecycle of uiextension provider is timeout. +constexpr int32_t ERROR_CODE_UIEXTENSION_LIFECYCLE_TIMEOUT = 100015; // C-API errors constexpr int32_t ERROR_CODE_NATIVE_IMPL_LIBRARY_NOT_FOUND = 106101; diff --git a/frameworks/core/components_ng/pattern/ui_extension/session_wrapper.h b/frameworks/core/components_ng/pattern/ui_extension/session_wrapper.h index 66078a9ad02..54374df7f2e 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/session_wrapper.h +++ b/frameworks/core/components_ng/pattern/ui_extension/session_wrapper.h @@ -99,6 +99,7 @@ public: // The interface for responsing provider virtual void OnConnect() = 0; virtual void OnDisconnect(bool isAbnormal) = 0; + virtual void OnExtensionTimeout(int32_t errorCode) = 0; virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t offset) = 0; // The interface about the accessibility diff --git a/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.cpp b/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.cpp index 670f0183269..ec9fc239691 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.cpp +++ b/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.cpp @@ -52,6 +52,8 @@ constexpr char PULL_FAIL_NAME[] = "extension_pulling_up_fail"; constexpr char PULL_FAIL_MESSAGE[] = "pulling another embedded component failed, not allowed to cascade."; constexpr char EXIT_ABNORMALLY_NAME[] = "extension_exit_abnormally"; constexpr char EXIT_ABNORMALLY_MESSAGE[] = "the extension ability exited abnormally, please check AMS log."; +constexpr char LIFECYCLE_TIMEOUT_NAME[] = "extension_lifecycle_timeout"; +constexpr char LIFECYCLE_TIMEOUT_MESSAGE[] = "the lifecycle of extension ability is timeout, please check AMS log."; // Defines the want parameter to control the soft-keyboard area change of the provider. constexpr char OCCUPIED_AREA_CHANGE_KEY[] = "ability.want.params.IsNotifyOccupiedAreaChange"; // Set the UIExtension type of the EmbeddedComponent. @@ -91,6 +93,13 @@ public: sessionWrapper->OnDisconnect(true); } + void OnExtensionTimeout(int32_t errorCode) override + { + auto sessionWrapper = sessionWrapper_.Upgrade(); + CHECK_NULL_VOID(sessionWrapper); + sessionWrapper->OnExtensionTimeout(errorCode); + } + void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionOffset) override { auto sessionWrapper = sessionWrapper_.Upgrade(); @@ -411,7 +420,7 @@ void SessionWrapperImpl::NotifyDestroy() void SessionWrapperImpl::NotifyConfigurationUpdate() {} /************************************************ End: The lifecycle interface ****************************************/ -/************************* Begin: The interface to control the display area and the avoid area ************************/ +/************************************************ Begin: The interface for responsing provider ************************/ void SessionWrapperImpl::OnConnect() { taskExecutor_->PostTask( @@ -444,6 +453,18 @@ void SessionWrapperImpl::OnDisconnect(bool isAbnormal) TaskExecutor::TaskType::UI); } +void SessionWrapperImpl::OnExtensionTimeout(int32_t errorCode) +{ + taskExecutor_->PostTask( + [weak = hostPattern_]() { + auto pattern = weak.Upgrade(); + CHECK_NULL_VOID(pattern); + pattern->FireOnErrorCallback( + ERROR_CODE_UIEXTENSION_LIFECYCLE_TIMEOUT, LIFECYCLE_TIMEOUT_NAME, LIFECYCLE_TIMEOUT_MESSAGE); + }, + TaskExecutor::TaskType::UI); +} + void SessionWrapperImpl::OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t offset) { taskExecutor_->PostTask( @@ -454,7 +475,7 @@ void SessionWrapperImpl::OnAccessibilityEvent(const Accessibility::Accessibility }, TaskExecutor::TaskType::UI); } -/*************************** End: The interface to control the display area and the avoid area ************************/ +/************************************************** End: The interface for responsing provider ************************/ /************************************************ Begin: The interface about the accessibility ************************/ bool SessionWrapperImpl::TransferExecuteAction( diff --git a/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.h b/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.h index 2609475dc6f..e5de70a35cf 100644 --- a/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.h +++ b/frameworks/core/components_ng/pattern/ui_extension/session_wrapper_impl.h @@ -65,9 +65,10 @@ public: void NotifyDestroy() override; void NotifyConfigurationUpdate() override; - // Notify the Host + // The interface for responsing provider void OnConnect() override; void OnDisconnect(bool isAbnormal) override; + void OnExtensionTimeout(int32_t errorCode) override; void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t offset) override; // The interface about the accessibility diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index 5c56e5646e9..3129573e20f 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -74,6 +74,8 @@ public: void OnExtensionDied() override {} + void OnExtensionTimeout(int32_t errorCode) override {} + void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevelVec) override {}; -- Gitee