From 0e865eda271263bb8a661152e3c34cdb50b6c0e6 Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Mon, 16 Jun 2025 14:24:46 +0800 Subject: [PATCH 1/2] IKiaInterceptor.idl Signed-off-by: 18795846185 --- interfaces/inner_api/app_manager/BUILD.gn | 6 +- .../IKiaInterceptor.idl} | 39 +------- .../IQuickFixCallback.idl} | 31 ++----- .../include/appmgr/app_mgr_interface.h | 2 +- .../include/appmgr/kia_interceptor_proxy.h | 66 ------------- .../include/appmgr/kia_interceptor_stub.h | 68 -------------- .../include/appmgr/quick_fix_callback_proxy.h | 40 -------- .../include/appmgr/quick_fix_callback_stub.h | 44 --------- .../src/appmgr/kia_interceptor_proxy.cpp | 67 ------------- .../src/appmgr/kia_interceptor_stub.cpp | 59 ------------ .../src/appmgr/quick_fix_callback_proxy.cpp | 93 ------------------- .../src/appmgr/quick_fix_callback_stub.cpp | 71 -------------- .../appmgr/include/app_mgr_service_inner.h | 2 +- .../include/quick_fix_callback_with_record.h | 8 +- .../src/quick_fix_callback_with_record.cpp | 11 ++- .../src/quick_fix_manager_apply_task.cpp | 33 ++++--- .../include/mock_kia_interceptor.h | 6 +- .../include/mock_kia_interceptor.h | 6 +- .../ui_extension_stability_test/BUILD.gn | 8 +- test/unittest/ams_ipc_interface_test/BUILD.gn | 6 +- .../mock/include/mock_iapp_mgr.h | 2 +- .../app_mgr_proxy_test/app_mgr_proxy_test.cpp | 11 ++- .../app_mgr_service_inner_eighth_test.cpp | 4 +- .../app_mgr_service_inner_mock_test/BUILD.gn | 6 +- .../include/mock_app_mgr_service_inner.h | 4 +- .../include/mock_kia_interceptor_impl.h | 4 +- .../src/mock_kia_interceptor_impl.cpp | 4 +- .../app_mgr_service_inner_second_test.cpp | 4 +- .../app_running_manager_second_test.cpp | 20 ++-- .../main_fourth_test/main_fourth_test.cpp | 11 ++- .../main_thread_test/main_thread_test.cpp | 11 ++- .../include/mock_quick_fix_callback_stub.h | 8 +- .../quick_fix_callback_proxy_test.cpp | 8 +- .../quick_fix_callback_stub_test.cpp | 12 +-- .../quick_fix_callback_with_record_test.cpp | 11 ++- 35 files changed, 132 insertions(+), 654 deletions(-) rename interfaces/inner_api/app_manager/{include/appmgr/kia_interceptor_interface.h => idl/IKiaInterceptor.idl} (39%) rename interfaces/inner_api/app_manager/{include/appmgr/iquick_fix_callback.h => idl/IQuickFixCallback.idl} (37%) delete mode 100644 interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_proxy.h delete mode 100644 interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_stub.h delete mode 100644 interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_proxy.h delete mode 100644 interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_stub.h delete mode 100644 interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_proxy.cpp delete mode 100644 interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_stub.cpp delete mode 100644 interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_proxy.cpp delete mode 100644 interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_stub.cpp diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 59318b86d69..e31cb7a8462 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -45,6 +45,8 @@ idl_gen_interface("appmgr_innerkits") { sources = [ "idl/IAbilityDebugResponse.idl", "idl/IAppDebugListener.idl", + "idl/IKiaInterceptor.idl", + "idl/IQuickFixCallback.idl", "idl/IStartSpecifiedAbilityResponse.idl", ] log_domainid = "0xD001311" @@ -202,8 +204,6 @@ ohos_shared_library("app_manager") { "src/appmgr/configuration_observer_stub.cpp", "src/appmgr/configuration_policy.cpp", "src/appmgr/fault_data.cpp", - "src/appmgr/kia_interceptor_proxy.cpp", - "src/appmgr/kia_interceptor_stub.cpp", "src/appmgr/killed_process_info.cpp", "src/appmgr/memory_level_info.cpp", "src/appmgr/native_child_notify_proxy.cpp", @@ -214,8 +214,6 @@ ohos_shared_library("app_manager") { "src/appmgr/process_info.cpp", "src/appmgr/process_memory_state.cpp", "src/appmgr/profile.cpp", - "src/appmgr/quick_fix_callback_proxy.cpp", - "src/appmgr/quick_fix_callback_stub.cpp", "src/appmgr/render_process_info.cpp", "src/appmgr/render_scheduler_host.cpp", "src/appmgr/render_scheduler_proxy.cpp", diff --git a/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_interface.h b/interfaces/inner_api/app_manager/idl/IKiaInterceptor.idl similarity index 39% rename from interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_interface.h rename to interfaces/inner_api/app_manager/idl/IKiaInterceptor.idl index 52dc49e2bbd..80564f2c441 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_interface.h +++ b/interfaces/inner_api/app_manager/idl/IKiaInterceptor.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,37 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_INTERFACE_H +sequenceable want..OHOS.AAFwk.Want; -#include - -#include "want.h" - -namespace OHOS { -namespace AppExecFwk { -/** - * @class IKiaInterceptor - * IPC interface for KIA. - */ -class IKiaInterceptor : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IKiaInterceptor"); - - /** - * OnIntercept, processing method from KIA. - * - * @param want The param of openning the app. - * @return Error code of calling the function. - */ - virtual int OnIntercept(AAFwk::Want &want) = 0; - - enum { - // ipc code for calling OnIntercept - KIA_INTERCEPTOR_ON_INTERCEPT = 0, - }; -}; -} // namespace AppExecFwk -} // namespace OHOS - -#endif // OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_INTERFACE_H +interface OHOS.AppExecFwk.IKiaInterceptor { + void OnIntercept([inout] Want want); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/iquick_fix_callback.h b/interfaces/inner_api/app_manager/idl/IQuickFixCallback.idl similarity index 37% rename from interfaces/inner_api/app_manager/include/appmgr/iquick_fix_callback.h rename to interfaces/inner_api/app_manager/idl/IQuickFixCallback.idl index f2e45b845d6..63a31421cdb 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/iquick_fix_callback.h +++ b/interfaces/inner_api/app_manager/idl/IQuickFixCallback.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,27 +13,8 @@ * limitations under the License. */ -#ifndef OHOS_ABILITY_RUNTIME_IQUICK_FIX_CALLBACK_H -#define OHOS_ABILITY_RUNTIME_IQUICK_FIX_CALLBACK_H - -#include "iremote_broker.h" - -namespace OHOS { -namespace AppExecFwk { -class IQuickFixCallback : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.QuickFixCallback"); - - virtual void OnLoadPatchDone(int32_t resultCode, int32_t recordId) = 0; - virtual void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) = 0; - virtual void OnReloadPageDone(int32_t resultCode, int32_t recordId) = 0; - - enum QuickFixCallbackCmd { - ON_NOTIFY_LOAD_PATCH = 0, // ipc id for OnLoadPatchDone - ON_NOTIFY_UNLOAD_PATCH = 1, // ipc id for OnUnloadPatchDone - ON_NOTIFY_RELOAD_PAGE = 2, // ipc id for OnReloadPageDone - }; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_IQUICK_FIX_CALLBACK_H +interface OHOS.AppExecFwk.IQuickFixCallback { + void OnLoadPatchDone([in] int resultCode, [in] int recordId); + void OnUnloadPatchDone([in] int resultCode, [in] int recordId); + void OnReloadPageDone([in] int resultCode, [in] int recordId); +} \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index f0d1dbfabbf..99a765c85a6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -32,10 +32,10 @@ #include "child_process_request.h" #endif // SUPPORT_CHILD_PROCESS #include "fault_data.h" -#include "kia_interceptor_interface.h" #include "iapp_state_callback.h" #include "iapplication_state_observer.h" #include "iconfiguration_observer.h" +#include "ikia_interceptor.h" #include "iquick_fix_callback.h" #include "iremote_broker.h" #include "iremote_object.h" diff --git a/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_proxy.h deleted file mode 100644 index 328ac436beb..00000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_proxy.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_PROXY_H -#define OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_PROXY_H - -#include "kia_interceptor_interface.h" - -#include - -namespace OHOS { -namespace AppExecFwk { -/** - * @class KiaInterceptorProxy - * IPC proxy of IKiaInterceptor. - */ -class KiaInterceptorProxy : public IRemoteProxy { -public: - /** - * KiaInterceptorProxy, constructor. - * - * @param impl The implementation of IKiaInterceptor. - */ - explicit KiaInterceptorProxy(const sptr &impl) : IRemoteProxy(impl) - {} - - /** - * KiaInterceptorProxy, destructor. - * - */ - virtual ~KiaInterceptorProxy() - {} - - /** - * OnIntercept, processing method from KIA. - * - * @param want The param of openning the app. - */ - virtual int OnIntercept(AAFwk::Want &want) override; - -private: - /** - * WriteInterfaceToken. - * - * @param data The message parcel data. - * @return Flag whether write is successful. - */ - bool WriteInterfaceToken(MessageParcel &data); - - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_stub.h b/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_stub.h deleted file mode 100644 index 784a3d80ebd..00000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/kia_interceptor_stub.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_STUB_H -#define OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_STUB_H - -#include "kia_interceptor_interface.h" - -#include -#include - -namespace OHOS { -namespace AppExecFwk { -/** - * @class KiaInterceptorStub - * IPC stub of IKiaInterceptor. - */ -class KiaInterceptorStub : public IRemoteStub { -public: - /** - * KiaInterceptorStub, constructor. - * - */ - KiaInterceptorStub(); - - /** - * KiaInterceptorStub, destructor. - * - */ - virtual ~KiaInterceptorStub(); - - /** - * OnRemoteRequest, IPC method. - * - * @param code The IPC code. - * @param data The message parcel data. - * @param reply The message parcel reply. - * @param option The message parcel option. - * @return Error code of calling the function. - */ - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - /** - * OnInterceptInner, inner processing method from KIA. - * - * @param data The message parcel data. - * @param reply The message parcel reply. - * @return Error code of calling the function. - */ - int OnInterceptInner(MessageParcel &data, MessageParcel &reply); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_KIA_INTERCEPTOR_STUB_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_proxy.h deleted file mode 100644 index d2daba0fea1..00000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_proxy.h +++ /dev/null @@ -1,40 +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_QUICK_FIX_CALLBACK_PROXY_H -#define OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_PROXY_H - -#include "iquick_fix_callback.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -class QuickFixCallbackProxy : public IRemoteProxy { -public: - explicit QuickFixCallbackProxy(const sptr &impl) : IRemoteProxy(impl) {}; - virtual ~QuickFixCallbackProxy() = default; - - void OnLoadPatchDone(int32_t resultCode, int32_t recordId) override; - void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override; - void OnReloadPageDone(int32_t resultCode, int32_t recordId) override; - -private: - bool SendRequestWithCmd(uint32_t code, MessageParcel &data, MessageParcel &reply); - - static inline BrokerDelegator delegator_; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_PROXY_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_stub.h b/interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_stub.h deleted file mode 100644 index 9dcf43da589..00000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/quick_fix_callback_stub.h +++ /dev/null @@ -1,44 +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_QUICK_FIX_CALLBACK_STUB_H -#define OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_STUB_H - -#include - -#include "iquick_fix_callback.h" -#include "iremote_stub.h" -#include "message_parcel.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AppExecFwk { -class QuickFixCallbackStub : public IRemoteStub { -public: - QuickFixCallbackStub(); - virtual ~QuickFixCallbackStub(); - - int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int32_t HandleOnLoadPatchDoneInner(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnUnloadPatchDoneInner(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnReloadPageDoneInner(MessageParcel &data, MessageParcel &reply); - - DISALLOW_COPY_AND_MOVE(QuickFixCallbackStub); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_STUB_H diff --git a/interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_proxy.cpp deleted file mode 100644 index 15f2e759cd4..00000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_proxy.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "kia_interceptor_proxy.h" - -#include "hilog_tag_wrapper.h" -#include "ipc_capacity_wrap.h" - -namespace OHOS { -namespace AppExecFwk { -bool KiaInterceptorProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(KiaInterceptorProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "write interface token failed"); - return false; - } - return true; -} - -int KiaInterceptorProxy::OnIntercept(AAFwk::Want &want) -{ - MessageParcel data; - MessageParcel reply; - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - MessageOption option(MessageOption::TF_SYNC); - if (!WriteInterfaceToken(data)) { - return ERR_INVALID_VALUE; - } - data.WriteParcelable(&want); - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote() is NULL"); - return ERR_INVALID_VALUE; - } - int32_t ret = remote->SendRequest(static_cast(IKiaInterceptor::KIA_INTERCEPTOR_ON_INTERCEPT), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d.", ret); - return ret; - } - int resultCode = reply.ReadInt32(); - if (resultCode != ERR_OK) { - TAG_LOGE(AAFwkTag::APPMGR, "OnIntercept failed, resultCode=%{public}d.", resultCode); - return resultCode; - } - sptr resultWant = reply.ReadParcelable(); - if (resultWant == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "resultWant is nullptr."); - return ERR_INVALID_VALUE; - } - want = *resultWant; - return resultCode; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_stub.cpp deleted file mode 100644 index 96eb5f75048..00000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/kia_interceptor_stub.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "kia_interceptor_stub.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -KiaInterceptorStub::KiaInterceptorStub() {} - -KiaInterceptorStub::~KiaInterceptorStub() {} - -int KiaInterceptorStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - TAG_LOGD(AAFwkTag::APPMGR, "cmd=%d,flags=%d", code, option.GetFlags()); - std::u16string descriptor = KiaInterceptorStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGI(AAFwkTag::APPMGR, "local descriptor is not equal to remote"); - return ERR_INVALID_STATE; - } - - if (code == KIA_INTERCEPTOR_ON_INTERCEPT) { - return OnInterceptInner(data, reply); - } - TAG_LOGW(AAFwkTag::APPMGR, "KiaInterceptorStub::OnRemoteRequest, default case, need check."); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int KiaInterceptorStub::OnInterceptInner(MessageParcel &data, MessageParcel &reply) -{ - sptr want = data.ReadParcelable(); - int resultCode = OnIntercept(*want); - if (!reply.WriteInt32(resultCode)) { - TAG_LOGE(AAFwkTag::APPMGR, "write resultCode failed."); - return ERR_INVALID_VALUE; - } - if (!reply.WriteParcelable(want)) { - TAG_LOGE(AAFwkTag::APPMGR, "write want failed."); - return ERR_INVALID_VALUE; - } - - return NO_ERROR; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_proxy.cpp deleted file mode 100644 index ed1c8310efa..00000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_proxy.cpp +++ /dev/null @@ -1,93 +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 "quick_fix_callback_proxy.h" - -#include "hilog_tag_wrapper.h" -#include "message_parcel.h" -#include "parcel_macro_base.h" - -namespace OHOS { -namespace AppExecFwk { -void QuickFixCallbackProxy::OnLoadPatchDone(int32_t resultCode, int32_t recordId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - - MessageParcel data; - MessageParcel reply; - WRITE_PARCEL_AND_RETURN(InterfaceToken, data, QuickFixCallbackProxy::GetDescriptor()); - WRITE_PARCEL_AND_RETURN(Int32, data, resultCode); - WRITE_PARCEL_AND_RETURN(Int32, data, recordId); - if (!SendRequestWithCmd(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH, data, reply)) { - return; - } - - TAG_LOGD(AAFwkTag::APPMGR, "function finished."); - return; -} - -void QuickFixCallbackProxy::OnUnloadPatchDone(int32_t resultCode, int32_t recordId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - - MessageParcel data; - MessageParcel reply; - WRITE_PARCEL_AND_RETURN(InterfaceToken, data, QuickFixCallbackProxy::GetDescriptor()); - WRITE_PARCEL_AND_RETURN(Int32, data, resultCode); - WRITE_PARCEL_AND_RETURN(Int32, data, recordId); - if (!SendRequestWithCmd(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_UNLOAD_PATCH, data, reply)) { - return; - } - - TAG_LOGD(AAFwkTag::APPMGR, "function finished."); - return; -} - -void QuickFixCallbackProxy::OnReloadPageDone(int32_t resultCode, int32_t recordId) -{ - TAG_LOGD(AAFwkTag::APPMGR, "called"); - - MessageParcel data; - MessageParcel reply; - WRITE_PARCEL_AND_RETURN(InterfaceToken, data, QuickFixCallbackProxy::GetDescriptor()); - WRITE_PARCEL_AND_RETURN(Int32, data, resultCode); - WRITE_PARCEL_AND_RETURN(Int32, data, recordId); - if (!SendRequestWithCmd(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_RELOAD_PAGE, data, reply)) { - return; - } - - TAG_LOGD(AAFwkTag::APPMGR, "function finished."); - return; -} - -bool QuickFixCallbackProxy::SendRequestWithCmd(uint32_t code, MessageParcel &data, MessageParcel &reply) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr."); - return false; - } - - MessageOption option(MessageOption::TF_SYNC); - auto ret = remote->SendRequest(code, data, reply, option); - if (ret != 0) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed with error %{public}d.", ret); - return false; - } - - return true; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_stub.cpp deleted file mode 100644 index e557f4802a5..00000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/quick_fix_callback_stub.cpp +++ /dev/null @@ -1,71 +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 "quick_fix_callback_stub.h" - -#include "hilog_tag_wrapper.h" - -namespace OHOS { -namespace AppExecFwk { -QuickFixCallbackStub::QuickFixCallbackStub() {} - -QuickFixCallbackStub::~QuickFixCallbackStub() {} - -int QuickFixCallbackStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - if (data.ReadInterfaceToken() != IQuickFixCallback::GetDescriptor()) { - TAG_LOGE(AAFwkTag::APPMGR, "local descriptor is not equal to remote."); - return ERR_INVALID_STATE; - } - - switch (code) { - case ON_NOTIFY_LOAD_PATCH: - return HandleOnLoadPatchDoneInner(data, reply); - case ON_NOTIFY_UNLOAD_PATCH: - return HandleOnUnloadPatchDoneInner(data, reply); - case ON_NOTIFY_RELOAD_PAGE: - return HandleOnReloadPageDoneInner(data, reply); - } - - TAG_LOGW(AAFwkTag::APPMGR, "default case, need check value of code!"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int32_t QuickFixCallbackStub::HandleOnLoadPatchDoneInner(MessageParcel &data, MessageParcel &reply) -{ - int32_t resultCode = data.ReadInt32(); - int32_t recordId = data.ReadInt32(); - OnLoadPatchDone(resultCode, recordId); - return ERR_OK; -} - -int32_t QuickFixCallbackStub::HandleOnUnloadPatchDoneInner(MessageParcel &data, MessageParcel &reply) -{ - int32_t resultCode = data.ReadInt32(); - int32_t recordId = data.ReadInt32(); - OnUnloadPatchDone(resultCode, recordId); - return ERR_OK; -} - -int32_t QuickFixCallbackStub::HandleOnReloadPageDoneInner(MessageParcel &data, MessageParcel &reply) -{ - int32_t resultCode = data.ReadInt32(); - int32_t recordId = data.ReadInt32(); - OnReloadPageDone(resultCode, recordId); - return ERR_OK; -} -} // namespace AAFwk -} // namespace OHOS diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 4f4588802e2..dbe861e5cd0 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -61,10 +61,10 @@ #include "iapp_state_callback.h" #include "iapplication_state_observer.h" #include "iconfiguration_observer.h" +#include "ikia_interceptor.h" #include "iremote_object.h" #include "irender_state_observer.h" #include "istart_specified_ability_response.h" -#include "kia_interceptor_interface.h" #include "kill_process_config.h" #include "killed_process_info.h" #include "process_memory_state.h" diff --git a/services/appmgr/include/quick_fix_callback_with_record.h b/services/appmgr/include/quick_fix_callback_with_record.h index cd64bb9f98a..2a8b6665882 100644 --- a/services/appmgr/include/quick_fix_callback_with_record.h +++ b/services/appmgr/include/quick_fix_callback_with_record.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -32,9 +32,9 @@ public: ~QuickFixCallbackWithRecord() override; - void OnLoadPatchDone(int32_t resultCode, int32_t recordId) override; - void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override; - void OnReloadPageDone(int32_t resultCode, int32_t recordId) override; + ErrCode OnLoadPatchDone(int32_t resultCode, int32_t recordId) override; + ErrCode OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override; + ErrCode OnReloadPageDone(int32_t resultCode, int32_t recordId) override; void AddRecordId(int32_t recordId); void RemoveRecordId(int32_t recordId); diff --git a/services/appmgr/src/quick_fix_callback_with_record.cpp b/services/appmgr/src/quick_fix_callback_with_record.cpp index 877e2148924..f9e18dbf904 100644 --- a/services/appmgr/src/quick_fix_callback_with_record.cpp +++ b/services/appmgr/src/quick_fix_callback_with_record.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -24,31 +24,34 @@ QuickFixCallbackWithRecord::~QuickFixCallbackWithRecord() TAG_LOGD(AAFwkTag::APPMGR, "destroyed."); } -void QuickFixCallbackWithRecord::OnLoadPatchDone(int32_t resultCode, int32_t recordId) +ErrCode QuickFixCallbackWithRecord::OnLoadPatchDone(int32_t resultCode, int32_t recordId) { TAG_LOGD(AAFwkTag::APPMGR, "called"); ProcessCallback(resultCode, recordId); if (IsRecordListEmpty() && callback_ != nullptr) { callback_->OnLoadPatchDone(finalResult.load(), recordId); } + return ERR_OK; } -void QuickFixCallbackWithRecord::OnUnloadPatchDone(int32_t resultCode, int32_t recordId) +ErrCode QuickFixCallbackWithRecord::OnUnloadPatchDone(int32_t resultCode, int32_t recordId) { TAG_LOGD(AAFwkTag::APPMGR, "called"); ProcessCallback(resultCode, recordId); if (IsRecordListEmpty() && callback_ != nullptr) { callback_->OnUnloadPatchDone(finalResult.load(), recordId); } + return ERR_OK; } -void QuickFixCallbackWithRecord::OnReloadPageDone(int32_t resultCode, int32_t recordId) +ErrCode QuickFixCallbackWithRecord::OnReloadPageDone(int32_t resultCode, int32_t recordId) { TAG_LOGD(AAFwkTag::APPMGR, "called"); ProcessCallback(resultCode, recordId); if (IsRecordListEmpty() && callback_ != nullptr) { callback_->OnReloadPageDone(finalResult.load(), recordId); } + return ERR_OK; } void QuickFixCallbackWithRecord::ProcessCallback(int32_t resultCode, int32_t recordId) diff --git a/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp b/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp index 86d3df61ded..7235fc4bf38 100644 --- a/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp +++ b/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -235,52 +235,55 @@ public: TAG_LOGD(AAFwkTag::QUICKFIX, "destroyed"); } - void OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + ErrCode OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override { TAG_LOGD(AAFwkTag::QUICKFIX, "called"); if (resultCode != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "notify patch failed: %{public}d", resultCode); applyTask_->NotifyApplyStatus(QUICK_FIX_NOTIFY_LOAD_PATCH_FAILED); applyTask_->RemoveSelf(); - return; + return ERR_INVALID_VALUE; } applyTask_->PostDeleteQuickFixTask(); + return ERR_OK; } - void OnUnloadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + ErrCode OnUnloadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override { TAG_LOGD(AAFwkTag::QUICKFIX, "called"); if (resultCode != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "notify patch failed: %{public}d", resultCode); applyTask_->NotifyApplyStatus(QUICK_FIX_NOTIFY_UNLOAD_PATCH_FAILED); applyTask_->RemoveSelf(); - return; + return ERR_INVALID_VALUE; } if (applyTask_->GetTaskType() == QuickFixManagerApplyTask::TaskType::QUICK_FIX_APPLY) { applyTask_->PostSwitchQuickFixTask(); - return; + return ERR_OK; } else if (applyTask_->GetTaskType() == QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE) { applyTask_->PostRevokeQuickFixDeleteTask(); - return; + return ERR_OK; } TAG_LOGW(AAFwkTag::QUICKFIX, "Invalid task type"); + return ERR_OK; } - void OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + ErrCode OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override { TAG_LOGD(AAFwkTag::QUICKFIX, "called"); if (resultCode != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "notify app load patch failed: %{public}d", resultCode); applyTask_->NotifyApplyStatus(QUICK_FIX_NOTIFY_RELOAD_PAGE_FAILED); applyTask_->RemoveSelf(); - return; + return ERR_INVALID_VALUE; } applyTask_->NotifyApplyStatus(QUICK_FIX_OK); applyTask_->RemoveSelf(); + return ERR_OK; } private: @@ -295,11 +298,15 @@ public: virtual ~RevokeQuickFixNotifyCallback() = default; - void OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override - {} + ErrCode OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + { + return ERR_OK; + } - void OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override - {} + ErrCode OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + { + return ERR_OK; + } }; QuickFixManagerApplyTask::~QuickFixManagerApplyTask() diff --git a/test/mock/mock_appmgr_service/include/mock_kia_interceptor.h b/test/mock/mock_appmgr_service/include/mock_kia_interceptor.h index 99dd0a835c0..294e9dfc6fa 100644 --- a/test/mock/mock_appmgr_service/include/mock_kia_interceptor.h +++ b/test/mock/mock_appmgr_service/include/mock_kia_interceptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -28,9 +28,9 @@ public: MockKiaInterceptor() {} virtual ~MockKiaInterceptor() = default; - int OnIntercept(AAFwk::Want &want) override + ErrCode OnIntercept(AAFwk::Want &want) override { - return 0; + return ERR_OK; } }; } // namespace AppExecFwk diff --git a/test/mock/services_appmgr_test/include/mock_kia_interceptor.h b/test/mock/services_appmgr_test/include/mock_kia_interceptor.h index 99dd0a835c0..092f5af6c20 100644 --- a/test/mock/services_appmgr_test/include/mock_kia_interceptor.h +++ b/test/mock/services_appmgr_test/include/mock_kia_interceptor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -28,9 +28,9 @@ public: MockKiaInterceptor() {} virtual ~MockKiaInterceptor() = default; - int OnIntercept(AAFwk::Want &want) override + ErrCode OnIntercept(AAFwk::Want &want) override { - return 0; + return ERR_OK; } }; } // namespace AppExecFwk diff --git a/test/moduletest/ui_extension_ability_test/ui_extension_stability_test/BUILD.gn b/test/moduletest/ui_extension_ability_test/ui_extension_stability_test/BUILD.gn index 235ec854fbb..ae347347ccb 100644 --- a/test/moduletest/ui_extension_ability_test/ui_extension_stability_test/BUILD.gn +++ b/test/moduletest/ui_extension_ability_test/ui_extension_stability_test/BUILD.gn @@ -18,6 +18,12 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_moduletest("ui_extension_stability_test") { module_out_path = "ability_runtime/ability_runtime/ui_extension" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + include_dirs = [ "../include", "${ability_runtime_test_path}/mock/mock_sa_call", @@ -49,8 +55,8 @@ ohos_moduletest("ui_extension_stability_test") { "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "c_utils:utils", "cJSON:cjson_static", + "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", "googletest:gmock_main", diff --git a/test/unittest/ams_ipc_interface_test/BUILD.gn b/test/unittest/ams_ipc_interface_test/BUILD.gn index 4265e2f8404..7de5dadff38 100644 --- a/test/unittest/ams_ipc_interface_test/BUILD.gn +++ b/test/unittest/ams_ipc_interface_test/BUILD.gn @@ -28,7 +28,11 @@ ohos_unittest("AmsIpcAppSchedulerInterfaceTest") { if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - deps = [ "${ability_runtime_test_path}/unittest:appmgr_test_source" ] + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/appkit:appkit_native", + "${ability_runtime_test_path}/unittest:appmgr_test_source", + ] external_deps = [ "ability_base:base", diff --git a/test/unittest/app_exit_reason_helper_fourth_test/mock/include/mock_iapp_mgr.h b/test/unittest/app_exit_reason_helper_fourth_test/mock/include/mock_iapp_mgr.h index 027540709f7..98065698790 100644 --- a/test/unittest/app_exit_reason_helper_fourth_test/mock/include/mock_iapp_mgr.h +++ b/test/unittest/app_exit_reason_helper_fourth_test/mock/include/mock_iapp_mgr.h @@ -34,11 +34,11 @@ #include "iapp_state_callback.h" #include "iapplication_state_observer.h" #include "iconfiguration_observer.h" +#include "ikia_interceptor.h" #include "iquick_fix_callback.h" #include "iremote_broker.h" #include "iremote_object.h" #include "irender_state_observer.h" -#include "kia_interceptor_interface.h" #include "killed_process_info.h" #include "memory_level_info.h" #include "page_state_data.h" diff --git a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp index dcc5295348f..355a0d846fc 100644 --- a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp +++ b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -56,19 +56,22 @@ public: QuickFixCallbackImpl() = default; virtual ~QuickFixCallbackImpl() = default; - void OnLoadPatchDone(int32_t resultCode, int32_t recordId) override + ErrCode OnLoadPatchDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } - void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override + ErrCode OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } - void OnReloadPageDone(int32_t resultCode, int32_t recordId) override + ErrCode OnReloadPageDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } }; diff --git a/test/unittest/app_mgr_service_inner_eighth_test/app_mgr_service_inner_eighth_test.cpp b/test/unittest/app_mgr_service_inner_eighth_test/app_mgr_service_inner_eighth_test.cpp index d6b2b7fe7bf..a683251b8bc 100644 --- a/test/unittest/app_mgr_service_inner_eighth_test/app_mgr_service_inner_eighth_test.cpp +++ b/test/unittest/app_mgr_service_inner_eighth_test/app_mgr_service_inner_eighth_test.cpp @@ -54,9 +54,9 @@ public: }; class MyKiaInterceptor : public IKiaInterceptor { public: - int OnIntercept(AAFwk::Want &want) override + ErrCode OnIntercept(AAFwk::Want &want) override { - return 0; + return ERR_OK; } sptr AsObject() override diff --git a/test/unittest/app_mgr_service_inner_mock_test/BUILD.gn b/test/unittest/app_mgr_service_inner_mock_test/BUILD.gn index 2ac11e3423a..ad8b946b92e 100644 --- a/test/unittest/app_mgr_service_inner_mock_test/BUILD.gn +++ b/test/unittest/app_mgr_service_inner_mock_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-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 @@ -33,8 +33,6 @@ ohos_unittest("app_mgr_service_inner_mock_test") { ] sources = [ - "${ability_runtime_innerkits_path}/app_manager/src/appmgr/kia_interceptor_proxy.cpp", - "${ability_runtime_innerkits_path}/app_manager/src/appmgr/kia_interceptor_stub.cpp", "app_mgr_service_inner_mock_test.cpp", "src/app_utils.cpp", "src/mock_app_mgr_service_inner.cpp", @@ -43,7 +41,7 @@ ohos_unittest("app_mgr_service_inner_mock_test") { "src/window_manager.cpp", ] - deps = [] + deps = [ "${ability_runtime_innerkits_path}/app_manager:app_manager" ] external_deps = [ "ability_base:want", diff --git a/test/unittest/app_mgr_service_inner_mock_test/include/mock_app_mgr_service_inner.h b/test/unittest/app_mgr_service_inner_mock_test/include/mock_app_mgr_service_inner.h index 4643203e841..9346c35a917 100644 --- a/test/unittest/app_mgr_service_inner_mock_test/include/mock_app_mgr_service_inner.h +++ b/test/unittest/app_mgr_service_inner_mock_test/include/mock_app_mgr_service_inner.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -18,7 +18,7 @@ #include "app_running_manager.h" #include "app_running_record.h" -#include "kia_interceptor_interface.h" +#include "ikia_interceptor.h" namespace OHOS { namespace AppExecFwk { diff --git a/test/unittest/app_mgr_service_inner_mock_test/include/mock_kia_interceptor_impl.h b/test/unittest/app_mgr_service_inner_mock_test/include/mock_kia_interceptor_impl.h index 7cc6e045531..d6a23ffc789 100644 --- a/test/unittest/app_mgr_service_inner_mock_test/include/mock_kia_interceptor_impl.h +++ b/test/unittest/app_mgr_service_inner_mock_test/include/mock_kia_interceptor_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -31,7 +31,7 @@ public: static int onInterceptRetCode; static std::string kiaWatermarkBusinessName; static bool isWatermarkEnabled; - virtual int OnIntercept(AAFwk::Want &want) override; + virtual ErrCode OnIntercept(AAFwk::Want &want) override; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_mock_test/src/mock_kia_interceptor_impl.cpp b/test/unittest/app_mgr_service_inner_mock_test/src/mock_kia_interceptor_impl.cpp index 0ccd59da340..1a7bf5872b2 100644 --- a/test/unittest/app_mgr_service_inner_mock_test/src/mock_kia_interceptor_impl.cpp +++ b/test/unittest/app_mgr_service_inner_mock_test/src/mock_kia_interceptor_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -23,7 +23,7 @@ int MockKiaInterceptorImpl::onInterceptRetCode = 0; std::string MockKiaInterceptorImpl::kiaWatermarkBusinessName; bool MockKiaInterceptorImpl::isWatermarkEnabled = false; -int MockKiaInterceptorImpl::OnIntercept(AAFwk::Want &want) +ErrCode MockKiaInterceptorImpl::OnIntercept(AAFwk::Want &want) { if (onInterceptRetCode != 0) { return onInterceptRetCode; diff --git a/test/unittest/app_mgr_service_inner_second_test/app_mgr_service_inner_second_test.cpp b/test/unittest/app_mgr_service_inner_second_test/app_mgr_service_inner_second_test.cpp index b65ae0f706e..3b749f1c9c0 100644 --- a/test/unittest/app_mgr_service_inner_second_test/app_mgr_service_inner_second_test.cpp +++ b/test/unittest/app_mgr_service_inner_second_test/app_mgr_service_inner_second_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -133,7 +133,7 @@ class IKiaInterceptorTest : public IKiaInterceptor { public: IKiaInterceptorTest() = default; virtual ~IKiaInterceptorTest() = default; - int OnIntercept(AAFwk::Want &want) override { return 0; } + ErrCode OnIntercept(AAFwk::Want &want) override { return ERR_OK; } }; /** diff --git a/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp b/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp index c253b23dbea..630de599030 100644 --- a/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp +++ b/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -48,14 +48,20 @@ public: QuickFixCallbackImpl() = default; virtual ~QuickFixCallbackImpl() = default; - void OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override - {} + ErrCode OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + { + return ERR_OK; + } - void OnUnloadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override - {} + ErrCode OnUnloadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + { + return ERR_OK; + } - void OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override - {} + ErrCode OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + { + return ERR_OK; + } }; } diff --git a/test/unittest/appkit/main_fourth_test/main_fourth_test.cpp b/test/unittest/appkit/main_fourth_test/main_fourth_test.cpp index afeaf72e9b7..bfbdecfedb3 100644 --- a/test/unittest/appkit/main_fourth_test/main_fourth_test.cpp +++ b/test/unittest/appkit/main_fourth_test/main_fourth_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -43,19 +43,22 @@ public: QuickFixCallbackImpl() = default; virtual ~QuickFixCallbackImpl() = default; - void OnLoadPatchDone(int32_t resultCode, int32_t recordId) override + ErrCode OnLoadPatchDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } - void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override + ErrCode OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } - void OnReloadPageDone(int32_t resultCode, int32_t recordId) override + ErrCode OnReloadPageDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } }; diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index ac1a95f76c5..4541ef62154 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -42,19 +42,22 @@ public: QuickFixCallbackImpl() = default; virtual ~QuickFixCallbackImpl() = default; - void OnLoadPatchDone(int32_t resultCode, int32_t recordId) override + ErrCode OnLoadPatchDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } - void OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override + ErrCode OnUnloadPatchDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } - void OnReloadPageDone(int32_t resultCode, int32_t recordId) override + ErrCode OnReloadPageDone(int32_t resultCode, int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); + return ERR_OK; } }; diff --git a/test/unittest/quick_fix/mock/include/mock_quick_fix_callback_stub.h b/test/unittest/quick_fix/mock/include/mock_quick_fix_callback_stub.h index 17b49464e13..835c4a1801e 100644 --- a/test/unittest/quick_fix/mock/include/mock_quick_fix_callback_stub.h +++ b/test/unittest/quick_fix/mock/include/mock_quick_fix_callback_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,9 +24,9 @@ namespace AppExecFwk { class MockQuickFixCallbackStub : public QuickFixCallbackStub { public: MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel&, MessageParcel&, MessageOption&)); - MOCK_METHOD2(OnLoadPatchDone, void(int32_t resultCode, int32_t recordId)); - MOCK_METHOD2(OnUnloadPatchDone, void(int32_t resultCode, int32_t recordId)); - MOCK_METHOD2(OnReloadPageDone, void(int32_t resultCode, int32_t recordId)); + MOCK_METHOD2(OnLoadPatchDone, ErrCode(int32_t resultCode, int32_t recordId)); + MOCK_METHOD2(OnUnloadPatchDone, ErrCode(int32_t resultCode, int32_t recordId)); + MOCK_METHOD2(OnReloadPageDone, ErrCode(int32_t resultCode, int32_t recordId)); int InvokeSendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { diff --git a/test/unittest/quick_fix/quick_fix_callback_proxy_test/quick_fix_callback_proxy_test.cpp b/test/unittest/quick_fix/quick_fix_callback_proxy_test/quick_fix_callback_proxy_test.cpp index 6c96b8d56c0..c142cbd5b57 100644 --- a/test/unittest/quick_fix/quick_fix_callback_proxy_test/quick_fix_callback_proxy_test.cpp +++ b/test/unittest/quick_fix/quick_fix_callback_proxy_test/quick_fix_callback_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -74,7 +74,7 @@ HWTEST_F(QuickFixCallbackProxyTest, OnLoadPatchDone_0100, TestSize.Level1) quickFixMgrProxy_->OnLoadPatchDone(resultCode, recordId); EXPECT_EQ(mockCallbackService_->code_, - static_cast(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH)); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_LOAD_PATCH_DONE)); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } @@ -98,7 +98,7 @@ HWTEST_F(QuickFixCallbackProxyTest, OnUnloadPatchDone_0100, TestSize.Level1) quickFixMgrProxy_->OnUnloadPatchDone(resultCode, recordId); EXPECT_EQ(mockCallbackService_->code_, - static_cast(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_UNLOAD_PATCH)); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_UNLOAD_PATCH_DONE)); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } @@ -122,7 +122,7 @@ HWTEST_F(QuickFixCallbackProxyTest, OnReloadPageDone_0100, TestSize.Level1) quickFixMgrProxy_->OnReloadPageDone(resultCode, recordId); EXPECT_EQ(mockCallbackService_->code_, - static_cast(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_RELOAD_PAGE)); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_RELOAD_PAGE_DONE)); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } diff --git a/test/unittest/quick_fix/quick_fix_callback_stub_test/quick_fix_callback_stub_test.cpp b/test/unittest/quick_fix/quick_fix_callback_stub_test/quick_fix_callback_stub_test.cpp index 85ffb70f707..aa558e2e9b5 100644 --- a/test/unittest/quick_fix/quick_fix_callback_stub_test/quick_fix_callback_stub_test.cpp +++ b/test/unittest/quick_fix/quick_fix_callback_stub_test/quick_fix_callback_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -74,7 +74,7 @@ HWTEST_F(QuickFixCallbackStubTest, OnLoadPatchDone_0100, TestSize.Level1) EXPECT_CALL(*mockQuickFixCallback_, OnLoadPatchDone(_, _)).Times(1); auto result = mockQuickFixCallback_->OnRemoteRequest( - IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH, data, reply, option); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_LOAD_PATCH_DONE), data, reply, option); EXPECT_EQ(result, NO_ERROR); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); @@ -103,7 +103,7 @@ HWTEST_F(QuickFixCallbackStubTest, OnUnloadPatchDone_0100, TestSize.Level1) EXPECT_CALL(*mockQuickFixCallback_, OnUnloadPatchDone(_, _)).Times(1); auto result = mockQuickFixCallback_->OnRemoteRequest( - IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_UNLOAD_PATCH, data, reply, option); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_UNLOAD_PATCH_DONE), data, reply, option); EXPECT_EQ(result, NO_ERROR); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); @@ -132,7 +132,7 @@ HWTEST_F(QuickFixCallbackStubTest, OnReloadPageDone_0100, TestSize.Level1) EXPECT_CALL(*mockQuickFixCallback_, OnReloadPageDone(_, _)).Times(1); auto result = mockQuickFixCallback_->OnRemoteRequest( - IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_RELOAD_PAGE, data, reply, option); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_RELOAD_PAGE_DONE), data, reply, option); EXPECT_EQ(result, NO_ERROR); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); @@ -157,8 +157,8 @@ HWTEST_F(QuickFixCallbackStubTest, OnRemoteRequest_0100, TestSize.Level1) data.WriteInt32(resultCode); auto result = mockQuickFixCallback_->OnRemoteRequest( - IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH, data, reply, option); - EXPECT_EQ(result, ERR_INVALID_STATE); + static_cast(IQuickFixCallbackIpcCode::COMMAND_ON_LOAD_PATCH_DONE), data, reply, option); + EXPECT_EQ(result, ERR_TRANSACTION_FAILED); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } diff --git a/test/unittest/quick_fix/quick_fix_callback_with_record_test/quick_fix_callback_with_record_test.cpp b/test/unittest/quick_fix/quick_fix_callback_with_record_test/quick_fix_callback_with_record_test.cpp index 54aba74a686..5d7a6739dc0 100644 --- a/test/unittest/quick_fix/quick_fix_callback_with_record_test/quick_fix_callback_with_record_test.cpp +++ b/test/unittest/quick_fix/quick_fix_callback_with_record_test/quick_fix_callback_with_record_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -28,28 +28,31 @@ public: QuickFixCallbackImpl() = default; virtual ~QuickFixCallbackImpl() = default; - void OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + ErrCode OnLoadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); loadPatchDone_ = true; loadPatchResult_ = resultCode; loadPatchTimes_++; + return ERR_OK; } - void OnUnloadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + ErrCode OnUnloadPatchDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); unloadPatchDone_ = true; unloadPatchResult_ = resultCode; unloadPatchTimes_++; + return ERR_OK; } - void OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override + ErrCode OnReloadPageDone(int32_t resultCode, [[maybe_unused]] int32_t recordId) override { TAG_LOGD(AAFwkTag::TEST, "function called."); reloadPageDone_ = true; reloadPageResult_ = resultCode; reloadPageTimes_++; + return ERR_OK; } bool loadPatchDone_ = false; -- Gitee From 72ff1f68b944058689cb0d67275ae068ab30bb50 Mon Sep 17 00:00:00 2001 From: 18795846185 Date: Tue, 17 Jun 2025 14:05:28 +0800 Subject: [PATCH 2/2] INativeChildNotify Signed-off-by: 18795846185 --- .../include/native_child_callback.h | 8 +- .../src/native_child_callback.cpp | 18 +-- interfaces/inner_api/app_manager/BUILD.gn | 3 +- .../INativeChildNotify.idl} | 34 ++--- .../include/appmgr/app_mgr_interface.h | 2 +- .../appmgr/native_child_notify_interface.h | 65 ---------- .../appmgr/native_child_notify_proxy.h | 44 ------- .../src/appmgr/native_child_notify_proxy.cpp | 116 ------------------ .../src/appmgr/native_child_notify_stub.cpp | 81 ------------ .../include/native_child_ipc_process.h | 4 +- .../appmgr/include/app_mgr_service_inner.h | 2 +- .../appmgr/include/app_native_spawn_manager.h | 2 +- ...cesappmgrnativechildnotifyproxy_fuzzer.cpp | 19 +-- ...acesappmgrnativechildnotifystub_fuzzer.cpp | 23 ++-- .../fuzztest/cleanallmissions_fuzzer/BUILD.gn | 6 +- test/unittest/BUILD.gn | 2 - test/unittest/ams_ipc_interface_test/BUILD.gn | 2 +- .../ams_ipc_appmgr_interface_test.cpp | 17 ++- .../app_mgr_stub_test/app_mgr_stub_test.cpp | 17 ++- 19 files changed, 77 insertions(+), 388 deletions(-) rename interfaces/inner_api/app_manager/{include/appmgr/native_child_notify_stub.h => idl/INativeChildNotify.idl} (38%) delete mode 100644 interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h delete mode 100644 interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h delete mode 100644 interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp delete mode 100644 interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp diff --git a/frameworks/native/child_process/include/native_child_callback.h b/frameworks/native/child_process/include/native_child_callback.h index 128ef026e50..c13e68d8d02 100644 --- a/frameworks/native/child_process/include/native_child_callback.h +++ b/frameworks/native/child_process/include/native_child_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -29,9 +29,9 @@ public: explicit NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb); ~NativeChildCallback() = default; - void OnNativeChildStarted(const sptr &nativeChild) override; - void OnError(int32_t errCode) override; - int32_t OnNativeChildExit(int32_t pid, int32_t signal) override; + ErrCode OnNativeChildStarted(const sptr &nativeChild) override; + ErrCode OnError(int32_t errCode) override; + ErrCode OnNativeChildExit(int32_t pid, int32_t signal) override; bool IsCallbacksEmpty(); void AddExitCallback(OH_Ability_OnNativeChildProcessExit callback); diff --git a/frameworks/native/child_process/src/native_child_callback.cpp b/frameworks/native/child_process/src/native_child_callback.cpp index 86e45164342..95a743ba6be 100644 --- a/frameworks/native/child_process/src/native_child_callback.cpp +++ b/frameworks/native/child_process/src/native_child_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -26,16 +26,16 @@ NativeChildCallback::NativeChildCallback(OH_Ability_OnNativeChildProcessStarted { } -void NativeChildCallback::OnNativeChildStarted(const sptr &nativeChild) +ErrCode NativeChildCallback::OnNativeChildStarted(const sptr &nativeChild) { if (callback_ == nullptr) { TAG_LOGE(AAFwkTag::PROCESSMGR, "null callback_"); - return; + return ERR_INVALID_VALUE; } if (!nativeChild) { TAG_LOGE(AAFwkTag::PROCESSMGR, "null nativeChild"); - return; + return ERR_INVALID_VALUE; } TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process started"); @@ -44,20 +44,21 @@ void NativeChildCallback::OnNativeChildStarted(const sptr &native if (ipcProxy == nullptr) { TAG_LOGE(AAFwkTag::PROCESSMGR, "null ipcProxy"); callback_(NCP_ERR_INTERNAL, nullptr); - return; + return ERR_INVALID_VALUE; } callback_(static_cast(ChildProcessManagerErrorCode::ERR_OK), ipcProxy); callback_ = nullptr; ChildCallbackManager::GetInstance().RemoveRemoteObject(this); + return ERR_OK; } -void NativeChildCallback::OnError(int32_t errCode) +ErrCode NativeChildCallback::OnError(int32_t errCode) { if (callback_ == nullptr) { TAG_LOGE(AAFwkTag::PROCESSMGR, "null callback_"); - return; + return ERR_INVALID_VALUE; } TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process start err %{public}d", errCode); @@ -65,9 +66,10 @@ void NativeChildCallback::OnError(int32_t errCode) callback_ = nullptr; ChildCallbackManager::GetInstance().RemoveRemoteObject(this); + return ERR_OK; } -int32_t NativeChildCallback::OnNativeChildExit(int32_t pid, int32_t signal) +ErrCode NativeChildCallback::OnNativeChildExit(int32_t pid, int32_t signal) { auto exitCallbacks = GetExitCallbacks(); for (const auto &exitCallback : exitCallbacks) { diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index e31cb7a8462..d9c9bdf700f 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -46,6 +46,7 @@ idl_gen_interface("appmgr_innerkits") { "idl/IAbilityDebugResponse.idl", "idl/IAppDebugListener.idl", "idl/IKiaInterceptor.idl", + "idl/INativeChildNotify.idl", "idl/IQuickFixCallback.idl", "idl/IStartSpecifiedAbilityResponse.idl", ] @@ -206,8 +207,6 @@ ohos_shared_library("app_manager") { "src/appmgr/fault_data.cpp", "src/appmgr/killed_process_info.cpp", "src/appmgr/memory_level_info.cpp", - "src/appmgr/native_child_notify_proxy.cpp", - "src/appmgr/native_child_notify_stub.cpp", "src/appmgr/page_state_data.cpp", "src/appmgr/priority_object.cpp", "src/appmgr/process_data.cpp", diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h b/interfaces/inner_api/app_manager/idl/INativeChildNotify.idl similarity index 38% rename from interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h rename to interfaces/inner_api/app_manager/idl/INativeChildNotify.idl index e81ad08281f..49699047468 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h +++ b/interfaces/inner_api/app_manager/idl/INativeChildNotify.idl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,30 +13,10 @@ * limitations under the License. */ -#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H -#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H +sequenceable OHOS.IRemoteObject; -#include "native_child_notify_interface.h" -#include "iremote_stub.h" - -namespace OHOS { -namespace AppExecFwk { - -class NativeChildNotifyStub : public IRemoteStub { -public: - NativeChildNotifyStub() = default; - virtual ~NativeChildNotifyStub() = default; - - int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int32_t HandleOnNativeChildStarted(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnError(MessageParcel &data, MessageParcel &reply); - int32_t HandleOnNativeChildExit(MessageParcel &data, MessageParcel &reply); -}; - -} // OHOS -} // AppExecFwk - -#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H \ No newline at end of file +interface OHOS.AppExecFwk.INativeChildNotify { + [oneway] void OnNativeChildStarted([in] IRemoteObject nativeChild); + [oneway] void OnError([in] int errorCode); + [oneway] void OnNativeChildExit([in] int pid, [in] int signal); +}; \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 99a765c85a6..677b1e28794 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -35,6 +35,7 @@ #include "iapp_state_callback.h" #include "iapplication_state_observer.h" #include "iconfiguration_observer.h" +#include "inative_child_notify.h" #include "ikia_interceptor.h" #include "iquick_fix_callback.h" #include "iremote_broker.h" @@ -51,7 +52,6 @@ #include "app_jsheap_mem_info.h" #include "app_cjheap_mem_info.h" #include "running_multi_info.h" -#include "native_child_notify_interface.h" namespace OHOS { namespace AppExecFwk { diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h deleted file mode 100644 index 3eba849f17f..00000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H -#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H - -#include "iremote_broker.h" - -namespace OHOS { -namespace AppExecFwk { - -class INativeChildNotify : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.NativeChildNotify"); - - /** - * Notify native child process started. - * - * @param nativeChild child process ipc object - */ - virtual void OnNativeChildStarted(const sptr &nativeChild) = 0; - - /** - * Notify native child process start failed. - * - * @param errCode failed error code - */ - virtual void OnError(int32_t errCode) = 0; - - /** - * Notify native child process exit. - * - * @param pid child process pid - * @param signal child process exit signal - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t OnNativeChildExit(int32_t pid, int32_t signal) = 0; - - enum { - // ipc id for OnNativeChildStarted - IPC_ID_ON_NATIVE_CHILD_STARTED = 0, - - // ipc id for OnError - IPC_ID_ON_ERROR = 1, - - IPC_ID_ON_NATIVE_CHILD_EXIT = 2 - }; -}; - -} // OHOS -} // AppExecFwk - -#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h deleted file mode 100644 index d843439fb1e..00000000000 --- a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H -#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H - -#include "native_child_notify_interface.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { - -class NativeChildNotifyProxy : public IRemoteProxy { -public: - explicit NativeChildNotifyProxy(const sptr &impl); - virtual ~NativeChildNotifyProxy() = default; - - void OnNativeChildStarted(const sptr &nativeChild) override; - void OnError(int32_t errCode) override; - int32_t OnNativeChildExit(int32_t pid, int32_t signal) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption& option); - - static inline BrokerDelegator delegator_; -}; - -} // OHOS -} // AppExecFwk - -#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp deleted file mode 100644 index 533799eaa6a..00000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_child_notify_proxy.h" -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" - -namespace OHOS { -namespace AppExecFwk { - -NativeChildNotifyProxy::NativeChildNotifyProxy(const sptr &impl) - : IRemoteProxy(impl) -{ -} - -bool NativeChildNotifyProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(NativeChildNotifyProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write interface token failed"); - return false; - } - - return true; -} - -int32_t NativeChildNotifyProxy::SendRequest(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption& option) -{ - sptr remote = Remote(); - if (!remote) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy get remote object failed"); - return ERR_NULL_OBJECT; - } - - int32_t ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy SendRequest failed(%{public}d)", ret); - return ret; - } - - return NO_ERROR; -} - -void NativeChildNotifyProxy::OnNativeChildStarted(const sptr &nativeChild) -{ - TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnNativeChildStarted"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (!data.WriteRemoteObject(nativeChild)) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write native child ipc object failed."); - return; - } - - SendRequest(INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED, data, reply, option); -} - -void NativeChildNotifyProxy::OnError(int32_t errCode) -{ - TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnError(%{public}d)", errCode); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - - if (!data.WriteInt32(errCode)) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write error code failed."); - return; - } - - SendRequest(INativeChildNotify::IPC_ID_ON_ERROR, data, reply, option); -} - -int32_t NativeChildNotifyProxy::OnNativeChildExit(int32_t pid, int32_t signal) -{ - TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnNativeChildExit"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return ERR_NULL_OBJECT; - } - - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write native child pid failed."); - return ERR_NULL_OBJECT; - } - - if (!data.WriteInt32(signal)) { - TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write native child signal failed."); - return ERR_NULL_OBJECT; - } - - return SendRequest(INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_EXIT, data, reply, option); -} - -} // OHOS -} // AppExecFwk \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp deleted file mode 100644 index 7d1e4925154..00000000000 --- a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_child_notify_stub.h" -#include "hilog_tag_wrapper.h" -#include "ipc_types.h" - -namespace OHOS { -namespace AppExecFwk { - -int NativeChildNotifyStub::OnRemoteRequest(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyStub::OnRemoteRequest, code=%{public}u, flags=%{public}d.", - code, option.GetFlags()); - std::u16string descriptor = NativeChildNotifyStub::GetDescriptor(); - std::u16string remoteDesc = data.ReadInterfaceToken(); - if (descriptor != remoteDesc) { - TAG_LOGE(AAFwkTag::APPMGR, "A local descriptor is not equivalent to a remote"); - return ERR_INVALID_STATE; - } - - int32_t ret; - switch (code) { - case INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED: - ret = HandleOnNativeChildStarted(data, reply); - break; - - case INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_EXIT: - ret = HandleOnNativeChildExit(data, reply); - break; - - case INativeChildNotify::IPC_ID_ON_ERROR: - ret = HandleOnError(data, reply); - break; - - default: - TAG_LOGW(AAFwkTag::APPMGR, "NativeChildNotifyStub Unknow ipc call(%{public}u)", code); - ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); - break; - } - - TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyStub::OnRemoteRequest end"); - return ret; -} - -int32_t NativeChildNotifyStub::HandleOnNativeChildStarted(MessageParcel &data, MessageParcel &reply) -{ - sptr cb = data.ReadRemoteObject(); - OnNativeChildStarted(cb); - return ERR_NONE; -} - -int32_t NativeChildNotifyStub::HandleOnNativeChildExit(MessageParcel &data, MessageParcel &reply) -{ - int pid = data.ReadInt32(); - int signal = data.ReadInt32(); - return OnNativeChildExit(pid, signal); -} - -int32_t NativeChildNotifyStub::HandleOnError(MessageParcel &data, MessageParcel &reply) -{ - int32_t err = data.ReadInt32(); - OnError(err); - return ERR_NONE; -} - -} // OHOS -} // AppExecFwk diff --git a/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h b/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h index 5a007069e87..f69b5fb9144 100644 --- a/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h +++ b/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -18,7 +18,7 @@ #include #include "child_process.h" -#include "native_child_notify_interface.h" +#include "inative_child_notify.h" #include "ipc_inner_object.h" namespace OHOS { diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index dbe861e5cd0..0437ca56d88 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -62,6 +62,7 @@ #include "iapplication_state_observer.h" #include "iconfiguration_observer.h" #include "ikia_interceptor.h" +#include "inative_child_notify.h" #include "iremote_object.h" #include "irender_state_observer.h" #include "istart_specified_ability_response.h" @@ -82,7 +83,6 @@ #include "running_multi_info.h" #include "multi_user_config_mgr.h" #include "iuser_callback.h" -#include "native_child_notify_interface.h" namespace OHOS { namespace AbilityRuntime { diff --git a/services/appmgr/include/app_native_spawn_manager.h b/services/appmgr/include/app_native_spawn_manager.h index 31f4a2793c7..0fcfd4153ec 100644 --- a/services/appmgr/include/app_native_spawn_manager.h +++ b/services/appmgr/include/app_native_spawn_manager.h @@ -20,7 +20,7 @@ #include #include "nocopyable.h" #include "app_running_manager.h" -#include "native_child_notify_interface.h" +#include "inative_child_notify.h" namespace OHOS { namespace AppExecFwk { diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer.cpp index 0a571fa70c9..3b8a5210b42 100644 --- a/test/fuzztest/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer.cpp +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer/abilityinterfacesappmgrnativechildnotifyproxy_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -19,8 +19,8 @@ #include #define private public +#include "inative_child_notify.h" #include "native_child_notify_proxy.h" -#include "native_child_notify_interface.h" #undef private #include "securec.h" @@ -72,21 +72,6 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) infosProxy->OnNativeChildStarted(nativeChild); int32_t errCode = static_cast(GetU32Data(data)); infosProxy->OnError(errCode); - MessageParcel parcel; - parcel.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN); - parcel.WriteBuffer(data, size); - parcel.RewindRead(0); - MessageParcel parcels; - parcels.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN); - parcels.WriteBuffer(data, size); - parcels.RewindRead(0); - infosProxy->WriteInterfaceToken(parcels); - uint32_t codeOne = static_cast(INPUT_ZERO); - MessageParcel reply; - MessageOption option; - infosProxy->SendRequest(codeOne, parcel, reply, option); - uint32_t codeTwo = static_cast(INPUT_ONE); - infosProxy->SendRequest(codeTwo, parcel, reply, option); return true; } } diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp index ac67588a931..68361148c33 100644 --- a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 @@ -20,8 +20,8 @@ #define private public #define protected public +#include "inative_child_notify.h" #include "native_child_notify_stub.h" -#include "native_child_notify_interface.h" #undef protected #undef private @@ -58,9 +58,18 @@ public: virtual ~ NativeChildNotifyStubFUZZ() {}; int OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override{ return 0; }; - void OnNativeChildStarted(const sptr &nativeChild) override{}; - void OnError(int32_t errCode) override{}; - int32_t OnNativeChildExit(int32_t pid, int32_t signal) override{ return 0; }; + ErrCode OnNativeChildStarted(const sptr &nativeChild) override + { + return ERR_OK; + } + ErrCode OnError(int32_t errCode) override + { + return ERR_OK; + } + ErrCode OnNativeChildExit(int32_t pid, int32_t signal) override + { + return ERR_OK; + } }; sptr GetFuzzAbilityToken() @@ -79,7 +88,7 @@ sptr GetFuzzAbilityToken() bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { - uint32_t code = static_cast(INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED); + uint32_t code = static_cast(INativeChildNotifyIpcCode::COMMAND_ON_NATIVE_CHILD_STARTED); MessageParcel parcel; parcel.WriteInterfaceToken(NATIVE_CHILD_NOTIFY_TOKEN); parcel.WriteBuffer(data, size); @@ -88,7 +97,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) MessageOption option; std::shared_ptr abms = std::make_shared(); abms->OnRemoteRequest(code, parcel, reply, option); - code = static_cast(INativeChildNotify::IPC_ID_ON_ERROR); + code = static_cast(INativeChildNotifyIpcCode::COMMAND_ON_ERROR); abms->OnRemoteRequest(code, parcel, reply, option); return true; } diff --git a/test/fuzztest/cleanallmissions_fuzzer/BUILD.gn b/test/fuzztest/cleanallmissions_fuzzer/BUILD.gn index 0f2a26569e1..d5fa5ab7067 100755 --- a/test/fuzztest/cleanallmissions_fuzzer/BUILD.gn +++ b/test/fuzztest/cleanallmissions_fuzzer/BUILD.gn @@ -38,7 +38,10 @@ ohos_fuzztest("CleanAllMissionsFuzzTest") { "${ability_runtime_services_path}/abilitymgr:abilityms_config", ] - deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager" ] + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_innerkits", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager" , + ] external_deps = [ "ability_base:want", @@ -46,6 +49,7 @@ ohos_fuzztest("CleanAllMissionsFuzzTest") { "ability_runtime:app_manager", "c_utils:utils", "eventhandler:libeventhandler", + "hilog:libhilog", "ipc:ipc_core", "jsoncpp:jsoncpp", "relational_store:native_dataability", diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 88c49ffabd1..56ca4fa8c83 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -43,8 +43,6 @@ ohos_source_set("appmgr_test_source") { "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_scheduler_host.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_scheduler_proxy.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/fault_data.cpp", - "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_proxy.cpp", - "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_stub.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_info.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/profile.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/render_scheduler_host.cpp", diff --git a/test/unittest/ams_ipc_interface_test/BUILD.gn b/test/unittest/ams_ipc_interface_test/BUILD.gn index 7de5dadff38..f794cca64cc 100644 --- a/test/unittest/ams_ipc_interface_test/BUILD.gn +++ b/test/unittest/ams_ipc_interface_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test/unittest/ams_ipc_interface_test/ams_ipc_appmgr_interface_test.cpp b/test/unittest/ams_ipc_interface_test/ams_ipc_appmgr_interface_test.cpp index f12b91f70f0..6372eb3d018 100644 --- a/test/unittest/ams_ipc_interface_test/ams_ipc_appmgr_interface_test.cpp +++ b/test/unittest/ams_ipc_interface_test/ams_ipc_appmgr_interface_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -45,9 +45,18 @@ public: NativeChildCallbackMock() = default; virtual ~NativeChildCallbackMock() = default; - void OnNativeChildStarted(const sptr &nativeChild) {} - void OnError(int32_t errCode) {} - int32_t OnNativeChildExit(int32_t pid, int32_t signal) { return 0; } + ErrCode OnNativeChildStarted(const sptr &nativeChild) + { + return ERR_OK; + } + ErrCode OnError(int32_t errCode) + { + return ERR_OK; + } + ErrCode OnNativeChildExit(int32_t pid, int32_t signal) + { + return ERR_OK; + } }; class AmsIpcAppMgrInterfaceTest : public testing::Test { diff --git a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp index 7cdbab6100c..1de9b86baf1 100644 --- a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp +++ b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -58,9 +58,18 @@ public: NativeChildCallbackMock() = default; virtual ~NativeChildCallbackMock() = default; - void OnNativeChildStarted(const sptr &nativeChild) {} - void OnError(int32_t errCode) {} - int32_t OnNativeChildExit(int32_t pid, int32_t signal) { return 0; } + ErrCode OnNativeChildStarted(const sptr &nativeChild) + { + return ERR_OK; + } + ErrCode OnError(int32_t errCode) + { + return ERR_OK; + } + ErrCode OnNativeChildExit(int32_t pid, int32_t signal) + { + return ERR_OK; + } }; class AppMgrStubTest : public testing::Test { -- Gitee