From fda8c7d3c25bf294cee544016cb83f35a0488f70 Mon Sep 17 00:00:00 2001 From: zhengzhuolan Date: Fri, 28 Mar 2025 17:08:15 +0800 Subject: [PATCH] ans operation callback Signed-off-by: zhengzhuolan --- frameworks/ans/BUILD.gn | 71 ++++++++++++++++++- .../IAnsOperationCallback.idl} | 59 +++++---------- frameworks/ans/src/notification_helper.cpp | 4 +- .../core/include/ans_manager_interface.h | 4 +- frameworks/core/include/ans_manager_proxy.h | 2 +- frameworks/core/include/ans_manager_stub.h | 2 +- frameworks/core/include/ans_notification.h | 2 +- .../include/ans_operation_callback_proxy.h | 37 ---------- .../include/ans_operation_callback_stub.h | 38 ---------- frameworks/core/src/ans_notification.cpp | 2 +- .../listener/ans_operation_callback_proxy.cpp | 48 ------------- .../listener/ans_operation_callback_stub.cpp | 51 ------------- .../core/src/manager/ans_manager_proxy.cpp | 4 +- .../src/manager/ans_manager_stub_invalid.cpp | 2 +- .../ans_notification_branch_test.cpp | 2 +- .../include/distributed_operation_callback.h | 4 +- .../src/distributed_operation_callback.cpp | 5 +- interfaces/inner_api/notification_helper.h | 6 +- .../include/advanced_notification_service.h | 2 +- .../notification_operation_service.h | 8 +-- .../advanced_notification_publish_service.cpp | 4 +- services/ans/src/ans_manager_stub.cpp | 2 +- services/ans/src/ans_manager_stub_invalid.cpp | 2 +- .../notification_operation_service.cpp | 2 +- ...nced_notification_publish_service_test.cpp | 2 +- 25 files changed, 118 insertions(+), 247 deletions(-) rename frameworks/{core/include/ans_operation_callback_interface.h => ans/IAnsOperationCallback.idl} (43%) delete mode 100644 frameworks/core/include/ans_operation_callback_proxy.h delete mode 100644 frameworks/core/include/ans_operation_callback_stub.h delete mode 100644 frameworks/core/src/listener/ans_operation_callback_proxy.cpp delete mode 100644 frameworks/core/src/listener/ans_operation_callback_stub.cpp diff --git a/frameworks/ans/BUILD.gn b/frameworks/ans/BUILD.gn index d3bc5fc36..bf798c13f 100644 --- a/frameworks/ans/BUILD.gn +++ b/frameworks/ans/BUILD.gn @@ -30,6 +30,14 @@ idl_gen_interface("ans_dialog_callback_interface") { part_name = "distributed_notification_service" } +idl_gen_interface("ans_operation_callback_interface") { + sources = [ "IAnsOperationCallback.idl" ] + log_domainid = "0xD001203" + log_tag = "Ans" + subsystem_name = "notification" + part_name = "distributed_notification_service" +} + group("ans_client") { deps = [ ":ans_innerkits" ] } @@ -61,6 +69,19 @@ config("ans_innerkits_config") { configs = [ "${multimedia_path}/interfaces/innerkits:image_external_config" ] } +config("ans_operation_callback_config") { + visibility = [ "./../../*" ] + + include_dirs = [ + "${inner_api_path}", + "${interfaces_path}/kits/native", + "${core_path}/common/include", + "${core_path}/include", + "${target_gen_dir}", + ] + configs = [ "${multimedia_path}/interfaces/innerkits:image_external_config" ] +} + config("swing_call_back_config") { visibility = [ "./../../*" ] @@ -138,8 +159,6 @@ ohos_shared_library("ans_innerkits") { "${core_path}/src/ans_image_util.cpp", "${core_path}/src/ans_notification.cpp", "${core_path}/src/dialog_status_data.cpp", - "${core_path}/src/listener/ans_operation_callback_proxy.cpp", - "${core_path}/src/listener/ans_operation_callback_stub.cpp", "${core_path}/src/listener/ans_subscriber_listener.cpp", "${core_path}/src/listener/ans_subscriber_local_live_view_proxy.cpp", "${core_path}/src/listener/ans_subscriber_local_live_view_stub.cpp", @@ -209,6 +228,8 @@ ohos_shared_library("ans_innerkits") { deps = [ ":ans_dialog_callback_proxy", ":ans_dialog_callback_stub", + ":ans_operation_callback_proxy", + ":ans_operation_callback_stub", ] external_deps = [ @@ -303,3 +324,49 @@ ohos_source_set("ans_dialog_callback_stub") { subsystem_name = "notification" part_name = "distributed_notification_service" } + +ohos_source_set("ans_operation_callback_proxy") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":ans_operation_callback_config" ] + output_values = get_target_outputs(":ans_operation_callback_interface") + sources = filter_include(output_values, [ "*_proxy.cpp" ]) + deps = [ ":ans_operation_callback_interface" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + subsystem_name = "notification" + part_name = "distributed_notification_service" +} + +ohos_source_set("ans_operation_callback_stub") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":ans_operation_callback_config" ] + output_values = get_target_outputs(":ans_operation_callback_interface") + sources = filter_include(output_values, [ "*_stub.cpp" ]) + deps = [ ":ans_operation_callback_interface" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + subsystem_name = "notification" + part_name = "distributed_notification_service" +} diff --git a/frameworks/core/include/ans_operation_callback_interface.h b/frameworks/ans/IAnsOperationCallback.idl similarity index 43% rename from frameworks/core/include/ans_operation_callback_interface.h rename to frameworks/ans/IAnsOperationCallback.idl index f5e2c7576..6e2bedee0 100644 --- a/frameworks/core/include/ans_operation_callback_interface.h +++ b/frameworks/ans/IAnsOperationCallback.idl @@ -1,41 +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 BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_INTERFACE_H -#define BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_INTERFACE_H - -#include "iremote_broker.h" - -#include "nocopyable.h" -#include "parcel.h" - -namespace OHOS::Notification { - -class OperationCallbackInterface : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.AnsDistributedOperationCallback"); - - OperationCallbackInterface() = default; - ~OperationCallbackInterface() override = default; - DISALLOW_COPY_AND_MOVE(OperationCallbackInterface); - - virtual void OnOperationCallback(int32_t operationResult) = 0; - - enum { ON_DISTRIBUTED_OPERATION_CALLBACK = 1 }; -}; -} // namespace OHOS::Notification - -#endif // BASE_NOTIFICATION_ANS_DIALOG_CALLBACK_INTERFACE_H - +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface OHOS.Notification.IAnsOperationCallback { + void OnOperationCallback([in] int operationResult); +} \ No newline at end of file diff --git a/frameworks/ans/src/notification_helper.cpp b/frameworks/ans/src/notification_helper.cpp index c06dd19e3..930eada13 100644 --- a/frameworks/ans/src/notification_helper.cpp +++ b/frameworks/ans/src/notification_helper.cpp @@ -1,5 +1,5 @@ /* - * 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 @@ -634,7 +634,7 @@ ErrCode NotificationHelper::GetDoNotDisturbProfile(int32_t id, sptr& operationInfo, - const sptr &callback) + const sptr &callback) { return DelayedSingleton::GetInstance()->DistributeOperation(operationInfo, callback); } diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h index 3a59ea218..2d4e330b2 100644 --- a/frameworks/core/include/ans_manager_interface.h +++ b/frameworks/core/include/ans_manager_interface.h @@ -32,7 +32,7 @@ #include "notification_slot.h" #include "notification_subscribe_info.h" #include "reminder_request.h" -#include "ans_operation_callback_interface.h" +#include "ians_operation_callback.h" namespace OHOS { namespace Notification { @@ -1027,7 +1027,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ virtual ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) = 0; + const sptr &callback) = 0; /** * @brief Reply distribute operation. diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h index 0bc5181df..07f365004 100644 --- a/frameworks/core/include/ans_manager_proxy.h +++ b/frameworks/core/include/ans_manager_proxy.h @@ -1008,7 +1008,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override; + const sptr &callback) override; /** * @brief Reply distribute operation. diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index eccb94413..1e278d05f 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.h @@ -1009,7 +1009,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ virtual ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override; + const sptr &callback) override; /** * @brief Reply distribute operation. diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index 14f96359c..4eaf7139f 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -1248,7 +1248,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback); + const sptr &callback); /** * @brief Reply distribute operation. diff --git a/frameworks/core/include/ans_operation_callback_proxy.h b/frameworks/core/include/ans_operation_callback_proxy.h deleted file mode 100644 index 5366d21b4..000000000 --- a/frameworks/core/include/ans_operation_callback_proxy.h +++ /dev/null @@ -1,37 +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 BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_PROXY_H -#define BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_PROXY_H - -#include "ans_operation_callback_interface.h" - -#include "iremote_proxy.h" - -namespace OHOS::Notification { -class OperationCallbackProxy : public IRemoteProxy { -public: - explicit OperationCallbackProxy(const sptr &impl) - : IRemoteProxy(impl) {} - ~OperationCallbackProxy() override = default; - DISALLOW_COPY_AND_MOVE(OperationCallbackProxy); - void OnOperationCallback(int32_t operationResult) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS::Notification - -#endif // BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_PROXY_H diff --git a/frameworks/core/include/ans_operation_callback_stub.h b/frameworks/core/include/ans_operation_callback_stub.h deleted file mode 100644 index 6bf76115d..000000000 --- a/frameworks/core/include/ans_operation_callback_stub.h +++ /dev/null @@ -1,38 +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 BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_STUB_H -#define BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_STUB_H - -#include "ans_operation_callback_interface.h" - -#include - -#include "iremote_stub.h" - -namespace OHOS::Notification { -class OperationCallbackStub : public IRemoteStub { -public: - OperationCallbackStub() = default; - ~OperationCallbackStub() override = default; - DISALLOW_COPY_AND_MOVE(OperationCallbackStub); - void OnOperationCallback(int32_t operationResult) override; - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) override; -}; -} // namespace OHOS::Notification - -#endif // BASE_NOTIFICATION_ANS_DISTRIBUTED_OPERATION_CALLBACK_STUB_H - diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 63a0c9217..c4311db5c 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -2084,7 +2084,7 @@ ErrCode AnsNotification::DisableNotificationFeature(const NotificationDisable &n } ErrCode AnsNotification::DistributeOperation(sptr& operationInfo, - const sptr &callback) + const sptr &callback) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); if (operationInfo == nullptr || callback == nullptr) { diff --git a/frameworks/core/src/listener/ans_operation_callback_proxy.cpp b/frameworks/core/src/listener/ans_operation_callback_proxy.cpp deleted file mode 100644 index c4fd10560..000000000 --- a/frameworks/core/src/listener/ans_operation_callback_proxy.cpp +++ /dev/null @@ -1,48 +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 "ans_operation_callback_proxy.h" - -#include "ans_log_wrapper.h" - -namespace OHOS::Notification { -void OperationCallbackProxy::OnOperationCallback(int32_t operationResult) -{ - ANS_LOGD("enter"); - MessageParcel data; - if (!data.WriteInterfaceToken(OperationCallbackProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return; - } - if (!data.WriteInt32(operationResult)) { - ANS_LOGE("Write statusData failed."); - return; - } - - sptr remote = Remote(); - if (remote == nullptr) { - ANS_LOGE("Remote is NULL"); - return; - } - - MessageParcel reply; - MessageOption option; - int error = remote->SendRequest(ON_DISTRIBUTED_OPERATION_CALLBACK, data, reply, option); - if (error != ERR_OK) { - ANS_LOGE("SendRequest fail, error: %{public}d", error); - } -} -} // namespace OHOS::Notification - diff --git a/frameworks/core/src/listener/ans_operation_callback_stub.cpp b/frameworks/core/src/listener/ans_operation_callback_stub.cpp deleted file mode 100644 index 5e2ec6102..000000000 --- a/frameworks/core/src/listener/ans_operation_callback_stub.cpp +++ /dev/null @@ -1,51 +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 "ans_operation_callback_stub.h" - -#include "ans_log_wrapper.h" -#include "ans_inner_errors.h" - -namespace OHOS::Notification { - -void OperationCallbackStub::OnOperationCallback(int32_t operationResult) -{ -} - -int32_t OperationCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - auto descriptorToken = data.ReadInterfaceToken(); - if (descriptorToken != GetDescriptor()) { - ANS_LOGE("Remote descriptor not the same as local descriptor."); - return ERR_INVALID_STATE; - } - switch (code) { - case ON_DISTRIBUTED_OPERATION_CALLBACK: { - int32_t resultCode = 0; - if (!data.ReadInt32(resultCode)) { - ANS_LOGE("read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - OnOperationCallback(resultCode); - break; - } - default: { - return ERR_INVALID_STATE; - } - } - return ERR_NONE; -} -} // namespace OHOS::Notification diff --git a/frameworks/core/src/manager/ans_manager_proxy.cpp b/frameworks/core/src/manager/ans_manager_proxy.cpp index 14c208215..45db4ec75 100644 --- a/frameworks/core/src/manager/ans_manager_proxy.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy.cpp @@ -1,5 +1,5 @@ /* - * 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 @@ -1042,7 +1042,7 @@ ErrCode AnsManagerProxy::DisableNotificationFeature(const sptr& operationInfo, - const sptr &callback) + const sptr &callback) { MessageParcel data; if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { diff --git a/frameworks/core/src/manager/ans_manager_stub_invalid.cpp b/frameworks/core/src/manager/ans_manager_stub_invalid.cpp index cbf0abf28..b091fc074 100644 --- a/frameworks/core/src/manager/ans_manager_stub_invalid.cpp +++ b/frameworks/core/src/manager/ans_manager_stub_invalid.cpp @@ -633,7 +633,7 @@ ErrCode AnsManagerStub::GetTargetDeviceStatus(const std::string &deviceType, int } ErrCode AnsManagerStub::DistributeOperation(sptr& operationInfo, - const sptr &callback) + const sptr &callback) { ANS_LOGE("DistributeOperation called!"); return ERR_INVALID_OPERATION; diff --git a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp index 5f18b8a63..242788b9a 100644 --- a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp @@ -612,7 +612,7 @@ public: } ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override + const sptr &callback) override { return ERR_ANS_INVALID_PARAM; } diff --git a/frameworks/js/napi/include/distributed_operation_callback.h b/frameworks/js/napi/include/distributed_operation_callback.h index 456f6bdea..62899cc77 100644 --- a/frameworks/js/napi/include/distributed_operation_callback.h +++ b/frameworks/js/napi/include/distributed_operation_callback.h @@ -23,11 +23,11 @@ namespace OHOS::NotificationNapi { -class DistributedOperationCallback : public OperationCallbackStub { +class DistributedOperationCallback : public AnsOperationCallbackStub { public: explicit DistributedOperationCallback(const AsyncOperationCallbackInfo &asyncCallbackInfo); ~DistributedOperationCallback() override; - void OnOperationCallback(const int32_t operationResult) override; + ErrCode OnOperationCallback(const int32_t operationResult) override; private: static void UvWorkOnCallBack(uv_work_t *work, int32_t status); diff --git a/frameworks/js/napi/src/distributed_operation_callback.cpp b/frameworks/js/napi/src/distributed_operation_callback.cpp index aa7de7d2f..a0d58a33d 100644 --- a/frameworks/js/napi/src/distributed_operation_callback.cpp +++ b/frameworks/js/napi/src/distributed_operation_callback.cpp @@ -28,12 +28,12 @@ DistributedOperationCallback::~DistributedOperationCallback() { } -void DistributedOperationCallback::OnOperationCallback(const int32_t operationResult) +ErrCode DistributedOperationCallback::OnOperationCallback(const int32_t operationResult) { OperationOnCallBack *operationOnCallBack = new (std::nothrow) OperationOnCallBack(); if (operationOnCallBack == nullptr) { ANS_LOGE("new operationOnCallBack failed"); - return; + return ERR_INVALID_DATA; } if (operationResult != ERR_OK) { @@ -47,6 +47,7 @@ void DistributedOperationCallback::OnOperationCallback(const int32_t operationRe if (!bRet) { ANS_LOGE("DistributedOperationCallback::OnCallBack failed"); } + return ERR_OK; } void DistributedOperationCallback::UvWorkOnCallBack(uv_work_t *work, int32_t status) diff --git a/interfaces/inner_api/notification_helper.h b/interfaces/inner_api/notification_helper.h index 397bfc792..b10aa878c 100644 --- a/interfaces/inner_api/notification_helper.h +++ b/interfaces/inner_api/notification_helper.h @@ -1,5 +1,5 @@ /* - * 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 @@ -29,7 +29,7 @@ #include "notification_local_live_view_subscriber.h" #include "want_params.h" #include -#include "ans_operation_callback_interface.h" +#include "ians_operation_callback.h" namespace OHOS { namespace Notification { @@ -1217,7 +1217,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ static ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback); + const sptr &callback); /** * @brief Reply distribute operation. diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 41d0b5f96..7ead58d2d 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1140,7 +1140,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override; + const sptr &callback) override; /** * @brief Reply distribute operation. diff --git a/services/ans/include/notification_extension/notification_operation_service.h b/services/ans/include/notification_extension/notification_operation_service.h index b1bacc7f2..983cb7c73 100644 --- a/services/ans/include/notification_extension/notification_operation_service.h +++ b/services/ans/include/notification_extension/notification_operation_service.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 @@ -21,7 +21,7 @@ #include "notification_config_parse.h" #include "distributed_data_define.h" #include "itimer_info.h" -#include "ans_operation_callback_interface.h" +#include "ians_operation_callback.h" #include #include @@ -68,7 +68,7 @@ class DistributedOperationService { public: static DistributedOperationService& GetInstance(); void AddOperation(const std::string& hashCode, - const sptr &callback); + const sptr &callback); void ReplyOperationResponse(const std::string& hashCode, int32_t result); void HandleOperationTimeOut(const std::string& hashCode); void RemoveOperationResponse(const std::string& hashCode); @@ -81,7 +81,7 @@ private: std::mutex mapLock_; std::shared_ptr operationQueue_ = nullptr; std::map timerMap_; - std::map> callbackMap_; + std::map> callbackMap_; }; } } diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 17e8f6c33..8de6ad586 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -3322,7 +3322,7 @@ ErrCode AdvancedNotificationService::RemoveAllNotificationsByBundleName(const st } ErrCode DistributeOperationParamCheck(sptr& operationInfo, - const sptr &callback) + const sptr &callback) { if (operationInfo == nullptr || operationInfo->GetHashCode().empty()) { ANS_LOGE("hashCode is empty."); @@ -3350,7 +3350,7 @@ ErrCode DistributeOperationParamCheck(sptr& operation } ErrCode AdvancedNotificationService::DistributeOperation(sptr& operationInfo, - const sptr &callback) + const sptr &callback) { ErrCode result = DistributeOperationParamCheck(operationInfo, callback); if (result != ERR_OK) { diff --git a/services/ans/src/ans_manager_stub.cpp b/services/ans/src/ans_manager_stub.cpp index 6bb9d69f7..813aee181 100644 --- a/services/ans/src/ans_manager_stub.cpp +++ b/services/ans/src/ans_manager_stub.cpp @@ -2691,7 +2691,7 @@ ErrCode AnsManagerStub::HandleDistributeOperation(MessageParcel &data, MessagePa return ERR_INVALID_DATA; } - sptr callback = iface_cast(remote); + sptr callback = iface_cast(remote); if (callback.GetRefPtr() == nullptr) { ANS_LOGE("callback is null"); return ERR_INVALID_DATA; diff --git a/services/ans/src/ans_manager_stub_invalid.cpp b/services/ans/src/ans_manager_stub_invalid.cpp index 3a5f27b18..509733848 100644 --- a/services/ans/src/ans_manager_stub_invalid.cpp +++ b/services/ans/src/ans_manager_stub_invalid.cpp @@ -594,7 +594,7 @@ ErrCode AnsManagerStub::GetTargetDeviceStatus(const std::string &deviceType, int } ErrCode AnsManagerStub::DistributeOperation(sptr& operationInfo, - const sptr &callback) + const sptr &callback) { ANS_LOGE("DistributeOperation called!"); return ERR_INVALID_OPERATION; diff --git a/services/ans/src/notification_extension/notification_operation_service.cpp b/services/ans/src/notification_extension/notification_operation_service.cpp index da309df44..293fc7bc9 100644 --- a/services/ans/src/notification_extension/notification_operation_service.cpp +++ b/services/ans/src/notification_extension/notification_operation_service.cpp @@ -48,7 +48,7 @@ DistributedOperationService::DistributedOperationService() } void DistributedOperationService::AddOperation(const std::string& hashCode, - const sptr &callback) + const sptr &callback) { int32_t timeout = DistributedExtensionService::GetInstance().GetOperationReplyTimeout(); int64_t expiredTime = NotificationAnalyticsUtil::GetCurrentTime() + timeout; diff --git a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp index 54151455e..2c19f8d34 100644 --- a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp @@ -1489,7 +1489,7 @@ HWTEST_F(AnsPublishServiceTest, RemoveAllNotificationsByBundleName_00001, Functi HWTEST_F(AnsPublishServiceTest, DistributeOperation_00001, Function | SmallTest | Level1) { sptr operationInfo = new (std::nothrow) NotificationOperationInfo(); - sptr callback = nullptr; + sptr callback = nullptr; auto ret = advancedNotificationService_->DistributeOperation(operationInfo, callback); ASSERT_EQ(ret, ERR_ANS_INVALID_PARAM); std::string hashCode = "123456"; -- Gitee