From 8a671fd37c814b1eff39c06f9cc1698abc1f6fa3 Mon Sep 17 00:00:00 2001 From: zexin_c Date: Mon, 2 Feb 2026 16:07:55 +0800 Subject: [PATCH] add agentuiextenion Signed-off-by: zexin_c --- .../frameworks/js/napi/BUILD.gn | 1 + .../napi/agent_ui_extension_ability/BUILD.gn | 60 ++++++ .../agent_ui_extension_ability.js | 18 ++ .../agent_ui_extension_module.cpp | 54 +++++ .../agent_ui_extension_ability/BUILD.gn | 193 ++++++++++++++++++ .../agent_ui_extension.cpp | 40 ++++ .../agent_ui_extension_module_loader.cpp | 48 +++++ .../js_agent_ui_extension.cpp | 39 ++++ .../agent_ui_extension/agent_ui_extension.h | 52 +++++ .../agent_ui_extension_module_loader.h | 61 ++++++ .../js_agent_ui_extension.h | 49 +++++ bundle.json | 3 +- 12 files changed, 617 insertions(+), 1 deletion(-) create mode 100644 agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/BUILD.gn create mode 100644 agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_ability.js create mode 100644 agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_module.cpp create mode 100644 agent_runtime_framework/frameworks/native/agent_ui_extension_ability/BUILD.gn create mode 100644 agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension.cpp create mode 100644 agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension_module_loader.cpp create mode 100644 agent_runtime_framework/frameworks/native/agent_ui_extension_ability/js_agent_ui_extension.cpp create mode 100644 agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension.h create mode 100644 agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension_module_loader.h create mode 100644 agent_runtime_framework/interfaces/kits/agent_ui_extension/js_agent_ui_extension.h diff --git a/agent_runtime_framework/frameworks/js/napi/BUILD.gn b/agent_runtime_framework/frameworks/js/napi/BUILD.gn index bb249d3cf4..3b41c37d48 100644 --- a/agent_runtime_framework/frameworks/js/napi/BUILD.gn +++ b/agent_runtime_framework/frameworks/js/napi/BUILD.gn @@ -18,5 +18,6 @@ group("agent_runtime_napi_packages") { deps = [ "${agent_runtime_framework_path}/frameworks/js/napi/agent_extension_ability:agentextensionability", "${agent_runtime_framework_path}/frameworks/js/napi/agent_extension_context:agentextensioncontext_napi", + "${agent_runtime_framework_path}/frameworks/js/napi/agent_ui_extension_ability:agentuiextensionability", ] } diff --git a/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/BUILD.gn b/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/BUILD.gn new file mode 100644 index 0000000000..a907849dd6 --- /dev/null +++ b/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/BUILD.gn @@ -0,0 +1,60 @@ +# Copyright (c) 2026 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/components/ets_frontend/es2abc_config.gni") +import("//build/ohos.gni") + +es2abc_gen_abc("gen_agent_ui_extension_ability_abc") { + src_js = rebase_path("agent_ui_extension_ability.js") + dst_file = rebase_path(target_out_dir + "/agent_ui_extension_ability.abc") + in_puts = [ "agent_ui_extension_ability.js" ] + out_puts = [ target_out_dir + "/agent_ui_extension_ability.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("agent_ui_extension_ability_js") { + input = "agent_ui_extension_ability.js" + output = target_out_dir + "/agent_ui_extension_ability.o" +} + +gen_js_obj("agent_ui_extension_ability_abc") { + input = get_label_info(":gen_agent_ui_extension_ability_abc", + "target_out_dir") + "/agent_ui_extension_ability.abc" + output = target_out_dir + "/agent_ui_extension_ability_abc.o" + dep = ":gen_agent_ui_extension_ability_abc" +} + +ohos_shared_library("agentuiextensionability") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + sources = [ "agent_ui_extension_module.cpp" ] + + deps = [ + ":agent_ui_extension_ability_abc", + ":agent_ui_extension_ability_js", + ] + + external_deps = [ "napi:ace_napi" ] + + relative_install_dir = "module/app/ability" + subsystem_name = "ability" + part_name = "ability_runtime" +} \ No newline at end of file diff --git a/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_ability.js b/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_ability.js new file mode 100644 index 0000000000..758f24ded1 --- /dev/null +++ b/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_ability.js @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2026 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let UIExtensionAbility = requireNapi('app.ability.UIExtensionAbility'); + +export default class AgentUIExtensionAbility extends UIExtensionAbility {} \ No newline at end of file diff --git a/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_module.cpp b/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_module.cpp new file mode 100644 index 0000000000..dab18fdab9 --- /dev/null +++ b/agent_runtime_framework/frameworks/js/napi/agent_ui_extension_ability/agent_ui_extension_module.cpp @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2026 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "native_engine/native_engine.h" + +extern const char _binary_agent_ui_extension_ability_js_start[]; +extern const char _binary_agent_ui_extension_ability_js_end[]; +extern const char _binary_agent_ui_extension_ability_abc_start[]; +extern const char _binary_agent_ui_extension_ability_abc_end[]; + +static napi_module _module = { + .nm_version = 0, + .nm_filename = "app/ability/libagentuiextensionability.so/agent_ui_extension_ability.js", + .nm_modname = "app.ability.AgentUIExtensionAbility", +}; +extern "C" __attribute__((constructor)) void NAPI_app_ability_AgentUIExtensionAbility_AutoRegister() +{ + napi_module_register(&_module); +} + +extern "C" __attribute__((visibility("default"))) void NAPI_app_ability_AgentUIExtensionAbility_GetJSCode( + const char **buf, int *bufLen) +{ + if (buf != nullptr) { + *buf = _binary_agent_ui_extension_ability_js_start; + } + + if (bufLen != nullptr) { + *bufLen = _binary_agent_ui_extension_ability_js_end - _binary_agent_ui_extension_ability_js_start; + } +} + +extern "C" __attribute__((visibility("default"))) void NAPI_app_ability_AgentUIExtensionAbility_GetABCCode( + const char **buf, int *buflen) +{ + if (buf != nullptr) { + *buf = _binary_agent_ui_extension_ability_abc_start; + } + if (buflen != nullptr) { + *buflen = _binary_agent_ui_extension_ability_abc_end - _binary_agent_ui_extension_ability_abc_start; + } +} \ No newline at end of file diff --git a/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/BUILD.gn b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/BUILD.gn new file mode 100644 index 0000000000..75cf392f2b --- /dev/null +++ b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/BUILD.gn @@ -0,0 +1,193 @@ +# Copyright (c) 2026 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + + +config("ability_config") { + visibility = [ ":*" ] + visibility += [ + "${ability_runtime_native_path}/ability/native/*", + "${ability_runtime_test_path}/*", + "${distributeddatamgr_path}/data_share/interfaces/inner_api/*", + "${imf_path}/frameworks/kits/extension/*", + "${print_fwk_path}/frameworks/kits/extension/*", + "${user_file_service_innerkits_path}/file_access/*", + "${wallpaper_mgr_path}/frameworks/kits/extension/*", + ] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/ability/native", + "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/distributed", + "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/kits", + "${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/remote_register_service", + "${ability_runtime_path}/interfaces/kits/native/ability/native/distributed_ability_runtime", + "${ability_runtime_path}/interfaces/kits/native/appkit/app", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_innerkits_path}/uri/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app", + "${ability_runtime_innerkits_path}/ability_manager/include/continuation", + "${ability_runtime_path}/interfaces/kits/native/appkit/app/task", + "${ability_runtime_napi_path}/inner/napi_common", + "${ability_runtime_napi_path}/featureAbility", + ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + defines = [ "AMS_LOG_TAG = \"Ability\"" ] + defines += [ "AMS_LOG_DOMAIN = 0xD001300" ] + if (target_cpu == "arm64") { + defines += [ "_ARM64_" ] + } + + if (target_cpu == "arm64") { + defines += [ "APP_USE_ARM64" ] + } else if (target_cpu == "arm") { + defines += [ "APP_USE_ARM" ] + } else if (target_cpu == "x86_64") { + defines += [ "APP_USE_X86_64" ] + } + + if (ability_runtime_graphics) { + defines += [ + "SUPPORT_GRAPHICS", + "SUPPORT_SCREEN", + ] + } +} + +config("agent_ui_extension_config") { + visibility = [ ":*" ] + include_dirs = [ + "${agent_runtime_framework_path}/interfaces/kits/native/ability/native/agent_ui_extension_ability", + "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_runtime", + "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_extension_base", + "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", + ] +} + +ohos_shared_library("agent_ui_extension") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + + configs = [ + ":agent_ui_extension_config", + "${ability_runtime_services_path}/common:optimize_config", + ] + + include_dirs = [ "${agent_runtime_framework_path}/interfaces/kits/native/agent_ui_extension", ] + + sources = [ + "${agent_runtime_framework_path}/frameworks/native/agent_ui_extension_ability/agent_ui_extension.cpp", + "${agent_runtime_framework_path}/frameworks/native/agent_ui_extension_ability/js_agent_ui_extension.cpp", + ] + + deps = [ + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:abilitykit_utils", + "${ability_runtime_native_path}/ability/native:extensionkit_native", + "${ability_runtime_native_path}/ability/native:ui_extension", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_napi_path}/inner/napi_common:napi_common", + "${ability_runtime_native_path}/ability:ability_context_native", + "${ability_runtime_native_path}/ability/native:ability_business_error", + "${ability_runtime_native_path}/appkit:app_context", + ] + + external_deps = [ + "ability_base:want", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_napi", + "ipc:ipc_single", + "napi:ace_napi", + ] + + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } + + subsystem_name = "ability" + part_name = "ability_runtime" +} + + +ohos_shared_library("agent_ui_extension_module") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ + "${agent_runtime_framework_path}/interfaces/kits/native/agent_ui_extension", + ] + sources = [ "${agent_runtime_framework_path}/frameworks/native/agent_ui_extension_ability/agent_ui_extension_module_loader.cpp" ] + + configs = [ + ":ability_config", + ":agent_ui_extension_config", + ] + + deps = [ + ":agent_ui_extension", + "${ability_runtime_innerkits_path}/runtime:runtime", + ] + + external_deps = [ + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "bundle_framework:appexecfwk_core", + "hilog:libhilog", + "ipc:ipc_napi", + "ipc:ipc_single", + "napi:ace_napi", + ] + + if (ability_runtime_graphics) { + external_deps += [ + "form_fwk:form_manager", + "window_manager:libwm", + ] + } + + relative_install_dir = "extensionability/" + subsystem_name = "ability" + part_name = "ability_runtime" +} \ No newline at end of file diff --git a/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension.cpp b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension.cpp new file mode 100644 index 0000000000..8db2d1ee93 --- /dev/null +++ b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension.cpp @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2026 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "agent_ui_extension.h" + +#include "hilog_tag_wrapper.h" +#include "js_agent_ui_extension.h" +#include "runtime.h" +#include "ui_extension_context.h" + + +namespace OHOS { +namespace AgentRuntime { +AgentUIExtension *AgentUIExtension::Create(const std::unique_ptr &runtime) +{ + TAG_LOGD(AAFwkTag::SER_ROUTER, "called"); + if (!runtime) { + return new AgentUIExtension(); + } + switch (runtime->GetLanguage()) { + case AbilityRuntime::Runtime::Language::JS: + return JsAgentUIExtension::Create(runtime); + default: + return new AgentUIExtension(); + } +} +} // namespace AgentRuntime +} // namespace OHOS diff --git a/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension_module_loader.cpp b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension_module_loader.cpp new file mode 100644 index 0000000000..9d5da1fd85 --- /dev/null +++ b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/agent_ui_extension_module_loader.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "agent_ui_extension_module_loader.h" + +#include "agent_ui_extension.h" +#include "hilog_tag_wrapper.h" + +namespace OHOS { +namespace AgentRuntime { +AgentUIExtensionModuleLoader::AgentUIExtensionModuleLoader() = default; +AgentUIExtensionModuleLoader::~AgentUIExtensionModuleLoader() = default; + +AbilityRuntime::Extension *AgentUIExtensionModuleLoader::Create( + const std::unique_ptr &runtime) const +{ + TAG_LOGD(AAFwkTag::SER_ROUTER, "called"); +return AgentUIExtension::Create(runtime); +} + +std::map AgentUIExtensionModuleLoader::GetParams() +{ + TAG_LOGD(AAFwkTag::SER_ROUTER, "called"); + std::map params; + // type means extension type in ExtensionAbilityType of extension_ability_info.h, 38 means agent ui extension. + params.insert(std::pair("type", "38")); + params.insert(std::pair("name", "AgentUIExtensionAbility")); + return params; +} + +extern "C" __attribute__((visibility("default"))) void *OHOS_EXTENSION_GetExtensionModule() +{ + return &AgentUIExtensionModuleLoader::GetInstance(); +} +} // namespace AgentRuntime +} // namespace OHOS \ No newline at end of file diff --git a/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/js_agent_ui_extension.cpp b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/js_agent_ui_extension.cpp new file mode 100644 index 0000000000..16facdba12 --- /dev/null +++ b/agent_runtime_framework/frameworks/native/agent_ui_extension_ability/js_agent_ui_extension.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2026 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "agent_ui_extension.h" + +#include "hilog_tag_wrapper.h" +#include "js_agent_ui_extension.h" +#include "runtime.h" +#include "ui_extension_context.h" + +namespace OHOS { +namespace AgentRuntime { +AgentUIExtension *AgentUIExtension::Create(const std::unique_ptr &runtime) +{ + TAG_LOGD(AAFwkTag::SER_ROUTER, "called"); + if (!runtime) { + return new AgentUIExtension(); + } + switch (runtime->GetLanguage()) { + case AbilityRuntime::Runtime::Language::JS: + return JsAgentUIExtension::Create(runtime); + default: + return new AgentUIExtension(); + } +} +} // namespace AgentRuntime +} // namespace OHOS \ No newline at end of file diff --git a/agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension.h b/agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension.h new file mode 100644 index 0000000000..80d1de04c3 --- /dev/null +++ b/agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2026 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AGENT_RUNTIME_AGENT_UI_EXTENSION_H +#define OHOS_AGENT_RUNTIME_AGENT_UI_EXTENSION_H + +#include + +#include "ui_extension_base.h" + +namespace OHOS { +namespace AbilityRuntime { +class Runtime; +} // namespace AbilityRuntime + +namespace AgentRuntime { +/** + * @brief Agent UI Extension base class. + * + * This class provides the base functionality for Agent UI Extension abilities. + * It extends UIExtensionBase and provides factory methods for creating + * language-specific implementations. + */ +class AgentUIExtension : public AbilityRuntime::UIExtensionBase<> { +public: + AgentUIExtension() = default; + virtual ~AgentUIExtension() = default; + + /** + * @brief Create an AgentUIExtension instance based on the runtime language. + * + * @param runtime The runtime instance used to determine the language implementation. + * @return Returns a pointer to the created AgentUIExtension instance. + */ + static AgentUIExtension *Create(const std::unique_ptr &runtime); +}; + +} // namespace AgentRuntime +} // namespace OHOS +#endif // OHOS_AGENT_RUNTIME_AGENT_UI_EXTENSION_H diff --git a/agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension_module_loader.h b/agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension_module_loader.h new file mode 100644 index 0000000000..3d82ccfe40 --- /dev/null +++ b/agent_runtime_framework/interfaces/kits/agent_ui_extension/agent_ui_extension_module_loader.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2026 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AGENT_RUNTIME_AGENT_UI_EXTENSION_MODULE_LOADER_H +#define OHOS_AGENT_RUNTIME_AGENT_UI_EXTENSION_MODULE_LOADER_H + +#include +#include +#include + +#include "extension_module_loader.h" + +namespace OHOS { +namespace AbilityRuntime { +class Runtime; +} // namespace AbilityRuntime + +namespace AgentRuntime { +/** + * @brief Module loader for Agent UI Extension. + * + * This class is responsible for loading Agent UI Extension modules and + * providing the necessary parameters for extension registration. + */ +class AgentUIExtensionModuleLoader : public AbilityRuntime::ExtensionModuleLoader { +public: + AgentUIExtensionModuleLoader(); + virtual ~AgentUIExtensionModuleLoader(); + + /** + * @brief Create an Extension instance based on the runtime. + * + * @param runtime The runtime instance used to create the extension. + * @return Returns a pointer to the created Extension instance. + */ + AbilityRuntime::Extension *Create( + const std::unique_ptr &runtime) const override; + + /** + * @brief Get the parameters for the Agent UI Extension module. + * + * @return Returns a map containing the module parameters including type and name. + */ + std::map GetParams() override; +}; + +} // namespace AgentRuntime +} // namespace OHOS +#endif // OHOS_AGENT_RUNTIME_AGENT_UI_EXTENSION_MODULE_LOADER_H diff --git a/agent_runtime_framework/interfaces/kits/agent_ui_extension/js_agent_ui_extension.h b/agent_runtime_framework/interfaces/kits/agent_ui_extension/js_agent_ui_extension.h new file mode 100644 index 0000000000..7a6805167e --- /dev/null +++ b/agent_runtime_framework/interfaces/kits/agent_ui_extension/js_agent_ui_extension.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2026 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AGENT_RUNTIME_JS_AGENT_UI_EXTENSION_H +#define OHOS_AGENT_RUNTIME_JS_AGENT_UI_EXTENSION_H + +#include + +#include "agent_ui_extension.h" + +namespace OHOS::AbilityRuntime { +class Runtime; +class JsUIExtensionBase; +} + +namespace OHOS { +namespace AgentRuntime { +class AgentUIExtension; +/** + * @brief Basic action extension components. + */ +class JsAgentUIExtension : public AgentUIExtension, public std::enable_shared_from_this { +public: + explicit JsAgentUIExtension(const std::unique_ptr &runtime); + virtual ~JsAgentUIExtension() override; + + /** + * @brief Create JsAgentUIExtension. + * + * @param runtime The runtime. + * @return The JsAgentUIExtension instance. + */ + static JsAgentUIExtension *Create(const std::unique_ptr &runtime); +}; +} // namespace AgentRuntime +} // namespace OHOS +#endif // OHOS_AGENT_RUNTIME_JS_AGENT_UI_EXTENSION_H diff --git a/bundle.json b/bundle.json index 9867d80275..ae677f733c 100644 --- a/bundle.json +++ b/bundle.json @@ -156,7 +156,8 @@ "//foundation/ability/ability_runtime/service_router_framework:srms_target", "//foundation/ability/ability_runtime/service_router_framework:jsapi_target", "//foundation/ability/ability_runtime/agent_runtime_framework/frameworks/js/napi:agent_runtime_napi_packages", - "//foundation/ability/ability_runtime/agent_runtime_framework/frameworks/native/agent_extension:agent_extension_module" + "//foundation/ability/ability_runtime/agent_runtime_framework/frameworks/native/agent_extension:agent_extension_module", + "//foundation/ability/ability_runtime/agent_runtime_framework/frameworks/native/agent_ui_extension_ability:agent_ui_extension_module" ], "inner_api": [ {