diff --git a/frameworks/base/error/error_code.h b/frameworks/base/error/error_code.h index d18faba20c3869b7361802101463fb7163e93a93..7be46c581dd07da41da81cd9dfdf2c92ce6d85ef 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 66078a9ad029c0db8b8402ed3ebc70f219df55f9..54374df7f2e8980a82786e869b46bce14da81006 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 670f0183269a63610287cfade4d6a873dd0be44d..ec9fc239691bbad060553d1d4d06020606967e0d 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 2609475dc6f441109151ee14b63cf4ca6b9f046b..e5de70a35cfcb19f829b43fc60cfc0ae74b0d9de 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 5c56e5646e934123fa206356790fb2b48e03cf92..3129573e20fbd3bfa68ae2eb60b7fdf83db5d7a3 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 {};