diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 55d58d3ea7abfb7c584459f4181dd618d19c0223..3b34d044fdac14acb2f7ec28c1efa34d8510dd42 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -11,6 +11,7 @@ # 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") @@ -40,8 +41,9 @@ 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}", ] - + configs = [ "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", ] defines = [] if (ability_command_for_test) { @@ -62,7 +64,94 @@ config("ability_manager_public_config") { } } +idl_gen_interface("ability_manager_innerkits") { + sources = [ + "idl/IAppStates.idl", + ] + sources_callback = [ + ] + sources_common =[ + ] + log_domainid = "0xD001336" + log_tag = "AbilityMgr" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +config("ability_manager_innerkits_config") { + include_dirs = [ "${target_gen_dir}" ] +} + +ohos_source_set("ability_manager_innerkits_include") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + + public_configs = [ + ":ability_manager_innerkits_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + deps = [ ":ability_manager_innerkits" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("ability_manager_innerkits_source") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + output_values = get_target_outputs(":ability_manager_innerkits") + source_values = [ "*.cpp", ] + sources = filter_include(output_values, source_values) + + public_configs = [ + ":ability_manager_innerkits_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + deps = [ ":ability_manager_innerkits" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + ] + + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("ability_manager") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } use_exceptions = true branch_protector_ret = "pac_ret" @@ -139,6 +228,8 @@ ohos_shared_library("ability_manager") { public_deps = [ ":ability_connect_callback_stub" ] deps = [ + ":ability_manager_innerkits_include", + ":ability_manager_innerkits_source", ":ability_start_options", ":ability_start_setting", ":mission_info", diff --git a/interfaces/inner_api/ability_manager/idl/IAppStates.idl b/interfaces/inner_api/ability_manager/idl/IAppStates.idl new file mode 100644 index 0000000000000000000000000000000000000000..eb4e36302a271f6a0339f10eb615ceecf0e6e0ff --- /dev/null +++ b/interfaces/inner_api/ability_manager/idl/IAppStates.idl @@ -0,0 +1,18 @@ +/* + * 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.IAppStates { + void onAbilityRequestDone(); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index c9658b81753f9371a938e6f71a55f0b8f1ebf6d0..0bb7eea679ecd5dd5ed67e8f7727c99e62305f3c 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# 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 @@ -11,6 +11,7 @@ # 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") @@ -40,7 +41,116 @@ config("appmgr_core_config") { } } +idl_gen_interface("appmgr_innerkits") { + sources = [ + "idl/IAppStateCallback.idl", + ] + sources_common = [ + "IAppMgrConstants.idl", + ] + log_domainid = "0xD001311" + log_tag = "AppMgr" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +config("appmgr_innerkits_config") { + include_dirs = [ "${target_gen_dir}" ] +} + +ohos_source_set("appmgr_innerkits_include") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + + public_configs = [ + ":appmgr_innerkits_config", + # "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] + + deps = [ + ":appmgr_innerkits", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits", + "${ability_runtime_path}/utils/server/startup:startup_util", + ] + external_deps = [ + "bundle_framework:appexecfwk_base", + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "samgr:samgr_proxy", + "ability_base:configuration", + ] + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("appmgr_innerkits_source") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + configs = [ + ":appmgr_core_config", + ":appmgr_sdk_config", + ] + + public_configs = [ + ":appmgr_innerkits_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", + ] + + output_values = get_target_outputs(":appmgr_innerkits") + sources = filter_include(output_values, [ "*.cpp" ]) + + deps = [ + ":appmgr_innerkits", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits", + "${ability_runtime_path}/utils/server/startup:startup_util", + ] + external_deps = [ + "c_utils:utils", + "faultloggerd:libfaultloggerd", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "samgr:samgr_proxy", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "bundle_framework:appexecfwk_base", + ] + + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("app_manager") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } branch_protector_ret = "pac_ret" include_dirs = [ @@ -85,8 +195,6 @@ ohos_shared_library("app_manager") { "src/appmgr/app_scheduler_host.cpp", "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", @@ -128,7 +236,10 @@ ohos_shared_library("app_manager") { public_configs = [ ":appmgr_core_config", + ":appmgr_innerkits_config", ":appmgr_sdk_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_path}/utils/server/startup:startup_util_config", ] defines = [ "AMS_LOG_TAG = \"AppexecfwkCore\"" ] @@ -138,6 +249,7 @@ ohos_shared_library("app_manager") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ + ":appmgr_innerkits_source", "${ability_runtime_path}/utils/global/freeze:freeze_util", "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_services_path}/common:app_util", diff --git a/interfaces/inner_api/app_manager/idl/IAppMgrConstants.idl b/interfaces/inner_api/app_manager/idl/IAppMgrConstants.idl new file mode 100644 index 0000000000000000000000000000000000000000..6d1013bcfa56dbc986db7a3384c75d44bebe7d8b --- /dev/null +++ b/interfaces/inner_api/app_manager/idl/IAppMgrConstants.idl @@ -0,0 +1,28 @@ +/* + * 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 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, +}; diff --git a/interfaces/inner_api/app_manager/idl/IAppStateCallback.idl b/interfaces/inner_api/app_manager/idl/IAppStateCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..fff348fc806d71dcdd1686dddb07125a33706898 --- /dev/null +++ b/interfaces/inner_api/app_manager/idl/IAppStateCallback.idl @@ -0,0 +1,35 @@ +/* + * 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..OHOS.AppExecFwk.AppProcessData; +sequenceable OHOS.AppExecFwk.Configuration; +sequenceable bundle_info..OHOS.AppExecFwk.BundleInfo; +sequenceable running_process_info..OHOS.AppExecFwk.RunningProcessInfo; + +import IAppMgrConstants; + +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/app_mgr_constants.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h index ec040e460b4390f02c9f8578f7997da7e42517bd..27f8a73e5fde0b5312ebfb097600bf6866eaf6dc 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,7 @@ #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,18 +53,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, 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 deleted file mode 100644 index 6d4fac59090a44158ba381f490fe5bb7fc3d657a..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/app_state_callback_host.h +++ /dev/null @@ -1,106 +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. - */ - -#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" - -namespace OHOS { -namespace AppExecFwk { -class AppStateCallbackHost : public IRemoteStub { -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; - - /** - * Application state changed callback. - * - * @param appProcessData Process data - */ - virtual void OnAppStateChanged(const 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: - 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); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_HOST_H 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/src/appmgr/app_state_callback_host.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_host.cpp deleted file mode 100644 index 6583946d01f3215d43c11f92d21144cf35a34a06..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_host.cpp +++ /dev/null @@ -1,259 +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_host.h" - -#include "appexecfwk_errors.h" -#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) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void AppStateCallbackHost::OnAppStateChanged(const AppProcessData &) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void AppStateCallbackHost::NotifyAppPreCache(int32_t pid, int32_t userId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void AppStateCallbackHost::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) -{ -} - -void AppStateCallbackHost::NotifyStartResidentProcess(std::vector &bundleInfos) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void AppStateCallbackHost::NotifyStartKeepAliveProcess(std::vector &bundleInfos) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void AppStateCallbackHost::OnAppRemoteDied(const std::vector> &abilityTokens) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void AppStateCallbackHost::OnStartProcessFailed(sptr token) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); -} - -void 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; -} -} // 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/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index b1e9d373d3d8c656be1e22591d06408609ceea4b..ec72f4d2341049043ebd19bda88f23d802310724 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -43,6 +43,10 @@ config("wantagent_innerkits_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime", "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", ] + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", + ] } ohos_shared_library("wantagent_innerkits") { diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index b0fd3beeac876bf5434115ebc2555215b245e4e8..bf8072ee672aa9975e1f7ba0ed092950f4bd1311 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -65,6 +65,11 @@ config("abilityms_config") { "${ability_runtime_utils_path}/server/constant", ] + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", + ] + defines = [] if (ability_command_for_test) { diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index b2de5a3951123671c45bf65a83bfed95c0db35da..f956a62ef3c48197921767c2ac4ec7ad5dbb9a9f 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -25,7 +25,7 @@ #include "app_debug_listener_interface.h" #include "application_info.h" #include "appmgr/app_mgr_client.h" -#include "appmgr/app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "appmgr/start_specified_ability_response_stub.h" #include "bundle_info.h" #include "fault_data.h" @@ -141,7 +141,7 @@ public: * @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,49 @@ 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 +668,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/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index d6385c53b441b67a4d3d654c749e136024d108af..d3daa6149e35f9695e220cf4fa169ab3d09c2ca3 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); - callback->NotifyStartResidentProcess(bundleInfos); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); + callback->NotifyStartResidentProcess(const_cast&>(bundleInfos)); + return ERR_OK; } -void AppScheduler::NotifyStartKeepAliveProcess(std::vector &bundleInfos) +ErrCode AppScheduler::NotifyStartKeepAliveProcess(const std::vector &bundleInfos) { auto callback = callback_.lock(); - CHECK_POINTER(callback); - callback->NotifyStartKeepAliveProcess(bundleInfos); + CHECK_POINTER_AND_RETURN(callback, INNER_ERR); + callback->NotifyStartKeepAliveProcess(const_cast&>(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) diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/BUILD.gn b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/BUILD.gn index 94c7e0f3a5fee85be55bfc321dc47534b31d2fe6..3a82d3faef0a8845f16d1966bb7ed9285b005a96 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/BUILD.gn +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/BUILD.gn @@ -27,6 +27,10 @@ config("appexecfwk_core_mock_config") { "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/include/", "${ability_runtime_services_path}/common/include", ] + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", + ] } ohos_static_library("appexecfwk_appmgr_mock") { diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_process_data.h b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_process_data.h index 0e627fbde9d4f9be7ddb6b377f81a3a731d7b6da..7b8d03523126d798b82588e9d0800aae5e415942 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_process_data.h +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_process_data.h @@ -22,6 +22,10 @@ namespace OHOS { namespace AppExecFwk { +struct AppData { + std::string appName; + int32_t uid; +}; struct AppProcessData : public Parcelable { /** * @brief read this Sequenceable object from a Parcel. @@ -45,11 +49,13 @@ struct AppProcessData : public Parcelable { */ static AppProcessData* Unmarshalling(Parcel& parcel); - std::string appName; std::string processName; ApplicationState appState = ApplicationState::APP_STATE_CREATE; pid_t pid = 0; - int32_t uid = 0; + int32_t appIndex = 0; + std::vector appDatas; + std::string instanceKey = ""; + std::string bundleName = ""; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_state_callback_host.h b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_state_callback_host.h index e8ba483140af1b31ec98ec3bec84ba96c6ef9744..f92bb28abfad0adac99be6f8f142985420ac838a 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_state_callback_host.h +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_state_callback_host.h @@ -21,7 +21,7 @@ #include "nocopyable.h" #include "string_ex.h" #include "app_mgr_constants.h" -#include "appmgr/iapp_state_callback.h" +#include "iapp_state_callback.h" #include "bundle_info.h" #include "iremote_object.h" diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/app_state_callback_host.cpp b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/app_state_callback_host.cpp index 4758c246b572b315e44280efed8ecc42bd2bc188..261db6bff05c28e7255f72ffe132829cb3ba0e6c 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/app_state_callback_host.cpp +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/app_state_callback_host.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "appexecfwk_errors.h" #include "hilog_tag_wrapper.h" #include "ipc_types.h" diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp index f4019b1c58443722c397b983c6f3755389dd8b40..3e2913d299518c12da7bc4084f462b5dfeba9350 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp @@ -98,9 +98,10 @@ 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) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAbilityRequestDone()"); + return ERR_OK; } int AppScheduler::KillApplication(const std::string& bundleName, bool clearPageStack, int32_t appIndex) @@ -119,39 +120,46 @@ void AppScheduler::PrepareTerminate(const sptr& token, bool clear TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::PrepareTerminate()"); } -void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData) +ErrCode AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppStateChanged()"); + return ERR_OK; } -void AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) +ErrCode AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyConfigurationChange()"); + return ERR_OK; } -void AppScheduler::NotifyStartResidentProcess(std::vector &bundleInfos) +ErrCode AppScheduler::NotifyStartResidentProcess(const std::vector &bundleInfos) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartResidentProcess()"); + return ERR_OK; } -void AppScheduler::NotifyStartKeepAliveProcess(std::vector &bundleInfos) +ErrCode AppScheduler::NotifyStartKeepAliveProcess(const std::vector &bundleInfos) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartKeepAliveProcess()"); + return ERR_OK; } -void AppScheduler::OnAppRemoteDied(const std::vector> &abilityTokens) +ErrCode AppScheduler::OnAppRemoteDied(const std::vector> &abilityTokens) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppRemoteDied()"); + return ERR_OK; } -void AppScheduler::OnStartProcessFailed(sptr token) +ErrCode AppScheduler::OnStartProcessFailed(const sptr &token) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnStartProcessFailed()"); + return ERR_OK; } -void AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) +ErrCode AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyAppPreCache()"); + return ERR_OK; } void AppScheduler::UpdateAbilityState(const sptr& token, const AppExecFwk::AbilityState state) diff --git a/test/mock/services_appmgr_test/include/mock_iapp_state_callback.h b/test/mock/services_appmgr_test/include/mock_iapp_state_callback.h index 80e560b86d5736434626f6c5ce64c071952fe425..a078a289c8b301126ac39430732962657a3b600d 100644 --- a/test/mock/services_appmgr_test/include/mock_iapp_state_callback.h +++ b/test/mock/services_appmgr_test/include/mock_iapp_state_callback.h @@ -18,24 +18,29 @@ #include "gmock/gmock.h" #include "app_mgr_constants.h" -#include "app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "app_process_data.h" #include "bundle_info.h" namespace OHOS { namespace AppExecFwk { -class MockAppStateCallback : public AppStateCallbackHost { +class MockAppStateCallback : public AppStateCallbackStub { public: MockAppStateCallback() {} virtual ~MockAppStateCallback() {} - MOCK_METHOD1(OnAppStateChanged, void(const AppProcessData&)); - MOCK_METHOD2(OnAbilityRequestDone, void(const sptr&, const AbilityState)); - MOCK_METHOD1(NotifyStartResidentProcess, void(std::vector&)); - MOCK_METHOD1(NotifyStartKeepAliveProcess, void(std::vector&)); - MOCK_METHOD2(NotifyAppPreCache, void(int32_t, int32_t)); + MOCK_METHOD1(OnAppStateChanged, ErrCode(const AppProcessData&)); + MOCK_METHOD2(OnAbilityRequestDone, ErrCode(const sptr&, const AbilityState)); + MOCK_METHOD1(NotifyStartResidentProcess, ErrCode(const std::vector&)); + MOCK_METHOD1(NotifyStartKeepAliveProcess, ErrCode(const std::vector&)); + MOCK_METHOD2(NotifyAppPreCache, ErrCode(int32_t, int32_t)); + MOCK_METHOD2(NotifyConfigurationChange, ErrCode(const Configuration&, int32_t)); + MOCK_METHOD1(OnAppRemoteDied, ErrCode(const std::vector>&)); + MOCK_METHOD1(OnStartProcessFailed, ErrCode(const sptr&)); + MOCK_METHOD5(OnCacheExitInfo, ErrCode(uint32_t, const RunningProcessInfo&, + const std::string&, const std::vector&, const std::vector&)); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index c6d53ceff4d1956bdd7252313171a8f4e0ae3c1d..4d2385b0ff482fc0919b35ac173b3ce676983143 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -43,8 +43,6 @@ ohos_source_set("appmgr_test_source") { "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_record_id.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_scheduler_host.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_scheduler_proxy.cpp", - "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_state_callback_host.cpp", - "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_state_callback_proxy.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/fault_data.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_proxy.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_stub.cpp", diff --git a/test/unittest/ability_permission_util_second_test/mock/src/mock_app_scheduler.cpp b/test/unittest/ability_permission_util_second_test/mock/src/mock_app_scheduler.cpp index 8f44c754c21ce918c8146218c896c492288f0d91..2aed0965c799ad8506f7e2c84dfcaf5991214b7a 100644 --- a/test/unittest/ability_permission_util_second_test/mock/src/mock_app_scheduler.cpp +++ b/test/unittest/ability_permission_util_second_test/mock/src/mock_app_scheduler.cpp @@ -98,9 +98,10 @@ 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) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAbilityRequestDone()"); + return ERR_OK; } int AppScheduler::KillApplication(const std::string& bundleName, bool clearPageStack, int32_t appIndex) @@ -119,39 +120,46 @@ void AppScheduler::PrepareTerminate(const sptr& token, bool clear TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::PrepareTerminate()"); } -void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData) +ErrCode AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppStateChanged()"); + return ERR_OK; } -void AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration& config, int32_t userId) +ErrCode AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration& config, int32_t userId) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyConfigurationChange()"); + return ERR_OK; } -void AppScheduler::NotifyStartResidentProcess(std::vector& bundleInfos) +ErrCode AppScheduler::NotifyStartResidentProcess(const std::vector& bundleInfos) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartResidentProcess()"); + return ERR_OK; } -void AppScheduler::NotifyStartKeepAliveProcess(std::vector& bundleInfos) +ErrCode AppScheduler::NotifyStartKeepAliveProcess(const std::vector& bundleInfos) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartKeepAliveProcess()"); + return ERR_OK; } -void AppScheduler::OnAppRemoteDied(const std::vector>& abilityTokens) +ErrCode AppScheduler::OnAppRemoteDied(const std::vector>& abilityTokens) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppRemoteDied()"); + return ERR_OK; } -void AppScheduler::OnStartProcessFailed(sptr token) +ErrCode AppScheduler::OnStartProcessFailed(const sptr& token) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnStartProcessFailed()"); + return ERR_OK; } -void AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) +ErrCode AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyAppPreCache()"); + return ERR_OK; } void AppScheduler::UpdateAbilityState(const sptr& token, const AppExecFwk::AbilityState state) diff --git a/test/unittest/ability_running_record_test/ability_running_record_test.cpp b/test/unittest/ability_running_record_test/ability_running_record_test.cpp index 077c126b5dbcaaf5ea44e15e0084463d0737de0a..91f5f2848408a4ac3f2001a0f02a56953055832e 100644 --- a/test/unittest/ability_running_record_test/ability_running_record_test.cpp +++ b/test/unittest/ability_running_record_test/ability_running_record_test.cpp @@ -16,7 +16,7 @@ #include #include "ability_running_record.h" -#include "app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "hilog_tag_wrapper.h" #include "mock_ability_token.h" diff --git a/test/unittest/ams_app_state_callback_test/BUILD.gn b/test/unittest/ams_app_state_callback_test/BUILD.gn index 42801229395b397b8394cd607cf01f81ff7e4ebb..058a2f1940002849f82eed2b880d7dfa47edc253 100644 --- a/test/unittest/ams_app_state_callback_test/BUILD.gn +++ b/test/unittest/ams_app_state_callback_test/BUILD.gn @@ -20,10 +20,7 @@ ohos_unittest("AmsAppStateCallbackTest") { module_out_path = module_output_path cflags_cc = [] - sources = [ - "${ability_runtime_innerkits_path}//app_manager/src/appmgr/app_process_data.cpp", - "${ability_runtime_innerkits_path}//app_manager/src/appmgr/app_state_callback_host.cpp", - ] + sources = [ "${ability_runtime_innerkits_path}//app_manager/src/appmgr/app_process_data.cpp" ] sources += [ "ams_app_state_callback_test.cpp" ] diff --git a/test/unittest/ams_app_state_callback_test/ams_app_state_callback_test.cpp b/test/unittest/ams_app_state_callback_test/ams_app_state_callback_test.cpp index 2b73bf7040786e2f888c383d7db8c20919f99cce..bb05ff7e7621a8d501eb0bf6859fa7ebb027871c 100644 --- a/test/unittest/ams_app_state_callback_test/ams_app_state_callback_test.cpp +++ b/test/unittest/ams_app_state_callback_test/ams_app_state_callback_test.cpp @@ -14,7 +14,7 @@ */ #include -#include "app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "app_mgr_constants.h" #include "iapp_state_callback.h" #include "app_process_data.h" @@ -24,6 +24,58 @@ using namespace testing::ext; namespace OHOS { namespace AppExecFwk { +class MockAppStateCallbackStub : public AppStateCallbackStub { +public: + MockAppStateCallbackStub() = default; + ~MockAppStateCallbackStub() = default; + + ErrCode OnAppStateChanged(const AppProcessData& appProcessData) + { + return ERR_OK; + } + + ErrCode OnAbilityRequestDone(const sptr& token, AbilityState state) + { + return ERR_OK; + } + + ErrCode NotifyConfigurationChange(const Configuration& config, int32_t userId) + { + return ERR_OK; + } + + ErrCode NotifyStartResidentProcess(const std::vector& bundleInfos) + { + return ERR_OK; + } + + ErrCode NotifyStartKeepAliveProcess(const std::vector& bundleInfos) + { + return ERR_OK; + } + + ErrCode OnAppRemoteDied(const std::vector>& abilityTokens) + { + return ERR_OK; + } + + ErrCode OnStartProcessFailed(const sptr& token) + { + return ERR_OK; + } + + ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) + { + return ERR_OK; + } + + ErrCode OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo& exitInfo, + const std::string& bundleName, const std::vector& abilityNames, + const std::vector& uiExtensionNames) + { + return ERR_OK; + } +}; class AmsAppStateCallBackTest : public testing::Test { public: static void SetUpTestCase(); @@ -51,8 +103,8 @@ void AmsAppStateCallBackTest::TearDown() */ HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_001, TestSize.Level1) { - sptr host(new AppStateCallbackHost()); - EXPECT_NE(host, nullptr); + sptr stub(new MockAppStateCallbackStub()); + EXPECT_NE(stub, nullptr); MessageParcel data; MessageParcel reply; MessageOption option{ MessageOption::TF_ASYNC }; @@ -77,8 +129,8 @@ HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_001, TestSize.Level1) */ HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_002, TestSize.Level1) { - sptr host(new AppStateCallbackHost()); - EXPECT_NE(host, nullptr); + sptr stub(new MockAppStateCallbackStub()); + EXPECT_NE(stub, nullptr); MessageParcel data; MessageParcel reply; MessageOption option{ MessageOption::TF_ASYNC }; @@ -101,9 +153,9 @@ HWTEST_F(AmsAppStateCallBackTest, OnAbilityRequestDone_001, TestSize.Level1) { sptr token = nullptr; AbilityState state = AbilityState::ABILITY_STATE_CREATE; - sptr host(new AppStateCallbackHost()); - EXPECT_NE(host, nullptr); - host->OnAbilityRequestDone(token, state); + sptr stub(new MockAppStateCallbackStub()); + EXPECT_NE(stub, nullptr); + stub->OnAbilityRequestDone(token, state); } /* @@ -116,10 +168,10 @@ HWTEST_F(AmsAppStateCallBackTest, OnAbilityRequestDone_001, TestSize.Level1) */ HWTEST_F(AmsAppStateCallBackTest, NotifyStartResidentProcess_001, TestSize.Level1) { - sptr host(new AppStateCallbackHost()); - EXPECT_NE(host, nullptr); + sptr stub(new MockAppStateCallbackStub()); + EXPECT_NE(stub, nullptr); std::vector bundleInfos; - host->NotifyStartResidentProcess(bundleInfos); + stub->NotifyStartResidentProcess(bundleInfos); } /* @@ -132,10 +184,10 @@ HWTEST_F(AmsAppStateCallBackTest, NotifyStartResidentProcess_001, TestSize.Level */ HWTEST_F(AmsAppStateCallBackTest, NotifyStartKeepAliveProcess_001, TestSize.Level1) { - sptr host(new AppStateCallbackHost()); - EXPECT_NE(host, nullptr); + sptr stub(new MockAppStateCallbackStub()); + EXPECT_NE(stub, nullptr); std::vector bundleInfos; - host->NotifyStartKeepAliveProcess(bundleInfos); + stub->NotifyStartKeepAliveProcess(bundleInfos); } /* @@ -149,9 +201,9 @@ HWTEST_F(AmsAppStateCallBackTest, NotifyStartKeepAliveProcess_001, TestSize.Leve HWTEST_F(AmsAppStateCallBackTest, OnAppStateChanged_001, TestSize.Level1) { AppProcessData data; - sptr host(new AppStateCallbackHost()); - EXPECT_NE(host, nullptr); - host->OnAppStateChanged(data); + sptr stub(new MockAppStateCallbackStub()); + EXPECT_NE(stub, nullptr); + stub->OnAppStateChanged(data); } /* diff --git a/test/unittest/ams_ipc_interface_test/BUILD.gn b/test/unittest/ams_ipc_interface_test/BUILD.gn index 4265e2f8404f9b24b02efeb3a1434e015ddd1c68..76ebd0a575aa28948a0c4e156f30f5a1572b2157 100644 --- a/test/unittest/ams_ipc_interface_test/BUILD.gn +++ b/test/unittest/ams_ipc_interface_test/BUILD.gn @@ -28,7 +28,10 @@ ohos_unittest("AmsIpcAppSchedulerInterfaceTest") { if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - deps = [ "${ability_runtime_test_path}/unittest:appmgr_test_source" ] + deps = [ + "${ability_runtime_test_path}/unittest:appmgr_test_source", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + ] external_deps = [ "ability_base:base", diff --git a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index 7878a25713432860b36e5899e80b4780bfde043b..419d4cde4d7bee6d8617596048e539869d9f42f1 100644 --- a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -19,7 +19,7 @@ #include "ams_mgr_scheduler.h" #undef private -#include "app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "hilog_tag_wrapper.h" #include "mock_ability_token.h" #include "mock_app_mgr_service_inner.h" @@ -36,6 +36,58 @@ using testing::Return; namespace OHOS { namespace AppExecFwk { +class MockAppStateCallbackStub : public AppStateCallbackStub { +public: + MockAppStateCallbackStub() = default; + ~MockAppStateCallbackStub() = default; + + ErrCode OnAppStateChanged(const AppProcessData& appProcessData) + { + return ERR_OK; + } + + ErrCode OnAbilityRequestDone(const sptr& token, AbilityState state) + { + return ERR_OK; + } + + ErrCode NotifyConfigurationChange(const Configuration& config, int32_t userId) + { + return ERR_OK; + } + + ErrCode NotifyStartResidentProcess(const std::vector& bundleInfos) + { + return ERR_OK; + } + + ErrCode NotifyStartKeepAliveProcess(const std::vector& bundleInfos) + { + return ERR_OK; + } + + ErrCode OnAppRemoteDied(const std::vector>& abilityTokens) + { + return ERR_OK; + } + + ErrCode OnStartProcessFailed(const sptr& token) + { + return ERR_OK; + } + + ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) + { + return ERR_OK; + } + + ErrCode OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo& exitInfo, + const std::string& bundleName, const std::vector& abilityNames, + const std::vector& uiExtensionNames) + { + return ERR_OK; + } +}; class AmsMgrSchedulerTest : public testing::Test { public: static void SetUpTestCase(); @@ -235,10 +287,10 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_005, TestSize.Level1) std::make_unique(mockAppMgrServiceInner, GetAmsTaskHandler()); ASSERT_NE(amsMgrScheduler, nullptr); - sptr appStateCallbackHost = new AppStateCallbackHost(); + sptr appStateCallbackstub = new MockAppStateCallbackStub(); EXPECT_CALL(*mockAppMgrServiceInner, RegisterAppStateCallback(_)) .WillOnce(InvokeWithoutArgs(mockAppMgrServiceInner.get(), &MockAppMgrServiceInner::Post)); - amsMgrScheduler->RegisterAppStateCallback(appStateCallbackHost); + amsMgrScheduler->RegisterAppStateCallback(appStateCallbackstub); mockAppMgrServiceInner->Wait(); TAG_LOGD(AAFwkTag::TEST, "AmsMgrScheduler_005 end."); diff --git a/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp b/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp index cf59e356025590c8e2083e2f05d64692e7655d50..8b29dcc315b73babbeff9fe01de801563584c0bb 100644 --- a/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp +++ b/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp @@ -16,7 +16,7 @@ #include #include "app_config_data_manager.h" -#include "app_state_callback_host.h" +#include "app_state_callback_stub.h" #include "errors.h" #include "hilog_tag_wrapper.h" #include "mock_ability_token.h" diff --git a/test/unittest/app_exit_reason_helper_fourth_test/mock/src/mock_app_scheduler.cpp b/test/unittest/app_exit_reason_helper_fourth_test/mock/src/mock_app_scheduler.cpp index 33398096bfa44784e6da0457f75a6fa9f5a186e9..c08a28860c73140227101bfc5b0247383770fd2a 100644 --- a/test/unittest/app_exit_reason_helper_fourth_test/mock/src/mock_app_scheduler.cpp +++ b/test/unittest/app_exit_reason_helper_fourth_test/mock/src/mock_app_scheduler.cpp @@ -97,9 +97,10 @@ 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) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAbilityRequestDone()"); + return ERR_OK; } int AppScheduler::KillApplication(const std::string& bundleName, bool clearPageStack, int32_t appIndex) @@ -118,39 +119,46 @@ void AppScheduler::PrepareTerminate(const sptr& token, bool clear TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::PrepareTerminate()"); } -void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData) +ErrCode AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppStateChanged()"); + return ERR_OK; } -void AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration& config, int32_t userId) +ErrCode AppScheduler::NotifyConfigurationChange(const AppExecFwk::Configuration& config, int32_t userId) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyConfigurationChange()"); + return ERR_OK; } -void AppScheduler::NotifyStartResidentProcess(std::vector& bundleInfos) +ErrCode AppScheduler::NotifyStartResidentProcess(const std::vector& bundleInfos) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartResidentProcess()"); + return ERR_OK; } -void AppScheduler::NotifyStartKeepAliveProcess(std::vector& bundleInfos) +ErrCode AppScheduler::NotifyStartKeepAliveProcess(const std::vector& bundleInfos) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyStartKeepAliveProcess()"); + return ERR_OK; } -void AppScheduler::OnAppRemoteDied(const std::vector>& abilityTokens) +ErrCode AppScheduler::OnAppRemoteDied(const std::vector>& abilityTokens) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnAppRemoteDied()"); + return ERR_OK; } -void AppScheduler::OnStartProcessFailed(sptr token) +ErrCode AppScheduler::OnStartProcessFailed(const sptr &token) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::OnStartProcessFailed()"); + return ERR_OK; } -void AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) +ErrCode AppScheduler::NotifyAppPreCache(int32_t pid, int32_t userId) { TAG_LOGI(AAFwkTag::TEST, "Test AppScheduler::NotifyAppPreCache()"); + return ERR_OK; } void AppScheduler::UpdateAbilityState(const sptr& token, const AppExecFwk::AbilityState state) diff --git a/test/unittest/app_mgr_service_inner_fifth_test/app_mgr_service_inner_fifth_test.cpp b/test/unittest/app_mgr_service_inner_fifth_test/app_mgr_service_inner_fifth_test.cpp index d606d82a0ca7eede99892eebf82d6737b7622892..100be0d388baab02b1053d5fb113192248e97631 100644 --- a/test/unittest/app_mgr_service_inner_fifth_test/app_mgr_service_inner_fifth_test.cpp +++ b/test/unittest/app_mgr_service_inner_fifth_test/app_mgr_service_inner_fifth_test.cpp @@ -72,21 +72,54 @@ constexpr const char* PERMISSION_PROTECT_SCREEN_LOCK_DATA_TEST = "ohos.permissio class MockIAppStateCallback : public IAppStateCallback { public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppStateCallback"); - void OnAppStateChanged(const AppProcessData &appProcessData) override {}; - void OnAbilityRequestDone(const sptr &token, const AbilityState state) override {}; - void OnAppRemoteDied(const std::vector> &abilityTokens) + ErrCode OnAppStateChanged(const AppProcessData& appProcessData) override { dealed = true; + return ERR_OK; } - void OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, - const std::string &bundleName, const std::vector &abilityNames, - const std::vector &uiExtensionNames) override + + ErrCode OnAbilityRequestDone(const sptr& token, AbilityState state) override + { + return ERR_OK; + } + + ErrCode NotifyConfigurationChange(const Configuration& config, int32_t userId) override + { + return ERR_OK; + } + + ErrCode NotifyStartResidentProcess(const std::vector& bundleInfos) override + { + return ERR_OK; + } + + ErrCode NotifyStartKeepAliveProcess(const std::vector& bundleInfos) override + { + return ERR_OK; + } + + ErrCode OnAppRemoteDied(const std::vector>& abilityTokens) override { dealed = true; + return ERR_OK; + } + + ErrCode OnStartProcessFailed(const sptr& token) override + { + return ERR_OK; } - void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override + + ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) override + { + return ERR_OK; + } + + ErrCode OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo& exitInfo, + const std::string& bundle, const std::vector& abilityNames, + const std::vector&ExtensionNames) override { dealed = true; + return ERR_OK; } sptr AsObject() { diff --git a/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp b/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp index ebbdfb05c5285f435261fe900cd2a8f17acbce13..e40b3be386b1cc2792cdc589e3193502b311a5d5 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp @@ -104,19 +104,22 @@ class MockIAppStateCallback : public IAppStateCallback { public: MockIAppStateCallback() = default; virtual ~MockIAppStateCallback() = default; - MOCK_METHOD1(OnAppStateChanged, void(const AppProcessData &appProcessData)); - MOCK_METHOD2(OnAbilityRequestDone, void(const sptr &token, const AbilityState state)); - void NotifyAppPreCache(int32_t pid, int32_t userId) override + MOCK_METHOD1(OnAppStateChanged, ErrCode(const AppProcessData &appProcessData)); + MOCK_METHOD2(OnAbilityRequestDone, ErrCode(const sptr &token, const AbilityState state)); + ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) override { AAFwk::MyStatus::GetInstance().notifyAppPreCacheCalled_ = true; + return ERR_OK; } - void NotifyStartResidentProcess(std::vector &bundleInfos) override + ErrCode NotifyStartResidentProcess(const std::vector &bundleInfos) override { AAFwk::MyStatus::GetInstance().notifyStartResidentProcessCalled_ = true; + return ERR_OK; } - void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override + ErrCode NotifyStartKeepAliveProcess(const std::vector &bundleInfos) override { AAFwk::MyStatus::GetInstance().notifyStartKeepAliveProcessCalled_ = true; + return ERR_OK; } sptr AsObject() override { diff --git a/test/unittest/app_mgr_service_inner_tenth_test/app_mgr_service_inner_tenth_test.cpp b/test/unittest/app_mgr_service_inner_tenth_test/app_mgr_service_inner_tenth_test.cpp index 74b33289f770d997880bf8b57bdc8d566f64bc89..6fc9e6ced1d6e545266e581e8657adac9ddc10a9 100644 --- a/test/unittest/app_mgr_service_inner_tenth_test/app_mgr_service_inner_tenth_test.cpp +++ b/test/unittest/app_mgr_service_inner_tenth_test/app_mgr_service_inner_tenth_test.cpp @@ -103,20 +103,42 @@ class MockIAppStateCallback : public IAppStateCallback { public: MockIAppStateCallback() = default; virtual ~MockIAppStateCallback() = default; - MOCK_METHOD1(OnAppStateChanged, void(const AppProcessData &appProcessData)); - MOCK_METHOD2(OnAbilityRequestDone, void(const sptr &token, const AbilityState state)); - void NotifyAppPreCache(int32_t pid, int32_t userId) override + MOCK_METHOD1(OnAppStateChanged, ErrCode(const AppProcessData &appProcessData)); + MOCK_METHOD2(OnAbilityRequestDone, ErrCode(const sptr &token, const AbilityState state)); + ErrCode NotifyAppPreCache(int32_t pid, int32_t userId) override { AAFwk::MyStatus::GetInstance().notifyAppPreCacheCalled_ = true; + return ERR_OK; } - void NotifyStartResidentProcess(std::vector &bundleInfos) override + ErrCode NotifyStartResidentProcess(const std::vector &bundleInfos) override { AAFwk::MyStatus::GetInstance().notifyStartResidentProcessCalled_ = true; + return ERR_OK; } - void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override + ErrCode NotifyStartKeepAliveProcess(const std::vector &bundleInfos) override { AAFwk::MyStatus::GetInstance().notifyStartKeepAliveProcessCalled_ = true; + return ERR_OK; } + ErrCode NotifyConfigurationChange(const Configuration& config, int32_t userId) + { + return ERR_OK; + } + ErrCode OnAppRemoteDied(const std::vector>& abilityTokens) + { + return ERR_OK; + } + ErrCode OnStartProcessFailed(const sptr& token) + { + return ERR_OK; + } + ErrCode OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo& exitInfo, + const std::string& bundleName, const std::vector& abilityNames, + const std::vector& uiExtensionNames) + { + return ERR_OK; + } + sptr AsObject() override { return nullptr; diff --git a/test/unittest/app_preloader_test/BUILD.gn b/test/unittest/app_preloader_test/BUILD.gn index e271f94abcbddec64cbed76f09af70efe866f520..2e6201667732128c711e9ec86dfda8afa81dde0f 100755 --- a/test/unittest/app_preloader_test/BUILD.gn +++ b/test/unittest/app_preloader_test/BUILD.gn @@ -19,7 +19,11 @@ module_output_path = "ability_runtime/ability_runtime/appmgrservice" ohos_unittest("app_preloader_test") { module_out_path = module_output_path - configs = [ "${ability_runtime_services_path}/common:common_config" ] + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", + "${ability_runtime_services_path}/common:common_config", + ] include_dirs = [ "include", diff --git a/test/unittest/dfr_test/watchdog_test/BUILD.gn b/test/unittest/dfr_test/watchdog_test/BUILD.gn index 7d977ca14785d8bdd9e5f2bf001f48a3bcf0deb2..80b81f722aac5f1359b8627f3a1845ac3acbea54 100644 --- a/test/unittest/dfr_test/watchdog_test/BUILD.gn +++ b/test/unittest/dfr_test/watchdog_test/BUILD.gn @@ -56,6 +56,8 @@ ohos_unittest("watchdog_test") { configs = [ ":module_context_config", ":ability_start_setting_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", ] sources = [ diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index bea5089ae746e30037f88870954e304eaa757e26..4a8276bc2a8bb67bf6e0690f9ce591be30b0c8f2 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -141,8 +141,8 @@ ohos_unittest("application_test") { "napi:ace_napi", "resource_management:global_resmgr", "resource_management:librawfile", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -207,8 +207,8 @@ ohos_unittest("context_impl_test") { "napi:ace_napi", "resource_management:global_resmgr", "resource_management:librawfile", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -266,8 +266,8 @@ ohos_unittest("context_impl_second_test") { "ipc:ipc_core", "napi:ace_napi", "resource_management:global_resmgr", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -327,8 +327,8 @@ ohos_unittest("context_impl_third_test") { "napi:ace_napi", "resource_management:global_resmgr", "resource_management:librawfile", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -378,8 +378,8 @@ ohos_unittest("context_container_test") { "init:libbegetutil", "ipc:ipc_core", "napi:ace_napi", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -580,8 +580,8 @@ ohos_unittest("context_deal_test") { "ipc:ipc_core", "napi:ace_napi", "resource_management:global_resmgr", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -636,8 +636,8 @@ ohos_unittest("application_impl_test") { "init:libbegetutil", "ipc:ipc_core", "napi:ace_napi", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -782,8 +782,8 @@ ohos_unittest("form_extension_context_test") { "init:libbegetutil", "ipc:ipc_core", "napi:ace_napi", - "samgr:samgr_proxy", "runtime_core:ani", + "samgr:samgr_proxy", ] if (ability_runtime_graphics) { @@ -966,13 +966,13 @@ ohos_unittest("dump_runtime_helper_test") { "ability_runtime:runtime", "c_utils:utils", "faultloggerd:libfaultloggerd", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", "jsoncpp:jsoncpp", "napi:ace_napi", - "ffrt:libffrt", "storage_service:storage_manager_acl", ] } @@ -1017,7 +1017,11 @@ ohos_unittest("idle_time_test") { "idle_time_test.cpp", ] - configs = [ ":module_context_config" ] + configs = [ + ":module_context_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits_config", + "${ability_runtime_innerkits_path}/app_manager:appmgr_innerkits_config", + ] deps = [ "${ability_runtime_native_path}/appkit:appkit_native" ] @@ -1063,15 +1067,15 @@ ohos_unittest("dump_runtime_helper_second_test") { "c_utils:utils", "ets_runtime:libark_jsruntime", "faultloggerd:libfaultloggerd", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "init:libbegetutil", "ipc:ipc_core", "jsoncpp:jsoncpp", "napi:ace_napi", - "ffrt:libffrt", - "storage_service:storage_manager_acl", "runtime_core:ani", + "storage_service:storage_manager_acl", ] }