From f7213ce71a89f7ef7d2c20b6e8bebaf6b1db60df Mon Sep 17 00:00:00 2001 From: zhengzhuolan Date: Tue, 4 Mar 2025 19:41:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E9=80=9A=E7=9F=A5=E5=AD=90?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhengzhuolan --- frameworks/ans/BUILD.gn | 82 +++++++++++- .../ans/IAnsSubscriberLocalLiveView.idl | 22 ++++ ...otification_local_live_view_subscriber.cpp | 15 ++- .../core/include/ans_manager_interface.h | 6 +- frameworks/core/include/ans_manager_proxy.h | 4 +- frameworks/core/include/ans_manager_stub.h | 6 +- ...ans_subscriber_local_live_view_interface.h | 55 -------- .../ans_subscriber_local_live_view_proxy.h | 69 ---------- .../ans_subscriber_local_live_view_stub.h | 66 ---------- .../ans_subscriber_local_live_view_proxy.cpp | 119 ----------------- .../ans_subscriber_local_live_view_stub.cpp | 124 ------------------ .../core/src/manager/ans_manager_proxy.cpp | 4 +- .../src/manager/ans_manager_proxy_bundle.cpp | 4 +- .../src/manager/ans_manager_proxy_disturb.cpp | 4 +- .../src/manager/ans_manager_proxy_slot.cpp | 4 +- .../manager/ans_manager_proxy_subscribe.cpp | 6 +- .../src/manager/ans_manager_stub_invalid.cpp | 4 +- .../ans_notification_branch_test.cpp | 4 +- frameworks/reminder/BUILD.gn | 7 +- .../notification_local_live_view_subscriber.h | 8 +- .../include/advanced_notification_service.h | 4 +- .../include/disturb_manager/disturb_manager.h | 2 +- ...ation_local_live_view_subscriber_manager.h | 19 +-- .../ans/include/slot_manager/slot_manager.h | 4 +- .../advanced_notification_publish_service.cpp | 4 +- services/ans/src/ans_manager_stub.cpp | 6 +- services/ans/src/ans_manager_stub_invalid.cpp | 4 +- ...ion_local_live_view_subscriber_manager.cpp | 18 +-- ...ocal_live_view_subscriber_manager_test.cpp | 6 +- .../anssubscriberstub_fuzzer.cpp | 9 +- 30 files changed, 177 insertions(+), 512 deletions(-) create mode 100644 frameworks/ans/IAnsSubscriberLocalLiveView.idl delete mode 100644 frameworks/core/include/ans_subscriber_local_live_view_interface.h delete mode 100644 frameworks/core/include/ans_subscriber_local_live_view_proxy.h delete mode 100644 frameworks/core/include/ans_subscriber_local_live_view_stub.h delete mode 100644 frameworks/core/src/listener/ans_subscriber_local_live_view_proxy.cpp delete mode 100644 frameworks/core/src/listener/ans_subscriber_local_live_view_stub.cpp diff --git a/frameworks/ans/BUILD.gn b/frameworks/ans/BUILD.gn index 822e942a1..97a086695 100644 --- a/frameworks/ans/BUILD.gn +++ b/frameworks/ans/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 @@ -12,8 +12,17 @@ # limitations under the License. import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") +idl_gen_interface("ans_subscriber_local_live_view_interface") { + src_idl = rebase_path("IAnsSubscriberLocalLiveView.idl") + log_domainid = "0xD001203" + log_tag = "Ans" + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} + group("ans_client") { deps = [ ":ans_innerkits" ] } @@ -27,6 +36,20 @@ config("ans_innerkits_public_config") { "${core_path}/common/include", "${core_path}/include", "//third_party/json/single_include", + "${target_gen_dir}", + ] + configs = [ "${multimedia_path}/interfaces/innerkits:image_external_config" ] +} + +config("ans_innerkits_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" ] } @@ -52,8 +75,6 @@ ohos_shared_library("ans_innerkits") { "${core_path}/src/listener/ans_dialog_callback_proxy.cpp", "${core_path}/src/listener/ans_dialog_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", "${core_path}/src/listener/ans_subscriber_proxy.cpp", "${core_path}/src/listener/ans_subscriber_stub.cpp", "${core_path}/src/listener/swing_callback_proxy.cpp", @@ -117,6 +138,11 @@ ohos_shared_library("ans_innerkits") { defines = [] + deps = [ + ":ans_subscriber_local_live_view_proxy", + ":ans_subscriber_local_live_view_stub", + ] + external_deps = [ "ability_base:want", "ability_base:zuri", @@ -159,3 +185,53 @@ ohos_shared_library("ans_innerkits") { subsystem_name = "${subsystem_name}" part_name = "${component_name}" } + +ohos_source_set("ans_subscriber_local_live_view_proxy") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":ans_innerkits_config" ] + output_values = + get_target_outputs(":ans_subscriber_local_live_view_interface") + sources = filter_include(output_values, [ "*_proxy.cpp" ]) + deps = [ ":ans_subscriber_local_live_view_interface" ] + external_deps = [ + "ability_base:want", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} + +ohos_source_set("ans_subscriber_local_live_view_stub") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":ans_innerkits_config" ] + output_values = + get_target_outputs(":ans_subscriber_local_live_view_interface") + sources = filter_include(output_values, [ "*_stub.cpp" ]) + deps = [ ":ans_subscriber_local_live_view_interface" ] + external_deps = [ + "ability_base:want", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} diff --git a/frameworks/ans/IAnsSubscriberLocalLiveView.idl b/frameworks/ans/IAnsSubscriberLocalLiveView.idl new file mode 100644 index 000000000..7b42c7764 --- /dev/null +++ b/frameworks/ans/IAnsSubscriberLocalLiveView.idl @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +sequenceable OHOS.Notification.NotificationButtonOption; +interface OHOS.Notification.IAnsSubscriberLocalLiveView { + [oneway] void OnConnected(); + [oneway] void OnDisconnected(); + [oneway] void OnResponse([in] int notificationId, [in] NotificationButtonOption buttonOption); +} + \ No newline at end of file diff --git a/frameworks/ans/src/notification_local_live_view_subscriber.cpp b/frameworks/ans/src/notification_local_live_view_subscriber.cpp index dcc4aaa63..72a74d598 100644 --- a/frameworks/ans/src/notification_local_live_view_subscriber.cpp +++ b/frameworks/ans/src/notification_local_live_view_subscriber.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -40,7 +40,7 @@ NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::SubscriberLoca recipient_ = new (std::nothrow) DeathRecipient(*this); }; -void NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConnected() +ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConnected() { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); sptr proxy = GetAnsManagerProxy(); @@ -49,9 +49,10 @@ void NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConnect ANS_LOGD("%s, Add death recipient.", __func__); } subscriber_.OnConnected(); + return ERR_OK; } -void NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnDisconnected() +ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnDisconnected() { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); sptr proxy = GetAnsManagerProxy(); @@ -60,13 +61,15 @@ void NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnDisconn ANS_LOGD("%s, Remove death recipient.", __func__); } subscriber_.OnDisconnected(); + return ERR_OK; } -void NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnResponse(int32_t notificationId, - sptr buttonOption) +ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnResponse(int32_t notificationId, + const NotificationButtonOption& buttonOption) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - subscriber_.OnResponse(notificationId, buttonOption); + subscriber_.OnResponse(notificationId, new (std::nothrow) NotificationButtonOption(buttonOption)); + return ERR_OK; } sptr NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::GetAnsManagerProxy() diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h index 88a8343af..487bcfa3a 100644 --- a/frameworks/core/include/ans_manager_interface.h +++ b/frameworks/core/include/ans_manager_interface.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 @@ -21,7 +21,7 @@ #include "ans_dialog_callback_interface.h" #include "ans_subscriber_interface.h" -#include "ans_subscriber_local_live_view_interface.h" +#include "ians_subscriber_local_live_view.h" #include "iremote_broker.h" #include "notification_bundle_option.h" #include "notification_constant.h" @@ -484,7 +484,7 @@ public: * @param info Indicates the NotificationSubscribeInfo object. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode SubscribeLocalLiveView(const sptr &subscriber, + virtual ErrCode SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) = 0; /** diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h index 0049b83c7..60c135871 100644 --- a/frameworks/core/include/ans_manager_proxy.h +++ b/frameworks/core/include/ans_manager_proxy.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 @@ -465,7 +465,7 @@ public: * @param info Indicates the NotificationSubscribeInfo object. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SubscribeLocalLiveView(const sptr &subscriber, + ErrCode SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) override; /** diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index 91e10f234..0a66ecfa6 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.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 @@ -20,8 +20,8 @@ #include #include "ans_manager_interface.h" -#include "ans_subscriber_local_live_view_interface.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "iremote_stub.h" namespace OHOS { @@ -463,7 +463,7 @@ public: virtual ErrCode SubscribeSelf(const sptr &subscriber) override; virtual ErrCode SubscribeLocalLiveView( - const sptr &subscriber, + const sptr &subscriber, const sptr &info, const bool isNative) override; /** diff --git a/frameworks/core/include/ans_subscriber_local_live_view_interface.h b/frameworks/core/include/ans_subscriber_local_live_view_interface.h deleted file mode 100644 index 4b24f5477..000000000 --- a/frameworks/core/include/ans_subscriber_local_live_view_interface.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_LOCAL_LIVE_VIEW_SUBSCRIBER_INTERFACE_H -#define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_LOCAL_LIVE_VIEW_SUBSCRIBER_INTERFACE_H - -#include "iremote_broker.h" - -#include "badge_number_callback_data.h" -#include "enabled_notification_callback_data.h" -#include "notification.h" -#include "notification_constant.h" -#include "notification_do_not_disturb_date.h" -#include "notification_request.h" -#include "notification_sorting.h" -#include "notification_sorting_map.h" - -namespace OHOS { -namespace Notification { -class AnsSubscriberLocalLiveViewInterface : public IRemoteBroker { -public: - AnsSubscriberLocalLiveViewInterface() = default; - virtual ~AnsSubscriberLocalLiveViewInterface() override = default; - DISALLOW_COPY_AND_MOVE(AnsSubscriberLocalLiveViewInterface); - - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.AnsSubscriberLocalLiveViewInterface"); - - /** - * @brief The callback function for the subscriber to establish a connection. - */ - virtual void OnConnected() = 0; - - /** - * @brief The callback function for subscriber disconnected. - */ - virtual void OnDisconnected() = 0; - - virtual void OnResponse(int32_t notificationId, sptr buttonOption) = 0; -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_LOCAL_LIVE_VIEW_SUBSCRIBER_INTERFACE_H diff --git a/frameworks/core/include/ans_subscriber_local_live_view_proxy.h b/frameworks/core/include/ans_subscriber_local_live_view_proxy.h deleted file mode 100644 index 0bc561259..000000000 --- a/frameworks/core/include/ans_subscriber_local_live_view_proxy.h +++ /dev/null @@ -1,69 +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 BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_LOCAL_LIVE_VIEW_PROXY_H -#define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_LOCAL_LIVE_VIEW_PROXY_H - -#include "ans_subscriber_local_live_view_interface.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace Notification { -class AnsSubscriberLocalLiveViewProxy : public IRemoteProxy { -public: - AnsSubscriberLocalLiveViewProxy() = delete; - explicit AnsSubscriberLocalLiveViewProxy(const sptr &impl); - ~AnsSubscriberLocalLiveViewProxy() override; - DISALLOW_COPY_AND_MOVE(AnsSubscriberLocalLiveViewProxy); - - /** - * @brief The callback function for the subscriber to establish a connection. - */ - void OnConnected() override; - - /** - * @brief The callback function for subscriber disconnected. - */ - void OnDisconnected() override; - - void OnResponse(int32_t notificationId, sptr buttonOption) override; - -private: - ErrCode InnerTransact(NotificationInterfaceCode code, - MessageOption &flags, MessageParcel &data, MessageParcel &reply); - static inline BrokerDelegator delegator_; - - template - bool WriteParcelableVector(const std::vector> &parcelableVector, MessageParcel &data) - { - if (!data.WriteInt32(parcelableVector.size())) { - ANS_LOGE("write ParcelableVector size failed"); - return false; - } - - for (auto &parcelable : parcelableVector) { - if (!data.WriteStrongParcelable(parcelable)) { - ANS_LOGE("write ParcelableVector failed"); - return false; - } - } - return true; - } -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_LOCAL_LIVE_VIEW_PROXY_H diff --git a/frameworks/core/include/ans_subscriber_local_live_view_stub.h b/frameworks/core/include/ans_subscriber_local_live_view_stub.h deleted file mode 100644 index a7e9f1508..000000000 --- a/frameworks/core/include/ans_subscriber_local_live_view_stub.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_LOCAL_LIVE_VIEW_STUB_H -#define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_LOCAL_LIVE_VIEW_STUB_H - -#include "ans_subscriber_local_live_view_interface.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "iremote_stub.h" - -namespace OHOS { -namespace Notification { -class AnsSubscriberLocalLiveViewStub : public IRemoteStub { -public: - AnsSubscriberLocalLiveViewStub(); - ~AnsSubscriberLocalLiveViewStub() override; - DISALLOW_COPY_AND_MOVE(AnsSubscriberLocalLiveViewStub); - - /** - * @brief Handle remote request. - * - * @param data Indicates the input parcel. - * @param reply Indicates the output parcel. - * @param option Indicates the message option. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int32_t OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - - /** - * @brief The callback function for the subscriber to establish a connection. - */ - void OnConnected() override; - - /** - * @brief The callback function for subscriber disconnected. - */ - void OnDisconnected() override; - - void OnResponse(int32_t notificationId, sptr buttonOption) override; - -private: - - ErrCode HandleOnConnected(MessageParcel &data, MessageParcel &reply); - ErrCode HandleOnDisconnected(MessageParcel &data, MessageParcel &reply); - ErrCode HandleOnResponse(MessageParcel &data, MessageParcel &reply); - - template - bool ReadParcelableVector(std::vector> &parcelableInfos, MessageParcel &data); -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_SUBSCRIBER_LOCAL_LIVE_VIEW_STUB_H diff --git a/frameworks/core/src/listener/ans_subscriber_local_live_view_proxy.cpp b/frameworks/core/src/listener/ans_subscriber_local_live_view_proxy.cpp deleted file mode 100644 index 27e935805..000000000 --- a/frameworks/core/src/listener/ans_subscriber_local_live_view_proxy.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ans_subscriber_local_live_view_proxy.h" - -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "message_option.h" -#include "message_parcel.h" - -namespace OHOS { -namespace Notification { -AnsSubscriberLocalLiveViewProxy::AnsSubscriberLocalLiveViewProxy( - const sptr &impl) : IRemoteProxy(impl) -{} - -AnsSubscriberLocalLiveViewProxy::~AnsSubscriberLocalLiveViewProxy() -{} - -ErrCode AnsSubscriberLocalLiveViewProxy::InnerTransact( - NotificationInterfaceCode code, MessageOption &flags, MessageParcel &data, MessageParcel &reply) -{ - auto remote = Remote(); - if (remote == nullptr) { - ANS_LOGE("[InnerTransact] fail: get Remote fail code %{public}u", code); - return ERR_DEAD_OBJECT; - } - - int32_t err = remote->SendRequest(static_cast(code), data, reply, flags); - switch (err) { - case NO_ERROR: { - return ERR_OK; - } - case DEAD_OBJECT: { - ANS_LOGE("[InnerTransact] fail: ipcErr=%{public}d code %{public}d", err, code); - return ERR_DEAD_OBJECT; - } - default: { - ANS_LOGE("[InnerTransact] fail: ipcErr=%{public}d code %{public}d", err, code); - return ERR_ANS_TRANSACT_FAILED; - } - } -} - -void AnsSubscriberLocalLiveViewProxy::OnConnected() -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsSubscriberLocalLiveViewProxy::GetDescriptor())) { - ANS_LOGE("[OnConnected] fail: write interface token failed."); - return; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_ASYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ON_CONNECTED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[OnConnected] fail: transact ErrCode=ERR_ANS_TRANSACT_FAILED"); - return; - } -} - -void AnsSubscriberLocalLiveViewProxy::OnDisconnected() -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsSubscriberLocalLiveViewProxy::GetDescriptor())) { - ANS_LOGE("[OnDisconnected] fail: write interface token failed."); - return; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_ASYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ON_DISCONNECTED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[OnDisconnected] fail: transact ErrCode=ERR_ANS_TRANSACT_FAILED"); - return; - } -} - - -void AnsSubscriberLocalLiveViewProxy::OnResponse(int32_t notificationId, sptr buttonOption) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsSubscriberLocalLiveViewProxy::GetDescriptor())) { - ANS_LOGE("[OnResponse] fail: write interface token failed."); - return; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[OnResponse] fail: write notificationId failed"); - return; - } - - if (!data.WriteParcelable(buttonOption)) { - ANS_LOGE("[OnResponse] fail: write buttonName failed"); - return; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_ASYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ON_RESPONSE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[OnResponse] fail: transact ErrCode=ERR_ANS_TRANSACT_FAILED"); - return; - } -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/listener/ans_subscriber_local_live_view_stub.cpp b/frameworks/core/src/listener/ans_subscriber_local_live_view_stub.cpp deleted file mode 100644 index 9317706df..000000000 --- a/frameworks/core/src/listener/ans_subscriber_local_live_view_stub.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ans_subscriber_local_live_view_stub.h" - -#include "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "message_option.h" -#include "message_parcel.h" -#include "notification_bundle_option.h" -#include "notification_button_option.h" -#include "parcel.h" -#include "refbase.h" -#include - -namespace OHOS { -namespace Notification { -AnsSubscriberLocalLiveViewStub::AnsSubscriberLocalLiveViewStub() {} - -AnsSubscriberLocalLiveViewStub::~AnsSubscriberLocalLiveViewStub() {} - -int32_t AnsSubscriberLocalLiveViewStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &flags) -{ - std::u16string descriptor = AnsSubscriberLocalLiveViewStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - ANS_LOGW("[OnRemoteRequest] fail: invalid interface token!"); - return OBJECT_NULL; - } - ErrCode result = NO_ERROR; - switch (code) { - case static_cast(NotificationInterfaceCode::ON_CONNECTED): { - result = HandleOnConnected(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ON_DISCONNECTED): { - result = HandleOnDisconnected(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ON_RESPONSE): { - result = HandleOnResponse(data, reply); - break; - } - default: { - ANS_LOGE("[OnRemoteRequest] fail: unknown code!"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, flags); - } - } - return result; -} - -ErrCode AnsSubscriberLocalLiveViewStub::HandleOnConnected(MessageParcel &data, MessageParcel &reply) -{ - OnConnected(); - return ERR_OK; -} - -ErrCode AnsSubscriberLocalLiveViewStub::HandleOnDisconnected(MessageParcel &data, MessageParcel &reply) -{ - OnDisconnected(); - return ERR_OK; -} - -template -bool AnsSubscriberLocalLiveViewStub::ReadParcelableVector(std::vector> &parcelableInfos, MessageParcel &data) -{ - int32_t infoSize = 0; - if (!data.ReadInt32(infoSize)) { - ANS_LOGE("read Parcelable size failed."); - return false; - } - - parcelableInfos.clear(); - infoSize = (infoSize < MAX_PARCELABLE_VECTOR_NUM) ? infoSize : MAX_PARCELABLE_VECTOR_NUM; - for (int32_t index = 0; index < infoSize; index++) { - sptr info = data.ReadStrongParcelable(); - if (info == nullptr) { - ANS_LOGE("read Parcelable infos failed."); - return false; - } - parcelableInfos.emplace_back(info); - } - - return true; -} - -ErrCode AnsSubscriberLocalLiveViewStub::HandleOnResponse(MessageParcel &data, MessageParcel &reply) -{ - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleOnResponse] fail : read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - sptr buttonOption = nullptr; - buttonOption = data.ReadParcelable(); - if (buttonOption == nullptr) { - ANS_LOGE("[HandleOnResponse] fail : read buttonOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - OnResponse(notificationId, buttonOption); - return ERR_OK; -} - -void AnsSubscriberLocalLiveViewStub::OnConnected() {} - -void AnsSubscriberLocalLiveViewStub::OnDisconnected() {} - -void AnsSubscriberLocalLiveViewStub::OnResponse(int32_t notificationId, sptr buttonOption) {} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy.cpp b/frameworks/core/src/manager/ans_manager_proxy.cpp index 3a4b887b7..8cc7ef529 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 @@ -18,8 +18,8 @@ #include "ans_const_define.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "ans_subscriber_local_live_view_interface.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "message_option.h" #include "message_parcel.h" #include "notification_bundle_option.h" diff --git a/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp b/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp index 6f92fa870..88c94b0b6 100644 --- a/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy_bundle.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 @@ -18,8 +18,8 @@ #include "ans_const_define.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "ans_subscriber_local_live_view_interface.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "message_option.h" #include "message_parcel.h" #include "parcel.h" diff --git a/frameworks/core/src/manager/ans_manager_proxy_disturb.cpp b/frameworks/core/src/manager/ans_manager_proxy_disturb.cpp index 6655bfa7c..7331d9062 100644 --- a/frameworks/core/src/manager/ans_manager_proxy_disturb.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy_disturb.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 @@ -18,8 +18,8 @@ #include "ans_const_define.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "ans_subscriber_local_live_view_interface.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "message_option.h" #include "message_parcel.h" #include "parcel.h" diff --git a/frameworks/core/src/manager/ans_manager_proxy_slot.cpp b/frameworks/core/src/manager/ans_manager_proxy_slot.cpp index 8b4e9ad34..d122cfcea 100644 --- a/frameworks/core/src/manager/ans_manager_proxy_slot.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy_slot.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,8 @@ #include "ans_const_define.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "ans_subscriber_local_live_view_interface.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "message_option.h" #include "message_parcel.h" #include "parcel.h" diff --git a/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp b/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp index 19c90ad7b..c3ab868e0 100644 --- a/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,8 @@ #include "ans_const_define.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "ans_subscriber_local_live_view_interface.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "message_option.h" #include "message_parcel.h" #include "parcel.h" @@ -237,7 +237,7 @@ ErrCode AnsManagerProxy::SubscribeSelf(const sptr &subsc return result; } -ErrCode AnsManagerProxy::SubscribeLocalLiveView(const sptr &subscriber, +ErrCode AnsManagerProxy::SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) { if (subscriber == nullptr) { diff --git a/frameworks/core/src/manager/ans_manager_stub_invalid.cpp b/frameworks/core/src/manager/ans_manager_stub_invalid.cpp index 7c1af250c..91556d3a2 100644 --- a/frameworks/core/src/manager/ans_manager_stub_invalid.cpp +++ b/frameworks/core/src/manager/ans_manager_stub_invalid.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 @@ -325,7 +325,7 @@ ErrCode AnsManagerStub::SubscribeSelf(const sptr &subscr return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::SubscribeLocalLiveView(const sptr &subscriber, +ErrCode AnsManagerStub::SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) { ANS_LOGE("AnsManagerStub::SubscribeLocalLiveView called!"); 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 56d4f08b0..5710a523f 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -296,7 +296,7 @@ public: return ERR_ANS_INVALID_PARAM; } - ErrCode SubscribeLocalLiveView(const sptr &subscriber, + ErrCode SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNatives) override { return ERR_ANS_INVALID_PARAM; diff --git a/frameworks/reminder/BUILD.gn b/frameworks/reminder/BUILD.gn index 4598a3d8a..35f1f04e2 100644 --- a/frameworks/reminder/BUILD.gn +++ b/frameworks/reminder/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 @@ -55,7 +55,10 @@ ohos_shared_library("reminder_innerkits") { branch_protector_ret = "pac_ret" include_dirs = [ "${inner_api_path}" ] - public_configs = [ ":reminder_innerkits_public_config" ] + public_configs = [ + ":reminder_innerkits_public_config", + "${frameworks_path}/ans:ans_innerkits_config", + ] output_values = get_target_outputs(":reminder_service_interface") sources = [ "${frameworks_module_reminder_path}/src/reminder_helper.cpp", diff --git a/interfaces/inner_api/notification_local_live_view_subscriber.h b/interfaces/inner_api/notification_local_live_view_subscriber.h index b15f74160..a2699b757 100644 --- a/interfaces/inner_api/notification_local_live_view_subscriber.h +++ b/interfaces/inner_api/notification_local_live_view_subscriber.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -67,11 +67,11 @@ private: SubscriberLocalLiveViewImpl(NotificationLocalLiveViewSubscriber &subscriber); ~SubscriberLocalLiveViewImpl() {}; - void OnConnected() override; + ErrCode OnConnected() override; - void OnDisconnected() override; + ErrCode OnDisconnected() override; - void OnResponse(int32_t notificationId, sptr buttonOption) override; + ErrCode OnResponse(int32_t notificationId, const NotificationButtonOption& buttonOption) override; sptr GetAnsManagerProxy(); diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 8ae8e4f8e..f161fdd60 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.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 @@ -541,7 +541,7 @@ public: * @param info Indicates the NotificationSubscribeInfo object. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SubscribeLocalLiveView(const sptr &subscriber, + ErrCode SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) override; /** diff --git a/services/ans/include/disturb_manager/disturb_manager.h b/services/ans/include/disturb_manager/disturb_manager.h index ae9ba50f8..785cfd623 100644 --- a/services/ans/include/disturb_manager/disturb_manager.h +++ b/services/ans/include/disturb_manager/disturb_manager.h @@ -20,9 +20,9 @@ #include #include "ans_manager_interface.h" -#include "ans_subscriber_local_live_view_interface.h" #include "base_manager.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "iremote_stub.h" #include "singleton.h" diff --git a/services/ans/include/notification_local_live_view_subscriber_manager.h b/services/ans/include/notification_local_live_view_subscriber_manager.h index 92f0f1329..87d0b4635 100644 --- a/services/ans/include/notification_local_live_view_subscriber_manager.h +++ b/services/ans/include/notification_local_live_view_subscriber_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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,11 +24,12 @@ #include "event_handler.h" #include "event_runner.h" #include "ffrt.h" +#include "ians_subscriber_local_live_view.h" #include "nocopyable.h" #include "refbase.h" #include "singleton.h" -#include "ans_subscriber_local_live_view_interface.h" +#include "notification.h" #include "notification_bundle_option.h" #include "notification_constant.h" #include "notification_request.h" @@ -46,7 +47,7 @@ public: * @param subscribeInfo Indicates the NotificationSubscribeInfo object. * @return Indicates the result code. */ - ErrCode AddLocalLiveViewSubscriber(const sptr &subscriber, + ErrCode AddLocalLiveViewSubscriber(const sptr &subscriber, const sptr &subscribeInfo); /** @@ -56,7 +57,7 @@ public: * @param subscribeInfo Indicates the NotificationSubscribeInfo object. * @return Indicates the result code. */ - ErrCode RemoveLocalLiveViewSubscriber(const sptr &subscriber, + ErrCode RemoveLocalLiveViewSubscriber(const sptr &subscriber, const sptr &subscribeInfo); /** @@ -85,14 +86,14 @@ private: std::shared_ptr FindSubscriberRecord(const wptr &object); std::shared_ptr FindSubscriberRecord( - const sptr &subscriber); + const sptr &subscriber); std::shared_ptr CreateSubscriberRecord( - const sptr &subscriber, + const sptr &subscriber, const sptr &bundleOption); - ErrCode AddSubscriberInner(const sptr &subscriber, + ErrCode AddSubscriberInner(const sptr &subscriber, const sptr &bundleOption); - ErrCode RemoveSubscriberInner(const sptr &subscriber, + ErrCode RemoveSubscriberInner(const sptr &subscriber, const sptr &subscribeInfo); void NotifyTriggerResponseInner(const sptr ¬ification, @@ -103,7 +104,7 @@ private: std::list> buttonRecordList_ {}; std::shared_ptr runner_ {}; std::shared_ptr handler_ {}; - sptr ansSubscriberProxy_ {}; + sptr ansSubscriberProxy_ {}; sptr recipient_ {}; std::shared_ptr notificationButtonQueue_ = nullptr; diff --git a/services/ans/include/slot_manager/slot_manager.h b/services/ans/include/slot_manager/slot_manager.h index f13788280..440875574 100644 --- a/services/ans/include/slot_manager/slot_manager.h +++ b/services/ans/include/slot_manager/slot_manager.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 @@ -20,9 +20,9 @@ #include #include "ans_manager_interface.h" -#include "ans_subscriber_local_live_view_interface.h" #include "base_manager.h" #include "distributed_notification_service_ipc_interface_code.h" +#include "ians_subscriber_local_live_view.h" #include "iremote_stub.h" #include "singleton.h" diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 07b500820..a94470725 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.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 @@ -2658,7 +2658,7 @@ ErrCode AdvancedNotificationService::SetBadgeNumberByBundle( } ErrCode AdvancedNotificationService::SubscribeLocalLiveView( - const sptr &subscriber, + const sptr &subscriber, const sptr &info, const bool isNative) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); diff --git a/services/ans/src/ans_manager_stub.cpp b/services/ans/src/ans_manager_stub.cpp index 505444440..7f9a60e78 100644 --- a/services/ans/src/ans_manager_stub.cpp +++ b/services/ans/src/ans_manager_stub.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 @@ -17,8 +17,8 @@ #include "ans_const_define.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" -#include "ans_subscriber_local_live_view_interface.h" #include "disturb_manager.h" +#include "ians_subscriber_local_live_view.h" #include "message_option.h" #include "message_parcel.h" #include "notification_bundle_option.h" @@ -1533,7 +1533,7 @@ ErrCode AnsManagerStub::HandleSubscribeLocalLiveView(MessageParcel &data, Messag } ErrCode result = - SubscribeLocalLiveView(iface_cast(subscriber), info, isNative); + SubscribeLocalLiveView(iface_cast(subscriber), info, isNative); if (!reply.WriteInt32(result)) { ANS_LOGE("[HandleSubscribeLocalLiveView] fail: write result failed, ErrCode=%{public}d", result); return ERR_ANS_PARCELABLE_FAILED; diff --git a/services/ans/src/ans_manager_stub_invalid.cpp b/services/ans/src/ans_manager_stub_invalid.cpp index 99015e0f8..55c3a7897 100644 --- a/services/ans/src/ans_manager_stub_invalid.cpp +++ b/services/ans/src/ans_manager_stub_invalid.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 @@ -325,7 +325,7 @@ ErrCode AnsManagerStub::SubscribeSelf(const sptr &subscr return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::SubscribeLocalLiveView(const sptr &subscriber, +ErrCode AnsManagerStub::SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) { ANS_LOGE("AnsManagerStub::SubscribeLocalLiveView called!"); diff --git a/services/ans/src/notification_local_live_view_subscriber_manager.cpp b/services/ans/src/notification_local_live_view_subscriber_manager.cpp index b895f47fe..11f106727 100644 --- a/services/ans/src/notification_local_live_view_subscriber_manager.cpp +++ b/services/ans/src/notification_local_live_view_subscriber_manager.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 @@ -34,7 +34,7 @@ namespace OHOS { namespace Notification { struct NotificationLocalLiveViewSubscriberManager::LocalLiveViewSubscriberRecord { - sptr subscriber {nullptr}; + sptr subscriber {nullptr}; std::string bundleName {}; int32_t userId {SUBSCRIBE_USER_INIT}; }; @@ -65,7 +65,7 @@ void NotificationLocalLiveViewSubscriberManager::ResetFfrtQueue() } ErrCode NotificationLocalLiveViewSubscriberManager::AddLocalLiveViewSubscriber( - const sptr &subscriber, const sptr &subscribeInfo) + const sptr &subscriber, const sptr &subscribeInfo) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); if (subscriber == nullptr) { @@ -103,7 +103,7 @@ ErrCode NotificationLocalLiveViewSubscriberManager::AddLocalLiveViewSubscriber( } ErrCode NotificationLocalLiveViewSubscriberManager::RemoveLocalLiveViewSubscriber( - const sptr &subscriber, const sptr &subscribeInfo) + const sptr &subscriber, const sptr &subscribeInfo) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); if (subscriber == nullptr) { @@ -180,7 +180,7 @@ std::shared_ptr NotificationLocalLiveViewSubscriberManager::FindSubscriberRecord( - const sptr &subscriber) + const sptr &subscriber) { auto iter = buttonRecordList_.begin(); @@ -193,7 +193,7 @@ std::shared_ptr NotificationLocalLiveViewSubscriberManager::CreateSubscriberRecord( - const sptr &subscriber, + const sptr &subscriber, const sptr &bundleOption) { std::shared_ptr record = std::make_shared(); @@ -210,7 +210,7 @@ std::shared_ptr &subscriber, const sptr &bundleOption) + const sptr &subscriber, const sptr &bundleOption) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); std::shared_ptr record = FindSubscriberRecord(subscriber); @@ -232,7 +232,7 @@ ErrCode NotificationLocalLiveViewSubscriberManager::AddSubscriberInner( } ErrCode NotificationLocalLiveViewSubscriberManager::RemoveSubscriberInner( - const sptr &subscriber, const sptr &subscribeInfo) + const sptr &subscriber, const sptr &subscribeInfo) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); std::shared_ptr record = FindSubscriberRecord(subscriber); @@ -274,7 +274,7 @@ void NotificationLocalLiveViewSubscriberManager::NotifyTriggerResponseInner( ANS_LOGD("%{public}s record->userId = <%{public}d>, bundlename <%{public}s>", __FUNCTION__, record->userId, record->bundleName.c_str()); if (record->bundleName == bundleName && record->userId == sendUserId) { - record->subscriber->OnResponse(notification->GetId(), buttonOption); + record->subscriber->OnResponse(notification->GetId(), *buttonOption); } } } diff --git a/services/ans/test/unittest/notification_local_live_view_subscriber_manager_test.cpp b/services/ans/test/unittest/notification_local_live_view_subscriber_manager_test.cpp index 292da8ae8..636c3eb79 100644 --- a/services/ans/test/unittest/notification_local_live_view_subscriber_manager_test.cpp +++ b/services/ans/test/unittest/notification_local_live_view_subscriber_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -49,14 +49,14 @@ private: static std::shared_ptr notificationLocalLiveViewSubscriberManager_; static TestAnsSubscriber testAnsSubscriber_; - static sptr subscriber_; + static sptr subscriber_; }; std::shared_ptr NotificationLocalLiveViewSubscriberManagerTest::notificationLocalLiveViewSubscriberManager_ = nullptr; NotificationLocalLiveViewSubscriberManagerTest::TestAnsSubscriber NotificationLocalLiveViewSubscriberManagerTest::testAnsSubscriber_; -sptr +sptr NotificationLocalLiveViewSubscriberManagerTest::subscriber_ = nullptr; void NotificationLocalLiveViewSubscriberManagerTest::SetUpTestCase() diff --git a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp b/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp index c78d08017..de4988231 100644 --- a/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.cpp +++ b/test/fuzztest/anssubscriberstub_fuzzer/anssubscriberstub_fuzzer.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,7 +28,6 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider* fdp) { Notification::AnsSubscriberStub ansSubscriberStub; - Notification::AnsSubscriberLocalLiveViewStub ansSubscriberLocalLiveViewStub; uint32_t code = fdp->ConsumeIntegral(); MessageParcel datas; MessageParcel reply; @@ -75,18 +74,12 @@ namespace OHOS { sptr callbackData = new Notification::EnabledNotificationCallbackData(); // test HandleOnBadgeEnabledChanged function ansSubscriberStub.HandleOnBadgeEnabledChanged(datas, reply); - // test HandleOnResponse function - ansSubscriberLocalLiveViewStub.HandleOnResponse(datas, reply); // test HandleOnConsumedListMap function ansSubscriberStub.HandleOnConsumedListMap(datas, reply); - // test HandleOnDisconnected function - ansSubscriberLocalLiveViewStub.HandleOnDisconnected(datas, reply); // test HandleOnBadgeChanged function ansSubscriberStub.HandleOnBadgeChanged(datas, reply); // test HandleOnCanceledListMap function ansSubscriberStub.HandleOnCanceledListMap(datas, reply); - // test HandleOnConnected function - ansSubscriberLocalLiveViewStub.HandleOnConnected(datas, reply); return true; } } -- Gitee