diff --git a/frameworks/ans/BUILD.gn b/frameworks/ans/BUILD.gn index 822e942a14714afc06013ea21210b419470f57ed..97a086695718b9f5d06d1000a22f987c9e23ef4e 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 0000000000000000000000000000000000000000..7b42c776462b20463d10ac67d032164c13d7c193 --- /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 dcc4aaa637d87b1b202a22679708a09ee3aba1a4..72a74d59866e8bba562edcb5b939003b78504c19 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 88a8343af60f0286a7885fd5cfa2c7d241b0a003..487bcfa3ad819a2523087e255d18ed0ca40c16d5 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 0049b83c7c4136651a82a63cedc6db1ff200bb36..60c1358715c0290fa87ed02f72d682c87f5f0c26 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 91e10f2348524e4fea37563d93ee9eb980779e47..0a66ecfa61f99fca11aca3fb3217792f014283ae 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 4b24f5477073630597f9532e23f2364273d5d356..0000000000000000000000000000000000000000 --- 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 0bc561259a9c4496627baf37de86f4b74e98a527..0000000000000000000000000000000000000000 --- 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 a7e9f15087097fa7b78bd113c825fe5ab5c07b24..0000000000000000000000000000000000000000 --- 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 27e93580597d2ffd3419bf723eca96b3cfdad08f..0000000000000000000000000000000000000000 --- 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 9317706df60160b061f47f6f2c3f3306b260c0a6..0000000000000000000000000000000000000000 --- 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 3a4b887b75fa17b1db5451a404df391457ea43c8..8cc7ef529eca6e8345afa53338aa29987b8b3ba4 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 6f92fa8701a81224a201639879ffa6b47b872109..88c94b0b6283886a8c589a37e5868d7286a55be6 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 6655bfa7cd69e0516070c950134609f6d1dace40..7331d9062dd17f14a5789c3c5973fe019898f3a2 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 8b4e9ad34514c1a237f7a8284f30a617d0629d93..d122cfcea5ae341c4ce99169cf941c79092bfdc3 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 19c90ad7b2b30baf3d2e6b4aa0cc8061b35390a5..c3ab868e0988924f4020290a99c6e9783796369a 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 7c1af250c248747c44200adabe4627e74b3439cc..91556d3a270e74eb5e6a3fec121092f59282caf8 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 56d4f08b00e44dbae2f485d8cc1bebf20087657b..5710a523f97a9ca3496c8d081b4535ea1066abb6 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 4598a3d8a248ec03a903ed4e8971f412b54f1629..35f1f04e2f78db91373b1e99532d7f39afc88415 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 b15f741603f6c390d419f964f71e794ceb8349ce..a2699b757f760df8603fadf79961b861c4d23049 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 8ae8e4f8e8d1363d5623aa26203852e521ec4d78..f161fdd601006aca505bc23ea1640f57957db827 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 ae9ba50f8899984cdcf2792d1a51ad195640b8e5..785cfd623caef32f0488119d49d0151bbf8a7362 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 92f0f13296c9bf2e9b777ac2924bf9f6052a350b..87d0b463546b1a98957ab31ec4767fa98b31021a 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 f13788280dc711ec50cd9a3e5bac191094382bf3..44087557434a8fe08ceb7d3df58c7febf68fd349 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 07b5008207781e9569a55fb6dd0c9943cce601cf..a944707252e9797cdb43960fb16d188a5f1e3dcf 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 505444440ac0fad1c984ab643f46a766c2a226fb..7f9a60e785f88360188757769c89f70f37c30774 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 99015e0f89eecce36300b337659619e4c1c476a2..55c3a78977f7b741174a37d417dce0a62793cf48 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 b895f47fe20db8ea8b7aa689680bd86215799ad9..11f106727420d6d226d354376a7ccc85a2aec99f 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 292da8ae8f1ba84637178daacd317d3eb7b0e377..636c3eb79bf4dadca70ac5ec853b9a582baaaa52 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 c78d08017586f830f73f3e0d76bf1b6af2042165..de4988231391da65f3d512522bf55ea351d48ca0 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; } }