diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index daafb4b1ac5cb59d5fa2a3c593dd079ad4d302ac..977044755f7acca75375d26009a70d2afeeb61f8 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -289,8 +289,6 @@ ohos_shared_library("abilitykit_native") { "${ability_runtime_native_path}/ability/native/js_free_install_observer.cpp", "${ability_runtime_native_path}/ability/native/js_query_erms_observer.cpp", "${ability_runtime_native_path}/ability/native/new_ability_impl.cpp", - "${ability_runtime_native_path}/ability/native/query_erms_observer_proxy.cpp", - "${ability_runtime_native_path}/ability/native/query_erms_observer_stub.cpp", "${ability_runtime_native_path}/ability/native/service_ability_impl.cpp", "${ability_runtime_native_path}/appkit/app/app_context.cpp", "${ability_runtime_native_path}/appkit/app/context_container.cpp", @@ -302,6 +300,7 @@ 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}/wantagent:wantagent_innerkits_public_config", ] @@ -313,6 +312,8 @@ ohos_shared_library("abilitykit_native") { ":ui_service_extension_connection", "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_proxy", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", @@ -375,6 +376,8 @@ ohos_shared_library("abilitykit_native") { "jsoncpp:jsoncpp", "libuv:uv", "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", ] defines = [] diff --git a/frameworks/native/ability/native/js_query_erms_observer.cpp b/frameworks/native/ability/native/js_query_erms_observer.cpp index 5f9e56158c5851dd4d1c9f9a38a6ed9d4a6c941a..7c2848a8ee5c60209ffb3b0c50c5f379c8f4c882 100644 --- a/frameworks/native/ability/native/js_query_erms_observer.cpp +++ b/frameworks/native/ability/native/js_query_erms_observer.cpp @@ -29,7 +29,7 @@ JsQueryERMSObserver::JsQueryERMSObserver(napi_env env) : env_(env) {} JsQueryERMSObserver::~JsQueryERMSObserver() = default; -void JsQueryERMSObserver::OnQueryFinished(const std::string &appId, const std::string &startTime, +ErrCode JsQueryERMSObserver::OnQueryFinished(const std::string &appId, const std::string &startTime, const AtomicServiceStartupRule &rule, int32_t resultCode) { TAG_LOGD(AAFwkTag::QUERY_ERMS, "call"); @@ -51,6 +51,7 @@ void JsQueryERMSObserver::OnQueryFinished(const std::string &appId, const std::s std::unique_ptr execute = nullptr; NapiAsyncTask::Schedule("JsQueryERMSObserver::OnQueryFinished", env_, std::make_unique(callback, std::move(execute), std::move(complete))); + return ERR_OK; } void JsQueryERMSObserver::HandleOnQueryFinished(const std::string &appId, const std::string &startTime, diff --git a/frameworks/native/ability/native/query_erms_observer_proxy.cpp b/frameworks/native/ability/native/query_erms_observer_proxy.cpp deleted file mode 100644 index 7416ea1652313b0099c49e3e20fff5ec8d531202..0000000000000000000000000000000000000000 --- a/frameworks/native/ability/native/query_erms_observer_proxy.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 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 "query_erms_observer_proxy.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" - -namespace OHOS { -namespace AbilityRuntime { -QueryERMSObserverProxy::QueryERMSObserverProxy( - const sptr &impl) : IRemoteProxy(impl) -{} - -bool QueryERMSObserverProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(QueryERMSObserverProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::QUERY_ERMS, "write interface token failed"); - return false; - } - return true; -} - -void QueryERMSObserverProxy::OnQueryFinished(const std::string &appId, const std::string &startTime, - const AtomicServiceStartupRule &rule, int32_t resultCode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::QUERY_ERMS, "failed to write token"); - return; - } - - if (!data.WriteString(appId) || !data.WriteString(startTime) || !data.WriteBool(rule.isOpenAllowed) || - !data.WriteBool(rule.isEmbeddedAllowed) || !data.WriteInt32(resultCode)) { - TAG_LOGE(AAFwkTag::QUERY_ERMS, "params is wrong"); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::QUERY_ERMS, "remote is null"); - return; - } - int32_t ret = remote->SendRequest(IQueryERMSObserver::ON_QUERY_FINISHED, data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::QUERY_ERMS, "error code: %{public}d", ret); - } -} -} // namespace AbilityRuntime -} // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/ability/native/query_erms_observer_stub.cpp b/frameworks/native/ability/native/query_erms_observer_stub.cpp deleted file mode 100644 index 6035fe6bb19cdacdbbf2f1c19b7de2ff595ac9d8..0000000000000000000000000000000000000000 --- a/frameworks/native/ability/native/query_erms_observer_stub.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 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 "query_erms_observer_stub.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AbilityRuntime { -QueryERMSObserverStub::QueryERMSObserverStub() -{} - -QueryERMSObserverStub::~QueryERMSObserverStub() -{} - -int QueryERMSObserverStub::OnQueryFinishedInner(MessageParcel &data, MessageParcel &reply) -{ - std::string appId = data.ReadString(); - std::string startTime = data.ReadString(); - AtomicServiceStartupRule rule; - rule.isOpenAllowed = data.ReadBool(); - rule.isEmbeddedAllowed = data.ReadBool(); - int32_t resultCode = data.ReadInt32(); - - OnQueryFinished(appId, startTime, rule, resultCode); - return NO_ERROR; -} - -int QueryERMSObserverStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string descriptor = QueryERMSObserverStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::QUERY_ERMS, "descriptor is not equal remote"); - return ERR_INVALID_STATE; - } - - if (code == static_cast(IQueryERMSObserver::ON_QUERY_FINISHED)) { - return OnQueryFinishedInner(data, reply); - } - - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} -} // namespace AbilityRuntime -} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 0c0c0c6e71d4461e463cde9b0e2eadeb85344e7c..57058e7d07aa5f2c9bc7c5989c7bf734a2d7d02a 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -11,8 +11,30 @@ # 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 = [ + "IPrepareTerminateCallback.idl", + "IQueryERMSObserver.idl", + ] + 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}", + "include/", + ] +} config("ability_manager_public_config") { visibility = [ ":*" ] @@ -39,6 +61,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 = [] @@ -61,7 +84,174 @@ 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 = [ + "*prepare_terminate_callback_proxy.cpp", + "*query_e_r_m_s_observer_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 = [ + "*prepare_terminate_callback_stub.cpp", + "*query_e_r_m_s_observer_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" @@ -73,6 +263,7 @@ ohos_shared_library("ability_manager") { "${ability_runtime_native_path}/ability/native/task_handler_client.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_client.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_manager_client.cpp", + "${ability_runtime_services_path}/abilitymgr/src/atomic_service_startup_rule.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_manager_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_running_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_stub.cpp", @@ -95,8 +286,6 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/lifecycle_state_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/open_link/open_link_options.cpp", - "${ability_runtime_services_path}/abilitymgr/src/prepare_terminate_callback_proxy.cpp", - "${ability_runtime_services_path}/abilitymgr/src/prepare_terminate_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_stub.cpp", @@ -125,12 +314,15 @@ ohos_shared_library("ability_manager") { public_configs = [ ":ability_manager_public_config", + ":ability_manager_idl_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", ] public_deps = [ ":ability_connect_callback_stub" ] deps = [ + ":ability_manager_proxy", + ":ability_manager_stub", ":ability_start_options", ":ability_start_setting", ":mission_info", @@ -419,6 +611,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/include/iprepare_terminate_callback_interface.h b/interfaces/inner_api/ability_manager/IHiddenStartObserver.idl similarity index 44% rename from interfaces/inner_api/ability_manager/include/iprepare_terminate_callback_interface.h rename to interfaces/inner_api/ability_manager/IHiddenStartObserver.idl index 284bb943d89c6b3a3db9f7abbfcb960e16635905..8afe667d8c6ef018279840684c4ab0e63975ec67 100644 --- a/interfaces/inner_api/ability_manager/include/iprepare_terminate_callback_interface.h +++ b/interfaces/inner_api/ability_manager/IHiddenStartObserver.idl @@ -1,36 +1,18 @@ -/* - * 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_PREPARE_TERMINATE_CALLBACK_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_CALLBACK_INTERFACE_H - -#include "iremote_broker.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AAFwk { -class IPrepareTerminateCallback : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.prepareTerminateCallback"); - virtual void DoPrepareTerminate() {}; - enum { - // ipc id for DoPrepareTerminate (1) - ON_DO_PREPARE_TERMINATE = 1, - CODE_MAX - }; -}; -} // namespace AbilityRuntime -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_CALLBACK_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. + */ + +interface OHOS.AAFwk.IHiddenStartObserver { + boolean IsHiddenStart([in] int pid); +} \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/prepare_terminate_callback_stub.h b/interfaces/inner_api/ability_manager/IPrepareTerminateCallback.idl similarity index 39% rename from interfaces/inner_api/ability_manager/include/prepare_terminate_callback_stub.h rename to interfaces/inner_api/ability_manager/IPrepareTerminateCallback.idl index 7706d8aa6e377164e8e2d4f2e405d87e61e997d8..ac1945ef584505f8e3d0a306ba690153f13be331 100644 --- a/interfaces/inner_api/ability_manager/include/prepare_terminate_callback_stub.h +++ b/interfaces/inner_api/ability_manager/IPrepareTerminateCallback.idl @@ -1,39 +1,18 @@ -/* - * 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_PREPARE_TERMINATE_CALLBACK_STUB_H -#define OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_CALLBACK_STUB_H - -#include -#include "iprepare_terminate_callback_interface.h" -#include "iremote_stub.h" -#include "message_parcel.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AAFwk { -class PrepareTerminateCallbackStub : public IRemoteStub { -public: - PrepareTerminateCallbackStub(); - virtual ~PrepareTerminateCallbackStub(); - int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int DoPrepareTerminateInner(MessageParcel &data, MessageParcel &reply); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_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. + */ + +interface OHOS.AAFwk.IPrepareTerminateCallback { + void DoPrepareTerminate(); +} \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/IQueryERMSObserver.idl b/interfaces/inner_api/ability_manager/IQueryERMSObserver.idl new file mode 100644 index 0000000000000000000000000000000000000000..a1a51adf13c36bf84d5b782530379043a7ce20be --- /dev/null +++ b/interfaces/inner_api/ability_manager/IQueryERMSObserver.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. + */ +sequenceable OHOS.AbilityRuntime.AtomicServiceStartupRule; + +interface OHOS.AbilityRuntime.IQueryERMSObserver { + [oneway]void OnQueryFinished([in] String appId, [in] String startTime, + [in] AtomicServiceStartupRule rule, [in] int resultCode); +} \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/ability_manager_headers.gni b/interfaces/inner_api/ability_manager/ability_manager_headers.gni index ec72bedb4f51047b3d8068c4d87851d783303c74..90e0723f7fd2c7cae44c37ab5742a19c46b9b6ef 100644 --- a/interfaces/inner_api/ability_manager/ability_manager_headers.gni +++ b/interfaces/inner_api/ability_manager/ability_manager_headers.gni @@ -21,6 +21,7 @@ ability_manager_headers = { "ability_running_info.h", "ability_scheduler_interface.h", "extension_running_info.h", + "iprepare_terminate_callback.h", "lifecycle_state_info.h", "open_link_options.h", "ability_state.h", 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 e6a593210c57648a1f13c51f65a434ddf224191e..eb186d4ffc4faca032029d04ea8f3385ffcaf5ba 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -40,7 +40,7 @@ #include "insight_intent/insight_intent_execute_param.h" #include "insight_intent/insight_intent_execute_result.h" #include "insight_intent/insight_intent_info_for_query.h" -#include "iprepare_terminate_callback_interface.h" +#include "iprepare_terminate_callback.h" #include "keep_alive_info.h" #include "mission_info.h" #include "query_erms_observer_interface.h" diff --git a/interfaces/inner_api/ability_manager/include/prepare_terminate_callback_proxy.h b/interfaces/inner_api/ability_manager/include/atomic_service_startup_rule.h similarity index 42% rename from interfaces/inner_api/ability_manager/include/prepare_terminate_callback_proxy.h rename to interfaces/inner_api/ability_manager/include/atomic_service_startup_rule.h index 5c9af96bb067aead4b61863d97c0bfe01e5983bd..d4bdacc797be051c190c93420c5a83b3e702d21f 100644 --- a/interfaces/inner_api/ability_manager/include/prepare_terminate_callback_proxy.h +++ b/interfaces/inner_api/ability_manager/include/atomic_service_startup_rule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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 @@ -13,26 +13,29 @@ * limitations under the License. */ -#ifndef OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_CALLBACK_PROXY_H -#define OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_CALLBACK_PROXY_H +#ifndef OHOS_ATOMIC_SERVICE_STARTUP_RULE_H +#define OHOS_ATOMIC_SERVICE_STARTUP_RULE_H -#include "iremote_proxy.h" -#include "iprepare_terminate_callback_interface.h" +#include +#include "iremote_broker.h" namespace OHOS { -namespace AAFwk { -class PrepareTerminateCallbackProxy : public IRemoteProxy { -public: - explicit PrepareTerminateCallbackProxy - (const sptr &impl) : IRemoteProxy(impl) {} - - virtual ~PrepareTerminateCallbackProxy() {} - - virtual void DoPrepareTerminate() override; - -private: - static inline BrokerDelegator delegator_; +namespace AbilityRuntime { +struct AtomicServiceStartupRule : public Parcelable { + AtomicServiceStartupRule() + { + isOpenAllowed = false; + isEmbeddedAllowed = false; + } + AtomicServiceStartupRule(bool OpenAllowed, bool EmbeddedAllowed) : isOpenAllowed(OpenAllowed), + isEmbeddedAllowed(EmbeddedAllowed) {} + bool isOpenAllowed = false; + bool isEmbeddedAllowed = false; + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static AtomicServiceStartupRule *Unmarshalling(Parcel &parcel); }; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_PREPARE_TERMINATE_CALLBACK_PROXY_H +} +} + +#endif // OHOS_ATOMIC_SERVICE_STARTUP_RULE_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/query_erms_observer_interface.h b/interfaces/inner_api/ability_manager/include/query_erms_observer_interface.h index f51d8c914382321b4f62522a76606b8466feecdc..08c42d2fc9bcecf2cd91bcd569388e778173ef8d 100644 --- a/interfaces/inner_api/ability_manager/include/query_erms_observer_interface.h +++ b/interfaces/inner_api/ability_manager/include/query_erms_observer_interface.h @@ -16,36 +16,6 @@ #ifndef OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_INTERFACE_H #define OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_INTERFACE_H -#include -#include "iremote_broker.h" - -namespace OHOS { -namespace AbilityRuntime { -struct AtomicServiceStartupRule { - bool isOpenAllowed = false; - bool isEmbeddedAllowed = false; -}; - -class IQueryERMSObserver : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IQueryERMSObserver"); - - /** - * OnQueryFinished, return free install result. - * - * @param appId Query ERMS app id. - * @param startTime Free install start request time. - * @param rule The ERMS query result. - * @param resultCode The result code. - */ - virtual void OnQueryFinished(const std::string &appId, const std::string &startTime, - const AtomicServiceStartupRule &rule, int resultCode) = 0; - - enum { - ON_QUERY_FINISHED = 1, - }; -}; -} // namespace AbilityRuntime -} // namespace OHOS +#include "iquery_e_r_m_s_observer.h" #endif // OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_INTERFACE_H \ 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 99c5ec887c546bf0f622b0218d8e4253a822c75d..5b9b1c8190405eb699369b3e111afbaef87ac0bc 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -126,6 +126,7 @@ ohos_shared_library("app_manager") { public_configs = [ ":appmgr_core_config", ":appmgr_sdk_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", ] defines = [ "AMS_LOG_TAG = \"AppexecfwkCore\"" ] @@ -160,6 +161,7 @@ ohos_shared_library("app_manager") { "ability_base:want", "bundle_framework:appexecfwk_base", "image_framework:image_native", + "relational_store:native_dataability", "relational_store:native_rdb", ] if (ability_runtime_child_process) { diff --git a/interfaces/inner_api/extension_manager/BUILD.gn b/interfaces/inner_api/extension_manager/BUILD.gn index 2a0d85fb821d0fcbf9b261e096a6474f40bd6026..bb2caa0f8ff43ee3cc2d7a4dd8c95eb063de3321 100755 --- a/interfaces/inner_api/extension_manager/BUILD.gn +++ b/interfaces/inner_api/extension_manager/BUILD.gn @@ -44,7 +44,14 @@ ohos_shared_library("extension_manager") { ] configs = [ ":extension_manager_config" ] - public_configs = [ ":extension_manager_public_config" ] + public_configs = [ + ":extension_manager_public_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_interface", + ] public_deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub" ] @@ -55,6 +62,8 @@ ohos_shared_library("extension_manager") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_single", + "relational_store:native_dataability", + "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index a9f3008821ce8144f55e241721e9ab01b90077d1..0f39f91c107f2a8b7ffcd6b865ee0194bb2e44f4 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -64,9 +64,13 @@ 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", + ] deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_interface", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", @@ -92,6 +96,8 @@ ohos_shared_library("wantagent_innerkits") { "icu:shared_icuuc", "image_framework:image_native", "resource_management:global_resmgr", + "relational_store:native_dataability", + "relational_store:native_rdb", ] if (is_double_framework) { diff --git a/interfaces/kits/native/ability/native/js_query_erms_observer.h b/interfaces/kits/native/ability/native/js_query_erms_observer.h index e759d5dbe17fde9de6e7504d97c00877ac006b47..2058270d3503c03776082ce8367d8246e1fbae76 100644 --- a/interfaces/kits/native/ability/native/js_query_erms_observer.h +++ b/interfaces/kits/native/ability/native/js_query_erms_observer.h @@ -21,7 +21,7 @@ #include #include "native_engine/native_engine.h" -#include "query_erms_observer_stub.h" +#include "query_e_r_m_s_observer_stub.h" #include "js_runtime_utils.h" namespace OHOS { @@ -54,7 +54,7 @@ public: * @param rule The ERMS query result. * @param resultCode The result code. */ - void OnQueryFinished(const std::string &appId, const std::string &startTime, + ErrCode OnQueryFinished(const std::string &appId, const std::string &startTime, const AtomicServiceStartupRule &rule, int32_t resultCode) override; /** diff --git a/interfaces/kits/native/ability/native/query_erms_observer_proxy.h b/interfaces/kits/native/ability/native/query_erms_observer_proxy.h deleted file mode 100644 index 912301beeb90e734c860af10140353bf4020c523..0000000000000000000000000000000000000000 --- a/interfaces/kits/native/ability/native/query_erms_observer_proxy.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 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_QUERY_ERMS_OBSERVER_PROXY_H -#define OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_PROXY_H - -#include "query_erms_observer_interface.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AbilityRuntime { -/** - * @class QueryERMSObserverProxy - * IPC stub of IQueryERMSObserver. - */ -class QueryERMSObserverProxy : public IRemoteProxy { -public: - /** - * QueryERMSObserverProxy, constructor. - * - */ - explicit QueryERMSObserverProxy(const sptr &impl); - - /** - * QueryERMSObserverProxy, destructor. - * - */ - virtual ~QueryERMSObserverProxy() = default; - - /** - * OnQueryFinished, return free install result. - * - * @param appId Query ERMS app id. - * @param startTime Free install start request time. - * @param rule The ERMS query result. - * @param resultCode The result code. - */ - void OnQueryFinished(const std::string &appId, const std::string &startTime, - const AtomicServiceStartupRule &rule, int resultCode) override; - -private: - /** - * WriteInterfaceToken. - * - * @param data The message parcel data. - * @return Flag whether write is successful. - */ - bool WriteInterfaceToken(MessageParcel &data); - - static inline BrokerDelegator delegator_; -}; -} // namespace AbilityRuntime -} // namespace OHOS - -#endif // OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_PROXY_H \ No newline at end of file diff --git a/interfaces/kits/native/ability/native/query_erms_observer_stub.h b/interfaces/kits/native/ability/native/query_erms_observer_stub.h deleted file mode 100644 index 91b90e868fedd1f8b2721cfbd821f6add7b64d6c..0000000000000000000000000000000000000000 --- a/interfaces/kits/native/ability/native/query_erms_observer_stub.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 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_QUERY_ERMS_OBSERVER_STUB_H -#define OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_STUB_H - -#include - -#include "iremote_stub.h" -#include "query_erms_observer_interface.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AbilityRuntime { -/** - * @class QueryERMSObserverStub - * IPC stub of IQueryERMSObserver. - */ -class QueryERMSObserverStub : public IRemoteStub { -public: - /** - * QueryERMSObserverStub, constructor. - * - */ - QueryERMSObserverStub(); - - /** - * QueryERMSObserverStub, destructor. - * - */ - virtual ~QueryERMSObserverStub(); - - /** - * OnRemoteRequest, IPC method. - * - * @param code The IPC code. - * @param data The message parcel data. - * @param reply The message parcel reply. - * @param option The message parcel option. - * @return Error code of calling the function. - */ - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - DISALLOW_COPY_AND_MOVE(QueryERMSObserverStub); - - /** - * OnQueryFinishedInner, inner processing method for OnQueryFinished. - * - * @param data The message parcel data. - * @param reply The message parcel reply. - * @return Error code of calling the function. - */ - int OnQueryFinishedInner(MessageParcel &data, MessageParcel &reply); -}; -} // namespace AbilityRuntime -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_QUERY_ERMS_OBSERVER_STUB_H \ No newline at end of file diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index af8b5ab776e4cd7ae6d4871348f1cf10fc7f9e1a..7f656b6f29f241dce3a3e772933bbb3fa5850db3 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -119,6 +119,7 @@ ohos_shared_library("abilityms") { configs = [ ":abilityms_config", ":abilityms_exception_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", ] include_dirs = [ "${ability_runtime_services_path}/appdfr/include", @@ -129,6 +130,8 @@ ohos_shared_library("abilityms") { ":wantagent_manager", "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_proxy", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", @@ -307,6 +310,8 @@ ohos_shared_library("wantagent_manager") { "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", ] + configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config" ] + external_deps = [ "ability_base:want", "c_utils:utils", @@ -416,6 +421,8 @@ ohos_shared_library("mission_list") { "src/task_data_persistence_mgr.cpp", ] + configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config" ] + deps = [ ":abilityms", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", diff --git a/services/abilitymgr/src/prepare_terminate_callback_proxy.cpp b/services/abilitymgr/src/atomic_service_startup_rule.cpp similarity index 40% rename from services/abilitymgr/src/prepare_terminate_callback_proxy.cpp rename to services/abilitymgr/src/atomic_service_startup_rule.cpp index 85f1a665b7f7cba4efd47960d075ab630134b6b3..4732a9675faa36ee3602b4c7398c3e2d0b46ff24 100644 --- a/services/abilitymgr/src/prepare_terminate_callback_proxy.cpp +++ b/services/abilitymgr/src/atomic_service_startup_rule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * 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 @@ -13,31 +13,40 @@ * limitations under the License. */ -#include "prepare_terminate_callback_proxy.h" +#include "atomic_service_startup_rule.h" + +#include "nlohmann/json.hpp" +#include "string_ex.h" #include "hilog_tag_wrapper.h" +#include "parcel_macro_base.h" namespace OHOS { -namespace AAFwk { -void PrepareTerminateCallbackProxy::DoPrepareTerminate() +namespace AbilityRuntime { + +bool AtomicServiceStartupRule::ReadFromParcel(Parcel &parcel) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); - MessageParcel data; - if (!data.WriteInterfaceToken(IPrepareTerminateCallback::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return; - } - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote"); - return; - } - int error = remote->SendRequest(ON_DO_PREPARE_TERMINATE, data, reply, option); - if (error != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error); - } + isOpenAllowed = parcel.ReadBool(); + isEmbeddedAllowed = parcel.ReadBool(); + return true; } + +AtomicServiceStartupRule *AtomicServiceStartupRule::Unmarshalling(Parcel &parcel) +{ + AtomicServiceStartupRule *info = new (std::nothrow) AtomicServiceStartupRule(); + if (info && !info->ReadFromParcel(parcel)) { + TAG_LOGW(AAFwkTag::APPMGR, "read from parcel failed"); + delete info; + info = nullptr; + } + return info; } + +bool AtomicServiceStartupRule::Marshalling(Parcel &parcel) const +{ + parcel.WriteBool(isOpenAllowed); + parcel.WriteBool(isEmbeddedAllowed); + return true; } +} // namespace AbilityRuntime +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/prepare_terminate_callback_stub.cpp b/services/abilitymgr/src/prepare_terminate_callback_stub.cpp deleted file mode 100644 index 88ff8e278150b509e8c4f8b12d849e1b1db65e88..0000000000000000000000000000000000000000 --- a/services/abilitymgr/src/prepare_terminate_callback_stub.cpp +++ /dev/null @@ -1,52 +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 "prepare_terminate_callback_stub.h" -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AAFwk { - -PrepareTerminateCallbackStub::PrepareTerminateCallbackStub() {} - -PrepareTerminateCallbackStub::~PrepareTerminateCallbackStub() -{ - TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); -} - -int32_t PrepareTerminateCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (data.ReadInterfaceToken() != IPrepareTerminateCallback::GetDescriptor()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "InterfaceToken invalid"); - return ERR_INVALID_STATE; - } - - if (code == ON_DO_PREPARE_TERMINATE) { - return DoPrepareTerminateInner(data, reply); - } - - TAG_LOGW(AAFwkTag::ABILITYMGR, "default case, check"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t PrepareTerminateCallbackStub::DoPrepareTerminateInner(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); - DoPrepareTerminate(); - return ERR_OK; -} -} -} diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index ade83eb7a01b176365192a96036d9f218c33b6cb..b5d9da775e38efdf907fe810e0260b34b1931ad4 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -99,7 +99,10 @@ ohos_shared_library("libappms") { defines += [ "ABILITY_PLATFORM_CHECK_PERMISSION" ] } - configs = [ ":appmgr_config" ] + configs = [ + ":appmgr_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] diff --git a/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h b/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h index 1670a91eaedb0f6804dca984502cde200c1164fb..16b660ce1d0c41da49f95946a31a8d52953224a7 100644 --- a/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h +++ b/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h @@ -16,13 +16,13 @@ #ifndef PREPARE_TERMINATE_CALLBACK_H #define PREPARE_TERMINATE_CALLBACK_H -#include "iprepare_terminate_callback_interface.h" +#include "iprepare_terminate_callback.h" namespace OHOS { namespace AAFwk { class PrepareTerminateCallback : public IPrepareTerminateCallback { public: - MOCK_METHOD0(DoPrepareTerminate, void()); + MOCK_METHOD0(DoPrepareTerminate, ErrCode()); sptr AsObject() override { return {}; diff --git a/test/moduletest/ability_manager_client_test/mock_iqueryermsobserver.h b/test/moduletest/ability_manager_client_test/mock_iqueryermsobserver.h index b1d9cdf51817ddf0622519e8a96fc687a0bcf2cb..91dacbf9353dd5af7b1fd4585adee221c9cb1115 100644 --- a/test/moduletest/ability_manager_client_test/mock_iqueryermsobserver.h +++ b/test/moduletest/ability_manager_client_test/mock_iqueryermsobserver.h @@ -24,10 +24,10 @@ class IQueryERMSObserverMock : public IQueryERMSObserver { public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IQueryERMSObserver"); - void OnQueryFinished(const std::string &appId, const std::string &startTime, + ErrCode OnQueryFinished(const std::string &appId, const std::string &startTime, const AtomicServiceStartupRule &rule, int resultCode) { - return; + return ERR_OK; } sptr AsObject() { diff --git a/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp b/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp index 1d656bc8511ffb14ddb0b8c95f21332d40b64d23..ed6d11fc99c1b1ae4c969b95d7c848815c58eebf 100644 --- a/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp +++ b/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp @@ -103,6 +103,10 @@ class MockIPrepareTerminateCallback : public IPrepareTerminateCallback { public: MockIPrepareTerminateCallback() = default; virtual ~MockIPrepareTerminateCallback() = default; + ErrCode DoPrepareTerminate() override + { + return ERR_OK; + } sptr AsObject() override { return sptr(new IRemoteObjectMocker()); diff --git a/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp b/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp index 8492ec9fa5ade7b0ee9cd78df6315561388427ce..948f1a012872d1a1f64db8c81aa2b79142b9ce77 100644 --- a/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp +++ b/test/unittest/ability_manager_proxy_sixth_test/ability_manager_proxy_sixth_test.cpp @@ -37,9 +37,11 @@ namespace AAFwk { class MockIQueryERMSObserver : public AbilityRuntime::IQueryERMSObserver { public: - void OnQueryFinished(const std::string &appId, const std::string &startTime, + ErrCode OnQueryFinished(const std::string &appId, const std::string &startTime, const AtomicServiceStartupRule &rule, int resultCode) - {} + { + return ERR_OK; + } sptr AsObject() { return token_; @@ -51,7 +53,7 @@ class MockIHiddenStartObserver : public IHiddenStartObserver { public: bool IsHiddenStart(int32_t pid) { - return false; + return true; } sptr AsObject() { diff --git a/test/unittest/ability_manager_proxy_third_test/ability_manager_proxy_third_test.cpp b/test/unittest/ability_manager_proxy_third_test/ability_manager_proxy_third_test.cpp index 1a48b715b980fb73a1db49f66451261b340bb302..8cc3a73e98faf6102e9990a74d07d1e747a17ed2 100644 --- a/test/unittest/ability_manager_proxy_third_test/ability_manager_proxy_third_test.cpp +++ b/test/unittest/ability_manager_proxy_third_test/ability_manager_proxy_third_test.cpp @@ -126,7 +126,7 @@ public: class MockIPrepareTerminateCallback : public IPrepareTerminateCallback { public: - void DoPrepareTerminate() override {}; + ErrCode DoPrepareTerminate() override { return ERR_OK; }; sptr AsObject() override { return iremoteObject_; diff --git a/test/unittest/ability_manager_service_ninth_test/ability_manager_service_ninth_test.cpp b/test/unittest/ability_manager_service_ninth_test/ability_manager_service_ninth_test.cpp index a49aa8c74e7d5b20478366022a256120038b3dd8..698fe94f5338129b5986e0f6f10a17bd91622e27 100644 --- a/test/unittest/ability_manager_service_ninth_test/ability_manager_service_ninth_test.cpp +++ b/test/unittest/ability_manager_service_ninth_test/ability_manager_service_ninth_test.cpp @@ -68,7 +68,7 @@ class MockIPrepareTerminateCallback : public IPrepareTerminateCallback { public: MockIPrepareTerminateCallback() {}; virtual ~MockIPrepareTerminateCallback() {}; - void DoPrepareTerminate() override {}; + ErrCode DoPrepareTerminate() override { return ERR_OK; }; sptr AsObject() override { return {}; diff --git a/test/unittest/query_erms_manager_test/mock/mockquery_erms_observer_manager.cpp b/test/unittest/query_erms_manager_test/mock/mockquery_erms_observer_manager.cpp index cc52db4832d8ef7a88b1df3c53e6fa00d487b7d5..870eac5f6642d1dc4612a8f21512463ca12f98b5 100644 --- a/test/unittest/query_erms_manager_test/mock/mockquery_erms_observer_manager.cpp +++ b/test/unittest/query_erms_manager_test/mock/mockquery_erms_observer_manager.cpp @@ -24,8 +24,11 @@ namespace AAFwk { // Mock class for QueryERMSObserver class MockQueryERMSObserver : public IQueryERMSObserver { public: - void OnQueryFinished(const std::string &appId, const std::string &startTime, - const AbilityRuntime::AtomicServiceStartupRule &rule, int resultCode) override {} + ErrCode OnQueryFinished(const std::string &appId, const std::string &startTime, + const AbilityRuntime::AtomicServiceStartupRule &rule, int resultCode) override + { + return ERR_OK; + } sptr AsObject() override { return nullptr; } }; diff --git a/test/unittest/query_erms_observer_manager_test/query_erms_observer_manager_test.cpp b/test/unittest/query_erms_observer_manager_test/query_erms_observer_manager_test.cpp index 17e05439f708ae454375af600592ec8782d679c3..3c0c9c18ed20675048156c3187004df0707393d8 100644 --- a/test/unittest/query_erms_observer_manager_test/query_erms_observer_manager_test.cpp +++ b/test/unittest/query_erms_observer_manager_test/query_erms_observer_manager_test.cpp @@ -80,10 +80,10 @@ class IQueryERMSObserverMock : public IQueryERMSObserver { public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IQueryERMSObserver"); - void OnQueryFinished(const std::string &appId, const std::string &startTime, + ErrCode OnQueryFinished(const std::string &appId, const std::string &startTime, const AtomicServiceStartupRule &rule, int resultCode) { - return; + return ERR_OK; } sptr AsObject() { diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index 45ca82c63105416d77ab5fdd25320b54ce075741..04d456218e025db6308f77d6a1c1383e496028b4 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -94,7 +94,9 @@ ohos_executable("aa") { if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - + public_configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] deps = [ ":tools_aa_source_set" ] external_deps = [ diff --git a/tools/test/moduletest/aa/BUILD.gn b/tools/test/moduletest/aa/BUILD.gn index 34b448d6d51ef9882b2e3b6148858179a0a3c40b..3ffdb1b42b4feef790e3045b86a65f49ce214e3f 100644 --- a/tools/test/moduletest/aa/BUILD.gn +++ b/tools/test/moduletest/aa/BUILD.gn @@ -29,7 +29,10 @@ ohos_moduletest("aa_command_dumpsys_module_test") { sources = [ "aa_command_dumpsys_module_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -58,7 +61,10 @@ ohos_moduletest("aa_command_start_module_test") { sources = [ "aa_command_start_module_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -86,7 +92,10 @@ ohos_moduletest("aa_command_stop_service_module_test") { sources = [ "aa_command_stop_service_module_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -114,7 +123,10 @@ ohos_moduletest("aa_command_dump_module_test") { sources = [ "aa_command_dump_module_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { diff --git a/tools/test/moduletest/ability_delegator/BUILD.gn b/tools/test/moduletest/ability_delegator/BUILD.gn index 872901063e0d85c830c5d924d25413d21668694e..d6a35278a86651defe5af55abb3b9d6737988276 100644 --- a/tools/test/moduletest/ability_delegator/BUILD.gn +++ b/tools/test/moduletest/ability_delegator/BUILD.gn @@ -29,7 +29,10 @@ config("tools_ability_delegator_config") { ohos_moduletest("ability_command_module_test") { module_out_path = module_output_path - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] sources = [ "ability_command_module_test.cpp" ] sources += ability_delegator_mock_sources @@ -52,7 +55,10 @@ ohos_moduletest("ability_command_module_test") { ohos_moduletest("test_observer_module_test") { module_out_path = module_output_path - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] sources = [ "test_observer_module_test.cpp" ] sources += ability_delegator_mock_sources @@ -77,7 +83,10 @@ ohos_moduletest("shell_command_result_module_test") { sources = [ "shell_command_result_module_test.cpp" ] - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] diff --git a/tools/test/systemtest/aa/BUILD.gn b/tools/test/systemtest/aa/BUILD.gn index 5fb4b5be113d64d06de46b1b63c5bc7e194a7a54..13741645f13c2da92867f770d297eff347a3297e 100644 --- a/tools/test/systemtest/aa/BUILD.gn +++ b/tools/test/systemtest/aa/BUILD.gn @@ -28,7 +28,10 @@ ohos_systemtest("aa_command_start_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ + ":tools_aa_test_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -61,7 +64,10 @@ ohos_systemtest("aa_command_stop_service_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ + ":tools_aa_test_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -93,7 +99,10 @@ ohos_systemtest("aa_command_dump_system_test") { "tool_system_test.cpp", ] - configs = [ ":tools_aa_test_config" ] + configs = [ + ":tools_aa_test_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { diff --git a/tools/test/unittest/aa/BUILD.gn b/tools/test/unittest/aa/BUILD.gn index 99ef92ecb1c1fc3789c6f9bc62e0a7f679d1613d..621ae40396abc82dd0c69a35234b63ccb72ca869 100644 --- a/tools/test/unittest/aa/BUILD.gn +++ b/tools/test/unittest/aa/BUILD.gn @@ -29,7 +29,10 @@ ohos_unittest("aa_command_test") { sources = [ "aa_command_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -57,7 +60,10 @@ ohos_unittest("aa_command_ability_first_test") { sources = [ "aa_command_ability_first_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -85,7 +91,10 @@ ohos_unittest("aa_command_start_test") { sources = [ "aa_command_start_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -113,7 +122,10 @@ ohos_unittest("aa_command_stop_service_test") { sources = [ "aa_command_stop_service_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -141,7 +153,10 @@ ohos_unittest("aa_command_dump_test") { sources = [ "aa_command_dump_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -169,7 +184,10 @@ ohos_unittest("aa_command_dumpsys_test") { sources = [ "aa_command_dumpsys_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -197,7 +215,10 @@ ohos_unittest("aa_command_force_stop_test") { sources = [ "aa_command_force_stop_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -225,7 +246,10 @@ ohos_unittest("aa_command_force_timeout_test") { sources = [ "aa_command_force_timeout_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -253,7 +277,10 @@ ohos_unittest("aa_command_test_test") { sources = [ "aa_command_test_test.cpp" ] sources += tools_aa_mock_sources - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -280,7 +307,10 @@ ohos_unittest("aa_command_attach_test") { sources = [ "aa_command_attach_test.cpp" ] - configs = [ ":tools_aa_config_mock" ] + configs = [ + ":tools_aa_config_mock", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { @@ -308,6 +338,10 @@ if (accessibility_enable) { "accessibility_ability_utils_test.cpp", ] + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] + cflags = [] if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] diff --git a/tools/test/unittest/aa/aa_command_force_timeout_test.cpp b/tools/test/unittest/aa/aa_command_force_timeout_test.cpp index 0258bf72b5c6a5a8002a2462d1c1d8a4e7bad715..cf7bad6e2cadcfa96e81f2c73ab5739dfdb83688 100644 --- a/tools/test/unittest/aa/aa_command_force_timeout_test.cpp +++ b/tools/test/unittest/aa/aa_command_force_timeout_test.cpp @@ -147,9 +147,11 @@ HWTEST_F(AaCommandForceTimeOut, Aa_Command_Force_Timeout_0400, Function | Medium auto managerClientPtr = AbilityManagerClient::GetInstance(); auto mockAbilityManagerStub = sptr(new MockAbilityManagerStub()); ASSERT_NE(mockAbilityManagerStub, nullptr); +#ifdef ABILITY_COMMAND_FOR_TEST EXPECT_CALL(*mockAbilityManagerStub, ForceTimeoutForTest(_, _)) .Times(1) .WillOnce(Return(-1)); +#endif managerClientPtr->proxy_ = static_cast(mockAbilityManagerStub); EXPECT_EQ(cmd.ExecCommand(), STRING_FORCE_TIMEOUT_NG + "\n"); @@ -175,9 +177,11 @@ HWTEST_F(AaCommandForceTimeOut, Aa_Command_Force_Timeout_0500, Function | Medium auto managerClientPtr = AbilityManagerClient::GetInstance(); auto mockAbilityManagerStub = sptr(new MockAbilityManagerStub()); ASSERT_NE(mockAbilityManagerStub, nullptr); +#ifdef ABILITY_COMMAND_FOR_TEST EXPECT_CALL(*mockAbilityManagerStub, ForceTimeoutForTest(_, _)) .Times(1) .WillOnce(Return(0)); +#endif managerClientPtr->proxy_ = static_cast(mockAbilityManagerStub); EXPECT_EQ(cmd.ExecCommand(), STRING_FORCE_TIMEOUT_OK + "\n"); diff --git a/tools/test/unittest/ability_delegator/BUILD.gn b/tools/test/unittest/ability_delegator/BUILD.gn index 431e8bd2458df134e79c9f3256b99d29d5dbf4b5..726aade007f939a34864d885e3b6ccdd29aff60e 100644 --- a/tools/test/unittest/ability_delegator/BUILD.gn +++ b/tools/test/unittest/ability_delegator/BUILD.gn @@ -29,7 +29,10 @@ config("tools_ability_delegator_config") { ohos_unittest("ability_command_test") { module_out_path = module_output_path - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] sources = [ "ability_command_test.cpp" ] sources += ability_delegator_mock_sources @@ -52,7 +55,10 @@ ohos_unittest("ability_command_test") { ohos_unittest("ability_command_second_test") { module_out_path = module_output_path - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] sources = [ "ability_command_second_test.cpp" ] sources += ability_delegator_mock_sources @@ -80,7 +86,10 @@ ohos_unittest("ability_command_second_test") { ohos_unittest("test_observer_test") { module_out_path = module_output_path - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] sources = [ "test_observer_test.cpp" ] sources += ability_delegator_mock_sources @@ -138,7 +147,10 @@ ohos_unittest("shell_command_result_test") { sources = [ "shell_command_result_test.cpp" ] - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] @@ -159,7 +171,10 @@ if (accessibility_enable) { sources = [ "shell_command_executor_test.cpp" ] - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] @@ -183,7 +198,10 @@ if (accessibility_enable) { include_dirs = [] - configs = [ ":tools_ability_delegator_config" ] + configs = [ + ":tools_ability_delegator_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] sources = [ "${ability_runtime_path}/tools/aa/src/accessibility_ability_command.cpp", diff --git a/tools/test/unittest/ability_tool/BUILD.gn b/tools/test/unittest/ability_tool/BUILD.gn index 836b7e558d0a95502d0e3acc0a83ed9164ba18f6..deef37f3152c79741cc8a3942d08cee44dbfdee6 100644 --- a/tools/test/unittest/ability_tool/BUILD.gn +++ b/tools/test/unittest/ability_tool/BUILD.gn @@ -29,7 +29,10 @@ ohos_unittest("ability_tool_test") { sources = [ "ability_tool_test.cpp" ] sources += test_ability_tool_mock_sources - configs = [ ":test_ability_tool_config" ] + configs = [ + ":test_ability_tool_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") {