diff --git a/frameworks/js/napi/app/app_manager/js_app_manager.cpp b/frameworks/js/napi/app/app_manager/js_app_manager.cpp index 2188d1fb2a6196a640ad3760f24fa0ba68dc77f3..143b3ef4563d18005422f1cfd0f9dec7f63531b4 100644 --- a/frameworks/js/napi/app/app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/app_manager/js_app_manager.cpp @@ -428,7 +428,10 @@ private: task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); return; } - auto ret = appManager->GetAmsMgr()->KillProcessWithAccount(bundleName, accountId); + bool clearPageStack = false; + int32_t appIndex = 0; + auto ret = appManager->GetAmsMgr()->KillProcessWithAccount(bundleName, accountId, + clearPageStack, appIndex); if (ret == 0) { task.Resolve(env, CreateJsUndefined(env)); } else { diff --git a/frameworks/js/napi/app_startup/startup_manager/BUILD.gn b/frameworks/js/napi/app_startup/startup_manager/BUILD.gn index 07a18a2e8febf826d4f3ad859a798c8b29e29d30..7bb76335b5ee4c8771428cd41148e878c41d0d01 100644 --- a/frameworks/js/napi/app_startup/startup_manager/BUILD.gn +++ b/frameworks/js/napi/app_startup/startup_manager/BUILD.gn @@ -31,7 +31,10 @@ ohos_shared_library("startupmanager_napi") { "startup_manager_module.cpp", ] - configs = [ "${ability_runtime_services_path}/common:common_config" ] + configs = [ + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + "${ability_runtime_services_path}/common:common_config", + ] include_dirs = [ "${ability_runtime_path}/interfaces/inner_api/error_utils/include", diff --git a/frameworks/js/napi/application/BUILD.gn b/frameworks/js/napi/application/BUILD.gn index 6e38f0181c5b7a6ec7ee6b60e1abb1a4356a493e..214dacbbe31288e0c41d59982680310423f8e750 100644 --- a/frameworks/js/napi/application/BUILD.gn +++ b/frameworks/js/napi/application/BUILD.gn @@ -37,7 +37,10 @@ ohos_shared_library("application_napi") { "js_application.cpp", ] - configs = [ "${ability_runtime_services_path}/common:common_config" ] + configs = [ + "${ability_runtime_services_path}/common:common_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + ] deps = [ "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index f625944593b896aa3162fffbb503a2e9ee8de995..fb12cce27cdc46c61acc59693d4f435d7fbbb474 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -332,6 +332,8 @@ ohos_shared_library("abilitykit_native") { public_configs = [ ":ability_public_config", "${ability_runtime_native_path}/ability:ability_context_public_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits_public_config", ] diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index c7f2c0bc18d6579f91af768a76e4c6cb06dd6ab6..32352cb95390304c40f347c578e6e96da028085f 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -11,9 +11,31 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") +idl_gen_interface("ability_manager_interface") { + sources = [ + "idl/IUserCallback.idl", + ] + sources_callback = [ + ] + sources_common =[ + ] + log_domainid = "0xD001336" + log_tag = "AbilityMgr" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +config("ability_manager_idl_config") { + include_dirs = [ + "${ability_runtime_innerkits_path}/dataobs_manager/include", + "${target_gen_dir}", + ] +} + config("ability_manager_public_config") { visibility = [ ":*" ] visibility += [ @@ -40,6 +62,7 @@ config("ability_manager_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", "${ability_runtime_path}/interfaces/kits/native/appkit", "${ability_runtime_innerkits_path}/dataobs_manager/include", + "${target_gen_dir}", ] defines = [] @@ -62,7 +85,332 @@ config("ability_manager_public_config") { } } +ohos_source_set("ability_manager_proxy") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":ability_manager_interface") + source_values = [ + "*user_callback_proxy.cpp", + ] + sources = filter_include(output_values, source_values) + + public_configs = [ + ":ability_manager_idl_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + public_deps = [ ":ability_connect_callback_stub" ] + + deps = [ + ":ability_manager_interface", + ":ability_start_options", + ":ability_start_setting", + ":mission_info", + ":process_options", + ":start_window_option", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + ] + + external_deps = [ + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "samgr:samgr_proxy", + ] + + if (host_cpu != "arm64") { + external_deps += [ "relational_store:native_rdb" ] + } + + public_external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "init:libbegetutil", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", + ] + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "ability_base:session_info", + "image_framework:image_native", + "window_manager:libwsutils", + "window_manager:session_manager_lite", + ] + public_external_deps += [ "graphic_2d:color_manager" ] + } + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("ability_manager_stub") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":ability_manager_interface") + source_values = [ + "*user_callback_stub.cpp", + ] + sources = filter_include(output_values, source_values) + + public_configs = [ + ":ability_manager_idl_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + public_deps = [ ":ability_connect_callback_stub" ] + + deps = [ + ":ability_manager_interface", + ":ability_start_options", + ":ability_start_setting", + ":mission_info", + ":process_options", + ":start_window_option", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + ] + + external_deps = [ + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "samgr:samgr_proxy", + ] + + if (host_cpu != "arm64") { + external_deps += [ "relational_store:native_rdb" ] + } + + public_external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "init:libbegetutil", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", + ] + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "ability_base:session_info", + "image_framework:image_native", + "window_manager:libwsutils", + "window_manager:session_manager_lite", + ] + public_external_deps += [ "graphic_2d:color_manager" ] + } + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("abilityms_proxy") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":ability_manager_interface") + source_values = [ + "*user_callback_proxy.cpp", + ] + sources = filter_include(output_values, source_values) + + public_configs = [ + ":ability_manager_idl_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + public_deps = [ ":ability_connect_callback_stub" ] + + deps = [ + ":ability_manager_interface", + ":ability_start_options", + ":ability_start_setting", + ":mission_info", + ":process_options", + ":start_window_option", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + ] + + external_deps = [ + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "samgr:samgr_proxy", + ] + + if (host_cpu != "arm64") { + external_deps += [ "relational_store:native_rdb" ] + } + + public_external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "init:libbegetutil", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", + ] + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "ability_base:session_info", + "image_framework:image_native", + "window_manager:libwsutils", + "window_manager:session_manager_lite", + ] + public_external_deps += [ "graphic_2d:color_manager" ] + } + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("abilityms_stub") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":ability_manager_interface") + source_values = [ + "*ability_managertest_stub.cpp", + ] + sources = filter_include(output_values, source_values) + + public_configs = [ + ":ability_manager_idl_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + public_deps = [ ":ability_connect_callback_stub" ] + + deps = [ + ":ability_manager_interface", + ":ability_start_options", + ":ability_start_setting", + ":mission_info", + ":process_options", + ":start_window_option", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + ] + + external_deps = [ + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "samgr:samgr_proxy", + ] + + if (host_cpu != "arm64") { + external_deps += [ "relational_store:native_rdb" ] + } + + public_external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "init:libbegetutil", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", + ] + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "ability_base:session_info", + "image_framework:image_native", + "window_manager:libwsutils", + "window_manager:session_manager_lite", + ] + public_external_deps += [ "graphic_2d:color_manager" ] + } + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("ability_manager") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } use_exceptions = true branch_protector_ret = "pac_ret" @@ -105,8 +453,6 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/ui_extension/ui_extension_ability_connect_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/ui_extension/ui_extension_host_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/ui_extension/ui_extension_session_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/user_callback_proxy.cpp", - "${ability_runtime_services_path}/abilitymgr/src/user_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/window_config.cpp", "src/aa_tools/abililty_start_with_wait_data.cpp", "src/aa_tools/ability_start_with_wait_observer_proxy.cpp", @@ -129,12 +475,17 @@ ohos_shared_library("ability_manager") { public_configs = [ ":ability_manager_public_config", + ":ability_manager_idl_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", ] public_deps = [ ":ability_connect_callback_stub" ] deps = [ + ":ability_manager_stub", + ":ability_manager_proxy", ":ability_start_options", ":ability_start_setting", ":mission_info", @@ -304,7 +655,11 @@ ohos_shared_library("ability_start_setting") { "${ability_runtime_services_path}/abilitymgr/src/ability_start_setting.cpp", ] - public_configs = [ ":ability_manager_public_config" ] + public_configs = [ + ":ability_manager_public_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] external_deps = [ "c_utils:utils" ] public_external_deps = [ @@ -409,7 +764,11 @@ ohos_shared_library("ability_connect_callback_stub") { sources = [ "${ability_runtime_services_path}/abilitymgr/src/ability_connect_callback_stub.cpp" ] - public_configs = [ ":ability_manager_public_config" ] + public_configs = [ + ":ability_manager_public_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] external_deps = [ "c_utils:utils", @@ -423,6 +782,8 @@ ohos_shared_library("ability_connect_callback_stub") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", ] if (ability_runtime_graphics) { external_deps += [ "graphic_2d:color_manager" ] diff --git a/interfaces/inner_api/ability_manager/idl/IUserCallback.idl b/interfaces/inner_api/ability_manager/idl/IUserCallback.idl new file mode 100755 index 0000000000000000000000000000000000000000..58534c1f0064fa7406545f92312e9969eee3e572 --- /dev/null +++ b/interfaces/inner_api/ability_manager/idl/IUserCallback.idl @@ -0,0 +1,20 @@ +/* + * 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. + */ + +interface OHOS.AAFwk.IUserCallback { + [oneway] void OnStopUserDone([in] int userId, [in] int errcode); + [oneway] void OnStartUserDone([in] int userId, [in] int errcode); + [oneway] void OnLogoutUserDone([in] int userId, [in] int errcode); +} \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 4280ebe0eb63fd683ea63ff03238a35ae58f3126..d303dd793bca5456665f1623abbffec11e1aeb45 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -29,7 +29,7 @@ #include "ability_start_setting.h" #include "ability_state.h" #include "ability_state_data.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "auto_startup_info.h" #include "dms_continueInfo.h" #include "exit_reason.h" @@ -50,7 +50,7 @@ #include "running_process_info.h" #include "sender_info.h" #include "start_options.h" -#include "user_callback.h" +#include "iuser_callback.h" #include "system_memory_attr.h" #include "ui_extension/ui_extension_ability_connect_info.h" #include "ui_extension/ui_extension_host_info.h" diff --git a/interfaces/inner_api/ability_manager/include/user_callback_proxy.h b/interfaces/inner_api/ability_manager/include/user_callback_proxy.h deleted file mode 100644 index e469b70b04d850e35dd14e65d69c4611761d4ca9..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/ability_manager/include/user_callback_proxy.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021-2023 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_ABILITY_RUNTIME_STOP_USER_CALLBACK_PROXY_H -#define OHOS_ABILITY_RUNTIME_STOP_USER_CALLBACK_PROXY_H - -#include -#include "iremote_proxy.h" -#include "user_callback.h" - -namespace OHOS { -namespace AAFwk { -/** - * interface for UserCallbackProxy. - */ -class UserCallbackProxy : public IRemoteProxy { -public: - explicit UserCallbackProxy(const sptr &impl) : IRemoteProxy(impl) - {} - ~UserCallbackProxy() = default; - - /** - * @brief OnStopUserDone. - * - * @param userId userId. - * @param errcode errcode. - */ - virtual void OnStopUserDone(int userId, int errcode) override; - - /** - * @brief OnStartUserDone. - * - * @param userId userId. - * @param errcode errcode. - */ - virtual void OnStartUserDone(int userId, int errcode) override; - - /** - * @brief OnLogoutUserDone. - * - * @param userId userId. - * @param errcode errcode. - */ - virtual void OnLogoutUserDone(int userId, int errcode) override; -private: - void SendRequestCommon(int userId, int errcode, IUserCallback::UserCallbackCmd cmd); - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_STOP_USER_CALLBACK_PROXY_H diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 99c5ec887c546bf0f622b0218d8e4253a822c75d..4e95e0b057c4e12afa6bbb6d3aa6591f04eaa2c1 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -11,9 +11,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") +config("appmgr_idl_config") { + include_dirs = [ + "${target_gen_dir}", + ] +} + config("appmgr_sdk_config") { include_dirs = [ "include/appmgr", @@ -40,7 +47,122 @@ config("appmgr_core_config") { } } +idl_gen_interface("app_mgr_interface") { + sources = [ + "idl/IAbilityDebugResponse.idl", + "idl/IAmsMgr.idl", + "idl/IAppDebugListener.idl", + "idl/IStartSpecifiedAbilityResponse.idl", + ] + sources_callback = [ + "IAppStateCallback.idl", + ] + sources_common = [ + "IAppMgrConstants.idl", + ] + log_domainid = "0xD001311" + log_tag = "AppMgr" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("app_mgr_proxy") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + configs = [ + ":appmgr_core_config", + ":appmgr_sdk_config", + ":appmgr_idl_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] + + output_values = get_target_outputs(":app_mgr_interface") + sources = filter_include(output_values, [ "*_proxy.cpp" ]) + + deps = [ + ":app_mgr_interface", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_interface", + ] + external_deps = [ + "c_utils:utils", + "faultloggerd:libbacktrace_local", + "faultloggerd:libdfx_dumpcatcher", + "faultloggerd:libfaultloggerd", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "json:nlohmann_json_static", + "samgr:samgr_proxy", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "bundle_framework:appexecfwk_base", + "image_framework:image_native", + "relational_store:native_rdb", + ] + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("app_mgr_stub") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + configs = [ + ":appmgr_core_config", + ":appmgr_sdk_config", + ":appmgr_idl_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] + + output_values = get_target_outputs(":app_mgr_interface") + sources = filter_include(output_values, [ "*_stub.cpp" ]) + + deps = [ + ":app_mgr_interface", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_interface", + ] + external_deps = [ + "c_utils:utils", + "faultloggerd:libbacktrace_local", + "faultloggerd:libdfx_dumpcatcher", + "faultloggerd:libfaultloggerd", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "json:nlohmann_json_static", + "samgr:samgr_proxy", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "bundle_framework:appexecfwk_base", + "image_framework:image_native", + "relational_store:native_rdb", + ] + + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("app_manager") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } branch_protector_ret = "pac_ret" include_dirs = [ @@ -55,18 +177,12 @@ ohos_shared_library("app_manager") { "${ability_runtime_services_path}/appdfr/src/appfreeze_manager.cpp", "src/appmgr/ability_controller_proxy.cpp", "src/appmgr/ability_controller_stub.cpp", - "src/appmgr/ability_debug_response_proxy.cpp", - "src/appmgr/ability_debug_response_stub.cpp", "src/appmgr/ability_foreground_state_observer_proxy.cpp", "src/appmgr/ability_foreground_state_observer_stub.cpp", "src/appmgr/ability_info_callback_proxy.cpp", "src/appmgr/ability_info_callback_stub.cpp", "src/appmgr/ability_state_data.cpp", - "src/appmgr/ams_mgr_proxy.cpp", - "src/appmgr/ams_mgr_stub.cpp", "src/appmgr/app_debug_info.cpp", - "src/appmgr/app_debug_listener_proxy.cpp", - "src/appmgr/app_debug_listener_stub.cpp", "src/appmgr/app_foreground_state_observer_proxy.cpp", "src/appmgr/app_foreground_state_observer_stub.cpp", "src/appmgr/app_jsheap_mem_info.cpp", @@ -83,7 +199,6 @@ ohos_shared_library("app_manager") { "src/appmgr/app_scheduler_proxy.cpp", "src/appmgr/app_service_manager.cpp", "src/appmgr/app_state_callback_host.cpp", - "src/appmgr/app_state_callback_proxy.cpp", "src/appmgr/app_state_data.cpp", "src/appmgr/application_state_observer_proxy.cpp", "src/appmgr/application_state_observer_stub.cpp", @@ -117,8 +232,6 @@ ohos_shared_library("app_manager") { "src/appmgr/render_state_observer_stub.cpp", "src/appmgr/running_multi_info.cpp", "src/appmgr/running_process_info.cpp", - "src/appmgr/start_specified_ability_response_proxy.cpp", - "src/appmgr/start_specified_ability_response_stub.cpp", "src/appmgr/system_memory_attr.cpp", "src/appmgr/process_bind_data.cpp", ] @@ -126,6 +239,9 @@ ohos_shared_library("app_manager") { public_configs = [ ":appmgr_core_config", ":appmgr_sdk_config", + ":appmgr_idl_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", ] defines = [ "AMS_LOG_TAG = \"AppexecfwkCore\"" ] @@ -135,6 +251,8 @@ ohos_shared_library("app_manager") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ + ":app_mgr_proxy", + ":app_mgr_stub", "${ability_runtime_path}/utils/global/freeze:freeze_util", "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_services_path}/common:res_sched_util", diff --git a/interfaces/inner_api/ability_manager/include/user_callback_stub.h b/interfaces/inner_api/app_manager/idl/IAbilityDebugResponse.idl old mode 100644 new mode 100755 similarity index 35% rename from interfaces/inner_api/ability_manager/include/user_callback_stub.h rename to interfaces/inner_api/app_manager/idl/IAbilityDebugResponse.idl index bed99d5a402af2831e52066b2c0f0bbebce6da74..e916862a0394079f217d9fde1507bf21cc49aadf --- a/interfaces/inner_api/ability_manager/include/user_callback_stub.h +++ b/interfaces/inner_api/app_manager/idl/IAbilityDebugResponse.idl @@ -1,49 +1,22 @@ -/* - * Copyright (c) 2021-2023 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_ABILITY_RUNTIME_USER_CALLBACK_STUB_H -#define OHOS_ABILITY_RUNTIME_USER_CALLBACK_STUB_H - -#include -#include -#include - -#include "user_callback.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AAFwk { -/** - * @class UserCallbackStub - * UserCallbackStub. - */ -class UserCallbackStub : public IRemoteStub { -public: - UserCallbackStub(); - virtual ~UserCallbackStub() = default; - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - DISALLOW_COPY_AND_MOVE(UserCallbackStub); - - int OnStopUserDoneInner(MessageParcel &data, MessageParcel &reply); - int OnStartUserDoneInner(MessageParcel &data, MessageParcel &reply); - int OnLogoutUserDoneInner(MessageParcel &data, MessageParcel &reply); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_USER_CALLBACK_STUB_H +/* + * 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. + */ + +sequenceable OHOS.IRemoteObject; + +interface OHOS.AppExecFwk.IAbilityDebugResponse { + void OnAbilitysDebugStarted([in] List tokens); + void OnAbilitysDebugStoped([in] List tokens); + void OnAbilitysAssertDebugChange([in] List tokens, [in] boolean isAssertDebug); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/idl/IAmsMgr.idl b/interfaces/inner_api/app_manager/idl/IAmsMgr.idl new file mode 100755 index 0000000000000000000000000000000000000000..5ac6e999f1d7cdf058af9a49ce0d689dc002f3ca --- /dev/null +++ b/interfaces/inner_api/app_manager/idl/IAmsMgr.idl @@ -0,0 +1,88 @@ +/* + * 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. + */ + +sequenceable OHOS.IRemoteObject; +sequenceable ability_info..OHOS.AppExecFwk.AbilityInfo; +sequenceable application_info..OHOS.AppExecFwk.ApplicationInfo; +sequenceable want..OHOS.AAFwk.Want; +sequenceable param..OHOS.AbilityRuntime.LoadParam; +sequenceable running_process_info..OHOS.AppExecFwk.RunningProcessInfo; + +import IAppStateCallback; +import IAppMgrConstants; + +interface OHOS.AAFwk.IUserCallback; +interface OHOS.AppExecFwk.IStartSpecifiedAbilityResponse; +interface OHOS.AppExecFwk.IAppDebugListener; +interface OHOS.AppExecFwk.IAbilityDebugResponse; + +interface OHOS.AppExecFwk.IAmsMgr { + void LoadAbility([in] sharedptr abilityInfo, [in] sharedptr appInfo, + [in] sharedptr want, [in] sharedptr loadParam); + void TerminateAbility([in] IRemoteObject token, [in] boolean clearMissionFlag); + void UpdateAbilityState([in] IRemoteObject token, [in] int state); + void UpdateExtensionState([in] IRemoteObject token, [in] ExtensionState state); + void RegisterAppStateCallback([in] IAppStateCallback appStateCallback); + void KillProcessByAbilityToken([in] IRemoteObject token); + void KillProcessesByUserId([in] int userId, [in] boolean isNeedSendAppSpawnMsg, [in] IUserCallback userCallback); + void KillProcessesByPids([in] int[] pids, [in] String reason, [in] boolean subProcess); + void AttachPidToParent([in] IRemoteObject token, [in] IRemoteObject callerToken); + void KillProcessWithAccount([in] String bundleName, [in] int accountId, [in] boolean clearPageStack, + [in] int appIndex); + void KillProcessesInBatch([in] int[] pids); + void UpdateApplicationInfoInstalled([in] String bundleName, [in] int uid, [in] String moduleName, + [in] boolean isPlugin); + void KillApplication([in] String bundleName, [in] boolean clearPageStack, [in] int appIndex); + void ForceKillApplication([in] String bundleName, [in] int userId, [in] int appIndex); + void KillProcessesByAccessTokenId([in] unsigned int accessTokenId); + void KillApplicationByUid([in] String bundleName, [in] int uid, [in] String reason); + void KillApplicationSelf([in] boolean clearPageStack, [in] String reason); + void AbilityAttachTimeOut([in] IRemoteObject token); + void PrepareTerminate([in] IRemoteObject token, [in] boolean clearMissionFlag); + void GetRunningProcessInfoByToken([in] IRemoteObject token, [out] RunningProcessInfo info); + void SetAbilityForegroundingFlagToAppRecord([in] int pid); + void StartSpecifiedAbility([in] Want want, [in] AbilityInfo abilityInfo, [in] int requestId); + void RegisterStartSpecifiedAbilityResponse([in] IStartSpecifiedAbilityResponse response); + void PrepareTerminateApp([in] int pid, [in] String moduleName); + void StartSpecifiedProcess([in] Want want, [in] AbilityInfo abilityInfo, [in] int requestId); + void GetApplicationInfoByProcessID([in] int pid, [out] ApplicationInfo application, [out] boolean debug); + void NotifyAppMgrRecordExitReason([in] int pid, [in] int reason, [in] String exitMsg); + void SetCurrentUserId([in] int userId); + void SetEnableStartProcessFlagByUserId([in] int userId, [in] boolean enableStartProcess); + void GetBundleNameByPid([in] int pid, [out] String bundleName, [out] int uid); + void RegisterAppDebugListener([in] IAppDebugListener listener); + void UnregisterAppDebugListener([in] IAppDebugListener listener); + void AttachAppDebug([in] String bundleName, [in] boolean isDebugFromLocal); + void DetachAppDebug([in] String bundleName); + void SetAppWaitingDebug([in] String bundleName, [in] boolean isPersist); + void CancelAppWaitingDebug(); + void GetWaitingDebugApp([out] String[] debugInfoList); + boolean IsWaitingDebugApp([in] String bundleName); + void ClearNonPersistWaitingDebugFlag(); + void RegisterAbilityDebugResponse([in] IAbilityDebugResponse response); + boolean IsAttachDebug([in] String bundleName); + void SetKeepAliveEnableState([in] String bundleName, [in] boolean enable, [in] int uid); + void SetKeepAliveDkv([in] String bundleName, [in] boolean enable, [in] int uid); + void ClearProcessByToken([in] IRemoteObject token); + boolean IsMemorySizeSufficent(); + boolean IsNoRequireBigMemory(); + void AttachedToStatusBar([in] IRemoteObject token); + void BlockProcessCacheByPids([in] int[] pids); + boolean IsKilledForUpgradeWeb([in] String bundleName); + boolean CleanAbilityByUserRequest([in] IRemoteObject token); + boolean IsProcessContainsOnlyUIAbility([in] int pid); + boolean IsProcessAttached([in] IRemoteObject token); + boolean IsCallerKilling([in] String callerKey); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_interface.h b/interfaces/inner_api/app_manager/idl/IAppDebugListener.idl old mode 100644 new mode 100755 similarity index 32% rename from interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_interface.h rename to interfaces/inner_api/app_manager/idl/IAppDebugListener.idl index 113002837ee096eeff6d444017c0b2645f674f91..2d5b69488a1c6ce08c7eaebef418482d8f78f41b --- a/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_interface.h +++ b/interfaces/inner_api/app_manager/idl/IAppDebugListener.idl @@ -1,50 +1,21 @@ -/* - * Copyright (c) 2023 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_ABILITY_RUNTIME_APP_DEBUG_LISTENER_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_APP_DEBUG_LISTENER_INTERFACE_H - -#include "app_debug_info.h" -#include "iremote_broker.h" - -namespace OHOS { -namespace AppExecFwk { -/** - * @brief Interface to monitor when debug mode. - */ -class IAppDebugListener : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.AppExecFwk.AppDebugListener"); - - /** - * @brief Notification of application information registered in listening and debugging mode. - * @param tokens The app info of app running record. - */ - virtual void OnAppDebugStarted(const std::vector &debugInfos) = 0; - - /** - * @brief Notification of application information registered in listening and remove debug mode. - * @param tokens The app info of app running record. - */ - virtual void OnAppDebugStoped(const std::vector &debugInfos) = 0; - - enum class Message { - ON_APP_DEBUG_STARTED = 0, - ON_APP_DEBUG_STOPED, - }; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_DEBUG_LISTENER_INTERFACE_H +/* + * 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. + */ + +sequenceable app_debug_info..AppDebugInfo; + +interface OHOS.AppExecFwk.IAppDebugListener { + [oneway] void OnAppDebugStarted([in] List debugInfos); + [oneway] void OnAppDebugStoped([in] List debugInfos); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_stub.h b/interfaces/inner_api/app_manager/idl/IAppMgrConstants.idl old mode 100644 new mode 100755 similarity index 39% rename from interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_stub.h rename to interfaces/inner_api/app_manager/idl/IAppMgrConstants.idl index 3aab199f486c133070a46827918d42d03c25293b..e30ad383002703ecb187c8d1cc9379ab96faad12 --- a/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_stub.h +++ b/interfaces/inner_api/app_manager/idl/IAppMgrConstants.idl @@ -1,42 +1,45 @@ -/* - * Copyright (c) 2023 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_ABILITY_RUNTIME_APP_DEBUG_LISTENER_STUB_H -#define OHOS_ABILITY_RUNTIME_APP_DEBUG_LISTENER_STUB_H - -#include - -#include "iremote_stub.h" -#include "app_debug_listener_interface.h" - -namespace OHOS { -namespace AppExecFwk { -class AppDebugListenerStub : public IRemoteStub { -public: - AppDebugListenerStub(); - virtual ~AppDebugListenerStub(); - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int32_t HandleOnAppDebugStarted(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnAppDebugStoped(MessageParcel &data, MessageParcel &reply); - - DISALLOW_COPY_AND_MOVE(AppDebugListenerStub); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_DEBUG_LISTENER_STUB_H +/* + * 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. + */ + +package OHOS.AppExecFwk; + +enum PreloadMode { + PRELOAD_NONE = -1, + PRESS_DOWN = 0, + PRE_MAKE = 1, + PRELOAD_MODULE = 2, +}; + +enum AbilityState { + ABILITY_STATE_CREATE = 0, + ABILITY_STATE_READY, + ABILITY_STATE_FOREGROUND, + ABILITY_STATE_FOCUS, + ABILITY_STATE_BACKGROUND, + ABILITY_STATE_TERMINATED, + ABILITY_STATE_END, + ABILITY_STATE_CONNECTED, + ABILITY_STATE_DISCONNECTED, +}; + +enum ExtensionState { + EXTENSION_STATE_CREATE = 0, + EXTENSION_STATE_READY, + EXTENSION_STATE_CONNECTED, + EXTENSION_STATE_DISCONNECTED, + EXTENSION_STATE_TERMINATED, + EXTENSION_STATE_FOREGROUND, + EXTENSION_STATE_BACKGROUND, +}; \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/user_callback.h b/interfaces/inner_api/app_manager/idl/IAppStateCallback.idl old mode 100644 new mode 100755 similarity index 31% rename from interfaces/inner_api/ability_manager/include/user_callback.h rename to interfaces/inner_api/app_manager/idl/IAppStateCallback.idl index f2fd6373927b80afe9da51a98ab1c6c90c0708b9..5bbbd32cb45659ac876e0064f9c0c61a71f8cf00 --- a/interfaces/inner_api/ability_manager/include/user_callback.h +++ b/interfaces/inner_api/app_manager/idl/IAppStateCallback.idl @@ -1,65 +1,35 @@ -/* - * Copyright (c) 2021-2023 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_ABILITY_RUNTIME_USER_CALLBACK_H -#define OHOS_ABILITY_RUNTIME_USER_CALLBACK_H - -#include "iremote_broker.h" - -namespace OHOS { -namespace AAFwk { -/** - * @class IUserCallback - * user callback. - */ -class IUserCallback : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.UserCallback"); - - virtual void OnStopUserDone(int userId, int errcode) = 0; - - /** - * @brief OnStartUserDone. - * - * @param userId userId. - * @param errcode errcode. - */ - virtual void OnStartUserDone(int userId, int errcode) = 0; - - /** - * @brief OnLogoutUserDone. - * - * @param userId userId. - * @param errcode errcode. - */ - virtual void OnLogoutUserDone(int userId, int errcode) {} - - enum UserCallbackCmd { - // ipc id for OnStopUserDone - ON_STOP_USER_DONE = 0, - - // ipc id for OnStartUserDone - ON_START_USER_DONE = 1, - - // ipc id for OnLogoutUserDone - ON_LOGOUT_USER_DONE = 2, - - // maximum of enum - CMD_MAX - }; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_USER_CALLBACK_H +/* + * 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. + */ + +sequenceable OHOS.IRemoteObject; +sequenceable app_process_data..AppProcessData; +sequenceable OHOS.AppExecFwk.Configuration; +sequenceable bundle_info..BundleInfo; +sequenceable running_process_info..OHOS.AppExecFwk.RunningProcessInfo; + +import IAppMgrConstants; + +[callback] interface OHOS.AppExecFwk.IAppStateCallback { + [oneway] void OnAppStateChanged([in] AppProcessData appProcessData); + [oneway] void OnAbilityRequestDone([in] IRemoteObject token, [in] AbilityState state); + [oneway] void NotifyConfigurationChange([in] Configuration config, [in] int userId); + [oneway] void NotifyStartResidentProcess([in] List bundleInfos); + [oneway] void NotifyStartKeepAliveProcess([in] List bundleInfos); + [oneway] void OnAppRemoteDied([in] List abilityTokens); + [oneway] void OnStartProcessFailed([in] IRemoteObject token); + [oneway] void NotifyAppPreCache([in] int pid, [in] int userId); + [oneway] void OnCacheExitInfo([in] unsigned int accessTokenId, [in] RunningProcessInfo exitInfo, + [in] String bundleName, [in] List abilityNames, [in] List uiExtensionNames); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_stub.h b/interfaces/inner_api/app_manager/idl/IStartSpecifiedAbilityResponse.idl old mode 100644 new mode 100755 similarity index 35% rename from interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_stub.h rename to interfaces/inner_api/app_manager/idl/IStartSpecifiedAbilityResponse.idl index 9753d7051b3d9a919fe390464038b42643e3528f..68f8facaecd2cae90f4c6dc6521c417025df48e8 --- a/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_stub.h +++ b/interfaces/inner_api/app_manager/idl/IStartSpecifiedAbilityResponse.idl @@ -1,43 +1,26 @@ -/* - * 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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_ABILIYT_DEBUG_RESPONSE_STUB_H -#define OHOS_ABILITY_RUNTIME_ABILIYT_DEBUG_RESPONSE_STUB_H - -#include - -#include "ability_debug_response_interface.h" -#include "iremote_stub.h" - -namespace OHOS { -namespace AppExecFwk { -class AbilityDebugResponseStub : public IRemoteStub { -public: - AbilityDebugResponseStub(); - virtual ~AbilityDebugResponseStub(); - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int32_t HandleOnAbilitysDebugStarted(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnAbilitysDebugStoped(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnAbilitysAssertDebugChange(MessageParcel &data, MessageParcel &reply); - - DISALLOW_COPY_AND_MOVE(AbilityDebugResponseStub); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ABILIYT_DEBUG_RESPONSE_STUB_H +/* + * 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. + */ + +sequenceable want..OHOS.AAFwk.Want; + +interface OHOS.AAFwk.IUserCallback; + +interface OHOS.AppExecFwk.IStartSpecifiedAbilityResponse { + [oneway] void OnAcceptWantResponse([in] Want want, [in] String flag, [in] int requestId); + [oneway] void OnTimeoutResponse([in] int requestId); + [oneway] void OnNewProcessRequestResponse([in] String flag, [in] int requestId); + [oneway] void OnNewProcessRequestTimeoutResponse([in] int requestId); + [oneway] void OnStartSpecifiedFailed([in] int requestId); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_interface.h deleted file mode 100644 index 87ec00b7b17419f546753f04aa51bd6063be409c..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_interface.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_RESPONSE_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_RESPONSE_INTERFACE_H - -#include "iremote_broker.h" - -namespace OHOS { -namespace AppExecFwk { -class IAbilityDebugResponse : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AbilityDebugResponse"); - - /** - * @brief Set ability attach debug flag to ability manager service. - * @param tokens The token of ability token. - */ - virtual void OnAbilitysDebugStarted(const std::vector> &tokens) = 0; - - /** - * @brief Cancel ability attach debug flag to ability manager service. - * @param tokens The token of ability token. - */ - virtual void OnAbilitysDebugStoped(const std::vector> &tokens) = 0; - - /** - * @brief Change ability assert debug flag. - * @param tokens The token of ability records. - * @param isAssertDebug Assert debug flag. - */ - virtual void OnAbilitysAssertDebugChange(const std::vector> &tokens, bool isAssertDebug) = 0; - - enum class Message { - ON_ABILITYS_DEBUG_STARTED = 0, - ON_ABILITYS_DEBUG_STOPED, - ON_ABILITYS_ASSERT_DEBUG, - }; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_RESPONSE_INTERFACE_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_proxy.h deleted file mode 100644 index 1bdac574de5079f573caa45cb0f94fa48f45b400..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/ability_debug_response_proxy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_RESPONSE_PROXY_H -#define OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_RESPONSE_PROXY_H - -#include "ability_debug_response_interface.h" -#include "iremote_object.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -class AbilityDebugResponseProxy : public IRemoteProxy { -public: - explicit AbilityDebugResponseProxy(const sptr &impl); - virtual ~AbilityDebugResponseProxy() = default; - - /** - * @brief Set ability attach debug flag through proxy project. - * @param tokens The token of ability token. - */ - void OnAbilitysDebugStarted(const std::vector> &tokens) override; - - /** - * @brief Cancel ability attach debug flag through proxy project. - * @param tokens The token of ability token. - */ - void OnAbilitysDebugStoped(const std::vector> &tokens) override; - - /** - * @brief Change ability assert debug flag. - * @param tokens The token of ability records. - * @param isAssertDebug Assert debug flag. - */ - void OnAbilitysAssertDebugChange(const std::vector> &tokens, bool isAssertDebug) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - void SendRequest(const IAbilityDebugResponse::Message &message, const std::vector> &tokens); - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_RESPONSE_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h deleted file mode 100644 index d919a230212a1e201219df9f6acb316c16ab10f6..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ /dev/null @@ -1,554 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_AMS_MGR_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_AMS_MGR_INTERFACE_H - -#include "ability_debug_response_interface.h" -#include "ability_info.h" -#include "app_debug_listener_interface.h" -#include "app_record_id.h" -#include "application_info.h" -#include "configuration.h" -#include "iapp_state_callback.h" -#include "iremote_broker.h" -#include "iremote_object.h" -#include "istart_specified_ability_response.h" -#include "running_process_info.h" -#include "user_callback.h" - -namespace OHOS { -namespace AbilityRuntime { -struct LoadParam; -} -namespace AppExecFwk { -class IAmsMgr : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IAmsMgr"); - - /** - * LoadAbility, call LoadAbility() through proxy project, load the ability that needed to be started. - * - * @param token, the unique identification to start the ability. - * @param preToken, the unique identification to call the ability. - * @param abilityInfo, the ability information. - * @param appInfo, the app information. - * @return - */ - virtual void LoadAbility(const std::shared_ptr &abilityInfo, - const std::shared_ptr &appInfo, - const std::shared_ptr &want, std::shared_ptr loadParam) {}; - - /** - * TerminateAbility, call TerminateAbility() through the proxy object, terminate the token ability. - * - * @param token, token, he unique identification to terminate the ability. - * @param clearMissionFlag, indicates whether terminate the ability when clearMission. - * @return - */ - virtual void TerminateAbility(const sptr &token, bool clearMissionFlag) = 0; - - /** - * UpdateAbilityState, call UpdateAbilityState() through the proxy object, update the ability status. - * - * @param token, the unique identification to update the ability. - * @param state, ability status that needs to be updated. - * @return - */ - virtual void UpdateAbilityState(const sptr &token, const AbilityState state) = 0; - - /** - * UpdateExtensionState, call UpdateExtensionState() through the proxy object, update the extension status. - * - * @param token, the unique identification to update the extension. - * @param state, extension status that needs to be updated. - * @return - */ - virtual void UpdateExtensionState(const sptr &token, const ExtensionState state) = 0; - - /** - * RegisterAppStateCallback, call RegisterAppStateCallback() through the proxy object, register the callback. - * - * @param callback, Ams register the callback. - * @return - */ - virtual void RegisterAppStateCallback(const sptr &callback) = 0; - - /** - * KillProcessByAbilityToken, call KillProcessByAbilityToken() through proxy object, - * kill the process by ability token. - * - * @param token, the unique identification to the ability. - * @return - */ - virtual void KillProcessByAbilityToken(const sptr &token) = 0; - - /** - * KillProcessesByUserId, call KillProcessesByUserId() through proxy object, - * kill the processes by userId. - * Send appSpawn uninstall debug hap message. - * - * @param userId, the user id. - * @param isNeedSendAppSpawnMsg, true send appSpawn message otherwise not send. - * @param callback, callback function for logout user. - * @return - */ - virtual void KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg = false, - sptr callback = nullptr) = 0; - - /** - * KillProcessesByPids, only in process call is allowed, - * kill the processes by pid list given. - * - * @param pids, the pid list of processes are going to be killed. - * @param reason, the reason to kill the processes. - * @param subProcess, kill SubProcess or not. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillProcessesByPids(const std::vector &pids, - const std::string &reason = "KillProcessesByPids", bool subProcess = false) = 0; - - /** - * Set child and parent relationship - * @param token child process - * @param callerToken parent process - */ - virtual void AttachPidToParent(const sptr &token, const sptr &callerToken) {} - - /** - * KillProcessWithAccount, call KillProcessWithAccount() through proxy object, - * kill the process. - * - * @param bundleName, bundle name in Application record. - * @param accountId, account ID. - * @return ERR_OK, return back success, others fail. - */ - virtual int KillProcessWithAccount(const std::string &bundleName, const int accountId, - const bool clearPageStack = false, int32_t appIndex = 0) = 0; - - /** - * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; - * the killed bundle won't be started by the watcher. - * - * @param pids, the pid list of processes are going to be killed. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillProcessesInBatch(const std::vector &pids) = 0; - - /** - * UpdateApplicationInfoInstalled, call UpdateApplicationInfoInstalled() through proxy object, - * update the application info after new module installed. - * - * @param bundleName, bundle name in Application record. - * @param uid, uid. - * @return ERR_OK, return back success, others fail. - */ - virtual int UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid, - const std::string &moduleName, bool isPlugin) = 0; - - /** - * KillApplication, call KillApplication() through proxy object, kill the application. - * - * @param bundleName, bundle name in Application record. - * @return ERR_OK, return back success, others fail. - */ - virtual int KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0) = 0; - - /** - * ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application. - * - * @param bundleName, bundle name in Application record. - * @param userId, userId. - * @param appIndex, appIndex. - * @return ERR_OK, return back success, others fail. - */ - virtual int ForceKillApplication(const std::string &bundleName, const int userId = -1, const int appIndex = 0) = 0; - - /** - * KillProcessesByAccessTokenId, call KillProcessesByAccessTokenId() through proxy object, - * force kill the application. - * - * @param accessTokenId, accessTokenId. - * @return ERR_OK, return back success, others fail. - */ - virtual int KillProcessesByAccessTokenId(const uint32_t accessTokenId) = 0; - - /** - * KillApplicationByUid, call KillApplicationByUid() through proxy object, kill the application. - * - * @param bundleName, bundle name in Application record. - * @param userId, userId. - * @param reason, caller function name. - * @return ERR_OK, return back success, others fail. - */ - virtual int KillApplicationByUid(const std::string &bundleName, const int uid, - const std::string& reason = "KillApplicationByUid") = 0; - - /** - * Kill the application self. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual int KillApplicationSelf(const bool clearPageStack = false, - const std::string& reason = "KillApplicationSelf") - { - return ERR_OK; - } - - /** - * Ability attach timeout. If start ability encounter failure, attach timeout to terminate. - * - * @param token Ability identify. - */ - virtual void AbilityAttachTimeOut(const sptr &token) = 0; - - /** - * Prepare terminate. - * - * @param token Ability identify. - * @param clearMissionFlag Clear mission flag. - */ - virtual void PrepareTerminate(const sptr &token, bool clearMissionFlag = false) = 0; - - /** - * Get running process information by ability token. - * - * @param token Ability identify. - * @param info Running process info. - */ - virtual void GetRunningProcessInfoByToken( - const sptr &token, OHOS::AppExecFwk::RunningProcessInfo &info) = 0; - - /** - * Set AbilityForegroundingFlag of an app-record to true. - * - * @param pid, pid. - * - */ - virtual void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) = 0; - - /** - * Start specified ability. - * - * @param want Want contains information of the ability to start. - * @param abilityInfo Ability information. - * @param requestId request id to callback - */ - virtual void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, - int32_t requestId = 0) = 0; - - /** - * Register response of start specified ability. - * - * @param response Response of start specified ability. - */ - virtual void RegisterStartSpecifiedAbilityResponse(const sptr &response) = 0; - - /** - * Prepare terminate application - * - * @param pid Process ID - * @param moduleName Module name - */ - virtual void PrepareTerminateApp(const pid_t pid, const std::string &moduleName) = 0; - - /** - * Start specified process. - * - * @param want Want contains information wish to start. - * @param abilityInfo Ability information. - * @param requestId for callback - */ - virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, - int32_t requestId = 0) = 0; - - /** - * Get application info by process id. - * - * @param pid Process id. - * @param application Application information got. - * @param debug Whether IsDebugApp. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) = 0; - - /** - * Record process exit reason to appRunningRecord - * @param pid pid - * @param reason reason enum - * @param exitMsg exitMsg - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) = 0; - - /** - * Set the current userId of appMgr. - * - * @param userId the user id. - * - * @return - */ - virtual void SetCurrentUserId(const int32_t userId) = 0; - - /** - * Set enable start process flag by userId - * @param userId the user id. - * @param enableStartProcess enable start process. - * @return - */ - virtual void SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) {} - - /** - * Get bundleName by pid. - * - * @param pid process id. - * @param bundleName Output parameters, return bundleName. - * @param uid Output parameters, return userId. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) = 0; - - /** - * @brief Register app debug listener. - * @param listener App debug listener. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t RegisterAppDebugListener(const sptr &listener) = 0; - - /** - * @brief Unregister app debug listener. - * @param listener App debug listener. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t UnregisterAppDebugListener(const sptr &listener) = 0; - - /** - * @brief Attach app debug. - * @param bundleName The application bundle name. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) = 0; - - /** - * @brief Detach app debug. - * @param bundleName The application bundle name. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t DetachAppDebug(const std::string &bundleName) = 0; - - /** - * @brief Set app waiting debug mode. - * @param bundleName The application bundle name. - * @param isPersist The persist flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t SetAppWaitingDebug(const std::string &bundleName, bool isPersist) = 0; - - /** - * @brief Cancel app waiting debug mode. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t CancelAppWaitingDebug() = 0; - - /** - * @brief Get waiting debug mode application. - * @param debugInfoList The debug info list, including bundle name and persist flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t GetWaitingDebugApp(std::vector &debugInfoList) = 0; - - /** - * @brief Determine whether it is a waiting debug application based on the bundle name. - * @return Returns true if it is a waiting debug application, otherwise it returns false. - */ - virtual bool IsWaitingDebugApp(const std::string &bundleName) = 0; - - /** - * @brief Clear non persist waiting debug flag. - */ - virtual void ClearNonPersistWaitingDebugFlag() = 0; - - /** - * @brief Registering ability debug mode response. - * @param response Response for ability debug object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t RegisterAbilityDebugResponse(const sptr &response) = 0; - - /** - * @brief Determine whether it is an attachment debug application based on the bundle name. - * @param bundleName The application bundle name. - * @return Returns true if it is an attach debug application, otherwise it returns false. - */ - virtual bool IsAttachDebug(const std::string &bundleName) = 0; - - /** - * @brief Set resident process enable status. - * @param bundleName The application bundle name. - * @param enable The current updated enable status. - * @param uid indicates user, 0 for all users - */ - virtual void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) {}; - - /** - * @brief Set non-resident keep-alive process status. - * @param bundleName The application bundle name. - * @param enable The current updated enable status. - * @param uid indicates user, 0 for all users - */ - virtual void SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) {}; - - /** - * To clear the process by ability token. - * - * @param token the unique identification to the ability. - */ - virtual void ClearProcessByToken(sptr token) {} - - /** - * whether memory size is sufficient. - * @return Returns true is sufficient memory size, others return false. - */ - virtual bool IsMemorySizeSufficent() = 0; - - /** - * whether or not requier a big memory - * @return Returens true is no big memory, others return false. - */ - virtual bool IsNoRequireBigMemory() { return true; } - - /** - * Notifies that one ability is attached to status bar. - * - * @param token the token of the abilityRecord that is attached to status bar. - */ - virtual void AttachedToStatusBar(const sptr &token) {} - - /** - * Temporarily block the process cache feature. - * - * @param pids the pids of the processes that should be blocked. - */ - virtual void BlockProcessCacheByPids(const std::vector &pids) {} - - /** - * whether killed for upgrade web. - * - * @param bundleName the bundle name is killed for upgrade web. - * @return Returns true is killed for upgrade web, others return false. - */ - virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) - { - return true; - } - - /** - * Request to clean uiability from user. - * - * @param token the token of ability. - * @return Returns true if clean success, others return false. - */ - virtual bool CleanAbilityByUserRequest(const sptr &token) - { - return false; - } - - /** - * whether the abilities of process specified by pid type only UIAbility. - * @return Returns true is only UIAbility, otherwise return false - */ - virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) - { - return false; - } - - /** - * Whether a process is attached, refer to AttachApplication - */ - virtual bool IsProcessAttached(sptr token) - { - return false; - } - - virtual bool IsCallerKilling(const std::string& callerKey) - { - return false; - } - - enum class Message { - LOAD_ABILITY = 0, - TERMINATE_ABILITY, - UPDATE_ABILITY_STATE, - UPDATE_EXTENSION_STATE, - REGISTER_APP_STATE_CALLBACK, - KILL_PEOCESS_BY_ABILITY_TOKEN, - KILL_PROCESSES_BY_USERID, - KILL_PROCESS_WITH_ACCOUNT, - KILL_APPLICATION, - ABILITY_ATTACH_TIMEOUT, - PREPARE_TERMINATE_ABILITY, - KILL_APPLICATION_BYUID, - GET_RUNNING_PROCESS_INFO_BY_TOKEN, - START_SPECIFIED_ABILITY, - REGISTER_START_SPECIFIED_ABILITY_RESPONSE, - UPDATE_CONFIGURATION, - GET_CONFIGURATION, - GET_APPLICATION_INFO_BY_PROCESS_ID, - KILL_APPLICATION_SELF, - UPDATE_APPLICATION_INFO_INSTALLED, - SET_CURRENT_USER_ID, - Get_BUNDLE_NAME_BY_PID, - SET_ABILITY_FOREGROUNDING_FLAG, - REGISTER_APP_DEBUG_LISTENER, - UNREGISTER_APP_DEBUG_LISTENER, - ATTACH_APP_DEBUG, - DETACH_APP_DEBUG, - SET_APP_WAITING_DEBUG, - CANCEL_APP_WAITING_DEBUG, - GET_WAITING_DEBUG_APP, - IS_WAITING_DEBUG_APP, - CLEAR_NON_PERSIST_WAITING_DEBUG_FLAG, - REGISTER_ABILITY_DEBUG_RESPONSE, - IS_ATTACH_DEBUG, - START_SPECIFIED_PROCESS, - CLEAR_PROCESS_BY_TOKEN, - REGISTER_ABILITY_MS_DELEGATE, - KILL_PROCESSES_BY_PIDS, - ATTACH_PID_TO_PARENT, - IS_MEMORY_SIZE_SUFFICIENT, - NOTIFY_APP_MGR_RECORD_EXIT_REASON, - SET_KEEP_ALIVE_ENABLE_STATE, - ATTACHED_TO_STATUS_BAR, - BLOCK_PROCESS_CACHE_BY_PIDS, - IS_KILLED_FOR_UPGRADE_WEB, - IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION, - FORCE_KILL_APPLICATION, - CLEAN_UIABILITY_BY_USER_REQUEST, - FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID = 49, - IS_PROCESS_ATTACHED, - IS_CALLER_KILLING, - ENABLE_START_PROCESS_FLAG_BY_USER_ID, - SET_KEEP_ALIVE_DKV, - KILL_PROCESSES_IN_BATCH, - PREPARE_TERMINATE_APP, - IS_NO_REQUIRE_BIG_MEMORY, - // Add enumeration values above - END - }; -}; -} // namespace AppExecFwk -} // namespace OHOS - -#endif // OHOS_ABILITY_RUNTIME_AMS_MGR_INTERFACE_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h deleted file mode 100644 index fec486a478f85c862b9dfa97cb26618c0f1b60a3..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_AMS_MGR_PROXY_H -#define OHOS_ABILITY_RUNTIME_AMS_MGR_PROXY_H - -#include "ams_mgr_interface.h" -#include "app_debug_listener_interface.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -class AmsMgrProxy : public IRemoteProxy { -public: - explicit AmsMgrProxy(const sptr &impl); - virtual ~AmsMgrProxy() = default; - - /** - * LoadAbility, call LoadAbility() through proxy project, load the ability that needed to be started. - * - * @param token, the unique identification to start the ability. - * @param preToken, the unique identification to call the ability. - * @param abilityInfo, the ability information. - * @param appInfo, the app information. - * @return - */ - virtual void LoadAbility(const std::shared_ptr &abilityInfo, - const std::shared_ptr &appInfo, - const std::shared_ptr &want, std::shared_ptr loadParam) override; - - /** - * TerminateAbility, call TerminateAbility() through the proxy object, terminate the token ability. - * - * @param token, token, he unique identification to terminate the ability. - * @param clearMissionFlag, indicates whether terminate the ability when clearMission. - * @return - */ - virtual void TerminateAbility(const sptr &token, bool clearMissionFlag) override; - - /** - * UpdateAbilityState, call UpdateAbilityState() through the proxy object, update the ability status. - * - * @param token, the unique identification to update the ability. - * @param state, ability status that needs to be updated. - * @return - */ - virtual void UpdateAbilityState(const sptr &token, const AbilityState state) override; - - /** - * UpdateExtensionState, call UpdateExtensionState() through the proxy object, update the extension status. - * - * @param token, the unique identification to update the extension. - * @param state, extension status that needs to be updated. - * @return - */ - virtual void UpdateExtensionState(const sptr &token, const ExtensionState state) override; - - /** - * RegisterAppStateCallback, call RegisterAppStateCallback() through the proxy object, register the callback. - * - * @param callback, Ams register the callback. - * @return - */ - virtual void RegisterAppStateCallback(const sptr &callback) override; - - /** - * KillProcessByAbilityToken, call KillProcessByAbilityToken() through proxy object, - * kill the process by ability token. - * - * @param token, the unique identification to the ability. - * @return - */ - virtual void KillProcessByAbilityToken(const sptr &token) override; - - /** - * KillProcessesByUserId, call KillProcessesByUserId() through proxy object, - * kill the processes by userId. - * Send appSpawn uninstall debug hap message. - * - * @param userId, the user id. - * @param isNeedSendAppSpawnMsg, true send appSpawn message otherwise not send. - * @return - */ - virtual void KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg = false, - sptr callback = nullptr) override; - - /** - * KillProcessesByPids, only in process call is allowed, - * kill the processes by pid list given. - * - * @param pids, the pid list of processes are going to be killed. - * @param reason, the reason to kill the processes. - * @param subProcess, kill SubProcess or not. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillProcessesByPids(const std::vector &pids, - const std::string &reason = "KillProcessesByPids", bool subProcess = false) override; - - /** - * Set child and parent relationship - * @param token child process - * @param callerToken parent process - */ - virtual void AttachPidToParent(const sptr &token, const sptr &callerToken) override; - - /** - * KillProcessWithAccount, call KillProcessWithAccount() through proxy object, - * kill the process. - * - * @param bundleName, bundle name in Application record. - * @param accountId, account ID. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillProcessWithAccount(const std::string &bundleName, const int accountId, - const bool clearPageStack = false, int32_t appIndex = 0) override; - - /** - * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; - * the killed bundle won't be started by the watcher. - * - * @param pids, the pid list of processes are going to be killed. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillProcessesInBatch(const std::vector &pids) override; - - /** - * UpdateApplicationInfoInstalled, call UpdateApplicationInfoInstalled() through proxy object, - * update the application info after new module installed. - * - * @param bundleName, bundle name in Application record. - * @param uid, uid. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid, - const std::string &moduleName, bool isPlugin) override; - - /** - * KillApplication, call KillApplication() through proxy object, kill the application. - * - * @param bundleName, bundle name in Application record. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, - int32_t appIndex = 0) override; - - /** - * ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application. - * - * @param bundleName, bundle name in Application record. - * @param userId, userId. - * @param appIndex, appIndex. - * @return ERR_OK, return back success, others fail. - */ - virtual int ForceKillApplication(const std::string &bundleName, const int userId = -1, - const int appIndex = 0) override; - - /** - * KillProcessesByAccessTokenId, call KillProcessesByAccessTokenId() through proxy object, - * force kill the application. - * - * @param accessTokenId, accessTokenId. - * @return ERR_OK, return back success, others fail. - */ - virtual int KillProcessesByAccessTokenId(const uint32_t accessTokenId) override; - - /** - * KillApplication, call KillApplication() through proxy object, kill the application. - * - * @param bundleName, bundle name in Application record. - * @param uid, uid. - * @param reason, caller function name. - * @return ERR_OK, return back success, others fail. - */ - virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid, - const std::string& reason = "KillApplicationByUid") override; - - virtual int KillApplicationSelf(const bool clearPageStack = false, - const std::string& reason = "KillApplicationSelf") override; - - /** - * Get application info by process id. - * - * @param pid Process id. - * @param application Application information got. - * @param debug Whether IsDebugApp. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, - bool &debug) override; - - /** - * Record process exit reason to appRunningRecord - * @param pid pid - * @param reason reason enum - * @param exitMsg exitMsg - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) override; - - /** - * Ability attach timeout. If start ability encounter failure, attach timeout to terminate. - * - * @param token Ability identify. - */ - virtual void AbilityAttachTimeOut(const sptr &token) override; - - /** - * Prepare terminate. - * - * @param token Ability identify. - * @param clearMissionFlag Clear mission flag. - */ - virtual void PrepareTerminate(const sptr &token, bool clearMissionFlag = false) override; - - /** - * Get running process information by ability token. - * - * @param token Ability identify. - * @param info Running process info. - */ - void GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info) override; - - /** - * Set AbilityForegroundingFlag of an app-record to true. - * - * @param pid, pid. - * - */ - void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) override; - - /** - * Prepare terminate application - * - * @param pid Process ID - * @param moduleName Module name - */ - virtual void PrepareTerminateApp(const pid_t pid, const std::string &moduleName) override; - - /** - * Start specified ability. - * - * @param want Want contains information of the ability to start. - * @param abilityInfo Ability information. - * @param requestId request id to callback - */ - virtual void StartSpecifiedAbility( - const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; - - /** - * Register response of start specified ability. - * - * @param response Response of start specified ability. - */ - virtual void RegisterStartSpecifiedAbilityResponse(const sptr &response) override; - - /** - * Start specified process. - * - * @param want Want contains information wish to start. - * @param abilityInfo Ability information. - * @param requestId for callback - */ - virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, - int32_t requestId = 0) override; - - virtual void SetCurrentUserId(const int32_t userId) override; - - virtual void SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) override; - - virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) override; - - /** - * @brief Register app debug listener. - * @param listener App debug listener. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t RegisterAppDebugListener(const sptr &listener) override; - - /** - * @brief Unregister app debug listener. - * @param listener App debug listener. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t UnregisterAppDebugListener(const sptr &listener) override; - - /** - * @brief Attach app debug. - * @param bundleName The application bundle name. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; - - /** - * @brief Detach app debug. - * @param bundleName The application bundle name. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t DetachAppDebug(const std::string &bundleName) override; - - /** - * @brief Set app waiting debug mode. - * @param bundleName The application bundle name. - * @param isPersist The persist flag. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t SetAppWaitingDebug(const std::string &bundleName, bool isPersist) override; - - /** - * @brief Cancel app waiting debug mode. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t CancelAppWaitingDebug() override; - - /** - * @brief Get waiting debug mode application. - * @param debugInfoList The debug info list, including bundle name and persist flag. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t GetWaitingDebugApp(std::vector &debugInfoList) override; - - /** - * @brief Determine whether it is a waiting debug application based on the bundle name. - * @return Returns true if it is a waiting debug application, otherwise it returns false. - */ - bool IsWaitingDebugApp(const std::string &bundleName) override; - - /** - * @brief Clear non persist waiting debug flag. - */ - void ClearNonPersistWaitingDebugFlag() override; - - /** - * @brief Registering ability debug mode response. - * @param response Response for ability debug object. - * @return Returns ERR_OK on success, others on failure. - */ - int32_t RegisterAbilityDebugResponse(const sptr &response) override; - - /** - * @brief Determine whether it is an attachment debug application based on the bundle name. - * @param bundleName The application bundle name. - * @return Returns true if it is an attach debug application, otherwise it returns false. - */ - bool IsAttachDebug(const std::string &bundleName) override; - - /** - * @brief Set resident process enable status. - * @param bundleName The application bundle name. - * @param enable The current updated enable status. - * @param uid indicates user, 0 for all users - */ - void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) override; - - /** - * @brief Set non-resident keep-alive process status. - * @param bundleName The application bundle name. - * @param enable The current updated enable status. - * @param uid indicates user, 0 for all users - */ - void SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) override; - - /** - * To clear the process by ability token. - * - * @param token the unique identification to the ability. - */ - virtual void ClearProcessByToken(sptr token) override; - - /** - * whether memory size is sufficient. - * @return Returns true is sufficient memory size, others return false. - */ - virtual bool IsMemorySizeSufficent() override; - - /** - * whether or not requier a big memory - * @return Returens true is no big memory, others return false. - */ - virtual bool IsNoRequireBigMemory() override; - - /** - * Notifies that one ability is attached to status bar. - * - * @param token the token of the abilityRecord that is attached to status bar. - */ - virtual void AttachedToStatusBar(const sptr &token) override; - - /** - * Temporarily block the process cache feature. - * - * @param pids the pids of the processes that should be blocked. - */ - virtual void BlockProcessCacheByPids(const std::vector &pids) override; - - /** - * whether killed for upgrade web. - * - * @param bundleName the bundle name is killed for upgrade web. - * @return Returns true is killed for upgrade web, others return false. - */ - virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override; - - /** - * Request to clean uiability from user. - * - * @param token the token of ability. - * @return Returns true if clean success, others return false. - */ - virtual bool CleanAbilityByUserRequest(const sptr &token) override; - - /** - * whether the abilities of process specified by pid type only UIAbility. - * @return Returns true is only UIAbility, otherwise return false - */ - virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override; - - /** - * Whether a process is attached, refer to AttachApplication - */ - virtual bool IsProcessAttached(sptr token) override; - - virtual bool IsCallerKilling(const std::string& callerKey) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_AMS_MGR_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h deleted file mode 100644 index ef3ca793b0342ce433275dc72db3007180105d2d..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_AMS_MGR_STUB_H -#define OHOS_ABILITY_RUNTIME_AMS_MGR_STUB_H - -#include - -#include "iremote_stub.h" -#include "nocopyable.h" -#include "string_ex.h" -#include "ams_mgr_interface.h" - -namespace OHOS { -namespace AppExecFwk { -class AmsMgrStub : public IRemoteStub { -public: - AmsMgrStub(); - virtual ~AmsMgrStub(); - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - - /** - * UpdateExtensionState, call UpdateExtensionState() through the proxy object, update the extension status. - * - * @param token, the unique identification to update the extension. - * @param state, extension status that needs to be updated. - * @return - */ - virtual void UpdateExtensionState(const sptr &token, const ExtensionState state) override; -private: - void CreateMemberFuncMap(); - int32_t HandleLoadAbility(MessageParcel &data, MessageParcel &reply); - int32_t HandleTerminateAbility(MessageParcel &data, MessageParcel &reply); - int32_t HandleUpdateAbilityState(MessageParcel &data, MessageParcel &reply); - int32_t HandleUpdateExtensionState(MessageParcel &data, MessageParcel &reply); - int32_t HandleRegisterAppStateCallback(MessageParcel &data, MessageParcel &reply); - int32_t HandleReset(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillProcessByAbilityToken(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillProcessesByUserId(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillProcessesByPids(MessageParcel &data, MessageParcel &reply); - int32_t HandleAttachPidToParent(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillProcessWithAccount(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillProcessesInBatch(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillApplication(MessageParcel &data, MessageParcel &reply); - int32_t HandleForceKillApplication(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillProcessesByAccessTokenId(MessageParcel &data, MessageParcel &reply); - int32_t HandleAbilityAttachTimeOut(MessageParcel &data, MessageParcel &reply); - int32_t HandlePrepareTerminate(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillApplicationByUid(MessageParcel &data, MessageParcel &reply); - int32_t HandleKillApplicationSelf(MessageParcel &data, MessageParcel &reply); - int32_t HandleGetRunningProcessInfoByToken(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetAbilityForegroundingFlagToAppRecord(MessageParcel &data, MessageParcel &reply); - int32_t HandlePrepareTerminateApp(MessageParcel &data, MessageParcel &reply); - int32_t HandleStartSpecifiedAbility(MessageParcel &data, MessageParcel &reply); - int32_t HandleRegisterStartSpecifiedAbilityResponse(MessageParcel &data, MessageParcel &reply); - int32_t HandleGetApplicationInfoByProcessID(MessageParcel &data, MessageParcel &reply); - int32_t HandleNotifyAppMgrRecordExitReason(MessageParcel &data, MessageParcel &reply); - int32_t HandleUpdateApplicationInfoInstalled(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetCurrentUserId(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetEnableStartProcessFlagByUserId(MessageParcel &data, MessageParcel &reply); - int32_t HandleGetBundleNameByPid(MessageParcel &data, MessageParcel &reply); - int32_t HandleRegisterAppDebugListener(MessageParcel &data, MessageParcel &reply); - int32_t HandleUnregisterAppDebugListener(MessageParcel &data, MessageParcel &reply); - int32_t HandleAttachAppDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleDetachAppDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetAppWaitingDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleCancelAppWaitingDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleGetWaitingDebugApp(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsWaitingDebugApp(MessageParcel &data, MessageParcel &reply); - int32_t HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply); - int32_t HandleRegisterAbilityDebugResponse(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsAttachDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsMemorySizeSufficent(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsNoRequireBigMemory(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetKeepAliveDkv(MessageParcel &data, MessageParcel &reply); - int32_t HandleAttachedToStatusBar(MessageParcel &data, MessageParcel &reply); - int32_t OnRemoteRequestInner(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option); - int32_t OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option); - int32_t OnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option); - int32_t OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option); - int32_t OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option); - int32_t HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply); - int32_t HandleCleanAbilityByUserRequest(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply); - int32_t HandleIsCallerKilling(MessageParcel &data, MessageParcel &reply); - DISALLOW_COPY_AND_MOVE(AmsMgrStub); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_AMS_MGR_STUB_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_proxy.h deleted file mode 100644 index a309079a93810ad641b1c80af5bbf64a70c737b5..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/app_debug_listener_proxy.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023 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_ABILITY_RUNTIME_APP_DEBUG_LISTENER_PROXY_H -#define OHOS_ABILITY_RUNTIME_APP_DEBUG_LISTENER_PROXY_H - -#include "app_debug_info.h" -#include "app_debug_listener_interface.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -class AppDebugListenerProxy : public IRemoteProxy { -public: - explicit AppDebugListenerProxy(const sptr &impl); - virtual ~AppDebugListenerProxy() = default; - - /** - * @brief Notification of application information registered in listening and debugging mode. - * @param tokens The app info of app running record. - */ - void OnAppDebugStarted(const std::vector &debugInfos) override; - - /** - * @brief Notification of application information registered in listening and remove debug mode. - * @param tokens The app info of app running record. - */ - void OnAppDebugStoped(const std::vector &debugInfos) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - void SendRequest(const IAppDebugListener::Message &message, const std::vector &debugInfos); - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_DEBUG_LISTENER_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 64107d3c7e7744895934d180f5d19caef4caa120..053d9285f58aa55daf74e4ffab2f9cdfb6f13eea 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -16,9 +16,9 @@ #ifndef OHOS_ABILITY_RUNTIME_APP_MGR_CLIENT_H #define OHOS_ABILITY_RUNTIME_APP_MGR_CLIENT_H -#include "ability_debug_response_interface.h" +#include "iability_debug_response.h" #include "ability_info.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "app_malloc_info.h" #include "app_mem_info.h" #include "app_mgr_constants.h" diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h index ec040e460b4390f02c9f8578f7997da7e42517bd..11db362e94b1ebef3bb68ee4a0c59921704de463 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h @@ -16,6 +16,8 @@ #ifndef OHOS_ABILITY_RUNTIME_APP_MGR_CONSTANTS_H #define OHOS_ABILITY_RUNTIME_APP_MGR_CONSTANTS_H +#include "iapp_mgr_constants.h" + namespace OHOS { namespace AppExecFwk { namespace Constants { @@ -52,28 +54,6 @@ enum class ApplicationScheduleState { SCHEDULE_BACKGROUNDING, }; -enum class AbilityState { - ABILITY_STATE_CREATE = 0, - ABILITY_STATE_READY, - ABILITY_STATE_FOREGROUND, - ABILITY_STATE_FOCUS, - ABILITY_STATE_BACKGROUND, - ABILITY_STATE_TERMINATED, - ABILITY_STATE_END, - ABILITY_STATE_CONNECTED, - ABILITY_STATE_DISCONNECTED, -}; - -enum class ExtensionState { - EXTENSION_STATE_CREATE = 0, - EXTENSION_STATE_READY, - EXTENSION_STATE_CONNECTED, - EXTENSION_STATE_DISCONNECTED, - EXTENSION_STATE_TERMINATED, - EXTENSION_STATE_FOREGROUND, - EXTENSION_STATE_BACKGROUND, -}; - enum AppMgrResultCode { RESULT_OK = 0, ERROR_SERVICE_NOT_READY, @@ -105,13 +85,6 @@ enum class AppStartType { WARM }; -enum class PreloadMode { - PRELOAD_NONE = -1, - PRESS_DOWN = 0, - PRE_MAKE = 1, - PRELOAD_MODULE = 2, -}; - enum class AppStartReason { NONE = 0, PRE_MAKE = 1, diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index fd474e550268c59fc4b29ee9a752605ddabdbf9a..43161f25ceb323972f989074f5206e78c09fc63d 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -18,7 +18,7 @@ #include "ability_foreground_state_observer_interface.h" #include "ability_info.h" -#include "ams_mgr_interface.h" +#include "iams_mgr.h" #include "app_foreground_state_observer_interface.h" #include "app_malloc_info.h" #include "app_mgr_ipc_interface_code.h" @@ -440,7 +440,7 @@ public: /** * UpdateConfigurationForBackgroundApp - * + * * @param appInfos Background application information. * @param policy Update policy. * @param userId configuration for the user diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_host.h b/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_host.h index 6d4fac59090a44158ba381f490fe5bb7fc3d657a..e362f00feac954ca70398cff7561b1204df89ae4 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_host.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_host.h @@ -16,88 +16,73 @@ #ifndef OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_HOST_H #define OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_HOST_H -#include - -#include "iremote_stub.h" #include "nocopyable.h" #include "string_ex.h" #include "app_mgr_constants.h" #include "bundle_info.h" -#include "iapp_state_callback.h" +#include "app_state_callback_stub.h" namespace OHOS { namespace AppExecFwk { -class AppStateCallbackHost : public IRemoteStub { +class AppStateCallbackHost : public AppStateCallbackStub { public: AppStateCallbackHost(); virtual ~AppStateCallbackHost(); - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - /** * AbilityMgr's request is done. * * @param token Ability token. * @param state Application state. */ - virtual void OnAbilityRequestDone(const sptr &, const AbilityState) override; + virtual ErrCode OnAbilityRequestDone(const sptr &, const AbilityState) override; /** * Application state changed callback. * * @param appProcessData Process data */ - virtual void OnAppStateChanged(const AppProcessData &) override; + virtual ErrCode OnAppStateChanged(const AppProcessData &appProcessData) override; /** * @brief Notify application update system environment changes. * @param config System environment change parameters. * @param userId userId Designation User ID. */ - virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; + virtual ErrCode NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; /** * @brief Notify abilityms start resident process. * @param bundleInfos resident process bundle infos. */ - virtual void NotifyStartResidentProcess(std::vector &bundleInfos) override; + virtual ErrCode NotifyStartResidentProcess(const std::vector &bundleInfos) override; /** * @brief Notify abilityms start keep-alive process. * @param bundleInfos resident process bundle infos. */ - virtual void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override; + virtual ErrCode NotifyStartKeepAliveProcess(const std::vector &bundleInfos) override; /** * @brief Notify abilityms app process OnRemoteDied * @param abilityTokens abilities in died process. */ - virtual void OnAppRemoteDied(const std::vector> &abilityTokens) override; + virtual ErrCode OnAppRemoteDied(const std::vector> &abilityTokens) override; - virtual void OnStartProcessFailed(sptr token) override; + virtual ErrCode OnStartProcessFailed(const sptr &token) override; /** * @brief Notify abilityms app process pre cache * @param pid process pid. * @param userId userId Designation User ID. */ - virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override; + virtual ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) override; - virtual void OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, + virtual ErrCode OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, const std::string &bundleName, const std::vector &abilityNames, const std::vector &uiExtensionNames) override; private: - int32_t HandleOnAppStateChanged(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply); - int32_t HandleNotifyConfigurationChange(MessageParcel &data, MessageParcel &reply); - int32_t HandleNotifyStartResidentProcess(MessageParcel &data, MessageParcel &reply); - int32_t HandleNotifyStartKeepAliveProcess(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnAppRemoteDied(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnStartProcessFailed(MessageParcel &data, MessageParcel &reply); - int32_t HandleNotifyAppPreCache(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnCacheExitInfo(MessageParcel &data, MessageParcel &reply); DISALLOW_COPY_AND_MOVE(AppStateCallbackHost); }; diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_proxy.h deleted file mode 100644 index 8c3965652e47ca533e6e732b5b201b78732b4726..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_proxy.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2021-2023 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_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H -#define OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H - -#include "iremote_proxy.h" - -#include "app_mgr_constants.h" -#include "bundle_info.h" -#include "iapp_state_callback.h" - -namespace OHOS { -namespace AppExecFwk { -class AppStateCallbackProxy : public IRemoteProxy { -public: - explicit AppStateCallbackProxy(const sptr &impl); - virtual ~AppStateCallbackProxy() = default; - - /** - * AbilityMgr's request is done. - * - * @param token Ability token. - * @param state Application state. - */ - virtual void OnAbilityRequestDone(const sptr &token, const AbilityState state) override; - - /** - * Application state changed callback. - * - * @param appProcessData Process data - */ - virtual void OnAppStateChanged(const AppProcessData &appProcessData) override; - - /** - * @brief Notify application update system environment changes. - * @param config System environment change parameters. - * @param userId userId Designation User ID. - */ - virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; - - /** - * @brief Notify abilityms start resident process. - * @param bundleInfos resident process bundle infos. - */ - virtual void NotifyStartResidentProcess(std::vector &bundleInfos) override; - - /** - * @brief Notify abilityms start keep-alive process. - * @param bundleInfos resident process bundle infos. - */ - virtual void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override; - - /** - * @brief Notify abilityms app process OnRemoteDied - * @param abilityTokens abilities in died process. - */ - virtual void OnAppRemoteDied(const std::vector> &abilityTokens) override; - - virtual void OnStartProcessFailed(sptr token) override; - - /** - * @brief Notify abilityms app process pre cache - * @param pid process pid. - * @param userId userId Designation User ID. - */ - virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override; - - virtual void OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, - const std::string &bundleName, const std::vector &abilityNames, - const std::vector &uiExtensionNames) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - static inline BrokerDelegator delegator_; - int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/iapp_state_callback.h b/interfaces/inner_api/app_manager/include/appmgr/iapp_state_callback.h deleted file mode 100644 index e2c5ce5feeae937436c63f78433bbbc1d47e6e49..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/iapp_state_callback.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2021 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_ABILITY_RUNTIME_IAPP_STATE_CALLBACK_H -#define OHOS_ABILITY_RUNTIME_IAPP_STATE_CALLBACK_H - -#include "iremote_broker.h" -#include "iremote_object.h" - -#include "app_mgr_constants.h" -#include "app_process_data.h" -#include "bundle_info.h" -#include "running_process_info.h" - -namespace OHOS { -namespace AppExecFwk { - class Configuration; -} -} - -namespace OHOS { -namespace AppExecFwk { -class IAppStateCallback : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppStateCallback"); - - /** - * Application state changed callback. - * - * @param appProcessData Process data - */ - virtual void OnAppStateChanged(const AppProcessData &appProcessData) = 0; - - /** - * AbilityMgr's request is done. - * - * @param token Ability token. - * @param state Application state. - */ - virtual void OnAbilityRequestDone(const sptr &token, const AbilityState state) = 0; - - /** - * @brief Notify application update system environment changes. - * @param config System environment change parameters. - * @param userId userId Designation User ID. - */ - virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) {} - - /** - * @brief Notify abilityms start resident process. - * @param bundleInfos resident process bundle infos. - */ - virtual void NotifyStartResidentProcess(std::vector &bundleInfos) {} - - /** - * @brief Notify abilityms start keep-alive process. - * @param bundleInfos resident process bundle infos. - */ - virtual void NotifyStartKeepAliveProcess(std::vector &bundleInfos) {} - - /** - * @brief Notify abilityms app process OnRemoteDied - * @param abilityTokens abilities in died process. - */ - virtual void OnAppRemoteDied(const std::vector> &abilityTokens) {} - - /** - * @brief Notify abilityms start process failed when load ability - * @param token Failed ability token. - */ - virtual void OnStartProcessFailed(sptr token) {} - - /** - * @brief Notify abilityms app process pre cache - * @param pid process pid. - * @param userId userId Designation User ID. - */ - virtual void NotifyAppPreCache(int32_t pid, int32_t userId) {} - - virtual void OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, - const std::string &bundleName, const std::vector &abilityNames, - const std::vector &uiExtensionNames) {} - - enum class Message { - TRANSACT_ON_APP_STATE_CHANGED = 0, - TRANSACT_ON_ABILITY_REQUEST_DONE, - TRANSACT_ON_NOTIFY_CONFIG_CHANGE, - TRANSACT_ON_NOTIFY_START_RESIDENT_PROCESS, - TRANSACT_ON_APP_REMOTE_DIED, - TRANSACT_ON_APP_PRE_CACHE, - TRANSACT_ON_NOTIFY_START_KEEP_ALIVE_PROCESS, - TRANSACT_ON_START_PROCESS_FAILED, - TRANSACT_ON_CACHE_EXIT_INFO, - }; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_IAPP_STATE_CALLBACK_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h b/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h deleted file mode 100644 index 0777f67ee1d2ce89d4bd6aca6db7e97b324bef6a..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 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_ABILITY_RUNTIME_ISTART_SPECIFIED_ABILITY_RESPONSE_H -#define OHOS_ABILITY_RUNTIME_ISTART_SPECIFIED_ABILITY_RESPONSE_H - -#include "iremote_broker.h" -#include "iremote_object.h" -#include "want.h" - -namespace OHOS { -namespace AppExecFwk { -class IStartSpecifiedAbilityResponse : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.startSpecifiedAbilityResponse"); - - /** - * @brief called when the module's onAcceptWant done to notify ability mgr to continue - * @param want request param being accepted - * @param flag specified flag return by application - * @param requestId a number represents a request - */ - virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId) = 0; - - /** - * @brief called when the module's onAcceptWant happens time out - * @param requestId a number represents a request - */ - virtual void OnTimeoutResponse(int32_t requestId) = 0; - - virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) = 0; - - virtual void OnNewProcessRequestTimeoutResponse(int32_t requestId) = 0; - - virtual void OnStartSpecifiedFailed(int32_t requestId) {}; - - enum Message { - ON_ACCEPT_WANT_RESPONSE = 0, - ON_TIMEOUT_RESPONSE, - ON_NEW_PROCESS_REQUEST_RESPONSE, - ON_NEW_PROCESS_REQUEST_TIMEOUT_RESPONSE, - ON_START_SPECIFIED_FAILED - }; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ISTART_SPECIFIED_ABILITY_RESPONSE_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h deleted file mode 100644 index bf2037afc012bef53d69bc394ba8fc2e3ffa541d..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2022-2023 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_ABILITY_RUNTIME_START_SPECIFIED_ABILITY_RESPONSE_PROXY_H -#define OHOS_ABILITY_RUNTIME_START_SPECIFIED_ABILITY_RESPONSE_PROXY_H - -#include "iremote_proxy.h" -#include "istart_specified_ability_response.h" -namespace OHOS { -namespace AppExecFwk { -class StartSpecifiedAbilityResponseProxy : public IRemoteProxy { -public: - explicit StartSpecifiedAbilityResponseProxy(const sptr &impl); - virtual ~StartSpecifiedAbilityResponseProxy() = default; - - /** - * @brief called when the module's onAcceptWant done to notify ability mgr to continue - * @param want request param being accepted - * @param flag specified flag return by application - * @param requestId a number represents a request - */ - virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, - int32_t requestId) override; - - /** - * @brief called when the module's onAcceptWant happens time out - * @param requestId a number represents a request - */ - virtual void OnTimeoutResponse(int32_t requestId) override; - - virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId = 0) override; - - virtual void OnNewProcessRequestTimeoutResponse(int32_t requestId) override; - - virtual void OnStartSpecifiedFailed(int32_t requestId) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - static inline BrokerDelegator delegator_; - int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_START_SPECIFIED_ABILITY_RESPONSE_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_stub.h b/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_stub.h deleted file mode 100644 index 041320de260806846208a8dc0f70d8a861c507a9..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_stub.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 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_ABILITY_RUNTIME_START_SPECIFIED_ABILITY_RESPONSE_STUB_H -#define OHOS_ABILITY_RUNTIME_START_SPECIFIED_ABILITY_RESPONSE_STUB_H - -#include "iremote_stub.h" -#include "nocopyable.h" -#include "string_ex.h" -#include "istart_specified_ability_response.h" - -namespace OHOS { -namespace AppExecFwk { -class StartSpecifiedAbilityResponseStub : public IRemoteStub { -public: - StartSpecifiedAbilityResponseStub() = default; - virtual ~StartSpecifiedAbilityResponseStub() = default; - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int32_t HandleOnAcceptWantResponse(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnTimeoutResponse(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnNewProcessRequestResponse(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnNewProcessRequestTimeoutResponse(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnStartSpecifiedFailed(MessageParcel &data, MessageParcel &reply); - - DISALLOW_COPY_AND_MOVE(StartSpecifiedAbilityResponseStub); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_START_SPECIFIED_ABILITY_RESPONSE_STUB_H diff --git a/interfaces/inner_api/app_manager/src/appmgr/ability_debug_response_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ability_debug_response_proxy.cpp deleted file mode 100644 index 5736f1b596cc9b3cbfa92b607edb3e2fb3c07592..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/ability_debug_response_proxy.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 "ability_debug_response_proxy.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -constexpr int32_t CYCLE_LIMIT_MIN = 0; -constexpr int32_t CYCLE_LIMIT_MAX = 1000; -} -AbilityDebugResponseProxy::AbilityDebugResponseProxy( - const sptr &impl) : IRemoteProxy(impl) -{} - -bool AbilityDebugResponseProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(AbilityDebugResponseProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return false; - } - return true; -} - -void AbilityDebugResponseProxy::OnAbilitysDebugStarted(const std::vector> &tokens) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - SendRequest(IAbilityDebugResponse::Message::ON_ABILITYS_DEBUG_STARTED, tokens); -} - -void AbilityDebugResponseProxy::OnAbilitysDebugStoped(const std::vector> &tokens) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - SendRequest(IAbilityDebugResponse::Message::ON_ABILITYS_DEBUG_STOPED, tokens); -} - -void AbilityDebugResponseProxy::OnAbilitysAssertDebugChange( - const std::vector> &tokens, bool isAssertDebug) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - - if (tokens.size() <= CYCLE_LIMIT_MIN || tokens.size() > CYCLE_LIMIT_MAX || - !data.WriteInt32(tokens.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data size failed"); - return; - } - - for (const auto &item : tokens) { - if (!data.WriteRemoteObject(item)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - } - - if (!data.WriteBool(isAssertDebug)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write flag failed"); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "null remote"); - return; - } - - MessageParcel reply; - MessageOption option; - auto ret = remote->SendRequest(static_cast(Message::ON_ABILITYS_ASSERT_DEBUG), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -void AbilityDebugResponseProxy::SendRequest( - const IAbilityDebugResponse::Message &message, const std::vector> &tokens) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - - if (tokens.size() <= CYCLE_LIMIT_MIN || tokens.size() > CYCLE_LIMIT_MAX || - !data.WriteInt32(tokens.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data size failed"); - return; - } - - for (auto iter = tokens.begin(); iter != tokens.end(); iter++) { - if (!data.WriteRemoteObject(iter->GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "null remote"); - return; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = remote->SendRequest(static_cast(message), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/ability_debug_response_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ability_debug_response_stub.cpp deleted file mode 100644 index daf6a577ae851b01f3b24c02a06933c7521836d2..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/ability_debug_response_stub.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 "ability_debug_response_stub.h" - -#include "appexecfwk_errors.h" -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -constexpr int32_t CYCLE_LIMIT_MIN = 0; -constexpr int32_t CYCLE_LIMIT_MAX = 1000; -} -AbilityDebugResponseStub::AbilityDebugResponseStub() {} - -AbilityDebugResponseStub::~AbilityDebugResponseStub() {} - -int32_t AbilityDebugResponseStub::HandleOnAbilitysDebugStarted(MessageParcel &data, MessageParcel &reply) -{ - auto tokenSize = data.ReadInt32(); - if (tokenSize <= CYCLE_LIMIT_MIN || tokenSize > CYCLE_LIMIT_MAX) { - TAG_LOGE(AAFwkTag::APPMGR, "Token size exceeds limit"); - return ERR_INVALID_DATA; - } - - std::vector> tokens; - for (int32_t index = 0; index < tokenSize; index++) { - auto token = data.ReadRemoteObject(); - if (token == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "null token"); - return ERR_INVALID_DATA; - } - tokens.push_back(token); - } - OnAbilitysDebugStarted(tokens); - return NO_ERROR; -} - -int32_t AbilityDebugResponseStub::HandleOnAbilitysDebugStoped(MessageParcel &data, MessageParcel &reply) -{ - auto tokenSize = data.ReadInt32(); - if (tokenSize <= CYCLE_LIMIT_MIN || tokenSize > CYCLE_LIMIT_MAX) { - TAG_LOGE(AAFwkTag::APPMGR, "Token size exceeds limit"); - return ERR_INVALID_DATA; - } - - std::vector> tokens; - for (int32_t index = 0; index < tokenSize; index++) { - auto token = data.ReadRemoteObject(); - if (token == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "null token"); - return ERR_INVALID_DATA; - } - tokens.push_back(token); - } - OnAbilitysDebugStoped(tokens); - return NO_ERROR; -} - -int32_t AbilityDebugResponseStub::HandleOnAbilitysAssertDebugChange(MessageParcel &data, MessageParcel &reply) -{ - auto tokenSize = data.ReadInt32(); - if (tokenSize <= CYCLE_LIMIT_MIN || tokenSize > CYCLE_LIMIT_MAX) { - TAG_LOGE(AAFwkTag::APPMGR, "Token size exceeds limit"); - return ERR_INVALID_DATA; - } - - std::vector> tokens; - for (int32_t index = 0; index < tokenSize; index++) { - auto token = data.ReadRemoteObject(); - if (token == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "null token"); - return ERR_INVALID_DATA; - } - tokens.push_back(token); - } - auto isAssertDebug = data.ReadBool(); - OnAbilitysAssertDebugChange(tokens, isAssertDebug); - return NO_ERROR; -} - -int AbilityDebugResponseStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - TAG_LOGD(AAFwkTag::APPMGR, "code: %{public}u, flags: %{public}d", code, option.GetFlags()); - std::u16string descriptor = AbilityDebugResponseStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::APPMGR, "invalid descriptor"); - return ERR_INVALID_STATE; - } - - switch (code) { - case static_cast(IAbilityDebugResponse::Message::ON_ABILITYS_DEBUG_STARTED): - return HandleOnAbilitysDebugStarted(data, reply); - case static_cast(IAbilityDebugResponse::Message::ON_ABILITYS_DEBUG_STOPED): - return HandleOnAbilitysDebugStoped(data, reply); - } - - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp deleted file mode 100644 index bdee628ca548e0c1213850b365555d40859dcefe..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp +++ /dev/null @@ -1,1504 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#include "ams_mgr_proxy.h" -#include "freeze_util.h" -#include "ipc_types.h" -#include "iremote_object.h" -#include "param.h" -#include "string_ex.h" - -#include "appexecfwk_errors.h" -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -constexpr int32_t MAX_APP_DEBUG_COUNT = 100; -} -AmsMgrProxy::AmsMgrProxy(const sptr &impl) : IRemoteProxy(impl) -{} - -bool AmsMgrProxy::IsProcessContainsOnlyUIAbility(const pid_t pid) -{ - TAG_LOGD(AAFwkTag::APPMGR, "IsProcessContainsOnlyUIAbility start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return false; - } - if (!data.WriteInt32(static_cast(pid))) { - TAG_LOGE(AAFwkTag::APPMGR, "write pid failed"); - return false; - } - int32_t ret = - SendTransactCmd(static_cast( - IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return false; - } - TAG_LOGD(AAFwkTag::APPMGR, "IsProcessContainsOnlyUIAbility end"); - return reply.ReadBool(); -} - -bool AmsMgrProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(AmsMgrProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "write token failed"); - return false; - } - return true; -} -namespace { -bool WriteTokenObject(MessageParcel &data, sptr token) -{ - if (token) { - if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag or token"); - return false; - } - } else { - if (!data.WriteBool(false)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag"); - return false; - } - } - return true; -} -} - -void AmsMgrProxy::LoadAbility(const std::shared_ptr &abilityInfo, - const std::shared_ptr &appInfo, - const std::shared_ptr &want, std::shared_ptr loadParam) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - if (!abilityInfo || !appInfo) { - TAG_LOGE(AAFwkTag::APPMGR, "param error"); - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(abilityInfo.get())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write abilityInfo failed"); - return; - } - if (!data.WriteParcelable(appInfo.get())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write abilityInfo failed"); - return; - } - if (!data.WriteParcelable(want.get())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write want failed"); - return; - } - if (!data.WriteParcelable(loadParam.get())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data loadParam failed"); - return; - } - - int32_t ret = SendTransactCmd(static_cast(IAmsMgr::Message::LOAD_ABILITY), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - AbilityRuntime::FreezeUtil::GetInstance().AddLifecycleEvent(loadParam->token, - "AmsMgrProxy::LoadAbility fail, ipc error " + std::to_string(ret)); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::TerminateAbility(const sptr &token, bool clearMissionFlag) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - if (!data.WriteBool(clearMissionFlag)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write clearMissionFlag"); - return; - } - int32_t ret = SendTransactCmd(static_cast(IAmsMgr::Message::TERMINATE_ABILITY), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::UpdateAbilityState(const sptr &token, const AbilityState state) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write data"); - return; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - if (!data.WriteInt32(static_cast(state))) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::UPDATE_ABILITY_STATE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::UpdateExtensionState(const sptr &token, const ExtensionState state) -{ - TAG_LOGD(AAFwkTag::APPMGR, "UpdateExtensionState begin"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - if (!data.WriteInt32(static_cast(state))) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write state"); - return; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::UPDATE_EXTENSION_STATE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::RegisterAppStateCallback(const sptr &callback) -{ - TAG_LOGD(AAFwkTag::APPMGR, "begin"); - if (!callback) { - TAG_LOGE(AAFwkTag::APPMGR, "callback null"); - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (callback->AsObject()) { - if (!data.WriteBool(true) || !data.WriteRemoteObject(callback->AsObject())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag and callback"); - return; - } - } else { - if (!data.WriteBool(false)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag"); - return; - } - } - - int32_t ret = SendTransactCmd( - static_cast(IAmsMgr::Message::REGISTER_APP_STATE_CALLBACK), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::KillProcessByAbilityToken(const sptr &token) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - int32_t ret = SendTransactCmd(static_cast(IAmsMgr::Message::KILL_PEOCESS_BY_ABILITY_TOKEN), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg, - sptr callback) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel WriteInt32 failed"); - return; - } - if (!data.WriteBool(isNeedSendAppSpawnMsg)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel WriteBool failed"); - return; - } - if (callback == nullptr) { - TAG_LOGD(AAFwkTag::APPMGR, "callback is nullptr"); - data.WriteBool(false); - } else { - data.WriteBool(true); - if (!data.WriteRemoteObject(callback->AsObject())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write IUserCallback fail"); - return; - } - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::KILL_PROCESSES_BY_USERID), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "ending"); -} - -int32_t AmsMgrProxy::KillProcessesByPids(const std::vector &pids, const std::string &reason, - bool subProcess) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - if (!data.WriteUint32(pids.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write size failed"); - return ERR_FLATTEN_OBJECT; - } - for (const auto &pid: pids) { - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write pid failed"); - return ERR_FLATTEN_OBJECT; - } - } - if (!data.WriteString(reason)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write reason failed"); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteBool(subProcess)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write subProcess failed"); - return ERR_FLATTEN_OBJECT; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::KILL_PROCESSES_BY_PIDS), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); - return reply.ReadInt32(); -} - -void AmsMgrProxy::AttachPidToParent(const sptr &token, const sptr &callerToken) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - if (!data.WriteRemoteObject(callerToken)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write callerToken"); - return; - } - int32_t ret = SendTransactCmd(static_cast(IAmsMgr::Message::ATTACH_PID_TO_PARENT), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -int32_t AmsMgrProxy::KillProcessWithAccount( - const std::string &bundleName, const int accountId, const bool clearPageStack, int32_t appIndex) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteString failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteInt32(accountId)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel WriteInt32 failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteBool(clearPageStack)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel bool failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteInt32(appIndex)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel appIndex failed"); - return ERR_FLATTEN_OBJECT; - } - - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::KILL_PROCESS_WITH_ACCOUNT), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - - TAG_LOGD(AAFwkTag::APPMGR, "end"); - - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::KillProcessesInBatch(const std::vector &pids) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - - if (!data.WriteUint32(pids.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write size failed"); - return ERR_FLATTEN_OBJECT; - } - for (const auto &pid: pids) { - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write pid failed"); - return ERR_FLATTEN_OBJECT; - } - } - - int32_t ret = SendTransactCmd(static_cast(IAmsMgr::Message::KILL_PROCESSES_IN_BATCH), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::KillApplication(const std::string &bundleName, bool clearPageStack, int32_t appIndex) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteString failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteBool(clearPageStack)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel bool failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteInt32(appIndex)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel appIndex failed"); - return ERR_FLATTEN_OBJECT; - } - - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::KILL_APPLICATION), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d.", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::ForceKillApplication(const std::string &bundleName, - const int userId, const int appIndex) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel bundleName failed."); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel userId failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteInt32(appIndex)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel appIndex failed"); - return ERR_FLATTEN_OBJECT; - } - - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::FORCE_KILL_APPLICATION), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d.", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::KillProcessesByAccessTokenId(const uint32_t accessTokenId) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - - if (!data.WriteInt32(accessTokenId)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel accessTokenId failed"); - return ERR_FLATTEN_OBJECT; - } - - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d.", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid, - const std::string &moduleName, bool isPlugin) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start."); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteString failed"); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteInt32(uid)) { - TAG_LOGE(AAFwkTag::APPMGR, "uid write failed."); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteString(moduleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "moduleName WriteString failed"); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteBool(isPlugin)) { - TAG_LOGE(AAFwkTag::APPMGR, "isPlugin Write failed"); - return ERR_FLATTEN_OBJECT; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::UPDATE_APPLICATION_INFO_INSTALLED), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::KillApplicationByUid(const std::string &bundleName, const int uid, - const std::string& reason) -{ - TAG_LOGI(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "failed to write bundle name"); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteInt32(uid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write uid"); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteString(reason)) { - TAG_LOGE(AAFwkTag::APPMGR, "failedto write reason"); - return ERR_FLATTEN_OBJECT; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::KILL_APPLICATION_BYUID), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::KillApplicationSelf(const bool clearPageStack, const std::string& reason) -{ - TAG_LOGI(AAFwkTag::APPMGR, "call"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - - if (!data.WriteBool(clearPageStack)) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel bool failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!data.WriteString(reason)) { - TAG_LOGE(AAFwkTag::APPMGR, "failed to write reason"); - return ERR_FLATTEN_OBJECT; - } - - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::KILL_APPLICATION_SELF), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -void AmsMgrProxy::AbilityAttachTimeOut(const sptr &token) -{ - TAG_LOGD(AAFwkTag::APPMGR, "beginning"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::ABILITY_ATTACH_TIMEOUT), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::PrepareTerminate(const sptr &token, bool clearMissionFlag) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - if (!data.WriteBool(clearMissionFlag)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write clearMissionFlag"); - return; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::PREPARE_TERMINATE_ABILITY), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::GetRunningProcessInfoByToken( - const sptr &token, AppExecFwk::RunningProcessInfo &info) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (!data.WriteRemoteObject(token.GetRefPtr())) { - return; - } - - auto ret = SendTransactCmd( - static_cast(IAmsMgr::Message::GET_RUNNING_PROCESS_INFO_BY_TOKEN), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return; - } - - std::unique_ptr processInfo(reply.ReadParcelable()); - if (processInfo == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "recv process info faild"); - return; - } - - info = *processInfo; -} - -void AmsMgrProxy::SetAbilityForegroundingFlagToAppRecord(const pid_t pid) -{ - TAG_LOGD(AAFwkTag::APPMGR, "calling"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (!data.WriteInt32(static_cast(pid))) { - TAG_LOGE(AAFwkTag::APPMGR, "parcel WriteInt32 failed"); - return; - } - - auto ret = SendTransactCmd( - static_cast(IAmsMgr::Message::SET_ABILITY_FOREGROUNDING_FLAG), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -void AmsMgrProxy::PrepareTerminateApp(const pid_t pid, const std::string &moduleName) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "token write error"); - return; - } - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write PrepareTerminateApp pid failed."); - return; - } - if (!data.WriteString(moduleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write PrepareTerminateApp moduleName failed."); - return; - } - auto ret = SendTransactCmd( - static_cast(IAmsMgr::Message::PREPARE_TERMINATE_APP), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest PrepareTerminateApp err: %{public}d", ret); - return; - } - TAG_LOGD(AAFwkTag::APPMGR, "Get PrepareTerminateApp reply success"); -} - -void AmsMgrProxy::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, - int32_t requestId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (!data.WriteParcelable(&want) || !data.WriteParcelable(&abilityInfo) || - !data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - auto ret = SendTransactCmd( - static_cast(IAmsMgr::Message::START_SPECIFIED_ABILITY), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -void AmsMgrProxy::StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, - int32_t requestId) - -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - if (!data.WriteParcelable(&want) || !data.WriteParcelable(&abilityInfo) || - data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return; - } - auto ret = remote->SendRequest( - static_cast(IAmsMgr::Message::START_SPECIFIED_PROCESS), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -void AmsMgrProxy::RegisterStartSpecifiedAbilityResponse(const sptr &response) -{ - TAG_LOGD(AAFwkTag::APPMGR, "Register multi instances response by proxy."); - if (!response) { - TAG_LOGE(AAFwkTag::APPMGR, "response null"); - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(response->AsObject())) { - TAG_LOGE(AAFwkTag::APPMGR, "write remote obj failed"); - return; - } - - int32_t ret = SendTransactCmd( - static_cast(IAmsMgr::Message::REGISTER_START_SPECIFIED_ABILITY_RESPONSE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -int AmsMgrProxy::GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "token write error"); - return ERR_FLATTEN_OBJECT; - } - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "pid write error"); - return ERR_FLATTEN_OBJECT; - } - int32_t ret = SendTransactCmd( - static_cast(IAmsMgr::Message::GET_APPLICATION_INFO_BY_PROCESS_ID), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "send request fail"); - return ret; - } - auto result = reply.ReadInt32(); - if (result != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "reply result false"); - return result; - } - std::unique_ptr info(reply.ReadParcelable()); - if (!info) { - TAG_LOGE(AAFwkTag::APPMGR, "readParcelableInfo failed"); - return ERR_NAME_NOT_FOUND; - } - application = *info; - debug = reply.ReadBool(); - TAG_LOGD(AAFwkTag::APPMGR, "get parcelable info success"); - return NO_ERROR; -} - -int32_t AmsMgrProxy::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "token write error"); - return IPC_PROXY_ERR; - } - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write pid failed"); - return IPC_PROXY_ERR; - } - if (!data.WriteInt32(reason)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write reason failed"); - return IPC_PROXY_ERR; - } - if (!data.WriteString16(Str8ToStr16(exitMsg))) { - TAG_LOGE(AAFwkTag::APPMGR, "Write exitMsg failed"); - return IPC_PROXY_ERR; - } - int32_t ret = SendTransactCmd( - static_cast(IAmsMgr::Message::NOTIFY_APP_MGR_RECORD_EXIT_REASON), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "send request fail"); - return ret; - } - return reply.ReadInt32(); -} - -void AmsMgrProxy::SetCurrentUserId(const int32_t userId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write userId"); - return; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::SET_CURRENT_USER_ID), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write userId"); - return; - } - if (!data.WriteBool(enableStartProcess)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write enableStartProcess"); - return; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::ENABLE_START_PROCESS_FLAG_BY_USER_ID), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -int32_t AmsMgrProxy::GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_DATA; - } - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write pid"); - return ERR_INVALID_DATA; - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::Get_BUNDLE_NAME_BY_PID), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - bundleName = reply.ReadString(); - uid = reply.ReadInt32(); - return NO_ERROR; -} - -int32_t AmsMgrProxy::RegisterAppDebugListener(const sptr &listener) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - if (listener == nullptr || !data.WriteRemoteObject(listener->AsObject())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write listener failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::REGISTER_APP_DEBUG_LISTENER), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::UnregisterAppDebugListener(const sptr &listener) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - if (listener == nullptr || !data.WriteRemoteObject(listener->AsObject())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write listener failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::UNREGISTER_APP_DEBUG_LISTENER), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName failed"); - return ERR_INVALID_DATA; - } - - if (!data.WriteBool(isDebugFromLocal)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write isDebugFromLocal failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::ATTACH_APP_DEBUG), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::DetachAppDebug(const std::string &bundleName) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::DETACH_APP_DEBUG), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -void AmsMgrProxy::SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName fail"); - return; - } - if (!data.WriteBool(enable) || !data.WriteInt32(uid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write flag or uid fail"); - return; - } - MessageParcel reply; - MessageOption option; - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::SET_KEEP_ALIVE_ENABLE_STATE), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - } -} - -void AmsMgrProxy::SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName fail"); - return; - } - if (!data.WriteBool(enable) || !data.WriteInt32(uid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write flag or uid fail"); - return; - } - MessageParcel reply; - MessageOption option; - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::SET_KEEP_ALIVE_DKV), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - } -} - -int32_t AmsMgrProxy::SetAppWaitingDebug(const std::string &bundleName, bool isPersist) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName failed"); - return ERR_INVALID_DATA; - } - - if (!data.WriteBool(isPersist)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write persist flag failed."); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::SET_APP_WAITING_DEBUG), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::CancelAppWaitingDebug() -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::CANCEL_APP_WAITING_DEBUG), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -int32_t AmsMgrProxy::GetWaitingDebugApp(std::vector &debugInfoList) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::GET_WAITING_DEBUG_APP), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return ret; - } - - auto resultCode = reply.ReadInt32(); - if (resultCode != ERR_OK) { - TAG_LOGE(AAFwkTag::APPMGR, "Reply err: %{public}d", resultCode); - return resultCode; - } - - auto infoSize = reply.ReadInt32(); - if (infoSize > MAX_APP_DEBUG_COUNT) { - TAG_LOGE(AAFwkTag::APPMGR, "Max app debug count: %{public}d", infoSize); - return ERR_INVALID_DATA; - } - - if (!reply.ReadStringVector(&debugInfoList)) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadStringVector failed"); - return ERR_INVALID_DATA; - } - - return NO_ERROR; -} - -bool AmsMgrProxy::IsWaitingDebugApp(const std::string &bundleName) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return false; - } - - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName failed"); - return false; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_WAITING_DEBUG_APP), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return false; - } - return reply.ReadBool(); -} - -void AmsMgrProxy::ClearNonPersistWaitingDebugFlag() -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd( - static_cast(IAmsMgr::Message::CLEAR_NON_PERSIST_WAITING_DEBUG_FLAG), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - } -} - -int32_t AmsMgrProxy::RegisterAbilityDebugResponse(const sptr &response) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return ERR_INVALID_DATA; - } - - if (response == nullptr || !data.WriteRemoteObject(response->AsObject())) { - TAG_LOGE(AAFwkTag::APPMGR, "write remote obj failed"); - return ERR_INVALID_DATA; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - int32_t ret = SendTransactCmd( - static_cast(IAmsMgr::Message::REGISTER_ABILITY_DEBUG_RESPONSE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - return ret; - } - return reply.ReadInt32(); -} - -bool AmsMgrProxy::IsAttachDebug(const std::string &bundleName) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return false; - } - - if (bundleName.empty() || !data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write bundleName fail"); - return false; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_ATTACH_DEBUG), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return false; - } - return reply.ReadBool(); -} - -void AmsMgrProxy::ClearProcessByToken(sptr token) -{ - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - if (!data.WriteRemoteObject(token)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - MessageParcel reply; - MessageOption option; - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::CLEAR_PROCESS_BY_TOKEN), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } -} - -bool AmsMgrProxy::IsMemorySizeSufficent() -{ - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return true; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_MEMORY_SIZE_SUFFICIENT), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return true; - } - return reply.ReadBool(); -} - -bool AmsMgrProxy::IsNoRequireBigMemory() -{ - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return true; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_NO_REQUIRE_BIG_MEMORY), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return true; - } - return reply.ReadBool(); -} - -int32_t AmsMgrProxy::SendTransactCmd(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "null remote"); - return ERR_NULL_OBJECT; - } - - int32_t ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest err: %{public}d, ret: %{public}d", code, ret); - return ret; - } - return ret; -} - -void AmsMgrProxy::AttachedToStatusBar(const sptr &token) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(token)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return; - } - int32_t ret = SendTransactCmd(static_cast(IAmsMgr::Message::ATTACHED_TO_STATUS_BAR), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AmsMgrProxy::BlockProcessCacheByPids(const std::vector &pids) -{ - TAG_LOGD(AAFwkTag::APPMGR, "start"); - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return; - } - if (!data.WriteUint32(pids.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write size failed"); - return; - } - for (const auto &pid: pids) { - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write pid failed"); - return; - } - } - int32_t ret = - SendTransactCmd(static_cast(IAmsMgr::Message::BLOCK_PROCESS_CACHE_BY_PIDS), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -bool AmsMgrProxy::IsKilledForUpgradeWeb(const std::string &bundleName) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write token failed"); - return false; - } - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteString failed"); - return false; - } - - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request err: %{public}d", ret); - return false; - } - return reply.ReadBool(); -} - -bool AmsMgrProxy::CleanAbilityByUserRequest(const sptr &token) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return false; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return false; - } - - int32_t ret = SendTransactCmd( - static_cast(IAmsMgr::Message::CLEAN_UIABILITY_BY_USER_REQUEST), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest err: %{public}d", ret); - } - return reply.ReadBool(); -} - -bool AmsMgrProxy::IsProcessAttached(sptr token) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return false; - } - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write token"); - return false; - } - - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_PROCESS_ATTACHED), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, error code is %{public}d.", ret); - return false; - } - return reply.ReadBool(); -} - -bool AmsMgrProxy::IsCallerKilling(const std::string& callerKey) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return false; - } - if (!data.WriteString(callerKey)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write callerKey"); - return false; - } - - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::IS_CALLER_KILLING), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, error code is %{public}d.", ret); - return false; - } - return reply.ReadBool(); -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp deleted file mode 100644 index 4fc28df4288dfd2ad409575516cb1f9f0ff11b56..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp +++ /dev/null @@ -1,937 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#include "ams_mgr_stub.h" -#include "ability_manager_errors.h" -#include "ability_info.h" -#include "app_debug_listener_interface.h" -#include "app_mgr_proxy.h" -#include "app_scheduler_interface.h" -#include "appexecfwk_errors.h" -#include "hilog_tag_wrapper.h" -#include "hitrace_meter.h" -#include "iapp_state_callback.h" -#include "ipc_skeleton.h" -#include "ipc_types.h" -#include "iremote_object.h" -#include "param.h" -#include "string_ex.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -constexpr int32_t MAX_APP_DEBUG_COUNT = 100; -constexpr int32_t MAX_KILL_PROCESS_PID_COUNT = 100; -} - -AmsMgrStub::AmsMgrStub() -{ - CreateMemberFuncMap(); -} - -AmsMgrStub::~AmsMgrStub() {} - -void AmsMgrStub::CreateMemberFuncMap() {} - -int AmsMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (code != static_cast(IAmsMgr::Message::Get_BUNDLE_NAME_BY_PID)) { - TAG_LOGI(AAFwkTag::APPMGR, "OnReceived, code: %{public}u, flags: %{public}d", code, - option.GetFlags()); - } - std::u16string descriptor = AmsMgrStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::APPMGR, "invalid descriptor"); - return ERR_INVALID_STATE; - } - return OnRemoteRequestInner(code, data, reply, option); -} - -int32_t AmsMgrStub::OnRemoteRequestInner(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - int retCode = ERR_OK; - retCode = OnRemoteRequestInnerFirst(code, data, reply, option); - if (retCode != AAFwk::ERR_CODE_NOT_EXIST) { - return retCode; - } - retCode = OnRemoteRequestInnerSecond(code, data, reply, option); - if (retCode != AAFwk::ERR_CODE_NOT_EXIST) { - return retCode; - } - retCode = OnRemoteRequestInnerThird(code, data, reply, option); - if (retCode != AAFwk::ERR_CODE_NOT_EXIST) { - return retCode; - } - retCode = OnRemoteRequestInnerFourth(code, data, reply, option); - if (retCode != AAFwk::ERR_CODE_NOT_EXIST) { - return retCode; - } - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t AmsMgrStub::OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - switch (static_cast(code)) { - case static_cast(IAmsMgr::Message::LOAD_ABILITY): - return HandleLoadAbility(data, reply); - case static_cast(IAmsMgr::Message::TERMINATE_ABILITY): - return HandleTerminateAbility(data, reply); - case static_cast(IAmsMgr::Message::UPDATE_ABILITY_STATE): - return HandleUpdateAbilityState(data, reply); - case static_cast(IAmsMgr::Message::UPDATE_EXTENSION_STATE): - return HandleUpdateExtensionState(data, reply); - case static_cast(IAmsMgr::Message::REGISTER_APP_STATE_CALLBACK): - return HandleRegisterAppStateCallback(data, reply); - case static_cast(IAmsMgr::Message::KILL_PEOCESS_BY_ABILITY_TOKEN): - return HandleKillProcessByAbilityToken(data, reply); - case static_cast(IAmsMgr::Message::KILL_PROCESSES_BY_USERID): - return HandleKillProcessesByUserId(data, reply); - case static_cast(IAmsMgr::Message::KILL_PROCESS_WITH_ACCOUNT): - return HandleKillProcessWithAccount(data, reply); - case static_cast(IAmsMgr::Message::KILL_APPLICATION): - return HandleKillApplication(data, reply); - case static_cast(IAmsMgr::Message::ABILITY_ATTACH_TIMEOUT): - return HandleAbilityAttachTimeOut(data, reply); - case static_cast(IAmsMgr::Message::PREPARE_TERMINATE_ABILITY): - return HandlePrepareTerminate(data, reply); - case static_cast(IAmsMgr::Message::KILL_APPLICATION_BYUID): - return HandleKillApplicationByUid(data, reply); - case static_cast(IAmsMgr::Message::KILL_APPLICATION_SELF): - return HandleKillApplicationSelf(data, reply); - case static_cast(IAmsMgr::Message::GET_RUNNING_PROCESS_INFO_BY_TOKEN): - return HandleGetRunningProcessInfoByToken(data, reply); - } - return AAFwk::ERR_CODE_NOT_EXIST; -} - -int32_t AmsMgrStub::OnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - switch (static_cast(code)) { - case static_cast(IAmsMgr::Message::SET_ABILITY_FOREGROUNDING_FLAG): - return HandleSetAbilityForegroundingFlagToAppRecord(data, reply); - case static_cast(IAmsMgr::Message::START_SPECIFIED_ABILITY): - return HandleStartSpecifiedAbility(data, reply); - case static_cast(IAmsMgr::Message::REGISTER_START_SPECIFIED_ABILITY_RESPONSE): - return HandleRegisterStartSpecifiedAbilityResponse(data, reply); - case static_cast(IAmsMgr::Message::GET_APPLICATION_INFO_BY_PROCESS_ID): - return HandleGetApplicationInfoByProcessID(data, reply); - case static_cast(IAmsMgr::Message::NOTIFY_APP_MGR_RECORD_EXIT_REASON): - return HandleNotifyAppMgrRecordExitReason(data, reply); - case static_cast(IAmsMgr::Message::UPDATE_APPLICATION_INFO_INSTALLED): - return HandleUpdateApplicationInfoInstalled(data, reply); - case static_cast(IAmsMgr::Message::SET_CURRENT_USER_ID): - return HandleSetCurrentUserId(data, reply); - case static_cast(IAmsMgr::Message::ENABLE_START_PROCESS_FLAG_BY_USER_ID): - return HandleSetEnableStartProcessFlagByUserId(data, reply); - case static_cast(IAmsMgr::Message::Get_BUNDLE_NAME_BY_PID): - return HandleGetBundleNameByPid(data, reply); - case static_cast(IAmsMgr::Message::REGISTER_APP_DEBUG_LISTENER): - return HandleRegisterAppDebugListener(data, reply); - case static_cast(IAmsMgr::Message::UNREGISTER_APP_DEBUG_LISTENER): - return HandleUnregisterAppDebugListener(data, reply); - case static_cast(IAmsMgr::Message::ATTACH_APP_DEBUG): - return HandleAttachAppDebug(data, reply); - case static_cast(IAmsMgr::Message::DETACH_APP_DEBUG): - return HandleDetachAppDebug(data, reply); - case static_cast(IAmsMgr::Message::SET_APP_WAITING_DEBUG): - return HandleSetAppWaitingDebug(data, reply); - case static_cast(IAmsMgr::Message::CANCEL_APP_WAITING_DEBUG): - return HandleCancelAppWaitingDebug(data, reply); - case static_cast(IAmsMgr::Message::GET_WAITING_DEBUG_APP): - return HandleGetWaitingDebugApp(data, reply); - case static_cast(IAmsMgr::Message::IS_WAITING_DEBUG_APP): - return HandleIsWaitingDebugApp(data, reply); - } - return AAFwk::ERR_CODE_NOT_EXIST; -} - -int32_t AmsMgrStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - switch (static_cast(code)) { - case static_cast(IAmsMgr::Message::CLEAR_NON_PERSIST_WAITING_DEBUG_FLAG): - return HandleClearNonPersistWaitingDebugFlag(data, reply); - case static_cast(IAmsMgr::Message::REGISTER_ABILITY_DEBUG_RESPONSE): - return HandleRegisterAbilityDebugResponse(data, reply); - case static_cast(IAmsMgr::Message::IS_ATTACH_DEBUG): - return HandleIsAttachDebug(data, reply); - case static_cast(IAmsMgr::Message::CLEAR_PROCESS_BY_TOKEN): - return HandleClearProcessByToken(data, reply); - case static_cast(IAmsMgr::Message::KILL_PROCESSES_BY_PIDS): - return HandleKillProcessesByPids(data, reply); - case static_cast(IAmsMgr::Message::ATTACH_PID_TO_PARENT): - return HandleAttachPidToParent(data, reply); - case static_cast(IAmsMgr::Message::IS_MEMORY_SIZE_SUFFICIENT): - return HandleIsMemorySizeSufficent(data, reply); - case static_cast(IAmsMgr::Message::IS_NO_REQUIRE_BIG_MEMORY): - return HandleIsNoRequireBigMemory(data, reply); - case static_cast(IAmsMgr::Message::SET_KEEP_ALIVE_ENABLE_STATE): - return HandleSetKeepAliveEnableState(data, reply); - case static_cast(IAmsMgr::Message::ATTACHED_TO_STATUS_BAR): - return HandleAttachedToStatusBar(data, reply); - case static_cast(IAmsMgr::Message::UPDATE_CONFIGURATION): - return 0; - case static_cast(IAmsMgr::Message::GET_CONFIGURATION): - return 0; - case static_cast(IAmsMgr::Message::START_SPECIFIED_PROCESS): - return 0; - case static_cast(IAmsMgr::Message::REGISTER_ABILITY_MS_DELEGATE): - return 0; - case static_cast(IAmsMgr::Message::BLOCK_PROCESS_CACHE_BY_PIDS): - return HandleBlockProcessCacheByPids(data, reply); - case static_cast(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB): - return HandleIsKilledForUpgradeWeb(data, reply); - case static_cast(IAmsMgr::Message::PREPARE_TERMINATE_APP): - return HandlePrepareTerminateApp(data, reply); - } - return AAFwk::ERR_CODE_NOT_EXIST; -} - -int32_t AmsMgrStub::OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - switch (static_cast(code)) { - case static_cast(IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION): - return HandleIsProcessContainsOnlyUIAbility(data, reply); - case static_cast(IAmsMgr::Message::FORCE_KILL_APPLICATION): - return HandleForceKillApplication(data, reply); - case static_cast(IAmsMgr::Message::CLEAN_UIABILITY_BY_USER_REQUEST): - return HandleCleanAbilityByUserRequest(data, reply); - case static_cast(IAmsMgr::Message::FORCE_KILL_APPLICATION_BY_ACCESS_TOKEN_ID): - return HandleKillProcessesByAccessTokenId(data, reply); - case static_cast(IAmsMgr::Message::IS_PROCESS_ATTACHED): - return HandleIsProcessAttached(data, reply); - case static_cast(IAmsMgr::Message::IS_CALLER_KILLING): - return HandleIsCallerKilling(data, reply); - case static_cast(IAmsMgr::Message::SET_KEEP_ALIVE_DKV): - return HandleSetKeepAliveDkv(data, reply); - case static_cast(IAmsMgr::Message::KILL_PROCESSES_IN_BATCH): - return HandleKillProcessesInBatch(data, reply); - } - return AAFwk::ERR_CODE_NOT_EXIST; -} - -ErrCode AmsMgrStub::HandleLoadAbility(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - std::shared_ptr abilityInfo(data.ReadParcelable()); - if (!abilityInfo) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - std::shared_ptr appInfo(data.ReadParcelable()); - if (!appInfo) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - std::shared_ptr want(data.ReadParcelable()); - if (!want) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable want failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - std::shared_ptr loadParam(data.ReadParcelable()); - if (!loadParam) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable loadParam failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - LoadAbility(abilityInfo, appInfo, want, loadParam); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleTerminateAbility(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - bool clearMissionFlag = data.ReadBool(); - TerminateAbility(token, clearMissionFlag); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleUpdateAbilityState(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - int32_t state = data.ReadInt32(); - UpdateAbilityState(token, static_cast(state)); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleUpdateExtensionState(MessageParcel &data, MessageParcel &reply) -{ - sptr token = data.ReadRemoteObject(); - int32_t state = data.ReadInt32(); - UpdateExtensionState(token, static_cast(state)); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleRegisterAppStateCallback(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr callback = nullptr; - if (data.ReadBool()) { - sptr obj = data.ReadRemoteObject(); - callback = iface_cast(obj); - } - RegisterAppStateCallback(callback); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillProcessByAbilityToken(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - - KillProcessByAbilityToken(token); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillProcessesByUserId(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - int32_t userId = data.ReadInt32(); - sptr callback = nullptr; - bool isWithCallback = data.ReadBool(); - if (isWithCallback) { - callback = iface_cast(data.ReadRemoteObject()); - } - - KillProcessesByUserId(userId, callback); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillProcessesByPids(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - auto size = data.ReadUint32(); - if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) { - TAG_LOGE(AAFwkTag::APPMGR, "Invalid size"); - return ERR_INVALID_VALUE; - } - std::vector pids; - for (uint32_t i = 0; i < size; i++) { - pids.emplace_back(data.ReadInt32()); - } - std::string reason = data.ReadString(); - bool subProcess = data.ReadBool(); - int32_t ret = KillProcessesByPids(pids, reason, subProcess); - reply.WriteInt32(ret); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleAttachPidToParent(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - sptr callerToken = data.ReadRemoteObject(); - AttachPidToParent(token, callerToken); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillProcessWithAccount(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGI(AAFwkTag::APPMGR, "enter"); - - HITRACE_METER(HITRACE_TAG_APP); - - std::string bundleName = data.ReadString(); - int accountId = data.ReadInt32(); - bool clearPageStack = data.ReadBool(); - auto appIndex = data.ReadInt32(); - - TAG_LOGI(AAFwkTag::APPMGR, - "bundleName = %{public}s, accountId = %{public}d, clearPageStack = %{public}d", - bundleName.c_str(), accountId, clearPageStack); - - int32_t result = KillProcessWithAccount(bundleName, accountId, clearPageStack, appIndex); - reply.WriteInt32(result); - - TAG_LOGI(AAFwkTag::APPMGR, "end"); - - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillProcessesInBatch(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGI(AAFwkTag::APPMGR, "enter"); - - HITRACE_METER(HITRACE_TAG_APP); - - auto size = data.ReadUint32(); - TAG_LOGI(AAFwkTag::APPMGR, "pids.size=%{public}d", size); - if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) { - TAG_LOGE(AAFwkTag::APPMGR, "Invalid size"); - return ERR_INVALID_VALUE; - } - std::vector pids; - for (uint32_t i = 0; i < size; i++) { - pids.emplace_back(data.ReadInt32()); - } - - int32_t result = KillProcessesInBatch(pids); - reply.WriteInt32(result); - - TAG_LOGI(AAFwkTag::APPMGR, "end"); - - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillApplication(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - std::string bundleName = data.ReadString(); - bool clearPageStack = data.ReadBool(); - auto appIndex = data.ReadInt32(); - - TAG_LOGW(AAFwkTag::APPMGR, - "KillApplication,callingPid=%{public}d,bundleName=%{public}s,clearPageStack=%{public}d", - IPCSkeleton::GetCallingPid(), bundleName.c_str(), clearPageStack); - - int32_t result = KillApplication(bundleName, clearPageStack, appIndex); - reply.WriteInt32(result); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleForceKillApplication(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - std::string bundleName = data.ReadString(); - int userId = data.ReadInt32(); - int appIndex = data.ReadInt32(); - - TAG_LOGI(AAFwkTag::APPMGR, "bundleName = %{public}s,userId=%{public}d,appIndex=%{public}d", - bundleName.c_str(), userId, appIndex); - - int32_t result = ForceKillApplication(bundleName, userId, appIndex); - reply.WriteInt32(result); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillProcessesByAccessTokenId(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - int accessTokenId = data.ReadInt32(); - - TAG_LOGI(AAFwkTag::APPMGR, "accessTokenId=%{public}d", accessTokenId); - - int32_t result = KillProcessesByAccessTokenId(accessTokenId); - reply.WriteInt32(result); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillApplicationByUid(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - std::string bundleName = data.ReadString(); - int uid = data.ReadInt32(); - std::string reason = data.ReadString(); - TAG_LOGW(AAFwkTag::APPMGR, "KillApplicationByUid,callingPid=%{public}d", IPCSkeleton::GetCallingPid()); - int32_t result = KillApplicationByUid(bundleName, uid, reason); - reply.WriteInt32(result); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleKillApplicationSelf(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - TAG_LOGW(AAFwkTag::APPMGR, "KillApplicationSelf,callingPid=%{public}d", IPCSkeleton::GetCallingPid()); - bool clearPageStack = data.ReadBool(); - std::string reason = data.ReadString(); - int32_t result = KillApplicationSelf(clearPageStack, reason); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "result write failed."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleAbilityAttachTimeOut(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - AbilityAttachTimeOut(token); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandlePrepareTerminate(MessageParcel &data, MessageParcel &reply) -{ - sptr token = data.ReadRemoteObject(); - bool clearMissionFlag = data.ReadBool(); - PrepareTerminate(token, clearMissionFlag); - return NO_ERROR; -} - -void AmsMgrStub::UpdateExtensionState(const sptr &token, const ExtensionState state) -{} - -int32_t AmsMgrStub::HandleGetRunningProcessInfoByToken(MessageParcel &data, MessageParcel &reply) -{ - RunningProcessInfo processInfo; - auto token = data.ReadRemoteObject(); - GetRunningProcessInfoByToken(token, processInfo); - if (reply.WriteParcelable(&processInfo)) { - TAG_LOGE(AAFwkTag::APPMGR, "process info write failed."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleSetAbilityForegroundingFlagToAppRecord(MessageParcel &data, MessageParcel &reply) -{ - RunningProcessInfo processInfo; - auto pid = static_cast(data.ReadInt32()); - SetAbilityForegroundingFlagToAppRecord(pid); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandlePrepareTerminateApp(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto pid = static_cast(data.ReadInt32()); - auto moduleName = data.ReadString(); - PrepareTerminateApp(pid, moduleName); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleStartSpecifiedAbility(MessageParcel &data, MessageParcel &reply) -{ - AAFwk::Want *want = data.ReadParcelable(); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "want is nullptr"); - return ERR_INVALID_VALUE; - } - - AbilityInfo *abilityInfo = data.ReadParcelable(); - if (abilityInfo == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo is nullptr."); - delete want; - return ERR_INVALID_VALUE; - } - StartSpecifiedAbility(*want, *abilityInfo, data.ReadInt32()); - delete want; - delete abilityInfo; - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleRegisterStartSpecifiedAbilityResponse(MessageParcel &data, MessageParcel &reply) -{ - sptr obj = data.ReadRemoteObject(); - sptr response = iface_cast(obj); - RegisterStartSpecifiedAbilityResponse(response); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleGetApplicationInfoByProcessID(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - int32_t pid = data.ReadInt32(); - AppExecFwk::ApplicationInfo application; - bool debug; - int32_t result = GetApplicationInfoByProcessID(pid, application, debug); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "write result error."); - return ERR_INVALID_VALUE; - } - if (!reply.WriteParcelable(&application)) { - TAG_LOGE(AAFwkTag::APPMGR, "write application info failed"); - return ERR_INVALID_VALUE; - } - if (!reply.WriteBool(debug)) { - TAG_LOGE(AAFwkTag::APPMGR, "write debug info failed"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleNotifyAppMgrRecordExitReason(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - int32_t pid = data.ReadInt32(); - int32_t reason = data.ReadInt32(); - std::string exitMsg = Str16ToStr8(data.ReadString16()); - int32_t result = NotifyAppMgrRecordExitReason(pid, reason, exitMsg); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write result failed."); - return IPC_PROXY_ERR; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleUpdateApplicationInfoInstalled(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - std::string bundleName = data.ReadString(); - int uid = data.ReadInt32(); - std::string moduleName = data.ReadString(); - int32_t result = UpdateApplicationInfoInstalled(bundleName, uid, moduleName, data.ReadBool()); - reply.WriteInt32(result); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleSetCurrentUserId(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = data.ReadInt32(); - SetCurrentUserId(userId); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleSetEnableStartProcessFlagByUserId(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = data.ReadInt32(); - bool enableStartProcess = data.ReadBool(); - SetEnableStartProcessFlagByUserId(userId, enableStartProcess); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleGetBundleNameByPid(MessageParcel &data, MessageParcel &reply) -{ - int32_t pid = data.ReadInt32(); - std::string bundleName; - int32_t uid; - GetBundleNameByPid(pid, bundleName, uid); - - reply.WriteString(bundleName); - reply.WriteInt32(uid); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleRegisterAppDebugListener(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto appDebugLister = iface_cast(data.ReadRemoteObject()); - if (appDebugLister == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "App debug lister is null."); - return ERR_INVALID_VALUE; - } - - auto result = RegisterAppDebugListener(appDebugLister); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleUnregisterAppDebugListener(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto appDebugLister = iface_cast(data.ReadRemoteObject()); - if (appDebugLister == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "App debug lister is nullptr."); - return ERR_INVALID_VALUE; - } - - auto result = UnregisterAppDebugListener(appDebugLister); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleAttachAppDebug(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - if (bundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); - return ERR_INVALID_VALUE; - } - auto isDebugFromLocal = data.ReadBool(); - - auto result = AttachAppDebug(bundleName, isDebugFromLocal); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleDetachAppDebug(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - if (bundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); - return ERR_INVALID_VALUE; - } - - auto result = DetachAppDebug(bundleName); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleSetAppWaitingDebug(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - if (bundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); - return ERR_INVALID_VALUE; - } - auto isPersist = data.ReadBool(); - auto result = SetAppWaitingDebug(bundleName, isPersist); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleCancelAppWaitingDebug(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto result = CancelAppWaitingDebug(); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleGetWaitingDebugApp(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - std::vector debugInfoList; - auto result = GetWaitingDebugApp(debugInfoList); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - - int32_t listSize = static_cast(debugInfoList.size()); - if (listSize > MAX_APP_DEBUG_COUNT) { - TAG_LOGE(AAFwkTag::APPMGR, "Max app debug count is %{public}d.", listSize); - return ERR_INVALID_VALUE; - } - - if (!reply.WriteInt32(listSize)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write list size."); - return ERR_INVALID_VALUE; - } - - if (!reply.WriteStringVector(debugInfoList)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write string vector debug info list."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsWaitingDebugApp(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - if (bundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); - return ERR_INVALID_VALUE; - } - - auto result = IsWaitingDebugApp(bundleName); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - auto enable = data.ReadBool(); - auto uid = data.ReadInt32(); - SetKeepAliveEnableState(bundleName, enable, uid); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleSetKeepAliveDkv(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - auto enable = data.ReadBool(); - auto uid = data.ReadInt32(); - SetKeepAliveDkv(bundleName, enable, uid); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - ClearNonPersistWaitingDebugFlag(); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleRegisterAbilityDebugResponse(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto response = iface_cast(data.ReadRemoteObject()); - if (response == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Response is nullptr."); - return ERR_INVALID_VALUE; - } - - auto result = RegisterAbilityDebugResponse(response); - if (!reply.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsAttachDebug(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - if (bundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); - return ERR_INVALID_VALUE; - } - - auto result = IsAttachDebug(bundleName); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - ClearProcessByToken(token); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsMemorySizeSufficent(MessageParcel &data, MessageParcel &reply) -{ - auto result = IsMemorySizeSufficent(); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsNoRequireBigMemory(MessageParcel &data, MessageParcel &reply) -{ - auto result = IsNoRequireBigMemory(); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleAttachedToStatusBar(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - AttachedToStatusBar(token); - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - auto size = data.ReadUint32(); - if (size == 0 || size > MAX_KILL_PROCESS_PID_COUNT) { - TAG_LOGE(AAFwkTag::APPMGR, "Invalid size."); - return ERR_INVALID_VALUE; - } - std::vector pids; - for (uint32_t i = 0; i < size; i++) { - pids.emplace_back(data.ReadInt32()); - } - - BlockProcessCacheByPids(pids); - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - auto bundleName = data.ReadString(); - if (bundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); - return ERR_INVALID_VALUE; - } - - auto result = IsKilledForUpgradeWeb(bundleName); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -ErrCode AmsMgrStub::HandleCleanAbilityByUserRequest(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - auto result = CleanAbilityByUserRequest(token); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "fail to write the result."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply) -{ - auto pid = data.ReadUint32(); - - auto result = IsProcessContainsOnlyUIAbility(pid); - if (!reply.WriteBool(result)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result in HandleIsProcessContainsOnlyUIAbility."); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr token = data.ReadRemoteObject(); - auto isAttached = IsProcessAttached(token); - if (!reply.WriteBool(isAttached)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int32_t AmsMgrStub::HandleIsCallerKilling(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - auto callerKey = data.ReadString(); - auto isCallerKilling = IsCallerKilling(callerKey); - if (!reply.WriteBool(isCallerKilling)) { - TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_debug_listener_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_debug_listener_proxy.cpp deleted file mode 100644 index fc271be274a5c62723bbfb0fc75579120b1abfb4..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/app_debug_listener_proxy.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 "app_debug_listener_proxy.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -constexpr int32_t CYCLE_LIMIT_MIN = 0; -constexpr int32_t CYCLE_LIMIT_MAX = 1000; -} -AppDebugListenerProxy::AppDebugListenerProxy( - const sptr &impl) : IRemoteProxy(impl) -{} - -bool AppDebugListenerProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(AppDebugListenerProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return false; - } - return true; -} - -void AppDebugListenerProxy::OnAppDebugStarted(const std::vector &debugInfos) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - SendRequest(IAppDebugListener::Message::ON_APP_DEBUG_STARTED, debugInfos); -} - -void AppDebugListenerProxy::OnAppDebugStoped(const std::vector &debugInfos) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - SendRequest(IAppDebugListener::Message::ON_APP_DEBUG_STOPED, debugInfos); -} - -void AppDebugListenerProxy::SendRequest( - const IAppDebugListener::Message &message, const std::vector &debugInfos) -{ - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return; - } - - if (debugInfos.size() <= CYCLE_LIMIT_MIN || debugInfos.size() > CYCLE_LIMIT_MAX || - !data.WriteInt32(debugInfos.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "Write debug info size failed."); - return; - } - for (auto &debugInfo : debugInfos) { - if (!data.WriteParcelable(&debugInfo)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write debug info failed."); - return; - } - }; - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return; - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - int32_t ret = remote->SendRequest(static_cast(message), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_debug_listener_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_debug_listener_stub.cpp deleted file mode 100644 index ae20e2535b890b8947c0d4fdc3785ef359f8503c..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/app_debug_listener_stub.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 "app_debug_listener_stub.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -constexpr int32_t CYCLE_LIMIT_MIN = 0; -constexpr int32_t CYCLE_LIMIT_MAX = 1000; -} -AppDebugListenerStub::AppDebugListenerStub() {} - -AppDebugListenerStub::~AppDebugListenerStub() {} - -int AppDebugListenerStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - TAG_LOGD(AAFwkTag::APPMGR, "code = %{public}u, flags= %{public}d", code, option.GetFlags()); - std::u16string descriptor = AppDebugListenerStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::APPMGR, "Local descriptor is not equal to remote."); - return ERR_INVALID_STATE; - } - - switch (code) { - case static_cast(IAppDebugListener::Message::ON_APP_DEBUG_STARTED): - return HandleOnAppDebugStarted(data, reply); - case static_cast(IAppDebugListener::Message::ON_APP_DEBUG_STOPED): - return HandleOnAppDebugStoped(data, reply); - } - - TAG_LOGD(AAFwkTag::APPMGR, "AppDebugListenerStub::OnRemoteRequest end"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t AppDebugListenerStub::HandleOnAppDebugStarted(MessageParcel &data, MessageParcel &reply) -{ - auto infoSize = data.ReadInt32(); - if (infoSize <= CYCLE_LIMIT_MIN || infoSize > CYCLE_LIMIT_MAX) { - TAG_LOGE(AAFwkTag::APPMGR, "Token size exceeds limit."); - return ERR_INVALID_DATA; - } - - std::vector appDebugInfos; - for (int32_t index = 0; index < infoSize; index++) { - std::unique_ptr appDebugInfo(data.ReadParcelable()); - if (appDebugInfo == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Read app debug infos failed."); - return ERR_INVALID_DATA; - } - appDebugInfos.emplace_back(*appDebugInfo); - } - - OnAppDebugStarted(appDebugInfos); - return NO_ERROR; -} - -int32_t AppDebugListenerStub::HandleOnAppDebugStoped(MessageParcel &data, MessageParcel &reply) -{ - auto infoSize = data.ReadInt32(); - if (infoSize <= CYCLE_LIMIT_MIN || infoSize > CYCLE_LIMIT_MAX) { - TAG_LOGE(AAFwkTag::APPMGR, "Token size exceeds limit."); - return ERR_INVALID_DATA; - } - - std::vector appDebugInfos; - for (int32_t index = 0; index < infoSize; index++) { - std::unique_ptr appDebugInfo(data.ReadParcelable()); - if (appDebugInfo == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Read app debug infos failed."); - return ERR_INVALID_DATA; - } - appDebugInfos.emplace_back(*appDebugInfo); - } - - OnAppDebugStoped(appDebugInfos); - return NO_ERROR; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 232f8be1f975aab0cb2d2dc30292f200690fb8b4..57333b23c12d81d9a5bd43bca41ffb646bd8596b 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -197,7 +197,7 @@ AppMgrResultCode AppMgrClient::UpdateAbilityState(const sptr &tok if (service != nullptr) { sptr amsService = service->GetAmsMgr(); if (amsService != nullptr) { - amsService->UpdateAbilityState(token, state); + amsService->UpdateAbilityState(token, static_cast(state)); return AppMgrResultCode::RESULT_OK; } } @@ -597,7 +597,9 @@ bool AppMgrClient::IsProcessContainsOnlyUIAbility(const pid_t pid) if (service != nullptr) { sptr amsService = service->GetAmsMgr(); if (amsService != nullptr) { - return amsService->IsProcessContainsOnlyUIAbility(pid); + bool ret = false; + amsService->IsProcessContainsOnlyUIAbility(pid, ret); + return ret; } } return false; @@ -1107,7 +1109,9 @@ bool AppMgrClient::IsWaitingDebugApp(const std::string &bundleName) TAG_LOGE(AAFwkTag::APPMGR, "App manager service is not ready."); return false; } - return amsService_->IsWaitingDebugApp(bundleName); + bool ret = false; + amsService_->IsWaitingDebugApp(bundleName, ret); + return ret; } void AppMgrClient::ClearNonPersistWaitingDebugFlag() @@ -1132,7 +1136,9 @@ bool AppMgrClient::IsAttachDebug(const std::string &bundleName) if (!IsAmsServiceReady()) { return false; } - return amsService_->IsAttachDebug(bundleName); + bool ret = false; + amsService_->IsAttachDebug(bundleName, ret); + return ret; } bool AppMgrClient::IsAmsServiceReady() @@ -1345,7 +1351,9 @@ bool AppMgrClient::IsMemorySizeSufficent() const TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr."); return true; } - return amsService->IsMemorySizeSufficent(); + bool ret = false; + amsService->IsMemorySizeSufficent(ret); + return ret; } bool AppMgrClient::IsNoRequireBigMemory() const @@ -1360,7 +1368,9 @@ bool AppMgrClient::IsNoRequireBigMemory() const TAG_LOGE(AAFwkTag::APPMGR, "amsService is nullptr."); return true; } - return amsService->IsNoRequireBigMemory(); + bool ret = false; + amsService->IsNoRequireBigMemory(ret); + return ret; } int32_t AppMgrClient::PreloadApplication(const std::string &bundleName, int32_t userId, @@ -1506,7 +1516,9 @@ bool AppMgrClient::IsKilledForUpgradeWeb(const std::string &bundleName) return false; } TAG_LOGD(AAFwkTag::APPMGR, "call"); - return amsService->IsKilledForUpgradeWeb(bundleName); + bool ret = false; + amsService->IsKilledForUpgradeWeb(bundleName, ret); + return ret; } bool AppMgrClient::CleanAbilityByUserRequest(const sptr &token) @@ -1522,7 +1534,9 @@ bool AppMgrClient::CleanAbilityByUserRequest(const sptr &token) return false; } TAG_LOGD(AAFwkTag::APPMGR, "call"); - return amsService->CleanAbilityByUserRequest(token); + bool ret = false; + amsService->IsProcessAttached(token, ret); + return ret; } bool AppMgrClient::IsProcessAttached(sptr token) const @@ -1535,7 +1549,9 @@ bool AppMgrClient::IsProcessAttached(sptr token) const if (amsService == nullptr) { return false; } - return amsService->IsProcessAttached(token); + bool ret = false; + amsService->IsProcessAttached(token, ret); + return ret; } bool AppMgrClient::IsCallerKilling(const std::string& callerKey) const @@ -1548,7 +1564,9 @@ bool AppMgrClient::IsCallerKilling(const std::string& callerKey) const if (amsService == nullptr) { return false; } - return amsService->IsCallerKilling(callerKey); + bool ret = false; + amsService->IsCallerKilling(callerKey, ret); + return ret; } AppMgrResultCode AppMgrClient::IsAppRunningByBundleNameAndUserId(const std::string &bundleName, int32_t userId, diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_host.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_host.cpp index 6583946d01f3215d43c11f92d21144cf35a34a06..9223c94e17f91c94f32bdc89d8eb1c58f281ac06 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_host.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_host.cpp @@ -19,241 +19,67 @@ #include "configuration.h" #include "hitrace_meter.h" #include "hilog_tag_wrapper.h" -#include "ipc_types.h" #include "iremote_object.h" -#include "app_state_callback_proxy.h" - namespace OHOS { namespace AppExecFwk { -constexpr int32_t CYCLE_LIMIT = 1000; AppStateCallbackHost::AppStateCallbackHost() {} AppStateCallbackHost::~AppStateCallbackHost() {} -int AppStateCallbackHost::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - TAG_LOGD(AAFwkTag::APPMGR, "AppStateCallbackHost::OnReceived, code = %{public}u, flags= %{public}d.", code, - option.GetFlags()); - std::u16string descriptor = AppStateCallbackHost::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::APPMGR, "local descriptor is not equal to remote"); - return ERR_INVALID_STATE; - } - - switch (code) { - case static_cast(IAppStateCallback::Message::TRANSACT_ON_APP_STATE_CHANGED): - return HandleOnAppStateChanged(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_ABILITY_REQUEST_DONE): - return HandleOnAbilityRequestDone(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_CONFIG_CHANGE): - return HandleNotifyConfigurationChange(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_START_RESIDENT_PROCESS): - return HandleNotifyStartResidentProcess(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_APP_REMOTE_DIED): - return HandleOnAppRemoteDied(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_APP_PRE_CACHE): - return HandleNotifyAppPreCache(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_START_KEEP_ALIVE_PROCESS): - return HandleNotifyStartKeepAliveProcess(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_START_PROCESS_FAILED): - return HandleOnStartProcessFailed(data, reply); - case static_cast(IAppStateCallback::Message::TRANSACT_ON_CACHE_EXIT_INFO): - return HandleOnCacheExitInfo(data, reply); - } - - TAG_LOGD(AAFwkTag::APPMGR, "AppStateCallbackHost::OnRemoteRequest end"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -void AppStateCallbackHost::OnAbilityRequestDone(const sptr &, const AbilityState) +ErrCode AppStateCallbackHost::OnAbilityRequestDone(const sptr &, const AbilityState) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::OnAppStateChanged(const AppProcessData &) +ErrCode AppStateCallbackHost::OnAppStateChanged(const AppProcessData &appProcessData) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::NotifyAppPreCache(int32_t pid, int32_t userId) +ErrCode AppStateCallbackHost::NotifyAppPreCache(int32_t pid, int32_t userId) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) +ErrCode AppStateCallbackHost::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) { + return ERR_OK; } -void AppStateCallbackHost::NotifyStartResidentProcess(std::vector &bundleInfos) +ErrCode AppStateCallbackHost::NotifyStartResidentProcess(const std::vector &bundleInfos) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::NotifyStartKeepAliveProcess(std::vector &bundleInfos) +ErrCode AppStateCallbackHost::NotifyStartKeepAliveProcess(const std::vector &bundleInfos) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::OnAppRemoteDied(const std::vector> &abilityTokens) +ErrCode AppStateCallbackHost::OnAppRemoteDied(const std::vector> &abilityTokens) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::OnStartProcessFailed(sptr token) +ErrCode AppStateCallbackHost::OnStartProcessFailed(const sptr &token) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + return ERR_OK; } -void AppStateCallbackHost::OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, +ErrCode AppStateCallbackHost::OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, const std::string &bundleName, const std::vector &abilityNames, const std::vector &uiExtensionNames) { TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -int32_t AppStateCallbackHost::HandleOnAppStateChanged(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - std::unique_ptr processData(data.ReadParcelable()); - if (!processData) { - TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - OnAppStateChanged(*processData); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply) -{ - HITRACE_METER(HITRACE_TAG_APP); - sptr obj = nullptr; - if (data.ReadBool()) { - obj = data.ReadRemoteObject(); - } - int32_t state = data.ReadInt32(); - OnAbilityRequestDone(obj, static_cast(state)); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleNotifyConfigurationChange(MessageParcel &data, MessageParcel &reply) -{ - std::unique_ptr config(data.ReadParcelable()); - if (config == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "To read config failed."); - return ERR_DEAD_OBJECT; - } - auto userId = data.ReadInt32(); - NotifyConfigurationChange(*config, userId); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleNotifyStartResidentProcess(MessageParcel &data, MessageParcel &reply) -{ - std::vector bundleInfos; - int32_t infoSize = data.ReadInt32(); - if (infoSize > CYCLE_LIMIT) { - TAG_LOGE(AAFwkTag::APPMGR, "infoSize is too large"); - return ERR_INVALID_VALUE; - } - for (int32_t i = 0; i < infoSize; i++) { - std::unique_ptr bundleInfo(data.ReadParcelable()); - if (!bundleInfo) { - TAG_LOGE(AAFwkTag::APPMGR, "Read Parcelable infos failed."); - return ERR_INVALID_VALUE; - } - bundleInfos.emplace_back(*bundleInfo); - } - NotifyStartResidentProcess(bundleInfos); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleNotifyStartKeepAliveProcess(MessageParcel &data, MessageParcel &reply) -{ - std::vector bundleInfos; - int32_t infoSize = data.ReadInt32(); - if (infoSize > CYCLE_LIMIT) { - TAG_LOGE(AAFwkTag::APPMGR, "infoSize is too large"); - return ERR_INVALID_VALUE; - } - for (int32_t i = 0; i < infoSize; i++) { - std::unique_ptr bundleInfo(data.ReadParcelable()); - if (!bundleInfo) { - TAG_LOGE(AAFwkTag::APPMGR, "Read Parcelable infos failed."); - return ERR_INVALID_VALUE; - } - bundleInfos.emplace_back(*bundleInfo); - } - NotifyStartKeepAliveProcess(bundleInfos); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleOnAppRemoteDied(MessageParcel &data, MessageParcel &reply) -{ - std::vector> abilityTokens; - int32_t infoSize = data.ReadInt32(); - if (infoSize > CYCLE_LIMIT) { - TAG_LOGE(AAFwkTag::APPMGR, "infoSize is too large"); - return ERR_INVALID_VALUE; - } - for (int32_t i = 0; i < infoSize; i++) { - sptr obj = data.ReadRemoteObject(); - if (!obj) { - TAG_LOGE(AAFwkTag::APPMGR, "Read token failed."); - return ERR_INVALID_VALUE; - } - abilityTokens.emplace_back(obj); - } - OnAppRemoteDied(abilityTokens); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleOnStartProcessFailed(MessageParcel &data, MessageParcel &reply) -{ - sptr token = data.ReadRemoteObject(); - if (!token) { - TAG_LOGE(AAFwkTag::APPMGR, "null token"); - return ERR_INVALID_VALUE; - } - OnStartProcessFailed(token); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleNotifyAppPreCache(MessageParcel &data, MessageParcel &reply) -{ - int32_t pid = data.ReadInt32(); - if (pid <= 0) { - TAG_LOGE(AAFwkTag::APPMGR, "pid is illegal"); - return ERR_INVALID_VALUE; - } - int32_t userId = data.ReadInt32(); - if (userId < 0) { - TAG_LOGE(AAFwkTag::APPMGR, "userId is illegal"); - return ERR_INVALID_VALUE; - } - NotifyAppPreCache(pid, userId); - return NO_ERROR; -} - -int32_t AppStateCallbackHost::HandleOnCacheExitInfo(MessageParcel &data, MessageParcel &reply) -{ - uint32_t accessTokenId = data.ReadUint32(); - std::unique_ptr exitInfo(data.ReadParcelable()); - if (exitInfo == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "To read exitInfo failed"); - return ERR_DEAD_OBJECT; - } - std::string bundleName = data.ReadString(); - std::vector abilityNames; - data.ReadStringVector(&abilityNames); - std::vector uiExtensionNames; - data.ReadStringVector(&uiExtensionNames); - OnCacheExitInfo(accessTokenId, *exitInfo, bundleName, abilityNames, uiExtensionNames); - - return NO_ERROR; + return ERR_OK; } } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp deleted file mode 100644 index 4b33e4a21ee9dcc910b6ba48e2baf78dbb7c31a1..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2021-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 "app_state_callback_proxy.h" - -#include "configuration.h" -#include "ipc_types.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -AppStateCallbackProxy::AppStateCallbackProxy(const sptr &impl) : IRemoteProxy(impl) -{} - -bool AppStateCallbackProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(AppStateCallbackProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "write interface token failed"); - return false; - } - return true; -} - -void AppStateCallbackProxy::OnAbilityRequestDone(const sptr &token, const AbilityState state) -{ - TAG_LOGD(AAFwkTag::APPMGR, "begin"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (token) { - if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag and token"); - return; - } - } else { - if (!data.WriteBool(false)) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag"); - return; - } - } - - int32_t abilityState = static_cast(state); - data.WriteInt32(abilityState); - int32_t ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_ABILITY_REQUEST_DONE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AppStateCallbackProxy::OnAppStateChanged(const AppProcessData &appProcessData) -{ - TAG_LOGD(AAFwkTag::APPMGR, "begin"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - data.WriteParcelable(&appProcessData); - int32_t ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_APP_STATE_CHANGED), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); -} - -void AppStateCallbackProxy::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return; - } - if (!data.WriteParcelable(&config)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write config failed."); - return; - } - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write usr failed."); - return; - } - auto error = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_CONFIG_CHANGE), data, reply, option); - if (error != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send config error: %{public}d", error); - } -} - -void AppStateCallbackProxy::NotifyStartResidentProcess(std::vector &bundleInfos) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - - if (!data.WriteInt32(bundleInfos.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "write bundle info size failed."); - return; - } - - for (auto &bundleInfo : bundleInfos) { - if (!data.WriteParcelable(&bundleInfo)) { - TAG_LOGE(AAFwkTag::APPMGR, "write bundle info failed"); - return; - } - } - auto ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_START_RESIDENT_PROCESS), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void AppStateCallbackProxy::NotifyStartKeepAliveProcess(std::vector &bundleInfos) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - - if (!data.WriteInt32(bundleInfos.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "write bundle info size failed."); - return; - } - - for (auto &bundleInfo : bundleInfos) { - if (!data.WriteParcelable(&bundleInfo)) { - TAG_LOGE(AAFwkTag::APPMGR, "write bundle info failed"); - return; - } - } - auto ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_NOTIFY_START_KEEP_ALIVE_PROCESS), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void AppStateCallbackProxy::OnAppRemoteDied(const std::vector> &abilityTokens) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - - if (!data.WriteInt32(abilityTokens.size())) { - TAG_LOGE(AAFwkTag::APPMGR, "write token size failed."); - return; - } - - for (auto &token : abilityTokens) { - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "write token failed"); - return; - } - } - auto ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_APP_REMOTE_DIED), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void AppStateCallbackProxy::OnStartProcessFailed(sptr token) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - - if (!data.WriteRemoteObject(token.GetRefPtr())) { - TAG_LOGE(AAFwkTag::APPMGR, "write token failed"); - return; - } - auto ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_START_PROCESS_FAILED), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void AppStateCallbackProxy::OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, - const std::string &bundleName, const std::vector &abilityNames, - const std::vector &uiExtensionNames) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - if (!data.WriteUint32(accessTokenId)) { - TAG_LOGE(AAFwkTag::APPMGR, "accessTokenId write failed"); - return; - } - if (!data.WriteParcelable(&exitInfo)) { - TAG_LOGE(AAFwkTag::APPMGR, "exitInfo write failed"); - return; - } - if (!data.WriteString(bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "bundleName write failed"); - return; - } - if (!data.WriteStringVector(abilityNames)) { - TAG_LOGE(AAFwkTag::APPMGR, "abilityNames write failed"); - return; - } - if (!data.WriteStringVector(uiExtensionNames)) { - TAG_LOGE(AAFwkTag::APPMGR, "uiExtensionNames write failed"); - return; - } - auto ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_CACHE_EXIT_INFO), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } - -} - -void AppStateCallbackProxy::NotifyAppPreCache(int32_t pid, int32_t userId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); - return; - } - - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "write pid failed."); - return; - } - - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "write userId failed."); - return; - } - - auto ret = SendTransactCmd( - static_cast(IAppStateCallback::Message::TRANSACT_ON_APP_PRE_CACHE), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -int32_t AppStateCallbackProxy::SendTransactCmd(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return ERR_NULL_OBJECT; - } - - auto ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed with error code: %{public}d", ret); - return ret; - } - return ret; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/start_specified_ability_response_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/start_specified_ability_response_proxy.cpp deleted file mode 100644 index 024dfee1d07babb5c5b652b4b228d7d9c987b7e7..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/start_specified_ability_response_proxy.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2022-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 "start_specified_ability_response_proxy.h" -#include "ipc_types.h" -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -StartSpecifiedAbilityResponseProxy::StartSpecifiedAbilityResponseProxy(const sptr &impl) - : IRemoteProxy(impl) -{} - -bool StartSpecifiedAbilityResponseProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(StartSpecifiedAbilityResponseProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "write interface token failed"); - return false; - } - return true; -} - -void StartSpecifiedAbilityResponseProxy::OnAcceptWantResponse( - const AAFwk::Want &want, const std::string &flag, int32_t requestId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "On accept want by proxy."); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(&want) || !data.WriteString(flag) || - !data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - int32_t ret = SendTransactCmd( - static_cast(IStartSpecifiedAbilityResponse::Message::ON_ACCEPT_WANT_RESPONSE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void StartSpecifiedAbilityResponseProxy::OnTimeoutResponse(int32_t requestId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "On timeout response by proxy."); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - int32_t ret = SendTransactCmd(static_cast( - IStartSpecifiedAbilityResponse::Message::ON_TIMEOUT_RESPONSE), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -int32_t StartSpecifiedAbilityResponseProxy::SendTransactCmd(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return ERR_NULL_OBJECT; - } - - return remote->SendRequest(code, data, reply, option); -} - -void StartSpecifiedAbilityResponseProxy::OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "On satrt specified process response by proxy."); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteString(flag) || !data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return; - } - int32_t ret = remote->SendRequest( - static_cast(IStartSpecifiedAbilityResponse::Message::ON_NEW_PROCESS_REQUEST_RESPONSE), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void StartSpecifiedAbilityResponseProxy::OnNewProcessRequestTimeoutResponse(int32_t requestId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "On start specified process timeout response by proxy."); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return; - } - int32_t ret = remote->SendRequest(static_cast( - IStartSpecifiedAbilityResponse::Message::ON_NEW_PROCESS_REQUEST_TIMEOUT_RESPONSE), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} - -void StartSpecifiedAbilityResponseProxy::OnStartSpecifiedFailed(int32_t requestId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteInt32(requestId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write data failed."); - return; - } - - int32_t ret = SendTransactCmd( - static_cast(IStartSpecifiedAbilityResponse::Message::ON_START_SPECIFIED_FAILED), data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); - } -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/start_specified_ability_response_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/start_specified_ability_response_stub.cpp deleted file mode 100644 index 690da42b84a00652426d3e4dbc81d7c3663598d9..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/start_specified_ability_response_stub.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2022-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 "start_specified_ability_response_stub.h" -#include "appexecfwk_errors.h" -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AppExecFwk { -int32_t StartSpecifiedAbilityResponseStub::HandleOnAcceptWantResponse(MessageParcel &data, MessageParcel &reply) -{ - AAFwk::Want *want = data.ReadParcelable(); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "want is nullptr"); - return ERR_INVALID_VALUE; - } - - auto flag = Str16ToStr8(data.ReadString16()); - OnAcceptWantResponse(*want, flag, data.ReadInt32()); - delete want; - return NO_ERROR; -} - -int32_t StartSpecifiedAbilityResponseStub::HandleOnTimeoutResponse(MessageParcel &data, MessageParcel &reply) -{ - OnTimeoutResponse(data.ReadInt32()); - return NO_ERROR; -} - -int32_t StartSpecifiedAbilityResponseStub::HandleOnNewProcessRequestResponse(MessageParcel &data, MessageParcel &reply) -{ - auto flag = Str16ToStr8(data.ReadString16()); - OnNewProcessRequestResponse(flag, data.ReadInt32()); - return NO_ERROR; -} - -int32_t StartSpecifiedAbilityResponseStub::HandleOnNewProcessRequestTimeoutResponse(MessageParcel &data, - MessageParcel &reply) -{ - OnNewProcessRequestTimeoutResponse(data.ReadInt32()); - return NO_ERROR; -} - -int32_t StartSpecifiedAbilityResponseStub::HandleOnStartSpecifiedFailed(MessageParcel &data, - MessageParcel &reply) -{ - OnStartSpecifiedFailed(data.ReadInt32()); - return NO_ERROR; -} - -int StartSpecifiedAbilityResponseStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - TAG_LOGI(AAFwkTag::APPMGR, "StartSpecifiedAbilityResponseStub::OnReceived, code = %{public}u, flags= %{public}d.", - code, option.GetFlags()); - std::u16string descriptor = StartSpecifiedAbilityResponseStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::APPMGR, "local descriptor is not equal to remote"); - return ERR_INVALID_STATE; - } - - switch (code) { - case Message::ON_ACCEPT_WANT_RESPONSE: return HandleOnAcceptWantResponse(data, reply); - case Message::ON_TIMEOUT_RESPONSE: return HandleOnTimeoutResponse(data, reply); - case Message::ON_NEW_PROCESS_REQUEST_RESPONSE: return HandleOnNewProcessRequestResponse(data, reply); - case Message::ON_NEW_PROCESS_REQUEST_TIMEOUT_RESPONSE: - return HandleOnNewProcessRequestTimeoutResponse(data, reply); - case Message::ON_START_SPECIFIED_FAILED: return HandleOnStartSpecifiedFailed(data, reply); - default: return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index a9f3008821ce8144f55e241721e9ab01b90077d1..572f91aff77d8390fc5fa10f6c5430fc85340562 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -64,7 +64,12 @@ ohos_shared_library("wantagent_innerkits") { "src/want_agent_info.cpp", ] - public_configs = [ ":wantagent_innerkits_public_config" ] + public_configs = [ + ":wantagent_innerkits_public_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index f5fb60ef211d8b171d7053151a3b1c9de86c39df..00966af32b81b65480344a038773cd67db691920 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -80,7 +80,6 @@ abilityms_files = [ "src/ui_extension_record/ui_extension_record_factory.cpp", "src/screen_lock/unlock_screen_manager.cpp", "src/start_options.cpp", - "src/user_callback_proxy.cpp", "src/call_container.cpp", "src/call_record.cpp", "src/inner_mission_info.cpp", diff --git a/services/abilitymgr/include/ability_debug_deal.h b/services/abilitymgr/include/ability_debug_deal.h index 13e446b090bedede16749721e33add5ae3b4ca30..53f04555e7daf2eaabf0ef000ccb14998349281d 100644 --- a/services/abilitymgr/include/ability_debug_deal.h +++ b/services/abilitymgr/include/ability_debug_deal.h @@ -16,7 +16,7 @@ #ifndef OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_DEAL_H #define OHOS_ABILITY_RUNTIME_ABILITY_DEBUG_DEAL_H -#include "ability_debug_response_interface.h" +#include "iability_debug_response.h" #include "ability_debug_response_stub.h" namespace OHOS { @@ -60,9 +60,9 @@ public: virtual ~AbilityDebugResponse() = default; private: - void OnAbilitysDebugStarted(const std::vector> &tokens) override; - void OnAbilitysDebugStoped(const std::vector> &tokens) override; - void OnAbilitysAssertDebugChange(const std::vector> &tokens, bool isAssertDebug) override; + ErrCode OnAbilitysDebugStarted(const std::vector> &tokens) override; + ErrCode OnAbilitysDebugStoped(const std::vector> &tokens) override; + ErrCode OnAbilitysAssertDebugChange(const std::vector> &tokens, bool isAssertDebug) override; std::weak_ptr abilityDebugDeal_; }; diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 60f6a1adf947d6980234bc1d3e290ae45761cef7..68b52092e734bf89a56bb366a7a65b91ef9602c8 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -37,7 +37,7 @@ #include "ability_keep_alive_service.h" #include "ability_start_with_wait_observer_utils.h" #include "ams_configuration_parameter.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "app_exit_reason_helper.h" #include "app_mgr_interface.h" #include "app_scheduler.h" @@ -2105,9 +2105,9 @@ protected: void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; - void NotifyStartResidentProcess(std::vector &bundleInfos) override; + void NotifyStartResidentProcess(const std::vector &bundleInfos) override; - void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override; + void NotifyStartKeepAliveProcess(const std::vector &bundleInfos) override; /** * @brief Notify abilityms app process pre cache @@ -2130,7 +2130,7 @@ protected: int32_t GetCollaboratorType(const std::string &codePath) const; int32_t KillProcessForCollaborator(int32_t collaboratorType, const std::string &bundleName, int32_t userId); - + /** * Check if Caller is allowed to start AppServiceExtension(Stage). * @@ -2731,9 +2731,9 @@ private: ErrCode IntentOpenLinkInner(const std::shared_ptr ¶m, AbilityRuntime::ExtractInsightIntentGenericInfo &linkInfo, const int32_t userId); - + AbilityRuntime::ExtractInsightIntentGenericInfo GetInsightIntentGenericInfo(const InsightIntentExecuteParam ¶m); - + void CombinLinkInfo( const std::vector ¶mMappings, std::string &uri, AAFwk::Want &want); diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index b2de5a3951123671c45bf65a83bfed95c0db35da..58565ed4bb13549526cba361dee1ab693f791a1a 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -19,14 +19,14 @@ #include #include -#include "ability_debug_response_interface.h" +#include "iability_debug_response.h" #include "ability_info.h" #include "ability_manager_client.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "application_info.h" #include "appmgr/app_mgr_client.h" -#include "appmgr/app_state_callback_host.h" -#include "appmgr/start_specified_ability_response_stub.h" +#include "app_state_callback_stub.h" +#include "start_specified_ability_response_stub.h" #include "bundle_info.h" #include "fault_data.h" #include "iremote_object.h" @@ -98,9 +98,9 @@ public: virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) {} - virtual void NotifyStartResidentProcess(std::vector &bundleInfos) {} + virtual void NotifyStartResidentProcess(const std::vector &bundleInfos) {} - virtual void NotifyStartKeepAliveProcess(std::vector &bundleInfos) {} + virtual void NotifyStartKeepAliveProcess(const std::vector &bundleInfos) {} /** * @brief Notify abilityms app process pre cache @@ -114,7 +114,7 @@ public: * @param abilityTokens abilities in died process. */ virtual void OnAppRemoteDied(const std::vector> &abilityTokens) {} - + virtual void OnStartProcessFailed(sptr token) {} virtual void OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo, @@ -127,21 +127,21 @@ public: StartSpecifiedAbilityResponse() = default; virtual ~StartSpecifiedAbilityResponse() = default; - virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, + virtual ErrCode OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId) override; - virtual void OnTimeoutResponse(int32_t requestId) override; + virtual ErrCode OnTimeoutResponse(int32_t requestId) override; - virtual void OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override; - virtual void OnNewProcessRequestTimeoutResponse(int32_t requestId) override; + virtual ErrCode OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) override; + virtual ErrCode OnNewProcessRequestTimeoutResponse(int32_t requestId) override; - virtual void OnStartSpecifiedFailed(int32_t requestId) override; + virtual ErrCode OnStartSpecifiedFailed(int32_t requestId) override; }; /** * @class AppScheduler * AppScheduler , access app manager service. */ -class AppScheduler : virtual RefBase, public AppExecFwk::AppStateCallbackHost { +class AppScheduler : virtual RefBase, public AppExecFwk::AppStateCallbackStub { DECLARE_DELAYED_SINGLETON(AppScheduler) public: /** @@ -616,48 +616,48 @@ protected: * @param token,ability's token. * @param state,the state of ability lift cycle. */ - virtual void OnAbilityRequestDone(const sptr &token, const AppExecFwk::AbilityState state) override; + virtual ErrCode OnAbilityRequestDone(const sptr &token, const AppExecFwk::AbilityState state) override; /** * Application state changed callback. * * @param appProcessData Process data */ - virtual void OnAppStateChanged(const AppExecFwk::AppProcessData &appData) override; + virtual ErrCode OnAppStateChanged(const AppExecFwk::AppProcessData &appData) override; /** * @brief Notify application update system environment changes. * @param config System environment change parameters. * @param userId userId Designation User ID. */ - virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; + virtual ErrCode NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; /** * @brief Notify abilityms start resident process. * @param bundleInfos resident process bundle infos. */ - virtual void NotifyStartResidentProcess(std::vector &bundleInfos) override; + virtual ErrCode NotifyStartResidentProcess(const std::vector &bundleInfos) override; /** * @brief Notify abilityms start keep-alive process. * @param bundleInfos resident process bundle infos. */ - virtual void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override; + virtual ErrCode NotifyStartKeepAliveProcess(const std::vector &bundleInfos) override; /** * @brief Notify abilityms app process OnRemoteDied * @param abilityTokens abilities in died process. */ - virtual void OnAppRemoteDied(const std::vector> &abilityTokens) override; + virtual ErrCode OnAppRemoteDied(const std::vector> &abilityTokens) override; - virtual void OnStartProcessFailed(sptr token) override; + virtual ErrCode OnStartProcessFailed(const sptr &token) override; /** * @brief Notify abilityms app process pre cache * @param pid process pid. * @param userId userId Designation User ID. */ - virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override; + virtual ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) override; /** * @brief Notify abilityms exit info @@ -667,7 +667,7 @@ protected: * @param abilityNames abilityNames in app. * @param uiExtensionNames uiExtensionNames in app. */ - virtual void OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo, + virtual ErrCode OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo, const std::string &bundleName, const std::vector &abilityNames, const std::vector &uiExtensionNames) override; diff --git a/services/abilitymgr/src/ability_debug_deal.cpp b/services/abilitymgr/src/ability_debug_deal.cpp index 9493ef44d477c819b6405c76b41d33482b9b331e..6a41c648b3a9cd3cb34cab876c14bf5c5552e55d 100644 --- a/services/abilitymgr/src/ability_debug_deal.cpp +++ b/services/abilitymgr/src/ability_debug_deal.cpp @@ -74,50 +74,53 @@ void AbilityDebugDeal::OnAbilitysAssertDebugChange(const std::vector> &tokens) +ErrCode AbilityDebugResponse::OnAbilitysDebugStarted(const std::vector> &tokens) { if (tokens.empty()) { TAG_LOGW(AAFwkTag::ABILITYMGR, "tokens empty"); - return; + return ERR_INVALID_DATA; } auto deal = abilityDebugDeal_.lock(); if (deal == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "deal null"); - return; + return ERR_INVALID_DATA; } deal->OnAbilitysDebugStarted(tokens); + return ERR_OK; } -void AbilityDebugResponse::OnAbilitysDebugStoped(const std::vector> &tokens) +ErrCode AbilityDebugResponse::OnAbilitysDebugStoped(const std::vector> &tokens) { if (tokens.empty()) { TAG_LOGW(AAFwkTag::ABILITYMGR, "tokens empty"); - return; + return ERR_INVALID_DATA; } auto deal = abilityDebugDeal_.lock(); if (deal == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "deal null"); - return; + return ERR_INVALID_DATA; } deal->OnAbilitysDebugStoped(tokens); + return ERR_OK; } -void AbilityDebugResponse::OnAbilitysAssertDebugChange( +ErrCode AbilityDebugResponse::OnAbilitysAssertDebugChange( const std::vector> &tokens, bool isAssertDebug) { if (tokens.empty()) { TAG_LOGW(AAFwkTag::ABILITYMGR, "tokens empty"); - return; + return ERR_INVALID_DATA; } auto deal = abilityDebugDeal_.lock(); if (deal == nullptr) { TAG_LOGW(AAFwkTag::ABILITYMGR, "deal null"); - return; + return ERR_INVALID_DATA; } deal->OnAbilitysAssertDebugChange(tokens, isAssertDebug); + return ERR_OK; } } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 0fc4699c25338df2891defd0c9eee8e1c33bb97f..c546b531e0234d1e2cc1e470202131585a04af18 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -11983,7 +11983,7 @@ void AbilityManagerService::NotifyConfigurationChange(const AppExecFwk::Configur collaborator->UpdateConfiguration(config, userId); } -void AbilityManagerService::NotifyStartResidentProcess(std::vector &bundleInfos) +void AbilityManagerService::NotifyStartResidentProcess(const std::vector &bundleInfos) { if (userController_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "userController_ null"); @@ -12017,7 +12017,7 @@ void AbilityManagerService::NotifyStartResidentProcess(std::vector &bundleInfos) +void AbilityManagerService::NotifyStartKeepAliveProcess(const std::vector &bundleInfos) { if (!system::GetBoolParameter(PRODUCT_ENTERPRISE_FEATURE_SETTING_ENABLED, false)) { return; diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index d6385c53b441b67a4d3d654c749e136024d108af..3d182e21a8298bda0fbe896469c4df28ca51ffd4 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -199,65 +199,73 @@ AppAbilityState AppScheduler::GetAbilityState() const return appAbilityState_; } -void AppScheduler::OnAbilityRequestDone(const sptr &token, const AppExecFwk::AbilityState state) +ErrCode AppScheduler::OnAbilityRequestDone(const sptr &token, const AppExecFwk::AbilityState state) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::ABILITYMGR, "state:%{public}d", static_cast(state)); auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); appAbilityState_ = ConvertToAppAbilityState(static_cast(state)); callback->OnAbilityRequestDone(token, static_cast(state)); + return ERR_OK; } -void AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) +ErrCode AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->NotifyConfigurationChange(config, userId); + return ERR_OK; } -void AppScheduler::NotifyStartResidentProcess(std::vector &bundleInfos) +ErrCode AppScheduler::NotifyStartResidentProcess(const std::vector &bundleInfos) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->NotifyStartResidentProcess(bundleInfos); + return ERR_OK; } -void AppScheduler::NotifyStartKeepAliveProcess(std::vector &bundleInfos) +ErrCode AppScheduler::NotifyStartKeepAliveProcess(const std::vector &bundleInfos) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->NotifyStartKeepAliveProcess(bundleInfos); + return ERR_OK; } -void AppScheduler::OnAppRemoteDied(const std::vector> &abilityTokens) +ErrCode AppScheduler::OnAppRemoteDied(const std::vector> &abilityTokens) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->OnAppRemoteDied(abilityTokens); + return ERR_OK; } -void AppScheduler::OnStartProcessFailed(sptr token) +ErrCode AppScheduler::OnStartProcessFailed(const sptr &token) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->OnStartProcessFailed(token); + return ERR_OK; } -void AppScheduler::OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo, +ErrCode AppScheduler::OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo, const std::string &bundleName, const std::vector &abilityNames, const std::vector &uiExtensionNames) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->OnCacheExitInfo(accessTokenId, exitInfo, bundleName, abilityNames, uiExtensionNames); + return ERR_OK; } -void AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) +ErrCode AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) { auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); callback->NotifyAppPreCache(pid, userId); + return ERR_OK; } int AppScheduler::KillApplication(const std::string &bundleName, bool clearPageStack, int32_t appIndex) @@ -326,11 +334,11 @@ void AppScheduler::PrepareTerminate(const sptr &token, bool clear IN_PROCESS_CALL_WITHOUT_RET(appMgrClient_->PrepareTerminate(token, clearMissionFlag)); } -void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData &appData) +ErrCode AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData &appData) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto callback = callback_.lock(); - CHECK_POINTER(callback); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); AppInfo info; for (const auto &list : appData.appDatas) { AppData data; @@ -345,6 +353,7 @@ void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData &appData) info.instanceKey = appData.instanceKey; info.bundleName = appData.bundleName; callback->OnAppStateChanged(info); + return ERR_OK; } void AppScheduler::GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info) @@ -386,10 +395,11 @@ void AppScheduler::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecF IN_PROCESS_CALL_WITHOUT_RET(appMgrClient_->StartSpecifiedAbility(want, abilityInfo, requestId)); } -void StartSpecifiedAbilityResponse::OnAcceptWantResponse( +ErrCode StartSpecifiedAbilityResponse::OnAcceptWantResponse( const AAFwk::Want &want, const std::string &flag, int32_t requestId) { DelayedSingleton::GetInstance()->OnAcceptWantResponse(want, flag, requestId); + return ERR_OK; } void AppScheduler::PrepareTerminateApp(const pid_t pid, const std::string &moduleName) @@ -398,9 +408,10 @@ void AppScheduler::PrepareTerminateApp(const pid_t pid, const std::string &modul IN_PROCESS_CALL_WITHOUT_RET(appMgrClient_->PrepareTerminateApp(pid, moduleName)); } -void StartSpecifiedAbilityResponse::OnTimeoutResponse(int32_t requestId) +ErrCode StartSpecifiedAbilityResponse::OnTimeoutResponse(int32_t requestId) { DelayedSingleton::GetInstance()->OnStartSpecifiedAbilityTimeoutResponse(requestId); + return ERR_OK; } void AppScheduler::StartSpecifiedProcess( @@ -410,19 +421,22 @@ void AppScheduler::StartSpecifiedProcess( IN_PROCESS_CALL_WITHOUT_RET(appMgrClient_->StartSpecifiedProcess(want, abilityInfo, requestId)); } -void StartSpecifiedAbilityResponse::OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) +ErrCode StartSpecifiedAbilityResponse::OnNewProcessRequestResponse(const std::string &flag, int32_t requestId) { DelayedSingleton::GetInstance()->OnStartSpecifiedProcessResponse(flag, requestId); + return ERR_OK; } -void StartSpecifiedAbilityResponse::OnNewProcessRequestTimeoutResponse(int32_t requestId) +ErrCode StartSpecifiedAbilityResponse::OnNewProcessRequestTimeoutResponse(int32_t requestId) { DelayedSingleton::GetInstance()->OnStartSpecifiedProcessTimeoutResponse(requestId); + return ERR_OK; } -void StartSpecifiedAbilityResponse::OnStartSpecifiedFailed(int32_t requestId) +ErrCode StartSpecifiedAbilityResponse::OnStartSpecifiedFailed(int32_t requestId) { DelayedSingleton::GetInstance()->OnStartSpecifiedFailed(requestId); + return ERR_OK; } int AppScheduler::GetProcessRunningInfos(std::vector &info) diff --git a/services/abilitymgr/src/user_callback_proxy.cpp b/services/abilitymgr/src/user_callback_proxy.cpp deleted file mode 100644 index a94521710d7886f3a2db28e4e9966335044b8fee..0000000000000000000000000000000000000000 --- a/services/abilitymgr/src/user_callback_proxy.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2021-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 "user_callback_proxy.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AAFwk { -void UserCallbackProxy::OnStopUserDone(int userId, int errcode) -{ - SendRequestCommon(userId, errcode, IUserCallback::UserCallbackCmd::ON_STOP_USER_DONE); -} - -void UserCallbackProxy::OnStartUserDone(int userId, int errcode) -{ - SendRequestCommon(userId, errcode, IUserCallback::UserCallbackCmd::ON_START_USER_DONE); -} - -void UserCallbackProxy::OnLogoutUserDone(int userId, int errcode) -{ - SendRequestCommon(userId, errcode, IUserCallback::UserCallbackCmd::ON_LOGOUT_USER_DONE); -} - -void UserCallbackProxy::SendRequestCommon(int userId, int errcode, IUserCallback::UserCallbackCmd cmd) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - - TAG_LOGI(AAFwkTag::ABILITYMGR, - "UserCallbackProxy, sendrequest, cmd:%{public}d, userId:%{public}d, errcode:%{public}d", cmd, userId, errcode); - if (!data.WriteInterfaceToken(IUserCallback::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return; - } - - if (!data.WriteInt32(userId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write userId error"); - return; - } - - if (!data.WriteInt32(errcode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write errcode error"); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote object"); - return; - } - - int error = remote->SendRequest(cmd, data, reply, option); - if (error != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error); - return; - } -} -} // namespace AAFwk -} // namespace OHOS diff --git a/services/abilitymgr/src/user_callback_stub.cpp b/services/abilitymgr/src/user_callback_stub.cpp deleted file mode 100644 index fe078586ffd957f68134f805f47a643769dd7f93..0000000000000000000000000000000000000000 --- a/services/abilitymgr/src/user_callback_stub.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021-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 "user_callback_stub.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AAFwk { -UserCallbackStub::UserCallbackStub() {} - -int UserCallbackStub::OnStopUserDoneInner(MessageParcel &data, MessageParcel &reply) -{ - auto accountId = data.ReadInt32(); - auto errCode = data.ReadInt32(); - OnStopUserDone(accountId, errCode); - return NO_ERROR; -} - -int UserCallbackStub::OnStartUserDoneInner(MessageParcel &data, MessageParcel &reply) -{ - auto accountId = data.ReadInt32(); - auto errCode = data.ReadInt32(); - OnStartUserDone(accountId, errCode); - return NO_ERROR; -} - -int UserCallbackStub::OnLogoutUserDoneInner(MessageParcel &data, MessageParcel &reply) -{ - auto accountId = data.ReadInt32(); - auto errCode = data.ReadInt32(); - OnLogoutUserDone(accountId, errCode); - return NO_ERROR; -} - -int UserCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string descriptor = UserCallbackStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "local descriptor invalid"); - return ERR_INVALID_STATE; - } - - if (code < UserCallbackCmd::CMD_MAX && code >= 0) { - switch (code) { - case UserCallbackCmd::ON_STOP_USER_DONE: - return OnStopUserDoneInner(data, reply); - break; - case UserCallbackCmd::ON_START_USER_DONE: - return OnStartUserDoneInner(data, reply); - break; - case UserCallbackCmd::ON_LOGOUT_USER_DONE: - return OnLogoutUserDoneInner(data, reply); - break; - } - } - - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} -} // namespace AAFwk -} // namespace OHOS diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index 69af744e93aa70926dfb03e69bfec5cd5d5aa538..daf4ab40dbb73234fd2915c14f7ca43858ecb8eb 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -19,7 +19,7 @@ #include "ability_info.h" #include "ability_running_record.h" #include "ams_mgr_stub.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "app_mgr_constants.h" #include "app_mgr_service_inner.h" #include "app_record_id.h" @@ -50,9 +50,9 @@ public: * @param appInfo, the app information. * @param want, the starting information. */ - virtual void LoadAbility(const std::shared_ptr &abilityInfo, + virtual ErrCode LoadAbility(const std::shared_ptr &abilityInfo, const std::shared_ptr &appInfo, - const std::shared_ptr &want, std::shared_ptr loadParam) override; + const std::shared_ptr &want, const std::shared_ptr& loadParam) override; /** * TerminateAbility, call TerminateAbility() through the proxy object, terminate the token ability. @@ -61,7 +61,7 @@ public: * @param clearMissionFlag, indicates whether terminate the ability when clearMission. * @return */ - virtual void TerminateAbility(const sptr &token, bool clearMissionFlag) override; + virtual ErrCode TerminateAbility(const sptr &token, bool clearMissionFlag) override; /** * UpdateAbilityState, call UpdateAbilityState() through the proxy object, update the ability status. @@ -70,7 +70,7 @@ public: * @param state, ability status that needs to be updated. * @return */ - virtual void UpdateAbilityState(const sptr &token, const AbilityState state) override; + virtual ErrCode UpdateAbilityState(const sptr &token, int32_t state) override; /** * UpdateExtensionState, call UpdateExtensionState() through the proxy object, update the extension status. @@ -79,7 +79,7 @@ public: * @param state, extension status that needs to be updated. * @return */ - virtual void UpdateExtensionState(const sptr &token, const ExtensionState state) override; + virtual ErrCode UpdateExtensionState(const sptr &token, ExtensionState state) override; /** * RegisterAppStateCallback, call RegisterAppStateCallback() through the proxy object, register the callback. @@ -87,7 +87,7 @@ public: * @param callback, Ams register the callback. * @return */ - virtual void RegisterAppStateCallback(const sptr &callback) override; + virtual ErrCode RegisterAppStateCallback(const sptr &callback) override; /** * KillProcessByAbilityToken, call KillProcessByAbilityToken() through proxy object, @@ -96,7 +96,7 @@ public: * @param token, the unique identification to the ability. * @return */ - virtual void KillProcessByAbilityToken(const sptr &token) override; + virtual ErrCode KillProcessByAbilityToken(const sptr &token) override; /** * KillProcessesByUserId, call KillProcessesByUserId() through proxy object, @@ -107,8 +107,8 @@ public: * @param isNeedSendAppSpawnMsg, true send appSpawn message otherwise not send. * @return */ - virtual void KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg = false, - sptr callback = nullptr) override; + virtual ErrCode KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg, + const sptr& callback) override; /** * KillProcessesByPids, only in process call is allowed, @@ -119,15 +119,16 @@ public: * @param subProcess, kill SubProcess or not. * @return ERR_OK, return back success, others fail. */ - virtual int32_t KillProcessesByPids(const std::vector &pids, - const std::string &reason = "KillProcessesByPids", bool subProcess = false) override; + virtual ErrCode KillProcessesByPids(const std::vector &pids, + const std::string &reason, bool subProcess) override; /** * Set child and parent relationship * @param token child process * @param callerToken parent process */ - virtual void AttachPidToParent(const sptr &token, const sptr &callerToken) override; + virtual ErrCode AttachPidToParent(const sptr &token, + const sptr &callerToken) override; /** * KillProcessWithAccount, call KillProcessWithAccount() through proxy object, kill the @@ -137,8 +138,8 @@ public: * @param accountId, account ID. * @return ERR_OK, return back success, others fail. */ - virtual int32_t KillProcessWithAccount(const std::string &bundleName, const int accountId, - const bool clearPageStack = false, int32_t appIndex = 0) override; + virtual ErrCode KillProcessWithAccount(const std::string &bundleName, int32_t accountId, + bool clearPageStack, int32_t appIndex) override; /** * KillProcessesInBatch, kill processes in batch, call KillProcessesInBatch() through proxy object; @@ -147,7 +148,7 @@ public: * @param pids, the pid list of processes are going to be killed. * @return ERR_OK, return back success, others fail. */ - virtual int32_t KillProcessesInBatch(const std::vector &pids) override; + virtual ErrCode KillProcessesInBatch(const std::vector &pids) override; /** * UpdateApplicationInfoInstalled, call UpdateApplicationInfoInstalled() through proxy object, @@ -157,7 +158,7 @@ public: * @param uid, uid. * @return ERR_OK, return back success, others fail. */ - virtual int32_t UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid, + virtual ErrCode UpdateApplicationInfoInstalled(const std::string &bundleName, int32_t uid, const std::string &moduleName, bool isPlugin) override; /** @@ -166,7 +167,7 @@ public: * @param bundleName, bundle name in Application record. * @return ERR_OK, return back success, others fail. */ - virtual int32_t KillApplication(const std::string &bundleName, bool clearPageStack = false, + virtual ErrCode KillApplication(const std::string &bundleName, bool clearPageStack = false, int32_t appIndex = 0) override; /** @@ -177,8 +178,8 @@ public: * @param appIndex, appIndex. * @return ERR_OK, return back success, others fail. */ - virtual int32_t ForceKillApplication(const std::string &bundleName, const int userId = -1, - const int appIndex = 0) override; + virtual ErrCode ForceKillApplication(const std::string &bundleName, int32_t userId, + int32_t appIndex) override; /** * KillProcessesByAccessTokenId. @@ -186,7 +187,7 @@ public: * @param accessTokenId, accessTokenId. * @return ERR_OK, return back success, others fail. */ - virtual int32_t KillProcessesByAccessTokenId(const uint32_t accessTokenId) override; + virtual ErrCode KillProcessesByAccessTokenId(uint32_t accessTokenId) override; /** * KillApplicationByUid, call KillApplicationByUid() through proxy object, kill the application. @@ -196,8 +197,8 @@ public: * @param reason, caller function name. * @return ERR_OK, return back success, others fail. */ - virtual int KillApplicationByUid(const std::string &bundleName, const int uid, - const std::string& reason = "KillApplicationByUid") override; + virtual ErrCode KillApplicationByUid(const std::string &bundleName, int32_t uid, + const std::string& reason) override; /** * KillApplicationSelf, this allows app to terminate itself. @@ -205,8 +206,8 @@ public: * @param clearPageStack, the flag indicates if ClearPageStack lifecycle should be scheduled. * @return ERR_OK for success call, others for failure. */ - virtual int KillApplicationSelf(const bool clearPageStack = false, - const std::string& reason = "KillApplicationSelf") override; + virtual ErrCode KillApplicationSelf(bool clearPageStack, + const std::string& reason) override; /** * Get application info by process id. @@ -216,7 +217,7 @@ public: * @param debug Whether IsDebugApp. * @return Returns ERR_OK on success, others on failure. */ - int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) override; + ErrCode GetApplicationInfoByProcessID(int32_t pid, AppExecFwk::ApplicationInfo &application, bool &debug) override; /** * Record process exit reason to appRunningRecord @@ -225,14 +226,14 @@ public: * @param exitMsg exitMsg * @return Returns ERR_OK on success, others on failure. */ - virtual int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) override; + virtual ErrCode NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) override; /** * AbilityAttachTimeOut, called by ability manager service when an ability is loaded timeout. * * @param token indicates the token of the ability which is timeout. */ - virtual void AbilityAttachTimeOut(const sptr &token) override; + virtual ErrCode AbilityAttachTimeOut(const sptr &token) override; /** * PrepareTerminate, called before terminating one ability by ability manager service to notify application. @@ -240,7 +241,7 @@ public: * @param token indicates the token of the ability to be terminated. * @param clearMissionFlag indicates whether it is caused by cleaning mission. */ - virtual void PrepareTerminate(const sptr &token, bool clearMissionFlag = false) override; + virtual ErrCode PrepareTerminate(const sptr &token, bool clearMissionFlag) override; /** * GetRunningProcessInfoByToken, get process info for one ability. @@ -248,7 +249,7 @@ public: * @param token indicates the token of the ability requested. * @param info output of the information. */ - virtual void GetRunningProcessInfoByToken( + virtual ErrCode GetRunningProcessInfoByToken( const sptr &token, AppExecFwk::RunningProcessInfo &info) override; /** @@ -257,7 +258,7 @@ public: * @param pid, pid. * */ - void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) override; + ErrCode SetAbilityForegroundingFlagToAppRecord(int32_t pid) override; /** * Start specified ability. @@ -266,17 +267,18 @@ public: * @param abilityInfo Ability information. * @param requestId request id to callback */ - virtual void StartSpecifiedAbility( - const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; + virtual ErrCode StartSpecifiedAbility( + const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId) override; /** * Register response of start specified ability. * * @param response Response of start specified ability. */ - virtual void RegisterStartSpecifiedAbilityResponse(const sptr &response) override; + virtual ErrCode RegisterStartSpecifiedAbilityResponse( + const sptr &response) override; - virtual void PrepareTerminateApp(const pid_t pid, const std::string &moduleName) override; + virtual ErrCode PrepareTerminateApp(int32_t pid, const std::string &moduleName) override; /** * Start specified process. @@ -285,7 +287,7 @@ public: * @param abilityInfo Ability information. * @param requestId for callback */ - virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, + virtual ErrCode StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; /** @@ -293,9 +295,9 @@ public: * * @param userId the new user. */ - virtual void SetCurrentUserId(const int32_t userId) override; + virtual ErrCode SetCurrentUserId(int32_t userId) override; - virtual void SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) override; + virtual ErrCode SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) override; /** * GetBundleNameByPid, get bundleName and uid of a process. @@ -305,35 +307,35 @@ public: * @param uid output for uid. * @return ERR_OK for success call, others for failure. */ - virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) override; + virtual ErrCode GetBundleNameByPid(int32_t pid, std::string &bundleName, int32_t &uid) override; /** * @brief Register app debug listener. * @param listener App debug listener. * @return ERR_OK, return back success, others fail. */ - int32_t RegisterAppDebugListener(const sptr &listener) override; + ErrCode RegisterAppDebugListener(const sptr &listener) override; /** * @brief Unregister app debug listener. * @param listener App debug listener. * @return ERR_OK, return back success, others fail. */ - int32_t UnregisterAppDebugListener(const sptr &listener) override; + ErrCode UnregisterAppDebugListener(const sptr &listener) override; /** * @brief Attach app debug. * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; + ErrCode AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Detach app debug. * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t DetachAppDebug(const std::string &bundleName) override; + ErrCode DetachAppDebug(const std::string &bundleName) override; /** * @brief Set app waiting debug mode. @@ -341,45 +343,45 @@ public: * @param isPersist The persist flag. * @return Returns ERR_OK on success, others on failure. */ - int32_t SetAppWaitingDebug(const std::string &bundleName, bool isPersist) override; + ErrCode SetAppWaitingDebug(const std::string &bundleName, bool isPersist) override; /** * @brief Cancel app waiting debug mode. * @return Returns ERR_OK on success, others on failure. */ - int32_t CancelAppWaitingDebug() override; + ErrCode CancelAppWaitingDebug() override; /** * @brief Get waiting debug mode application. * @param debugInfoList The debug info list, including bundle name and persist flag. * @return Returns ERR_OK on success, others on failure. */ - int32_t GetWaitingDebugApp(std::vector &debugInfoList) override; + ErrCode GetWaitingDebugApp(std::vector &debugInfoList) override; /** * @brief Determine whether it is a waiting debug application based on the bundle name. * @return Returns true if it is a waiting debug application, otherwise it returns false. */ - bool IsWaitingDebugApp(const std::string &bundleName) override; + ErrCode IsWaitingDebugApp(const std::string &bundleName, bool& funcResult) override; /** * @brief Clear non persist waiting debug flag. */ - void ClearNonPersistWaitingDebugFlag() override; + ErrCode ClearNonPersistWaitingDebugFlag() override; /** * @brief Registering ability debug mode response. * @param response Response for ability debug object. * @return Returns ERR_OK on success, others on failure. */ - int32_t RegisterAbilityDebugResponse(const sptr &response) override; + ErrCode RegisterAbilityDebugResponse(const sptr &response) override; /** * @brief Determine whether it is an attachment debug application based on the bundle name. * @param bundleName The application bundle name. * @return Returns true if it is an attach debug application, otherwise it returns false. */ - bool IsAttachDebug(const std::string &bundleName) override; + ErrCode IsAttachDebug(const std::string &bundleName, bool& funcResult) override; /** * @brief Set resident process enable status. @@ -387,7 +389,7 @@ public: * @param enable The current updated enable status. * @param uid indicates user, 0 for all users */ - void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) override; + ErrCode SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) override; /** * @brief Set non-resident keep-alive process status. @@ -395,35 +397,35 @@ public: * @param enable The current updated enable status. * @param uid indicates user, 0 for all users */ - void SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) override; + ErrCode SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) override; /** * To clear the process by ability token. * * @param token the unique identification to the ability. */ - virtual void ClearProcessByToken(sptr token) override; + virtual ErrCode ClearProcessByToken(const sptr& token) override; /** * whether memory size is sufficient. * @return Returns true is sufficient memory size, others return false. */ - virtual bool IsMemorySizeSufficent() override; + virtual ErrCode IsMemorySizeSufficent(bool& funcResult) override; /** * whether or not requier a big memory * @return Returens true is no big memory, others return false. */ - virtual bool IsNoRequireBigMemory() override; + virtual ErrCode IsNoRequireBigMemory(bool& funcResult) override; /** * Notifies that one ability is attached to status bar. * * @param token the token of the abilityRecord that is attached to status bar. */ - void AttachedToStatusBar(const sptr &token) override; + ErrCode AttachedToStatusBar(const sptr &token) override; - virtual void BlockProcessCacheByPids(const std::vector &pids) override; + virtual ErrCode BlockProcessCacheByPids(const std::vector &pids) override; /** * whether killed for upgrade web. @@ -431,7 +433,7 @@ public: * @param bundleName the bundle name is killed for upgrade web. * @return Returns true is killed for upgrade web, others return false. */ - virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override; + virtual ErrCode IsKilledForUpgradeWeb(const std::string &bundleName, bool& funcResult) override; /** * Request to clean uiability from user. @@ -439,20 +441,20 @@ public: * @param token the token of ability. * @return Returns true if clean success, others return false. */ - virtual bool CleanAbilityByUserRequest(const sptr &token) override; + virtual ErrCode CleanAbilityByUserRequest(const sptr &token, bool& funcResult) override; /** * whether the abilities of process specified by pid type only UIAbility. * @return Returns true is only UIAbility, otherwise return false */ - virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override; + virtual ErrCode IsProcessContainsOnlyUIAbility(int32_t pid, bool& funcResult) override; /** * Whether a process is attached, refer to AttachApplication */ - virtual bool IsProcessAttached(sptr token) override; + virtual ErrCode IsProcessAttached(const sptr& token, bool& funcResult) override; - virtual bool IsCallerKilling(const std::string& callerKey) override; + virtual ErrCode IsCallerKilling(const std::string& callerKey, bool& funcResult) override; private: /** diff --git a/services/appmgr/include/app_debug_manager.h b/services/appmgr/include/app_debug_manager.h index 8da182c9428beb521781100b6930ca21e0aba8b9..d5203399e1030115746592b250ff8ee7628bd839 100644 --- a/services/appmgr/include/app_debug_manager.h +++ b/services/appmgr/include/app_debug_manager.h @@ -19,7 +19,7 @@ #include #include -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" namespace OHOS { namespace AppExecFwk { diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index a9ff630606a81324501b5e9523350ead8b12e9eb..59ccbd0a23a360d48aa0329d1cff3859ac335747 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -24,12 +24,12 @@ #include #include -#include "ability_debug_response_interface.h" +#include "iability_debug_response.h" #include "ability_foreground_state_observer_interface.h" #include "ability_info.h" #include "advanced_security_mode_manager.h" #include "app_death_recipient.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "app_debug_manager.h" #include "app_foreground_state_observer_interface.h" #include "app_malloc_info.h" @@ -80,7 +80,7 @@ #include "app_jsheap_mem_info.h" #include "running_multi_info.h" #include "multi_user_config_mgr.h" -#include "user_callback.h" +#include "iuser_callback.h" #include "native_child_notify_interface.h" namespace OHOS { diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 1915dd386602ef8dc104dc246e733a4aef1e4a7e..9a68dab24399d1b539a35359bd587db95820fa17 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -22,7 +22,7 @@ #include #include "ability_info.h" -#include "app_debug_listener_interface.h" +#include "iapp_debug_listener.h" #include "app_jsheap_mem_info.h" #include "app_malloc_info.h" #include "app_mem_info.h" @@ -397,7 +397,7 @@ public: int32_t RemoveUIExtensionBindItemById(int32_t uiExtensionBindAbilityId); std::shared_ptr GetAppRunningRecordByChildRecordPid(const pid_t pid); - + int32_t AssignRunningProcessInfoByAppRecord( std::shared_ptr appRecord, AppExecFwk::RunningProcessInfo &info) const; private: diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 3b45b531cc6e564068a8b631fe65ab0ee05ec7d0..0f9be40105695e2adc76683f5b608fa308da2269 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -65,22 +65,22 @@ AmsMgrScheduler::~AmsMgrScheduler() TAG_LOGI(AAFwkTag::APPMGR, "call"); } -void AmsMgrScheduler::LoadAbility(const std::shared_ptr &abilityInfo, +ErrCode AmsMgrScheduler::LoadAbility(const std::shared_ptr &abilityInfo, const std::shared_ptr &appInfo, - const std::shared_ptr &want, std::shared_ptr loadParam) + const std::shared_ptr &want, const std::shared_ptr& loadParam) { if (!abilityInfo || !appInfo) { TAG_LOGE(AAFwkTag::APPMGR, "param error"); - return; + return ERR_INVALID_VALUE; } if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } PerfProfile::GetInstance().SetAbilityLoadStartTime(GetTickCount()); TAG_LOGI(AAFwkTag::APPMGR, "SubmitLoadTask: %{public}s-%{public}s", abilityInfo->bundleName.c_str(), @@ -93,7 +93,7 @@ void AmsMgrScheduler::LoadAbility(const std::shared_ptr &abilityInf // cache other application load ability task before scene board attach if (!amsMgrServiceInner_->GetSceneBoardAttachFlag() && abilityInfo->bundleName != SCENE_BOARD_BUNDLE_NAME) { amsMgrServiceInner_->CacheLoadAbilityTask(std::move(loadAbilityFunc)); - return; + return ERR_INVALID_VALUE; } if (abilityInfo->bundleName == SCENE_BOARD_BUNDLE_NAME && abilityInfo->name == SCENEBOARD_ABILITY_NAME) { amsMgrServiceInner_->SetSceneBoardAttachFlag(false); @@ -122,36 +122,38 @@ void AmsMgrScheduler::LoadAbility(const std::shared_ptr &abilityInf } amsHandler_->SubmitTask(loadAbilityFunc, taskAttr); + return ERR_OK; } -void AmsMgrScheduler::UpdateAbilityState(const sptr &token, const AbilityState state) +ErrCode AmsMgrScheduler::UpdateAbilityState(const sptr &token, int32_t state) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } std::function updateAbilityStateFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, state] () { - amsMgrServiceInner->UpdateAbilityState(token, state); + amsMgrServiceInner->UpdateAbilityState(token, static_cast(state)); }; amsHandler_->SubmitTask(updateAbilityStateFunc, AAFwk::TaskAttribute{ .taskName_ = TASK_UPDATE_ABILITY_STATE, .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE }); + return ERR_OK; } -void AmsMgrScheduler::UpdateExtensionState(const sptr &token, const ExtensionState state) +ErrCode AmsMgrScheduler::UpdateExtensionState(const sptr &token, ExtensionState state) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } std::function updateExtensionStateFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, state]() { amsMgrServiceInner->UpdateExtensionState(token, state); @@ -160,17 +162,18 @@ void AmsMgrScheduler::UpdateExtensionState(const sptr &token, con .taskName_ = TASK_UPDATE_EXTENSION_STATE, .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE }); + return ERR_OK; } -void AmsMgrScheduler::TerminateAbility(const sptr &token, bool clearMissionFlag) +ErrCode AmsMgrScheduler::TerminateAbility(const sptr &token, bool clearMissionFlag) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } std::function terminateAbilityFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, clearMissionFlag]() { amsMgrServiceInner->TerminateAbility(token, clearMissionFlag); @@ -179,50 +182,53 @@ void AmsMgrScheduler::TerminateAbility(const sptr &token, bool cl .taskName_ = TASK_TERMINATE_ABILITY, .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE }); + return ERR_OK; } -void AmsMgrScheduler::RegisterAppStateCallback(const sptr &callback) +ErrCode AmsMgrScheduler::RegisterAppStateCallback(const sptr &callback) { if (!AAFwk::PermissionVerification::GetInstance()->IsSACall()) { TAG_LOGE(AAFwkTag::APPMGR, "caller is not SA"); - return; + return ERR_PERMISSION_DENIED; } if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } std::function registerAppStateCallbackFunc = [amsMgrServiceInner = amsMgrServiceInner_, callback]() { amsMgrServiceInner->RegisterAppStateCallback(callback); }; amsHandler_->SubmitTask(registerAppStateCallbackFunc, TASK_REGISTER_APP_STATE_CALLBACK); + return ERR_OK; } -void AmsMgrScheduler::KillProcessByAbilityToken(const sptr &token) +ErrCode AmsMgrScheduler::KillProcessByAbilityToken(const sptr &token) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyKillProcessPermission(token) != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } std::function killProcessByAbilityTokenFunc = [amsMgrServiceInner = amsMgrServiceInner_, token]() { amsMgrServiceInner->KillProcessByAbilityToken(token); }; amsHandler_->SubmitTask(killProcessByAbilityTokenFunc, TASK_KILL_PROCESS_BY_ABILITY_TOKEN); + return ERR_OK; } -void AmsMgrScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg, - sptr callback) +ErrCode AmsMgrScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSpawnMsg, + const sptr& callback) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (!AAFwk::PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { TAG_LOGE(AAFwkTag::APPMGR, "caller is not SA"); - return; + return ERR_PERMISSION_DENIED; } bool isCallingFromFoundation = @@ -231,7 +237,7 @@ void AmsMgrScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSp if (!isCallingFromFoundation && amsMgrServiceInner_->VerifyAccountPermission(permission, userId) == ERR_PERMISSION_DENIED) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } std::function killProcessesByUserIdFunc = [amsMgrServiceInner = amsMgrServiceInner_, userId, @@ -239,9 +245,10 @@ void AmsMgrScheduler::KillProcessesByUserId(int32_t userId, bool isNeedSendAppSp amsMgrServiceInner->KillProcessesByUserId(userId, isNeedSendAppSpawnMsg, callback); }; amsHandler_->SubmitTask(killProcessesByUserIdFunc, TASK_KILL_PROCESSES_BY_USERID); + return ERR_OK; } -int32_t AmsMgrScheduler::KillProcessesByPids(const std::vector &pids, const std::string &reason, +ErrCode AmsMgrScheduler::KillProcessesByPids(const std::vector &pids, const std::string &reason, bool subProcess) { if (!IsReady()) { @@ -258,27 +265,28 @@ int32_t AmsMgrScheduler::KillProcessesByPids(const std::vector &pids, c return amsMgrServiceInner_->KillProcessesByPids(pids, reason, subProcess); } -void AmsMgrScheduler::AttachPidToParent(const sptr &token, const sptr &callerToken) +ErrCode AmsMgrScheduler::AttachPidToParent(const sptr &token, const sptr &callerToken) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t pid = getprocpid(); if (callingPid != pid) { TAG_LOGE(AAFwkTag::APPMGR, "not allow other process to call"); - return; + return ERR_PERMISSION_DENIED; } std::function attachPidToParentFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, callerToken]() { amsMgrServiceInner->AttachPidToParent(token, callerToken); }; amsHandler_->SubmitTask(attachPidToParentFunc, TASK_ATTACH_PID_TO_PARENT); + return ERR_OK; } -int32_t AmsMgrScheduler::KillProcessWithAccount( - const std::string &bundleName, const int accountId, const bool clearPageStack, int32_t appIndex) +ErrCode AmsMgrScheduler::KillProcessWithAccount( + const std::string &bundleName, int32_t accountId, bool clearPageStack, int32_t appIndex) { TAG_LOGI(AAFwkTag::APPMGR, "bundle=%{public}s, appIndex=%{public}d, userId=%{public}d, clearPageStack=%{public}d", bundleName.c_str(), appIndex, accountId, clearPageStack); @@ -289,7 +297,7 @@ int32_t AmsMgrScheduler::KillProcessWithAccount( "KillProcessWithAccount"); } -int32_t AmsMgrScheduler::KillProcessesInBatch(const std::vector &pids) +ErrCode AmsMgrScheduler::KillProcessesInBatch(const std::vector &pids) { TAG_LOGI(AAFwkTag::APPMGR, "pids.size=%{public}zu", pids.size()); if (!IsReady()) { @@ -298,42 +306,44 @@ int32_t AmsMgrScheduler::KillProcessesInBatch(const std::vector &pids) return amsMgrServiceInner_->KillProcessesInBatch(pids); } -void AmsMgrScheduler::AbilityAttachTimeOut(const sptr &token) +ErrCode AmsMgrScheduler::AbilityAttachTimeOut(const sptr &token) { TAG_LOGI(AAFwkTag::APPMGR, "call"); if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } auto task = [amsMgrServiceInner = amsMgrServiceInner_, token]() { amsMgrServiceInner->HandleAbilityAttachTimeOut(token); }; amsHandler_->SubmitTask(task, "AbilityAttachTimeOut"); + return ERR_OK; } -void AmsMgrScheduler::PrepareTerminate(const sptr &token, bool clearMissionFlag) +ErrCode AmsMgrScheduler::PrepareTerminate(const sptr &token, bool clearMissionFlag) { TAG_LOGD(AAFwkTag::APPMGR, "Notify AppMgrService to prepare to terminate the ability."); if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } auto task = [=]() { amsMgrServiceInner_->PrepareTerminate(token, clearMissionFlag); }; amsHandler_->SubmitTask(task, { .taskName_ = "PrepareTerminate", .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE }); + return ERR_OK; } -int32_t AmsMgrScheduler::UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid, +ErrCode AmsMgrScheduler::UpdateApplicationInfoInstalled(const std::string &bundleName, int32_t uid, const std::string &moduleName, bool isPlugin) { if (!IsReady()) { @@ -354,8 +364,8 @@ int32_t AmsMgrScheduler::KillApplication(const std::string &bundleName, bool cle return amsMgrServiceInner_->KillApplication(bundleName, clearPageStack, appIndex); } -int32_t AmsMgrScheduler::ForceKillApplication(const std::string &bundleName, - const int userId, const int appIndex) +ErrCode AmsMgrScheduler::ForceKillApplication(const std::string &bundleName, + int32_t userId, int32_t appIndex) { TAG_LOGI(AAFwkTag::APPMGR, "bundleName=%{public}s,userId=%{public}d,apIndex=%{public}d", bundleName.c_str(), userId, appIndex); @@ -366,7 +376,7 @@ int32_t AmsMgrScheduler::ForceKillApplication(const std::string &bundleName, return amsMgrServiceInner_->ForceKillApplication(bundleName, userId, appIndex); } -int32_t AmsMgrScheduler::KillProcessesByAccessTokenId(const uint32_t accessTokenId) +ErrCode AmsMgrScheduler::KillProcessesByAccessTokenId(const uint32_t accessTokenId) { TAG_LOGI(AAFwkTag::APPMGR, "accessTokenId=%{public}d", accessTokenId); if (!IsReady()) { @@ -376,7 +386,7 @@ int32_t AmsMgrScheduler::KillProcessesByAccessTokenId(const uint32_t accessToken return amsMgrServiceInner_->KillProcessesByAccessTokenId(accessTokenId); } -int32_t AmsMgrScheduler::KillApplicationByUid(const std::string &bundleName, const int uid, +ErrCode AmsMgrScheduler::KillApplicationByUid(const std::string &bundleName, const int uid, const std::string& reason) { TAG_LOGI(AAFwkTag::APPMGR, "bundleName = %{public}s, uid = %{public}d", bundleName.c_str(), uid); @@ -386,7 +396,7 @@ int32_t AmsMgrScheduler::KillApplicationByUid(const std::string &bundleName, con return amsMgrServiceInner_->KillApplicationByUid(bundleName, uid, reason); } -int32_t AmsMgrScheduler::KillApplicationSelf(const bool clearPageStack, const std::string& reason) +ErrCode AmsMgrScheduler::KillApplicationSelf(const bool clearPageStack, const std::string& reason) { if (!IsReady()) { return ERR_INVALID_OPERATION; @@ -407,85 +417,92 @@ bool AmsMgrScheduler::IsReady() const return true; } -void AmsMgrScheduler::GetRunningProcessInfoByToken( +ErrCode AmsMgrScheduler::GetRunningProcessInfoByToken( const sptr &token, AppExecFwk::RunningProcessInfo &info) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->GetRunningProcessInfoByToken(token, info); + return ERR_OK; } -void AmsMgrScheduler::SetAbilityForegroundingFlagToAppRecord(const pid_t pid) +ErrCode AmsMgrScheduler::SetAbilityForegroundingFlagToAppRecord(int32_t pid) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->SetAbilityForegroundingFlagToAppRecord(pid); + return ERR_OK; } -void AmsMgrScheduler::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, +ErrCode AmsMgrScheduler::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } auto task = [=]() { amsMgrServiceInner_->StartSpecifiedAbility(want, abilityInfo, requestId); }; amsHandler_->SubmitTask(task, { .taskName_ = "StartSpecifiedAbility", .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE }); + return ERR_OK; } -void AmsMgrScheduler::PrepareTerminateApp(const pid_t pid, const std::string &moduleName) +ErrCode AmsMgrScheduler::PrepareTerminateApp(int32_t pid, const std::string &moduleName) { TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!IsReady()) { TAG_LOGW(AAFwkTag::APPMGR, "not ready"); - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->SchedulePrepareTerminate(pid, moduleName); + return ERR_OK; } -void AmsMgrScheduler::StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, +ErrCode AmsMgrScheduler::StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId) { if (!IsReady()) { TAG_LOGW(AAFwkTag::APPMGR, "not ready"); - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } auto task = [=]() { amsMgrServiceInner_->StartSpecifiedProcess(want, abilityInfo, requestId); }; amsHandler_->SubmitTask(task, { .taskName_ = "StartSpecifiedProcess", .taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE }); + return ERR_OK; } -void AmsMgrScheduler::RegisterStartSpecifiedAbilityResponse(const sptr &response) +ErrCode AmsMgrScheduler::RegisterStartSpecifiedAbilityResponse(const sptr &response) { if (!AAFwk::PermissionVerification::GetInstance()->IsSACall()) { TAG_LOGE(AAFwkTag::APPMGR, "caller is not SA"); - return; + return ERR_PERMISSION_DENIED; } if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } auto task = [=]() { amsMgrServiceInner_->RegisterStartSpecifiedAbilityResponse(response); }; amsHandler_->SubmitTask(task, "RegisterStartSpecifiedAbilityResponse"); + return ERR_OK; } -int AmsMgrScheduler::GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) +ErrCode AmsMgrScheduler::GetApplicationInfoByProcessID(int32_t pid, AppExecFwk::ApplicationInfo &application, + bool &debug) { if (!IsReady()) { return ERR_INVALID_OPERATION; @@ -493,7 +510,7 @@ int AmsMgrScheduler::GetApplicationInfoByProcessID(const int pid, AppExecFwk::Ap return amsMgrServiceInner_->GetApplicationInfoByProcessID(pid, application, debug); } -int32_t AmsMgrScheduler::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) +ErrCode AmsMgrScheduler::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) { if (!IsReady()) { return ERR_INVALID_OPERATION; @@ -501,27 +518,29 @@ int32_t AmsMgrScheduler::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reaso return amsMgrServiceInner_->NotifyAppMgrRecordExitReason(pid, reason, exitMsg); } -void AmsMgrScheduler::SetCurrentUserId(const int32_t userId) +ErrCode AmsMgrScheduler::SetCurrentUserId(const int32_t userId) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->SetCurrentUserId(userId); + return ERR_OK; } -void AmsMgrScheduler::SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) +ErrCode AmsMgrScheduler::SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return; + return ERR_PERMISSION_DENIED; } amsMgrServiceInner_->SetEnableStartProcessFlagByUserId(userId, enableStartProcess); + return ERR_OK; } -int32_t AmsMgrScheduler::GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) +ErrCode AmsMgrScheduler::GetBundleNameByPid(int32_t pid, std::string &bundleName, int32_t &uid) { if (!IsReady()) { return ERR_INVALID_OPERATION; @@ -529,7 +548,7 @@ int32_t AmsMgrScheduler::GetBundleNameByPid(const int pid, std::string &bundleNa return amsMgrServiceInner_->GetBundleNameByPid(pid, bundleName, uid); } -int32_t AmsMgrScheduler::RegisterAppDebugListener(const sptr &listener) +ErrCode AmsMgrScheduler::RegisterAppDebugListener(const sptr &listener) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -538,7 +557,7 @@ int32_t AmsMgrScheduler::RegisterAppDebugListener(const sptr return amsMgrServiceInner_->RegisterAppDebugListener(listener); } -int32_t AmsMgrScheduler::UnregisterAppDebugListener(const sptr &listener) +ErrCode AmsMgrScheduler::UnregisterAppDebugListener(const sptr &listener) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -547,7 +566,7 @@ int32_t AmsMgrScheduler::UnregisterAppDebugListener(const sptrUnregisterAppDebugListener(listener); } -int32_t AmsMgrScheduler::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) +ErrCode AmsMgrScheduler::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -560,7 +579,7 @@ int32_t AmsMgrScheduler::AttachAppDebug(const std::string &bundleName, bool isDe return amsMgrServiceInner_->AttachAppDebug(bundleName, isDebugFromLocal); } -int32_t AmsMgrScheduler::DetachAppDebug(const std::string &bundleName) +ErrCode AmsMgrScheduler::DetachAppDebug(const std::string &bundleName) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -573,7 +592,7 @@ int32_t AmsMgrScheduler::DetachAppDebug(const std::string &bundleName) return amsMgrServiceInner_->DetachAppDebug(bundleName); } -int32_t AmsMgrScheduler::SetAppWaitingDebug(const std::string &bundleName, bool isPersist) +ErrCode AmsMgrScheduler::SetAppWaitingDebug(const std::string &bundleName, bool isPersist) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -582,7 +601,7 @@ int32_t AmsMgrScheduler::SetAppWaitingDebug(const std::string &bundleName, bool return amsMgrServiceInner_->SetAppWaitingDebug(bundleName, isPersist); } -int32_t AmsMgrScheduler::CancelAppWaitingDebug() +ErrCode AmsMgrScheduler::CancelAppWaitingDebug() { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -591,7 +610,7 @@ int32_t AmsMgrScheduler::CancelAppWaitingDebug() return amsMgrServiceInner_->CancelAppWaitingDebug(); } -int32_t AmsMgrScheduler::GetWaitingDebugApp(std::vector &debugInfoList) +ErrCode AmsMgrScheduler::GetWaitingDebugApp(std::vector &debugInfoList) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -600,25 +619,28 @@ int32_t AmsMgrScheduler::GetWaitingDebugApp(std::vector &debugInfoL return amsMgrServiceInner_->GetWaitingDebugApp(debugInfoList); } -bool AmsMgrScheduler::IsWaitingDebugApp(const std::string &bundleName) +ErrCode AmsMgrScheduler::IsWaitingDebugApp(const std::string &bundleName, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->IsWaitingDebugApp(bundleName); + funcResult = amsMgrServiceInner_->IsWaitingDebugApp(bundleName); + return ERR_OK; } -void AmsMgrScheduler::ClearNonPersistWaitingDebugFlag() +ErrCode AmsMgrScheduler::ClearNonPersistWaitingDebugFlag() { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->ClearNonPersistWaitingDebugFlag(); + return ERR_OK; } -int32_t AmsMgrScheduler::RegisterAbilityDebugResponse(const sptr &response) +ErrCode AmsMgrScheduler::RegisterAbilityDebugResponse(const sptr &response) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -627,37 +649,41 @@ int32_t AmsMgrScheduler::RegisterAbilityDebugResponse(const sptrRegisterAbilityDebugResponse(response); } -bool AmsMgrScheduler::IsAttachDebug(const std::string &bundleName) +ErrCode AmsMgrScheduler::IsAttachDebug(const std::string &bundleName, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->IsAttachDebug(bundleName); + funcResult = amsMgrServiceInner_->IsAttachDebug(bundleName); + return ERR_OK; } -void AmsMgrScheduler::SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) +ErrCode AmsMgrScheduler::SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->SetKeepAliveEnableState(bundleName, enable, uid); + return ERR_OK; } -void AmsMgrScheduler::SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) +ErrCode AmsMgrScheduler::SetKeepAliveDkv(const std::string &bundleName, bool enable, int32_t uid) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return; + return ERR_INVALID_OPERATION; } amsMgrServiceInner_->SetKeepAliveDkv(bundleName, enable, uid); + return ERR_OK; } -void AmsMgrScheduler::ClearProcessByToken(sptr token) +ErrCode AmsMgrScheduler::ClearProcessByToken(const sptr& token) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } auto callerTokenId = IPCSkeleton::GetCallingTokenID(); @@ -665,131 +691,152 @@ void AmsMgrScheduler::ClearProcessByToken(sptr token) Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(callerTokenId, nativeInfo); if (nativeInfo.processName != "foundation") { TAG_LOGE(AAFwkTag::APPMGR, "not foundation"); - return; + return ERR_INVALID_OPERATION; } std::function clearProcessByTokenFunc = [amsMgrServiceInner = amsMgrServiceInner_, token]() { amsMgrServiceInner->ClearProcessByToken(token); }; amsHandler_->SubmitTask(clearProcessByTokenFunc, TASK_CLEAR_PROCESS_BY_ABILITY_TOKEN); + return ERR_OK; } -bool AmsMgrScheduler::IsMemorySizeSufficent() +ErrCode AmsMgrScheduler::IsMemorySizeSufficent(bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return true; + funcResult = true; + return ERR_OK; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return true; + funcResult = true; + return ERR_OK; } - return amsMgrServiceInner_->IsMemorySizeSufficient(); + funcResult = amsMgrServiceInner_->IsMemorySizeSufficient(); + return ERR_OK; } -bool AmsMgrScheduler::IsNoRequireBigMemory() +ErrCode AmsMgrScheduler::IsNoRequireBigMemory(bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return true; + funcResult = true; + return ERR_OK; } if (amsMgrServiceInner_->VerifyRequestPermission() != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); - return true; + funcResult = true; + return ERR_OK; } - return amsMgrServiceInner_->IsNoRequireBigMemory(); + funcResult = amsMgrServiceInner_->IsNoRequireBigMemory(); + return ERR_OK; } -void AmsMgrScheduler::AttachedToStatusBar(const sptr &token) +ErrCode AmsMgrScheduler::AttachedToStatusBar(const sptr &token) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return; + return ERR_INVALID_OPERATION; } auto callerTokenId = IPCSkeleton::GetCallingTokenID(); Security::AccessToken::NativeTokenInfo nativeInfo; Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(callerTokenId, nativeInfo); if (nativeInfo.processName != "foundation") { TAG_LOGE(AAFwkTag::APPMGR, "not foundation"); - return; + return ERR_INVALID_OPERATION; } std::function attachedToStatusBarFunc = std::bind(&AppMgrServiceInner::AttachedToStatusBar, amsMgrServiceInner_, token); amsHandler_->SubmitTask(attachedToStatusBarFunc, TASK_ATTACHED_TO_STATUS_BAR); + return ERR_OK; } -void AmsMgrScheduler::BlockProcessCacheByPids(const std::vector &pids) +ErrCode AmsMgrScheduler::BlockProcessCacheByPids(const std::vector &pids) { if (!IsReady()) { - return; + return ERR_INVALID_OPERATION; } pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t pid = getprocpid(); if (callingPid != pid) { TAG_LOGE(AAFwkTag::APPMGR, "not allow other process to call"); - return; + return ERR_PERMISSION_DENIED; } std::function blockProcCacheFunc = [amsMgrServiceInner = amsMgrServiceInner_, pids]() mutable { amsMgrServiceInner->BlockProcessCacheByPids(pids); }; amsHandler_->SubmitTask(blockProcCacheFunc, TASK_BLOCK_PROCESS_CACHE_BY_PIDS); + return ERR_OK; } -bool AmsMgrScheduler::IsKilledForUpgradeWeb(const std::string &bundleName) +ErrCode AmsMgrScheduler::IsKilledForUpgradeWeb(const std::string &bundleName, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->IsKilledForUpgradeWeb(bundleName); + funcResult = amsMgrServiceInner_->IsKilledForUpgradeWeb(bundleName); + return ERR_OK; } -bool AmsMgrScheduler::CleanAbilityByUserRequest(const sptr &token) +ErrCode AmsMgrScheduler::CleanAbilityByUserRequest(const sptr &token, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return false; + funcResult = false; + return ERR_OK; } if (IPCSkeleton::GetCallingPid() != getprocpid()) { TAG_LOGE(AAFwkTag::APPMGR, "not allow other process to call"); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->CleanAbilityByUserRequest(token); + funcResult = amsMgrServiceInner_->CleanAbilityByUserRequest(token); + return ERR_OK; } -bool AmsMgrScheduler::IsProcessContainsOnlyUIAbility(const pid_t pid) +ErrCode AmsMgrScheduler::IsProcessContainsOnlyUIAbility(int32_t pid, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return false; + funcResult = false; + return ERR_OK; } pid_t callingPid = IPCSkeleton::GetCallingPid(); pid_t procPid = getprocpid(); if (callingPid != procPid) { TAG_LOGE(AAFwkTag::APPMGR, "not allow other process to call"); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->IsProcessContainsOnlyUIAbility(pid); + funcResult = amsMgrServiceInner_->IsProcessContainsOnlyUIAbility(pid); + return ERR_OK; } -bool AmsMgrScheduler::IsProcessAttached(sptr token) +ErrCode AmsMgrScheduler::IsProcessAttached(const sptr& token, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->IsProcessAttached(token); + funcResult = amsMgrServiceInner_->IsProcessAttached(token); + return ERR_OK; } -bool AmsMgrScheduler::IsCallerKilling(const std::string& callerKey) +ErrCode AmsMgrScheduler::IsCallerKilling(const std::string& callerKey, bool& funcResult) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready."); - return false; + funcResult = false; + return ERR_OK; } - return amsMgrServiceInner_->IsCallerKilling(callerKey); + funcResult = amsMgrServiceInner_->IsCallerKilling(callerKey); + return ERR_OK; } } // namespace AppExecFwk } // namespace OHOS diff --git a/services/uripermmgr/BUILD.gn b/services/uripermmgr/BUILD.gn index c37fedf2dcdc7ddf6a7317e68354edb5012e48f7..004bcd2373aea4c25067800c49e886ea3de7fa4d 100644 --- a/services/uripermmgr/BUILD.gn +++ b/services/uripermmgr/BUILD.gn @@ -49,6 +49,9 @@ ohos_shared_library("libupms") { "${ability_runtime_innerkits_path}/app_manager:appmgr_sdk_config", "${ability_runtime_services_path}/common:common_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", ] public_configs = [ ":upms_config" ] diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index d6ec4e440c24ab088a7c976c62ade9d8402e6b8c..8276509d17e5fc198391574e3d0b23bd53c000e2 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -45,6 +45,8 @@ ohos_static_library("tools_aa_source_set") { public_configs = [ ":ability_command_config", ":ability_command_exception_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_idl_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", "${ability_runtime_services_path}/common:common_config", ]