From 061d2e0941d1d98987f33cf899ce0f30466ba382 Mon Sep 17 00:00:00 2001 From: yangxuguang-huawei Date: Mon, 14 Apr 2025 18:35:54 +0800 Subject: [PATCH] feat: add sts getForegroundUIAbilities Signed-off-by: yangxuguang-huawei --- frameworks/ets/ani/BUILD.gn | 1 + frameworks/ets/ani/ability_manager/BUILD.gn | 19 +++++++++ .../ets/@ohos.app.ability.abilityManager.ets | 39 +++++++++++++++++++ .../include/ani_common_ability_state_data.h | 2 +- .../src/ani_common_ability_state_data.cpp | 1 + frameworks/native/appkit/BUILD.gn | 1 + 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 frameworks/ets/ani/ability_manager/ets/@ohos.app.ability.abilityManager.ets diff --git a/frameworks/ets/ani/BUILD.gn b/frameworks/ets/ani/BUILD.gn index 9ccd869f389..d2c045122c4 100644 --- a/frameworks/ets/ani/BUILD.gn +++ b/frameworks/ets/ani/BUILD.gn @@ -17,6 +17,7 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") group("ani_packages") { deps = [ "${ability_runtime_path}/frameworks/ets/ani/ability_delegator:ability_delegator_registry_ani_kit", + "${ability_runtime_path}/frameworks/ets/ani/ability_manager:ability_ability_manager_abc_etc", "${ability_runtime_path}/frameworks/ets/ani/ability_manager:ability_manager_ani_kit", "${ability_runtime_path}/frameworks/ets/ani/ani_common:ani_common", "${ability_runtime_path}/frameworks/ets/ani/ani_wantagent_common:ani_wantagent_common", diff --git a/frameworks/ets/ani/ability_manager/BUILD.gn b/frameworks/ets/ani/ability_manager/BUILD.gn index 22436d712e3..ddf08669ea2 100644 --- a/frameworks/ets/ani/ability_manager/BUILD.gn +++ b/frameworks/ets/ani/ability_manager/BUILD.gn @@ -70,3 +70,22 @@ ohos_shared_library("ability_manager_ani_kit") { subsystem_name = "ability" part_name = "ability_runtime" } + +generate_static_abc("ability_ability_manager_abc") { + base_url = "./ets" + files = [ "./ets/@ohos.app.ability.abilityManager.ets" ] + + dst_file = "$target_out_dir/ability_ability_manager.abc" + out_puts = [ "$target_out_dir/ability_ability_manager.abc" ] + + is_boot_abc = "True" + device_dst_file = "/system/framework/ability_ability_manager.abc" +} + +ohos_prebuilt_etc("ability_ability_manager_abc_etc") { + source = "$target_out_dir/ability_ability_manager.abc" + module_install_dir = "framework" + subsystem_name = "ability" + part_name = "ability_runtime" + deps = [ ":ability_ability_manager_abc" ] +} diff --git a/frameworks/ets/ani/ability_manager/ets/@ohos.app.ability.abilityManager.ets b/frameworks/ets/ani/ability_manager/ets/@ohos.app.ability.abilityManager.ets new file mode 100644 index 00000000000..1a72b6b2b4b --- /dev/null +++ b/frameworks/ets/ani/ability_manager/ets/@ohos.app.ability.abilityManager.ets @@ -0,0 +1,39 @@ +/* + * 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. + */ + +import AbilityStateData from 'application.AbilityStateData'; + +export default namespace abilityManager { + loadLibrary("ability_manager_ani_kit.z") + + export native function nativeGetForegroundUIAbilities(): Array; + export function getForegroundUIAbilities():Promise> { + let p = new Promise>((resolve: (data: Array) => void, reject: (error: Error) => void): void => { + let executeFunc = (): Array => { + return nativeGetForegroundUIAbilities(); + }; + let p1 = taskpool.execute(executeFunc); + p1.then((e :NullishType)=>{ + let abilities: Array = e as Array; + resolve(abilities); + }, (err: Error): void => { + reject(err); + }); + }); + return p; + } +} + + diff --git a/frameworks/ets/ani/ani_common/include/ani_common_ability_state_data.h b/frameworks/ets/ani/ani_common/include/ani_common_ability_state_data.h index 9a6d68f555a..120dace7bbb 100644 --- a/frameworks/ets/ani/ani_common/include/ani_common_ability_state_data.h +++ b/frameworks/ets/ani/ani_common/include/ani_common_ability_state_data.h @@ -16,8 +16,8 @@ #ifndef OHOS_ABILITY_RUNNTIME_ANICOMMON_ABILITY_STATE_DATA_H #define OHOS_ABILITY_RUNNTIME_ANICOMMON_ABILITY_STATE_DATA_H -#include "ani_common_util.h" #include "ability_state_data.h" +#include "ani.h" namespace OHOS { namespace AppExecFwk { diff --git a/frameworks/ets/ani/ani_common/src/ani_common_ability_state_data.cpp b/frameworks/ets/ani/ani_common/src/ani_common_ability_state_data.cpp index 29abfa3e4e4..37b9381ad22 100644 --- a/frameworks/ets/ani/ani_common/src/ani_common_ability_state_data.cpp +++ b/frameworks/ets/ani/ani_common/src/ani_common_ability_state_data.cpp @@ -15,6 +15,7 @@ #include "ani_common_ability_state_data.h" +#include "ani_common_util.h" #include "hilog_tag_wrapper.h" namespace OHOS { diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 4972a335829..e61399eee98 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -169,6 +169,7 @@ ohos_shared_library("appkit_native") { "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:app_context_utils", "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/frameworks/ets/ani/ability_manager:ability_manager_ani_kit", "${ability_runtime_path}/js_environment/frameworks/js_environment:js_environment", "${ability_runtime_path}/utils/global/freeze:freeze_util", "${ability_runtime_services_path}/common:app_util", -- Gitee