diff --git a/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp b/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp index 351694cd4f8af5829fc1d804a8a1245d28b7a989..105588c85571688436aadf51fee94a841175b57c 100644 --- a/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp +++ b/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace AppExecFwk { namespace { constexpr const char *ABILITY_RESULT_CLASS_NAME = "Lability/abilityResult/AbilityResultInner;"; - } // namespace ani_object WrapAbilityResult(ani_env *env, int32_t resultCode, const AAFwk::Want &want) diff --git a/frameworks/ets/ani/native_constructor/context_native_constructor.cpp b/frameworks/ets/ani/native_constructor/context_native_constructor.cpp index cee2ac18682964abd6eefaf1a425e24bf0098318..2326c5f48bdbd1078317a50e95df562b3989b576 100644 --- a/frameworks/ets/ani/native_constructor/context_native_constructor.cpp +++ b/frameworks/ets/ani/native_constructor/context_native_constructor.cpp @@ -26,6 +26,10 @@ void ExtensionContextConstructor() { } +void UIAbilityContextConstructor() +{ +} + extern "C" { ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) { @@ -67,6 +71,21 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) TAG_LOGE(AAFwkTag::ETSRUNTIME, "Cannot bind native ctor to class %{public}s.", extensionContextClassName); return ANI_ERROR; }; + + ani_class uiAbilityClass; + static const char *uiAbilityClassName = "Lapplication/UIAbilityContext/UIAbilityContext;"; + if (ANI_OK != env->FindClass(uiAbilityClassName, &uiAbilityClass)) { + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Not found class %{public}s.", uiAbilityClassName); + return ANI_NOT_FOUND; + } + std::array classMethods_uiAbility = { + ani_native_function {"", ":V", reinterpret_cast(UIAbilityContextConstructor)}, + }; + if (ANI_OK != env->Class_BindNativeMethods(uiAbilityClass, classMethods_uiAbility.data(), + classMethods_uiAbility.size())) { + TAG_LOGE(AAFwkTag::ETSRUNTIME, "Cannot bind native ctor to class %{public}s.", uiAbilityClassName); + return ANI_ERROR; + }; *result = ANI_VERSION_1; return ANI_OK; } diff --git a/frameworks/ets/ets/@ohos.app.ability.contextConstant.ets b/frameworks/ets/ets/@ohos.app.ability.contextConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..bfcb768d98c28c8e23690d2ddcbe5b1c1882d7b4 --- /dev/null +++ b/frameworks/ets/ets/@ohos.app.ability.contextConstant.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +namespace contextConstant { + export enum AreaMode { + EL1 = 0, + EL2 = 1, + EL3 = 2, + EL4 = 3, + EL5 = 4 + } + + export enum ProcessMode { + NEW_PROCESS_ATTACH_TO_PARENT = 1, + NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM = 2, + ATTACH_TO_STATUS_BAR_ITEM = 3 + } + + export enum StartupVisibility { + STARTUP_HIDE = 0, + STARTUP_SHOW = 1 + } +} + +export default contextConstant; diff --git a/frameworks/ets/ets/BUILD.gn b/frameworks/ets/ets/BUILD.gn index 74866580771221d0eead6fee1b1e29fc8155542c..4fa2d8b8e1c6bf5fd99c0c084d2576ec6b165d6f 100644 --- a/frameworks/ets/ets/BUILD.gn +++ b/frameworks/ets/ets/BUILD.gn @@ -401,6 +401,23 @@ ohos_prebuilt_etc("ability_runtime_shell_cmd_result_abc_etc") { deps = [ ":ability_runtime_shell_cmd_result_abc" ] } +generate_static_abc("ability_runtime_ability_context_constant_abc") { + base_url = "./" + files = [ "./@ohos.app.ability.contextConstant.ets" ] + + is_boot_abc = "True" + device_dst_file = + "/system/framework/ability_runtime_ability_context_constant_abc.abc" +} + +ohos_prebuilt_etc("ability_runtime_ability_context_constant_abc_etc") { + source = "$target_out_dir/ability_runtime_ability_context_constant_abc.abc" + module_install_dir = "framework" + subsystem_name = "ability" + part_name = "ability_runtime" + deps = [ ":ability_runtime_ability_context_constant_abc" ] +} + group("ets_packages") { deps = [ ":ability_delegator_abc_etc", @@ -410,6 +427,7 @@ group("ets_packages") { ":ability_delegator_registry_abc_etc", ":ability_runtime_shell_cmd_result_abc_etc", ":ability_runtime_ability_constant_abc_etc", + ":ability_runtime_ability_context_constant_abc_etc", ":ability_runtime_ability_result_abc_etc", ":ability_runtime_ability_stage_abc_etc", ":ability_runtime_ability_utils_abc_etc", diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 689f05e3ff842b02253f29fc9a612c3e34701eff..71cf562509dd4cc06e800c5bf853f426da3892c2 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -20,6 +20,7 @@ #include "configuration_convertor.h" #include "display_util.h" #include "display_info.h" +#include "ets_ui_ability.h" #include "event_report.h" #include "hilog_tag_wrapper.h" #include "hitrace_meter.h" @@ -71,6 +72,8 @@ UIAbility *UIAbility::Create(const std::unique_ptr &runtime) case Runtime::Language::CJ: return CJUIAbility::Create(runtime); #endif + case Runtime::Language::ETS: + return EtsUIAbility::Create(runtime); default: return new (std::nothrow) UIAbility(); } diff --git a/frameworks/native/runtime/ets_data_struct_converter.cpp b/frameworks/native/runtime/ets_data_struct_converter.cpp index a3bf58cd7a6989203e3b92ca8413e4400d52f03a..17ef61e0e9a0321ee5cead43e22bf5fe3d45ab70 100644 --- a/frameworks/native/runtime/ets_data_struct_converter.cpp +++ b/frameworks/native/runtime/ets_data_struct_converter.cpp @@ -21,9 +21,9 @@ namespace OHOS { namespace AbilityRuntime { namespace { -constexpr const char *CLASSNAME_LAUNCHPARAM = "L@ohos/app/ability/AbilityConstant/LaunchParamImpl"; +constexpr const char *CLASSNAME_LAUNCHPARAM = "L@ohos/app/ability/AbilityConstant/LaunchParamImpl;"; constexpr const char *CLASSNAME_LAUNCHREASON = "L@ohos/app/ability/AbilityConstant/AbilityConstant/LaunchReason;"; -constexpr const char *CLASSNAME_LAST_EXITREASION = "L@ohos/app/ability/AbilityConstant/AbilityConstant/LastExitReason"; +constexpr const char *CLASSNAME_LAST_EXITREASION = "L@ohos/app/ability/AbilityConstant/AbilityConstant/LastExitReason;"; ani_string GetAniString(ani_env *env, const std::string &str) { diff --git a/frameworks/native/runtime/ets_runtime.cpp b/frameworks/native/runtime/ets_runtime.cpp index f851bf77ffbed3214af96818595da9d936a4d1c7..5d081e6a73dc84affffe6e3aabbe0bbd6ecc7440 100644 --- a/frameworks/native/runtime/ets_runtime.cpp +++ b/frameworks/native/runtime/ets_runtime.cpp @@ -433,7 +433,7 @@ std::unique_ptr ETSRuntime::LoadEtsModule(const std::string return std::make_unique(); } ani_method loadClassMethod = nullptr; - if (aniEnv->Class_FindMethod(cls, "loadClass", "Lstd/core/String;Z:Lstd/core/Class;", &loadClassMethod) != ANI_OK) { + if (aniEnv->Class_FindMethod(cls, "loadClass", nullptr, &loadClassMethod) != ANI_OK) { TAG_LOGE(AAFwkTag::ETSRUNTIME, "Class_FindMethod loadClass failed"); return std::make_unique(); }