From d2f0618a64072fa2d0df47ad7cc5f80a94748baf Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Thu, 29 May 2025 16:07:05 +0800 Subject: [PATCH 1/6] clm2025-IHiddenStartObserver Signed-off-by: 18795846185 Change-Id: Ic53d2497c2d5d95e1e31a8ce6b664cb31b4570aa --- .../js_embeddable_ui_ability_context.cpp | 4 - interfaces/inner_api/ability_manager/BUILD.gn | 195 +++++++++++++++++- ...rt_observer.h => IHiddenStartObserver.idl} | 61 ++---- .../include/hidden_start_observer_proxy.h | 50 ----- .../include/hidden_start_observer_stub.h | 45 ---- .../src/hidden_start_observer_proxy.cpp | 69 ------- .../src/hidden_start_observer_stub.cpp | 49 ----- interfaces/inner_api/wantagent/BUILD.gn | 5 +- services/abilitymgr/BUILD.gn | 3 + .../src/hidden_start_observer_manager.cpp | 4 +- .../mock_ihiddenstartobserver.h | 4 +- .../ability_manager_proxy_sixth_test.cpp | 4 +- .../BUILD.gn | 10 +- .../hidden_start_observer_manager_test.cpp | 2 +- .../ui_extension_context_test/BUILD.gn | 1 + .../ui_extension_context_test.cpp | 90 ++++++++ 16 files changed, 324 insertions(+), 272 deletions(-) rename interfaces/inner_api/ability_manager/{include/ihidden_start_observer.h => IHiddenStartObserver.idl} (44%) delete mode 100644 interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h delete mode 100644 interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h delete mode 100644 interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp delete mode 100644 interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp diff --git a/frameworks/native/ability/native/ui_extension_ability/js_embeddable_ui_ability_context.cpp b/frameworks/native/ability/native/ui_extension_ability/js_embeddable_ui_ability_context.cpp index 4c057d7752d..f846cc4dda4 100644 --- a/frameworks/native/ability/native/ui_extension_ability/js_embeddable_ui_ability_context.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_embeddable_ui_ability_context.cpp @@ -567,7 +567,6 @@ napi_value JsEmbeddableUIAbilityContext::OnSetRestoreEnabled(napi_env env, NapiC napi_value JsEmbeddableUIAbilityContext::OnSetColorMode(napi_env env, NapiCallbackInfo& info) { if (IsEmbeddableStart(screenMode_)) { - TAG_LOGE(AAFwkTag::UI_EXT, "OnSetColorMode in half screen mode"); CHECK_POINTER_RETURN(env, jsUIExtensionContext_); return jsUIExtensionContext_->OnSetColorMode(env, info); } @@ -578,7 +577,6 @@ napi_value JsEmbeddableUIAbilityContext::OnSetColorMode(napi_env env, NapiCallba napi_value JsEmbeddableUIAbilityContext::OnStartUIServiceExtension(napi_env env, NapiCallbackInfo& info) { if (IsEmbeddableStart(screenMode_)) { - TAG_LOGE(AAFwkTag::UI_EXT, "OnStartUIServiceExtension in half screen mode"); CHECK_POINTER_RETURN(env, jsUIExtensionContext_); return jsUIExtensionContext_->OnStartUIServiceExtension(env, info); } @@ -589,7 +587,6 @@ napi_value JsEmbeddableUIAbilityContext::OnStartUIServiceExtension(napi_env env, napi_value JsEmbeddableUIAbilityContext::OnConnectUIServiceExtension(napi_env env, NapiCallbackInfo& info) { if (IsEmbeddableStart(screenMode_)) { - TAG_LOGE(AAFwkTag::UI_EXT, "OnConnectUIServiceExtension in half screen mode"); CHECK_POINTER_RETURN(env, jsUIExtensionContext_); return jsUIExtensionContext_->OnConnectUIServiceExtension(env, info); } @@ -600,7 +597,6 @@ napi_value JsEmbeddableUIAbilityContext::OnConnectUIServiceExtension(napi_env en napi_value JsEmbeddableUIAbilityContext::OnDisconnectUIServiceExtension(napi_env env, NapiCallbackInfo& info) { if (IsEmbeddableStart(screenMode_)) { - TAG_LOGE(AAFwkTag::UI_EXT, "OnConnectUIServiceExtension in half screen mode"); CHECK_POINTER_RETURN(env, jsUIExtensionContext_); return jsUIExtensionContext_->OnDisconnectUIServiceExtension(env, info); } diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 0c0c0c6e71d..3edbd459510 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -11,8 +11,29 @@ # 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 = [ + "IHiddenStartObserver.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 +60,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,10 +83,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 = [ + "*hidden_start_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 = [ + "*hidden_start_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" - sources = [ "${ability_runtime_native_path}/ability/native/data_ability_operation.cpp", "${ability_runtime_native_path}/ability/native/data_ability_operation_builder.cpp", @@ -107,8 +293,6 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/user_callback_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/user_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/window_config.cpp", - "src/hidden_start_observer_proxy.cpp", - "src/hidden_start_observer_stub.cpp", "src/status_bar_delegate/status_bar_delegate_proxy.cpp", "src/status_bar_delegate/status_bar_delegate_stub.cpp", "src/window_manager_service_handler_proxy.cpp", @@ -125,6 +309,7 @@ ohos_shared_library("ability_manager") { public_configs = [ ":ability_manager_public_config", + ":ability_manager_idl_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", ] @@ -133,6 +318,8 @@ ohos_shared_library("ability_manager") { deps = [ ":ability_start_options", ":ability_start_setting", + ":ability_manager_proxy", + ":ability_manager_stub", ":mission_info", ":process_options", ":start_window_option", @@ -419,6 +606,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/ihidden_start_observer.h b/interfaces/inner_api/ability_manager/IHiddenStartObserver.idl similarity index 44% rename from interfaces/inner_api/ability_manager/include/ihidden_start_observer.h rename to interfaces/inner_api/ability_manager/IHiddenStartObserver.idl index 663f58c3024..8afe667d8c6 100644 --- a/interfaces/inner_api/ability_manager/include/ihidden_start_observer.h +++ b/interfaces/inner_api/ability_manager/IHiddenStartObserver.idl @@ -1,43 +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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_IHIDDEN_START_OBSERVER_H -#define OHOS_ABILITY_RUNTIME_IHIDDEN_START_OBSERVER_H - -#include -#include "iremote_object.h" -#include "iremote_broker.h" - -namespace OHOS { -namespace AAFwk { -class IHiddenStartObserver : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IHiddenStartObserver"); - - /** - * IsHiddenStart, return if the given app is started hidden. - * - * @param pid Pid of the given app's process. - * @return if the given app is started hidden - */ - virtual bool IsHiddenStart(int32_t pid) = 0; - - enum class Message { - TRANSACT_ON_IS_HIDDEN_START = 0, - }; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_IHIDDEN_START_OBSERVER_H \ No newline at end of file +/* + * 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/hidden_start_observer_proxy.h b/interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h deleted file mode 100644 index 40b0b2a0743..00000000000 --- a/interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_PROXY_H -#define OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_PROXY_H - -#include "iremote_proxy.h" -#include "ihidden_start_observer.h" - -namespace OHOS { -namespace AAFwk { -class HiddenStartObserverProxy : public IRemoteProxy { -public: - explicit HiddenStartObserverProxy(const sptr &impl); - virtual ~HiddenStartObserverProxy() = default; - - /** - * IsHiddenStart, return if the given app is started hidden. - * - * @param pid Pid of the given app's process. - * @return if the given app is started hidden - */ - virtual bool IsHiddenStart(int32_t pid) override; - -private: - /** - * WriteInterfaceToken. - * - * @param data The message parcel data. - * @return Flag whether write is successful. - */ - bool WriteInterfaceToken(MessageParcel &data); - static inline BrokerDelegator delegator_; - int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_PROXY_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h b/interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h deleted file mode 100644 index cf7a8678659..00000000000 --- a/interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ - -#ifndef OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_STUB_H -#define OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_STUB_H - -#include -#include - -#include "iremote_stub.h" -#include "nocopyable.h" -#include "string_ex.h" -#include "app_mgr_constants.h" -#include "ihidden_start_observer.h" - -namespace OHOS { -namespace AAFwk { -class HiddenStartObserverStub : public IRemoteStub { -public: - HiddenStartObserverStub() = default; - virtual ~HiddenStartObserverStub() = default; - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int32_t HandleIsHiddenStart(MessageParcel &data, MessageParcel &reply); - - DISALLOW_COPY_AND_MOVE(HiddenStartObserverStub); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_STUB_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp b/interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp deleted file mode 100644 index 7f76a178ba9..00000000000 --- a/interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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. - */ - -#include "hidden_start_observer_proxy.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" - - -namespace OHOS { -namespace AAFwk { -HiddenStartObserverProxy::HiddenStartObserverProxy( - const sptr &impl) : IRemoteProxy(impl) -{} - -bool HiddenStartObserverProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(HiddenStartObserverProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return false; - } - return true; -} - -bool HiddenStartObserverProxy::IsHiddenStart(int32_t pid) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "WriteInterfaceToken failed"); - return false; - } - data.WriteInt32(pid); - int32_t ret = SendTransactCmd( - static_cast(IHiddenStartObserver::Message::TRANSACT_ON_IS_HIDDEN_START), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGW(AAFwkTag::ABILITYMGR, "SendRequest is failed, error code: %{public}d.", ret); - return false; - } - return reply.ReadBool(); -} - -int32_t HiddenStartObserverProxy::SendTransactCmd(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote is nullptr."); - return ERR_NULL_OBJECT; - } - - return remote->SendRequest(code, data, reply, option); -} -} // namespace AAFwk -} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp b/interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp deleted file mode 100644 index 0b47d6ff5a4..00000000000 --- a/interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -#include "hidden_start_observer_stub.h" -#include "appexecfwk_errors.h" -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AAFwk { -int HiddenStartObserverStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string descriptor = HiddenStartObserverStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "local descriptor is not equal to remote."); - return ERR_INVALID_STATE; - } - - if (static_cast(code) == Message::TRANSACT_ON_IS_HIDDEN_START) { - return HandleIsHiddenStart(data, reply); - } - TAG_LOGW(AAFwkTag::ABILITYMGR, "HiddenStartObserverStub::OnRemoteRequest, default case, need check"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t HiddenStartObserverStub::HandleIsHiddenStart(MessageParcel &data, MessageParcel &reply) -{ - int32_t pid = data.ReadInt32(); - bool result = IsHiddenStart(pid); - reply.WriteBool(result); - return NO_ERROR; -} -} // namespace AAFwk -} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index a9f3008821c..ef7c8e71d29 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -64,7 +64,10 @@ 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_start_options", diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index af8b5ab776e..50346645058 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", @@ -131,6 +132,8 @@ ohos_shared_library("abilityms") { "${ability_runtime_innerkits_path}/ability_manager:ability_manager", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_proxy", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_stub", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/ability_manager:process_options", "${ability_runtime_innerkits_path}/ability_manager:start_window_option", diff --git a/services/abilitymgr/src/hidden_start_observer_manager.cpp b/services/abilitymgr/src/hidden_start_observer_manager.cpp index 134d481d65a..155f17c67b2 100644 --- a/services/abilitymgr/src/hidden_start_observer_manager.cpp +++ b/services/abilitymgr/src/hidden_start_observer_manager.cpp @@ -98,11 +98,13 @@ bool HiddenStartObserverManager::IsHiddenStart(int32_t pid) HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto observersCopy = GetObserversCopy(); TAG_LOGE(AAFwkTag::ABILITYMGR, "Need query %{public}zu observers.", observersCopy.size()); + bool funcResult = false; for (auto it = observersCopy.begin(); it != observersCopy.end(); ++it) { if (*it == nullptr) { continue; } - if ((*it)->IsHiddenStart(pid)) { + (*it)->IsHiddenStart(pid, funcResult); + if (funcResult) { return true; } } diff --git a/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h b/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h index 7e83a7fb17b..01b57ba88a8 100644 --- a/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h +++ b/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h @@ -21,9 +21,9 @@ namespace OHOS { namespace AAFwk { class MockIHiddenStartObserver : public IHiddenStartObserver { public: - bool IsHiddenStart(int32_t pid) override + ErrCode IsHiddenStart(int32_t pid, bool& funcResult) override { - return true; + return ERR_OK; } sptr AsObject() override { 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 8492ec9fa5a..c1a47f02856 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 @@ -49,9 +49,9 @@ public: class MockIHiddenStartObserver : public IHiddenStartObserver { public: - bool IsHiddenStart(int32_t pid) + OHOS::ErrCode IsHiddenStart(int32_t pid, bool& funcResult) { - return false; + return ERR_OK; } sptr AsObject() { diff --git a/test/unittest/hidden_start_observer_manager_test/BUILD.gn b/test/unittest/hidden_start_observer_manager_test/BUILD.gn index 9403ccd18e1..0fbcaa021ed 100644 --- a/test/unittest/hidden_start_observer_manager_test/BUILD.gn +++ b/test/unittest/hidden_start_observer_manager_test/BUILD.gn @@ -25,14 +25,20 @@ ohos_unittest("hidden_start_observer_manager_test") { } module_out_path = module_output_path - include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/include" ] + include_dirs = [ + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/include", + "${target_gen_dir}", + ] sources = [ "hidden_start_observer_manager_test.cpp", "${ability_runtime_services_path}/abilitymgr/src/hidden_start_observer_manager.cpp", ] - configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] deps = [ "${ability_runtime_innerkits_path}/app_manager:app_manager", diff --git a/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp b/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp index c09db615b7a..27cba015b2f 100644 --- a/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp +++ b/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp @@ -72,7 +72,7 @@ public: IHiddenStartObserverMock() = default; virtual ~IHiddenStartObserverMock() = default; - bool IsHiddenStart(int32_t pid) override + ErrCode IsHiddenStart(int32_t pid, bool& funcResult) override { return mockReturnValue; } diff --git a/test/unittest/ui_extension_context_test/BUILD.gn b/test/unittest/ui_extension_context_test/BUILD.gn index 29c903dc6cd..b79abe1726a 100644 --- a/test/unittest/ui_extension_context_test/BUILD.gn +++ b/test/unittest/ui_extension_context_test/BUILD.gn @@ -40,6 +40,7 @@ ohos_unittest("ui_extension_context_test") { "${ability_runtime_native_path}/ability/native:ui_extension", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_native", + "${ability_runtime_native_path}/ability:ability_context_native", ] external_deps = [ diff --git a/test/unittest/ui_extension_context_test/ui_extension_context_test.cpp b/test/unittest/ui_extension_context_test/ui_extension_context_test.cpp index 607a4ce3d47..9fe7f53bbd2 100644 --- a/test/unittest/ui_extension_context_test/ui_extension_context_test.cpp +++ b/test/unittest/ui_extension_context_test/ui_extension_context_test.cpp @@ -700,5 +700,95 @@ HWTEST_F(UIExtensionContextTest, RequestComponentTerminate_0200, TestSize.Level1 context->SetWindow(window); context->RequestComponentTerminate(); } + +/** + * @tc.number: StartAbilityByType_0100 + * @tc.name: UIExtensionContext StartAbilityByType + * @tc.desc: UIExtensionContext StartAbilityByType. + */ +HWTEST_F(UIExtensionContextTest, StartAbilityByType_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0100 start"); + + std::string type; + AAFwk::WantParams wantParam; + std::shared_ptr uiExtensionCallbacks{nullptr}; + + auto context = std::make_shared(); + auto result = context->StartAbilityByType(type, wantParam, uiExtensionCallbacks); + EXPECT_EQ(result, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0100 end"); +} + + /** + * @tc.number: StartAbilityByType_0200 + * @tc.name: UIExtensionContext StartAbilityByType + * @tc.desc: UIExtensionContext StartAbilityByType. + */ +HWTEST_F(UIExtensionContextTest, StartAbilityByType_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0200 start"); + + std::string type; + AAFwk::WantParams wantParam; + napi_env env; + std::shared_ptr uiExtensionCallbacks = std::make_shared(env); + + auto context = std::make_shared(); + context->SetWindow(nullptr); + auto result = context->StartAbilityByType(type, wantParam, uiExtensionCallbacks); + EXPECT_EQ(result, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0200 end"); +} + + /** + * @tc.number: StartAbilityByType_0300 + * @tc.name: UIExtensionContext StartAbilityByType + * @tc.desc: UIExtensionContext StartAbilityByType. + */ +HWTEST_F(UIExtensionContextTest, StartAbilityByType_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0300 start"); + + std::string type; + AAFwk::WantParams wantParam; + napi_env env; + std::shared_ptr uiExtensionCallbacks = std::make_shared(env); + sptr window = new MockWindow(); + + auto context = std::make_shared(); + context->SetWindow(window); + auto result = context->StartAbilityByType(type, wantParam, uiExtensionCallbacks); + EXPECT_EQ(result, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0300 end"); +} + + /** + * @tc.number: StartAbilityByType_0400 + * @tc.name: UIExtensionContext StartAbilityByType + * @tc.desc: UIExtensionContext StartAbilityByType. + */ +HWTEST_F(UIExtensionContextTest, StartAbilityByType_0400, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0400 start"); + + std::string type; + AAFwk::WantParams wantParam; + const std::string FLAG_AUTH_READ_URI_PERMISSION = "ability.want.params.uriPermissionFlag"; + wantParam.SetParam(FLAG_AUTH_READ_URI_PERMISSION, 0); + napi_env env; + std::shared_ptr uiExtensionCallbacks = std::make_shared(env); + sptr window = new MockWindow(); + + auto context = std::make_shared(); + context->SetWindow(window); + auto result = context->StartAbilityByType(type, wantParam, uiExtensionCallbacks); + EXPECT_EQ(result, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "StartAbilityByType_0400 end"); +} } // namespace AbilityRuntime } // namespace OHOS -- Gitee From 1dc2ea245c612b6fe4dd07df6c5d1dfe8fb9c953 Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Thu, 29 May 2025 19:52:42 +0800 Subject: [PATCH 2/6] temp2 Signed-off-by: 18795846185 Change-Id: Ib02a3227872c3b3691d8b59c5c8c4028b779fcbe --- interfaces/inner_api/ability_manager/BUILD.gn | 2 +- interfaces/inner_api/wantagent/BUILD.gn | 2 +- tools/aa/BUILD.gn | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 3edbd459510..5ca74beb9c5 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -31,7 +31,7 @@ config("ability_manager_idl_config") { include_dirs = [ "${ability_runtime_innerkits_path}/dataobs_manager/include", "${target_gen_dir}", - "include/", + #"include/", ] } diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index ef7c8e71d29..b501ae1fe0a 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -64,7 +64,7 @@ ohos_shared_library("wantagent_innerkits") { "src/want_agent_info.cpp", ] - public_configs = [ + public_configs = [ ":wantagent_innerkits_public_config", "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", ] diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index 45ca82c6310..ea7ab914626 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -95,6 +95,10 @@ ohos_executable("aa") { cflags += [ "-DBINDER_IPC_32BIT" ] } + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] + deps = [ ":tools_aa_source_set" ] external_deps = [ -- Gitee From 9ce5f32730cfe693bd98c5fed4a00f731fc66351 Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Fri, 30 May 2025 14:38:27 +0800 Subject: [PATCH 3/6] clm2025528-IHiddenStartObserver Signed-off-by: 18795846185 Change-Id: I78bd6e6c3f71ee022234b4b412bcb5c627f58830 --- frameworks/native/ability/native/BUILD.gn | 3 +++ interfaces/inner_api/ability_manager/BUILD.gn | 4 ++-- interfaces/inner_api/app_manager/BUILD.gn | 2 ++ interfaces/inner_api/extension_manager/BUILD.gn | 11 ++++++++++- interfaces/inner_api/wantagent/BUILD.gn | 3 +++ services/abilitymgr/BUILD.gn | 6 ++++++ services/appmgr/BUILD.gn | 5 ++++- .../hidden_start_observer_manager_test.cpp | 2 +- 8 files changed, 31 insertions(+), 5 deletions(-) diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index daafb4b1ac5..da31aacbbfd 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -302,6 +302,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 +314,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", diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 5ca74beb9c5..dc8fac09e7b 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -316,10 +316,10 @@ ohos_shared_library("ability_manager") { public_deps = [ ":ability_connect_callback_stub" ] deps = [ - ":ability_start_options", - ":ability_start_setting", ":ability_manager_proxy", ":ability_manager_stub", + ":ability_start_options", + ":ability_start_setting", ":mission_info", ":process_options", ":start_window_option", diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 99c5ec887c5..5b9b1c81904 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 2a0d85fb821..bb2caa0f8ff 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 b501ae1fe0a..0f39f91c107 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -70,6 +70,7 @@ ohos_shared_library("wantagent_innerkits") { ] 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", @@ -95,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/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 50346645058..1d05fb27ae0 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -130,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:ability_manager_proxy", @@ -310,6 +312,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", @@ -419,6 +423,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/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index ade83eb7a01..b5d9da775e3 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/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp b/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp index 27cba015b2f..2bd94cf213e 100644 --- a/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp +++ b/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp @@ -74,7 +74,7 @@ public: ErrCode IsHiddenStart(int32_t pid, bool& funcResult) override { - return mockReturnValue; + return funcResult = mockReturnValue; } sptr AsObject() override -- Gitee From b80625f880c0b743b38e1411ad59e431bee56d7a Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Sun, 1 Jun 2025 12:20:26 +0800 Subject: [PATCH 4/6] clm2025-IRemoteMissionListener Signed-off-by: 18795846185 Change-Id: I8382bb79aee5bf7e3d8c4e9399886baa33b72b41 --- interfaces/inner_api/ability_manager/BUILD.gn | 8 ++- .../include/hidden_start_observer_proxy.h | 50 ++++++++++++++ .../include/hidden_start_observer_stub.h | 45 ++++++++++++ .../ihidden_start_observer.h} | 61 +++++++++++----- .../src/hidden_start_observer_proxy.cpp | 69 +++++++++++++++++++ .../src/hidden_start_observer_stub.cpp | 49 +++++++++++++ .../src/hidden_start_observer_manager.cpp | 4 +- .../mock_ihiddenstartobserver.h | 4 +- .../ability_manager_proxy_sixth_test.cpp | 4 +- .../hidden_start_observer_manager_test.cpp | 4 +- 10 files changed, 268 insertions(+), 30 deletions(-) create mode 100644 interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h create mode 100644 interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h rename interfaces/inner_api/ability_manager/{IHiddenStartObserver.idl => include/ihidden_start_observer.h} (44%) create mode 100644 interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp create mode 100644 interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index dc8fac09e7b..484dd4a28b1 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -16,7 +16,7 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") idl_gen_interface("ability_manager_interface") { sources = [ - "IHiddenStartObserver.idl" + ] sources_common = [ @@ -92,7 +92,7 @@ ohos_source_set("ability_manager_proxy") { output_values = get_target_outputs(":ability_manager_interface") source_values = [ - "*hidden_start_observer_proxy.cpp", + #"*hidden_start_observer_proxy.cpp", ] sources = filter_include(output_values, source_values) @@ -172,7 +172,7 @@ ohos_source_set("ability_manager_stub") { output_values = get_target_outputs(":ability_manager_interface") source_values = [ - "*hidden_start_observer_stub.cpp", + #"*hidden_start_observer_stub.cpp", ] sources = filter_include(output_values, source_values) @@ -293,6 +293,8 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/user_callback_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/user_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/window_config.cpp", + "src/hidden_start_observer_proxy.cpp", + "src/hidden_start_observer_stub.cpp", "src/status_bar_delegate/status_bar_delegate_proxy.cpp", "src/status_bar_delegate/status_bar_delegate_stub.cpp", "src/window_manager_service_handler_proxy.cpp", diff --git a/interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h b/interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h new file mode 100644 index 00000000000..40b0b2a0743 --- /dev/null +++ b/interfaces/inner_api/ability_manager/include/hidden_start_observer_proxy.h @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#ifndef OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_PROXY_H +#define OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_PROXY_H + +#include "iremote_proxy.h" +#include "ihidden_start_observer.h" + +namespace OHOS { +namespace AAFwk { +class HiddenStartObserverProxy : public IRemoteProxy { +public: + explicit HiddenStartObserverProxy(const sptr &impl); + virtual ~HiddenStartObserverProxy() = default; + + /** + * IsHiddenStart, return if the given app is started hidden. + * + * @param pid Pid of the given app's process. + * @return if the given app is started hidden + */ + virtual bool IsHiddenStart(int32_t pid) override; + +private: + /** + * WriteInterfaceToken. + * + * @param data The message parcel data. + * @return Flag whether write is successful. + */ + bool WriteInterfaceToken(MessageParcel &data); + static inline BrokerDelegator delegator_; + int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_PROXY_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h b/interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h new file mode 100644 index 00000000000..cf7a8678659 --- /dev/null +++ b/interfaces/inner_api/ability_manager/include/hidden_start_observer_stub.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#ifndef OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_STUB_H +#define OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_STUB_H + +#include +#include + +#include "iremote_stub.h" +#include "nocopyable.h" +#include "string_ex.h" +#include "app_mgr_constants.h" +#include "ihidden_start_observer.h" + +namespace OHOS { +namespace AAFwk { +class HiddenStartObserverStub : public IRemoteStub { +public: + HiddenStartObserverStub() = default; + virtual ~HiddenStartObserverStub() = default; + + virtual int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + int32_t HandleIsHiddenStart(MessageParcel &data, MessageParcel &reply); + + DISALLOW_COPY_AND_MOVE(HiddenStartObserverStub); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_HIDDEN_START_OBSERVER_STUB_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/IHiddenStartObserver.idl b/interfaces/inner_api/ability_manager/include/ihidden_start_observer.h similarity index 44% rename from interfaces/inner_api/ability_manager/IHiddenStartObserver.idl rename to interfaces/inner_api/ability_manager/include/ihidden_start_observer.h index 8afe667d8c6..663f58c3024 100644 --- a/interfaces/inner_api/ability_manager/IHiddenStartObserver.idl +++ b/interfaces/inner_api/ability_manager/include/ihidden_start_observer.h @@ -1,18 +1,43 @@ -/* - * 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 +/* + * 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. + */ + +#ifndef OHOS_ABILITY_RUNTIME_IHIDDEN_START_OBSERVER_H +#define OHOS_ABILITY_RUNTIME_IHIDDEN_START_OBSERVER_H + +#include +#include "iremote_object.h" +#include "iremote_broker.h" + +namespace OHOS { +namespace AAFwk { +class IHiddenStartObserver : public OHOS::IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IHiddenStartObserver"); + + /** + * IsHiddenStart, return if the given app is started hidden. + * + * @param pid Pid of the given app's process. + * @return if the given app is started hidden + */ + virtual bool IsHiddenStart(int32_t pid) = 0; + + enum class Message { + TRANSACT_ON_IS_HIDDEN_START = 0, + }; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_IHIDDEN_START_OBSERVER_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp b/interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp new file mode 100644 index 00000000000..7f76a178ba9 --- /dev/null +++ b/interfaces/inner_api/ability_manager/src/hidden_start_observer_proxy.cpp @@ -0,0 +1,69 @@ +/* + * 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. + */ + +#include "hidden_start_observer_proxy.h" + +#include "hilog_tag_wrapper.h" +#include "ipc_types.h" + + +namespace OHOS { +namespace AAFwk { +HiddenStartObserverProxy::HiddenStartObserverProxy( + const sptr &impl) : IRemoteProxy(impl) +{} + +bool HiddenStartObserverProxy::WriteInterfaceToken(MessageParcel &data) +{ + if (!data.WriteInterfaceToken(HiddenStartObserverProxy::GetDescriptor())) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); + return false; + } + return true; +} + +bool HiddenStartObserverProxy::IsHiddenStart(int32_t pid) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "WriteInterfaceToken failed"); + return false; + } + data.WriteInt32(pid); + int32_t ret = SendTransactCmd( + static_cast(IHiddenStartObserver::Message::TRANSACT_ON_IS_HIDDEN_START), + data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "SendRequest is failed, error code: %{public}d.", ret); + return false; + } + return reply.ReadBool(); +} + +int32_t HiddenStartObserverProxy::SendTransactCmd(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption &option) +{ + sptr remote = Remote(); + if (remote == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote is nullptr."); + return ERR_NULL_OBJECT; + } + + return remote->SendRequest(code, data, reply, option); +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp b/interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp new file mode 100644 index 00000000000..0b47d6ff5a4 --- /dev/null +++ b/interfaces/inner_api/ability_manager/src/hidden_start_observer_stub.cpp @@ -0,0 +1,49 @@ +/* + * 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. + */ + +#include "hidden_start_observer_stub.h" +#include "appexecfwk_errors.h" +#include "hilog_tag_wrapper.h" +#include "ipc_types.h" +#include "iremote_object.h" + +namespace OHOS { +namespace AAFwk { +int HiddenStartObserverStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = HiddenStartObserverStub::GetDescriptor(); + std::u16string remoteDescriptor = data.ReadInterfaceToken(); + if (descriptor != remoteDescriptor) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "local descriptor is not equal to remote."); + return ERR_INVALID_STATE; + } + + if (static_cast(code) == Message::TRANSACT_ON_IS_HIDDEN_START) { + return HandleIsHiddenStart(data, reply); + } + TAG_LOGW(AAFwkTag::ABILITYMGR, "HiddenStartObserverStub::OnRemoteRequest, default case, need check"); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); +} + +int32_t HiddenStartObserverStub::HandleIsHiddenStart(MessageParcel &data, MessageParcel &reply) +{ + int32_t pid = data.ReadInt32(); + bool result = IsHiddenStart(pid); + reply.WriteBool(result); + return NO_ERROR; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/hidden_start_observer_manager.cpp b/services/abilitymgr/src/hidden_start_observer_manager.cpp index 155f17c67b2..134d481d65a 100644 --- a/services/abilitymgr/src/hidden_start_observer_manager.cpp +++ b/services/abilitymgr/src/hidden_start_observer_manager.cpp @@ -98,13 +98,11 @@ bool HiddenStartObserverManager::IsHiddenStart(int32_t pid) HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto observersCopy = GetObserversCopy(); TAG_LOGE(AAFwkTag::ABILITYMGR, "Need query %{public}zu observers.", observersCopy.size()); - bool funcResult = false; for (auto it = observersCopy.begin(); it != observersCopy.end(); ++it) { if (*it == nullptr) { continue; } - (*it)->IsHiddenStart(pid, funcResult); - if (funcResult) { + if ((*it)->IsHiddenStart(pid)) { return true; } } diff --git a/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h b/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h index 01b57ba88a8..43d337d07f6 100644 --- a/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h +++ b/test/moduletest/ability_manager_client_test/mock_ihiddenstartobserver.h @@ -21,9 +21,9 @@ namespace OHOS { namespace AAFwk { class MockIHiddenStartObserver : public IHiddenStartObserver { public: - ErrCode IsHiddenStart(int32_t pid, bool& funcResult) override + bool IsHiddenStart(int32_t pid) { - return ERR_OK; + return true; } sptr AsObject() override { 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 c1a47f02856..f59cfcc53bf 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 @@ -49,9 +49,9 @@ public: class MockIHiddenStartObserver : public IHiddenStartObserver { public: - OHOS::ErrCode IsHiddenStart(int32_t pid, bool& funcResult) + bool IsHiddenStart(int32_t pid) { - return ERR_OK; + return true; } sptr AsObject() { diff --git a/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp b/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp index 2bd94cf213e..c09db615b7a 100644 --- a/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp +++ b/test/unittest/hidden_start_observer_manager_test/hidden_start_observer_manager_test.cpp @@ -72,9 +72,9 @@ public: IHiddenStartObserverMock() = default; virtual ~IHiddenStartObserverMock() = default; - ErrCode IsHiddenStart(int32_t pid, bool& funcResult) override + bool IsHiddenStart(int32_t pid) override { - return funcResult = mockReturnValue; + return mockReturnValue; } sptr AsObject() override -- Gitee From 4ad02f56356a46c7a04661682ebf092b78e7ad1e Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Mon, 2 Jun 2025 03:42:57 +0800 Subject: [PATCH 5/6] clm2025-IRemoteMissionListener Signed-off-by: 18795846185 Change-Id: I3c5c643058eb35d723779a0ef3fc5a1dce387d30 --- .../distributed_mission_manager.cpp | 21 ++-- .../distributed_mission_manager.h | 6 +- interfaces/inner_api/ability_manager/BUILD.gn | 7 +- ...ener_stub.h => IRemoteMissionListener.idl} | 66 ++++------- .../include/ability_manager_interface.h | 2 +- .../remote_mission_listener_interface.h | 67 ----------- .../include/remote_mission_listener_proxy.h | 61 ---------- services/abilitymgr/abilitymgr.gni | 1 - .../src/remote_mission_listener_proxy.cpp | 107 ------------------ .../src/remote_mission_listener_stub.cpp | 78 ------------- .../registermissionlistener_fuzzer.cpp | 8 +- .../remotemissionlistenerstub_fuzzer.cpp | 6 +- .../unregistermissionlistener_fuzzer.cpp | 8 +- test/unittest/BUILD.gn | 8 +- .../ability_manager_service_second_test.cpp | 6 +- .../BUILD.gn | 4 +- .../remote_mission_listener_stub_mock.h | 8 +- .../mock_remote_mission_listener_stub.h | 6 +- 18 files changed, 69 insertions(+), 401 deletions(-) rename interfaces/inner_api/ability_manager/{include/remote_mission_listener_stub.h => IRemoteMissionListener.idl} (33%) delete mode 100644 interfaces/inner_api/ability_manager/include/remote_mission_listener_interface.h delete mode 100644 interfaces/inner_api/ability_manager/include/remote_mission_listener_proxy.h delete mode 100644 services/abilitymgr/src/remote_mission_listener_proxy.cpp delete mode 100644 services/abilitymgr/src/remote_mission_listener_stub.cpp diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp index 8b6683b6131..a34065edff5 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp @@ -1125,7 +1125,7 @@ void UvWorkOnCallback(uv_work_t *work, int status) TAG_LOGI(AAFwkTag::MISSION, "uv_queue_work end"); } -void NAPIRemoteMissionListener::NotifyMissionsChanged(const std::string &deviceId) +ErrCode NAPIRemoteMissionListener::NotifyMissionsChanged(const std::string &deviceId) { TAG_LOGI(AAFwkTag::MISSION, "called"); uv_loop_s *loop = nullptr; @@ -1133,7 +1133,7 @@ void NAPIRemoteMissionListener::NotifyMissionsChanged(const std::string &deviceI napi_get_uv_event_loop(env_, &loop); if (loop == nullptr) { TAG_LOGE(AAFwkTag::MISSION, "null loop"); - return; + return ERR_INVALID_VALUE; } uv_work_t *work = new uv_work_t; @@ -1142,7 +1142,7 @@ void NAPIRemoteMissionListener::NotifyMissionsChanged(const std::string &deviceI if (registerMissionCB == nullptr) { TAG_LOGE(AAFwkTag::MISSION, "null registerMissionCB"); delete work; - return; + return ERR_INVALID_VALUE; } registerMissionCB->cbBase.cbInfo.env = env_; registerMissionCB->cbBase.cbInfo.callback = notifyMissionsChangedRef_; @@ -1157,6 +1157,7 @@ void NAPIRemoteMissionListener::NotifyMissionsChanged(const std::string &deviceI delete work; } TAG_LOGI(AAFwkTag::MISSION, "end"); + return ERR_OK; } void NAPIRemoteOnListener::OnCallback(const uint32_t continueState, const std::string &srcDeviceId, @@ -1248,14 +1249,14 @@ void CallbackReturn(napi_value *result, RegisterMissionCB *registerMissionCB) napi_call_function(registerMissionCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[0], &callResult); } -void NAPIRemoteMissionListener::NotifySnapshot(const std::string &deviceId, int32_t missionId) +ErrCode NAPIRemoteMissionListener::NotifySnapshot(const std::string &deviceId, int32_t missionId) { uv_loop_s *loop = nullptr; napi_get_uv_event_loop(env_, &loop); if (loop == nullptr) { TAG_LOGE(AAFwkTag::MISSION, "null loop"); - return; + return ERR_INVALID_VALUE; } uv_work_t *work = new uv_work_t; @@ -1264,7 +1265,7 @@ void NAPIRemoteMissionListener::NotifySnapshot(const std::string &deviceId, int3 if (registerMissionCB == nullptr) { TAG_LOGE(AAFwkTag::MISSION, "null registerMissionCB"); delete work; - return; + return ERR_INVALID_VALUE; } registerMissionCB->cbBase.cbInfo.env = env_; registerMissionCB->cbBase.cbInfo.callback = notifySnapshotRef_; @@ -1280,6 +1281,7 @@ void NAPIRemoteMissionListener::NotifySnapshot(const std::string &deviceId, int3 delete work; } TAG_LOGI(AAFwkTag::MISSION, "NotifySnapshot end"); + return ERR_OK; } void UvWorkNotifyNetDisconnect(uv_work_t *work, int status) @@ -1320,7 +1322,7 @@ void UvWorkNotifyNetDisconnect(uv_work_t *work, int status) TAG_LOGI(AAFwkTag::MISSION, "uv_queue_work end"); } -void NAPIRemoteMissionListener::NotifyNetDisconnect(const std::string &deviceId, int32_t state) +ErrCode NAPIRemoteMissionListener::NotifyNetDisconnect(const std::string &deviceId, int32_t state) { TAG_LOGI(AAFwkTag::MISSION, "called. state: %{public}d", state); uv_loop_s *loop = nullptr; @@ -1328,7 +1330,7 @@ void NAPIRemoteMissionListener::NotifyNetDisconnect(const std::string &deviceId, napi_get_uv_event_loop(env_, &loop); if (loop == nullptr) { TAG_LOGE(AAFwkTag::MISSION, "null loop"); - return; + return ERR_INVALID_VALUE; } uv_work_t *work = new uv_work_t; @@ -1337,7 +1339,7 @@ void NAPIRemoteMissionListener::NotifyNetDisconnect(const std::string &deviceId, if (registerMissionCB == nullptr) { TAG_LOGE(AAFwkTag::MISSION, "null registerMissionCB"); delete work; - return; + return ERR_INVALID_VALUE; } registerMissionCB->cbBase.cbInfo.env = env_; registerMissionCB->cbBase.cbInfo.callback = notifyNetDisconnectRef_; @@ -1353,6 +1355,7 @@ void NAPIRemoteMissionListener::NotifyNetDisconnect(const std::string &deviceId, delete work; } TAG_LOGI(AAFwkTag::MISSION, "end"); + return ERR_OK; } void UnRegisterMissionExecuteCB(napi_env env, void *data) diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.h b/frameworks/js/napi/mission_manager/distributed_mission_manager.h index 0db0335a895..35b06b45aac 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.h +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.h @@ -82,9 +82,9 @@ class NAPIRemoteMissionListener : public AAFwk::RemoteMissionListenerStub { public: virtual ~NAPIRemoteMissionListener(); - void NotifyMissionsChanged(const std::string &deviceId) override; - void NotifySnapshot(const std::string &deviceId, int32_t missionId) override; - void NotifyNetDisconnect(const std::string &deviceId, int32_t state) override; + ErrCode NotifyMissionsChanged(const std::string &deviceId) override; + ErrCode NotifySnapshot(const std::string &deviceId, int32_t missionId) override; + ErrCode NotifyNetDisconnect(const std::string &deviceId, int32_t state) override; void SetEnv(const napi_env &env); void SetNotifyMissionsChangedCBRef(const napi_ref &ref); void SetNotifySnapshotCBRef(const napi_ref &ref); diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 484dd4a28b1..51bc67dc142 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -16,7 +16,7 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") idl_gen_interface("ability_manager_interface") { sources = [ - + "IRemoteMissionListener.idl", ] sources_common = [ @@ -92,7 +92,7 @@ ohos_source_set("ability_manager_proxy") { output_values = get_target_outputs(":ability_manager_interface") source_values = [ - #"*hidden_start_observer_proxy.cpp", + "*remote_mission_listener_proxy.cpp", ] sources = filter_include(output_values, source_values) @@ -172,7 +172,7 @@ ohos_source_set("ability_manager_stub") { output_values = get_target_outputs(":ability_manager_interface") source_values = [ - #"*hidden_start_observer_stub.cpp", + "*remote_mission_listener_stub.cpp", ] sources = filter_include(output_values, source_values) @@ -283,7 +283,6 @@ ohos_shared_library("ability_manager") { "${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", "${ability_runtime_services_path}/abilitymgr/src/system_ability_token_callback_stub.cpp", diff --git a/interfaces/inner_api/ability_manager/include/remote_mission_listener_stub.h b/interfaces/inner_api/ability_manager/IRemoteMissionListener.idl similarity index 33% rename from interfaces/inner_api/ability_manager/include/remote_mission_listener_stub.h rename to interfaces/inner_api/ability_manager/IRemoteMissionListener.idl index 920f58b2067..f39c89bb59d 100644 --- a/interfaces/inner_api/ability_manager/include/remote_mission_listener_stub.h +++ b/interfaces/inner_api/ability_manager/IRemoteMissionListener.idl @@ -1,46 +1,20 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_STUB_H -#define OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_STUB_H - -#include -#include - -#include "remote_mission_listener_interface.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AAFwk { -/** - * interface for remote mission listener proxy. - */ -class RemoteMissionListenerStub : public IRemoteStub { -public: - RemoteMissionListenerStub(); - virtual ~RemoteMissionListenerStub(); - - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; -private: - DISALLOW_COPY_AND_MOVE(RemoteMissionListenerStub); - - int32_t NotifyMissionsChangedInner(MessageParcel &data, MessageParcel &reply); - int32_t NotifySnapshotInner(MessageParcel &data, MessageParcel &reply); - int32_t NotifyNetDisconnectInner(MessageParcel &data, MessageParcel &reply); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_STUB_H +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface OHOS.AAFwk.IRemoteMissionListener { + void NotifyMissionsChanged([in] String deviceId); + void NotifySnapshot([in] String deviceId, [in] int missionId); + void NotifyNetDisconnect([in] String deviceId, [in] int state); +} \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index e6a593210c5..b8a6087a2bb 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -44,7 +44,7 @@ #include "keep_alive_info.h" #include "mission_info.h" #include "query_erms_observer_interface.h" -#include "remote_mission_listener_interface.h" +#include "iremote_mission_listener.h" #include "remote_on_listener_interface.h" #include "running_process_info.h" #include "sender_info.h" diff --git a/interfaces/inner_api/ability_manager/include/remote_mission_listener_interface.h b/interfaces/inner_api/ability_manager/include/remote_mission_listener_interface.h deleted file mode 100644 index c4ae1c4923b..00000000000 --- a/interfaces/inner_api/ability_manager/include/remote_mission_listener_interface.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_INTERFACE_H - -#include "iremote_broker.h" - -namespace OHOS { -namespace AAFwk { -/** - * @class IRemoteMissionListener - * IRemoteMissionListener is used to notify caller that remote device mission is changed. - */ -class IRemoteMissionListener : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.RemoteMissionListener"); - - /** - * @brief When the remote device mission changed, AbilityMs notify the listener. - * - * @param deviceId, remote device Id. - */ - virtual void NotifyMissionsChanged(const std::string& deviceId) = 0; - - /** - * @brief When the snapshot of a mission changed, AbilityMs notify the listener. - * - * @param deviceId, remote device Id. - * @param missionId, mission Id. - */ - virtual void NotifySnapshot(const std::string& deviceId, int32_t missionId) = 0; - - /** - * @brief When the remote device disconnect, AbilityMs notify the listener. - * - * @param deviceId, remote device Id. - * @param state, device state. - */ - virtual void NotifyNetDisconnect(const std::string& deviceId, int32_t state) = 0; - - enum { - // ipc id for NotifyMissionsChanged - NOTIFY_MISSION_CHANGED = 0, - - // ipc id for NotifySnapshot - NOTIFY_SNAPSHOT = 1, - - // ipc id for NotifyNetDisconnect - NOTIFY_NET_DISCONNECT = 2 - }; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_INTERFACE_H diff --git a/interfaces/inner_api/ability_manager/include/remote_mission_listener_proxy.h b/interfaces/inner_api/ability_manager/include/remote_mission_listener_proxy.h deleted file mode 100644 index 5a518f10093..00000000000 --- a/interfaces/inner_api/ability_manager/include/remote_mission_listener_proxy.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_PROXY_H -#define OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_PROXY_H - -#include "iremote_proxy.h" -#include "remote_mission_listener_interface.h" - -namespace OHOS { -namespace AAFwk { -/** - * interface for remote mission listener proxy. - */ -class RemoteMissionListenerProxy : public IRemoteProxy { -public: - explicit RemoteMissionListenerProxy(const sptr &impl) : IRemoteProxy(impl) - {} - - /** - * @brief When the remote device mission changed, AbilityMs notify the listener. - * - * @param deviceId, remote device Id. - */ - virtual void NotifyMissionsChanged(const std::string& deviceId) override; - - /** - * @brief When the snapshot of a mission changed, AbilityMs notify the listener. - * - * @param deviceId, remote device Id. - * @param missionId, mission Id. - */ - virtual void NotifySnapshot(const std::string& deviceId, int32_t missionId) override; - - /** - * @brief When the remote device disconnect, AbilityMs notify the listener. - * - * @param deviceId, remote device Id. - * @param state, device state. - */ - virtual void NotifyNetDisconnect(const std::string& deviceId, int32_t state) override; - -private: - static inline BrokerDelegator delegator_; - int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_REMOTE_MISSION_LISTENER_PROXY_H diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index 2fc0f8e6791..ed5538e8bf2 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -88,7 +88,6 @@ abilityms_files = [ "src/rdb/ability_resident_process_rdb.cpp", "src/rdb/parser_util.cpp", "src/rdb/rdb_data_manager.cpp", - "src/remote_mission_listener_proxy.cpp", "src/scene_board/status_bar_delegate_manager.cpp", "src/scene_board/ui_ability_lifecycle_manager.cpp", "src/deeplink_reserve/deeplink_reserve_config.cpp", diff --git a/services/abilitymgr/src/remote_mission_listener_proxy.cpp b/services/abilitymgr/src/remote_mission_listener_proxy.cpp deleted file mode 100644 index 868655b7f81..00000000000 --- a/services/abilitymgr/src/remote_mission_listener_proxy.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "remote_mission_listener_proxy.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AAFwk { -void RemoteMissionListenerProxy::NotifyMissionsChanged(const std::string& deviceId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RemoteMissionListenerProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyMissionsChanged Write interface token failed"); - return; - } - if (!data.WriteString(deviceId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyMissionsChanged Write deviceId failed"); - return; - } - int32_t result = SendTransactCmd(IRemoteMissionListener::NOTIFY_MISSION_CHANGED, data, reply, option); - if (result != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyMissionsChanged SendRequest fail, error: %{public}d", result); - return; - } -} - -void RemoteMissionListenerProxy::NotifySnapshot(const std::string& deviceId, int32_t missionId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RemoteMissionListenerProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifySnapshot Write interface token failed"); - return; - } - if (!data.WriteString(deviceId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifySnapshot Write deviceId failed"); - return; - } - if (!data.WriteInt32(missionId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifySnapshot Write missionId failed"); - return; - } - int32_t result = SendTransactCmd(IRemoteMissionListener::NOTIFY_SNAPSHOT, data, reply, option); - if (result != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifySnapshot SendRequest fail, error: %{public}d", result); - return; - } -} - -void RemoteMissionListenerProxy::NotifyNetDisconnect(const std::string& deviceId, int32_t state) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(RemoteMissionListenerProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyNetDisconnect Write interface token failed"); - return; - } - if (!data.WriteString(deviceId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyNetDisconnect Write deviceId failed"); - return; - } - if (!data.WriteInt32(state)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyNetDisconnect Write missionId failed"); - return; - } - int32_t result = SendTransactCmd(IRemoteMissionListener::NOTIFY_NET_DISCONNECT, data, reply, option); - if (result != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyNetDisconnect SendRequest fail, error: %{public}d", result); - return; - } -} - -int32_t RemoteMissionListenerProxy::SendTransactCmd(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote object"); - return ERR_NULL_OBJECT; - } - - int32_t ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail. code: %{public}d, ret: %{public}d", code, ret); - return ret; - } - return NO_ERROR; -} -} // namespace AAFwk -} // namespace OHOS diff --git a/services/abilitymgr/src/remote_mission_listener_stub.cpp b/services/abilitymgr/src/remote_mission_listener_stub.cpp deleted file mode 100644 index ce2f2ab3eca..00000000000 --- a/services/abilitymgr/src/remote_mission_listener_stub.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "remote_mission_listener_stub.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AAFwk { -RemoteMissionListenerStub::RemoteMissionListenerStub() -{} - -RemoteMissionListenerStub::~RemoteMissionListenerStub() -{} - -int RemoteMissionListenerStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string descriptor = RemoteMissionListenerStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "descriptor invalid"); - return ERR_INVALID_STATE; - } - - switch (code) { - case IRemoteMissionListener::NOTIFY_MISSION_CHANGED: { - return NotifyMissionsChangedInner(data, reply); - } - case IRemoteMissionListener::NOTIFY_SNAPSHOT: { - return NotifySnapshotInner(data, reply); - } - case IRemoteMissionListener::NOTIFY_NET_DISCONNECT: { - return NotifyNetDisconnectInner(data, reply); - } - default: { - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - } -} - -int32_t RemoteMissionListenerStub::NotifyMissionsChangedInner(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId = data.ReadString(); - NotifyMissionsChanged(deviceId); - return NO_ERROR; -} - -int32_t RemoteMissionListenerStub::NotifySnapshotInner(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId = data.ReadString(); - int32_t missionId = data.ReadInt32(); - NotifySnapshot(deviceId, missionId); - return NO_ERROR; -} - -int32_t RemoteMissionListenerStub::NotifyNetDisconnectInner(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId = data.ReadString(); - int32_t state = data.ReadInt32(); - NotifyNetDisconnect(deviceId, state); - return NO_ERROR; -} -} // namespace AAFwk -} // namespace OHOS diff --git a/test/fuzztest/registermissionlistener_fuzzer/registermissionlistener_fuzzer.cpp b/test/fuzztest/registermissionlistener_fuzzer/registermissionlistener_fuzzer.cpp index 48f3e7b730a..770826b79cb 100755 --- a/test/fuzztest/registermissionlistener_fuzzer/registermissionlistener_fuzzer.cpp +++ b/test/fuzztest/registermissionlistener_fuzzer/registermissionlistener_fuzzer.cpp @@ -20,7 +20,7 @@ #include "ability_manager_client.h" #include "mission_listener_interface.h" -#include "remote_mission_listener_interface.h" +#include "iremote_mission_listener.h" #include "securec.h" using namespace OHOS::AAFwk; @@ -48,9 +48,9 @@ class RemoteMissionListenerFuzz : public IRemoteMissionListener { public: explicit RemoteMissionListenerFuzz() {}; virtual ~RemoteMissionListenerFuzz() {}; - void NotifyMissionsChanged(const std::string& deviceId) override {}; - void NotifySnapshot(const std::string& deviceId, int32_t missionId) override {}; - void NotifyNetDisconnect(const std::string& deviceId, int32_t state) override {}; + ErrCode NotifyMissionsChanged(const std::string& deviceId) override {}; + ErrCode NotifySnapshot(const std::string& deviceId, int32_t missionId) override {}; + ErrCode NotifyNetDisconnect(const std::string& deviceId, int32_t state) override {}; }; bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { diff --git a/test/fuzztest/remotemissionlistenerstub_fuzzer/remotemissionlistenerstub_fuzzer.cpp b/test/fuzztest/remotemissionlistenerstub_fuzzer/remotemissionlistenerstub_fuzzer.cpp index 11df4a76870..23285792ccc 100755 --- a/test/fuzztest/remotemissionlistenerstub_fuzzer/remotemissionlistenerstub_fuzzer.cpp +++ b/test/fuzztest/remotemissionlistenerstub_fuzzer/remotemissionlistenerstub_fuzzer.cpp @@ -36,11 +36,11 @@ public: RemoteMissionListenerStubFuzzTest() = default; virtual ~RemoteMissionListenerStubFuzzTest() {}; - void NotifyMissionsChanged(const std::string& deviceId) override + ErrCode NotifyMissionsChanged(const std::string& deviceId) override {} - void NotifySnapshot(const std::string& deviceId, int32_t missionId) override + ErrCode NotifySnapshot(const std::string& deviceId, int32_t missionId) override {} - void NotifyNetDisconnect(const std::string& deviceId, int32_t state) override + ErrCode NotifyNetDisconnect(const std::string& deviceId, int32_t state) override {} }; diff --git a/test/fuzztest/unregistermissionlistener_fuzzer/unregistermissionlistener_fuzzer.cpp b/test/fuzztest/unregistermissionlistener_fuzzer/unregistermissionlistener_fuzzer.cpp index 23ae7a30f34..df4b46e587b 100644 --- a/test/fuzztest/unregistermissionlistener_fuzzer/unregistermissionlistener_fuzzer.cpp +++ b/test/fuzztest/unregistermissionlistener_fuzzer/unregistermissionlistener_fuzzer.cpp @@ -20,7 +20,7 @@ #include "ability_manager_client.h" #include "mission_listener_interface.h" -#include "remote_mission_listener_interface.h" +#include "iremote_mission_listener.h" #include "securec.h" using namespace OHOS::AAFwk; @@ -48,9 +48,9 @@ class RemoteMissionListenerFuzz : public IRemoteMissionListener { public: explicit RemoteMissionListenerFuzz() {}; virtual ~RemoteMissionListenerFuzz() {}; - void NotifyMissionsChanged(const std::string& deviceId) override {}; - void NotifySnapshot(const std::string& deviceId, int32_t missionId) override {}; - void NotifyNetDisconnect(const std::string& deviceId, int32_t state) override {}; + ErrCode NotifyMissionsChanged(const std::string& deviceId) override {}; + ErrCode NotifySnapshot(const std::string& deviceId, int32_t missionId) override {}; + ErrCode NotifyNetDisconnect(const std::string& deviceId, int32_t state) override {}; }; bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 291f27e62c3..e8b339427e1 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -210,7 +210,10 @@ ohos_source_set("abilityms_test_source") { ] cflags_cc = [] - configs = [ ":test_exception_config" ] + configs = [ + ":test_exception_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] public_configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config", @@ -222,6 +225,8 @@ ohos_source_set("abilityms_test_source") { } deps = [ "${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:process_options", "${ability_runtime_innerkits_path}/ability_manager:start_window_option", "${ability_runtime_innerkits_path}/app_manager:app_manager", @@ -298,7 +303,6 @@ ohos_source_set("abilityms_test_source") { "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_snapshot.cpp", - "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/system_dialog_scheduler.cpp", "${ability_runtime_services_path}/appdfr/src/application_anr_listener.cpp", diff --git a/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp b/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp index baa53693076..0db7d451f29 100644 --- a/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp +++ b/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp @@ -63,13 +63,13 @@ public: class MockIRemoteMissionListener : public IRemoteMissionListener { public: virtual ~MockIRemoteMissionListener() {} - void NotifyMissionsChanged(const std::string& deviceId) override + ErrCode NotifyMissionsChanged(const std::string& deviceId) override {} - void NotifySnapshot(const std::string& deviceId, int32_t missionId) override + ErrCode NotifySnapshot(const std::string& deviceId, int32_t missionId) override {} - void NotifyNetDisconnect(const std::string& deviceId, int32_t state) override + ErrCode NotifyNetDisconnect(const std::string& deviceId, int32_t state) override {} sptr AsObject() override diff --git a/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn b/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn index 2c33979f82a..6f205eaff93 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn @@ -28,6 +28,7 @@ ohos_unittest("ability_manager_service_thirteenth_test") { configs = [ ":abilityms_config", ":abilityms_exception_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", ] include_dirs = [ "mock/include", @@ -162,7 +163,6 @@ ohos_unittest("ability_manager_service_thirteenth_test") { "${ability_runtime_services_path}/abilitymgr/src/rdb/parser_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/rdb/rdb_data_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/recovery_info_timer.cpp", - "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/resident_process/resident_process_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/restart_app_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", @@ -230,6 +230,8 @@ ohos_unittest("ability_manager_service_thirteenth_test") { deps = [ "${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", diff --git a/test/unittest/remote_mission_listener_proxy_test/remote_mission_listener_stub_mock.h b/test/unittest/remote_mission_listener_proxy_test/remote_mission_listener_stub_mock.h index 3a82252d1b9..9bba71c25e9 100755 --- a/test/unittest/remote_mission_listener_proxy_test/remote_mission_listener_stub_mock.h +++ b/test/unittest/remote_mission_listener_proxy_test/remote_mission_listener_stub_mock.h @@ -18,7 +18,7 @@ #include #include #include -#include "remote_mission_listener_interface.h" +#include "iremote_mission_listener.h" namespace OHOS { namespace AAFwk { @@ -45,9 +45,9 @@ public: int code_ = 0; - virtual void NotifyMissionsChanged(const std::string& deviceId) {}; - virtual void NotifySnapshot(const std::string& deviceId, int32_t missionId) {}; - virtual void NotifyNetDisconnect(const std::string& deviceId, int32_t state) {}; + virtual ErrCode NotifyMissionsChanged(const std::string& deviceId) {}; + virtual ErrCode NotifySnapshot(const std::string& deviceId, int32_t missionId) {}; + virtual ErrCode NotifyNetDisconnect(const std::string& deviceId, int32_t state) {}; }; } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/remote_mission_listener_stub_test/mock_remote_mission_listener_stub.h b/test/unittest/remote_mission_listener_stub_test/mock_remote_mission_listener_stub.h index c726f434b88..8df218798c1 100755 --- a/test/unittest/remote_mission_listener_stub_test/mock_remote_mission_listener_stub.h +++ b/test/unittest/remote_mission_listener_stub_test/mock_remote_mission_listener_stub.h @@ -29,9 +29,9 @@ public: MockRemoteMissionListenerStub() = default; virtual ~MockRemoteMissionListenerStub() = default; - MOCK_METHOD1(NotifyMissionsChanged, void(const std::string& deviceId)); - MOCK_METHOD2(NotifySnapshot, void(const std::string& deviceId, int32_t missionId)); - MOCK_METHOD2(NotifyNetDisconnect, void(const std::string& deviceId, int32_t state)); + MOCK_METHOD1(NotifyMissionsChanged, ErrCode(const std::string& deviceId)); + MOCK_METHOD2(NotifySnapshot, ErrCode(const std::string& deviceId, int32_t missionId)); + MOCK_METHOD2(NotifyNetDisconnect, ErrCode(const std::string& deviceId, int32_t state)); }; } // namespace AAFwk } // namespace OHOS -- Gitee From 331a9ffdc3e96abaa96b728e48da0a07533ef286 Mon Sep 17 00:00:00 2001 From: chenliming Date: Mon, 2 Jun 2025 02:00:07 +0000 Subject: [PATCH 6/6] update test/unittest/ability_manager_service_fourteenth_test/BUILD.gn. Signed-off-by: chenliming --- .../unittest/ability_manager_service_fourteenth_test/BUILD.gn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn b/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn index 2c64030a5fd..9e32e070e01 100644 --- a/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn @@ -28,6 +28,7 @@ ohos_unittest("ability_manager_service_fourteenth_test") { configs = [ ":abilityms_config", ":abilityms_exception_config", + ":ability_manager_idl_config", ] include_dirs = [ "../ability_manager_service_thirteenth_test/mock/include", @@ -162,7 +163,6 @@ ohos_unittest("ability_manager_service_fourteenth_test") { "${ability_runtime_services_path}/abilitymgr/src/rdb/parser_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/rdb/rdb_data_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/recovery_info_timer.cpp", - "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/resident_process/resident_process_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/restart_app_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", @@ -231,6 +231,8 @@ ohos_unittest("ability_manager_service_fourteenth_test") { deps = [ "${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", -- Gitee