From 9b724c4de5ffc7d29a452188280d94e187c36981 Mon Sep 17 00:00:00 2001 From: zc Date: Thu, 27 Feb 2025 17:00:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E5=A4=A7overlayIcon?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E6=9A=B4=E9=9C=B2?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E7=AC=A6=E5=8F=B7=20Signed-off-by:=20zhangch?= =?UTF-8?q?en=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/ans/src/notification_helper.cpp | 5 ++ frameworks/ans/src/notification_request.cpp | 5 ++ frameworks/core/include/ans_image_util.h | 1 + .../core/include/ans_manager_interface.h | 2 + frameworks/core/include/ans_manager_proxy.h | 2 + frameworks/core/include/ans_manager_stub.h | 1 + frameworks/core/include/ans_notification.h | 2 + ..._notification_service_ipc_interface_code.h | 1 + frameworks/core/src/ans_image_util.cpp | 25 ++++++++++ frameworks/core/src/ans_notification.cpp | 19 +++++++- .../src/listener/ans_subscriber_proxy.cpp | 10 ++++ .../core/src/manager/ans_manager_proxy.cpp | 12 +++++ .../src/manager/ans_manager_proxy_utils.cpp | 21 ++++++++ .../js/napi/src/manager/napi_sync_config.cpp | 4 +- interfaces/inner_api/notification_constant.h | 3 ++ interfaces/inner_api/notification_helper.h | 2 + interfaces/inner_api/notification_request.h | 4 +- .../include/advanced_notification_service.h | 2 + .../ans/include/notification_config_parse.h | 2 + .../ans/include/notification_dialog_manager.h | 4 +- .../include/notification_extension_wrapper.h | 6 +++ .../ans/include/notification_preferences.h | 1 + .../notification_preferences_database.h | 1 + services/ans/libans.map | 3 ++ .../advanced_notification_publish_service.cpp | 20 ++++++-- services/ans/src/ans_manager_stub.cpp | 15 ++++++ .../src/common/notification_config_parse.cpp | 24 ++++++++++ .../ans/src/notification_dialog_manager.cpp | 13 +++++ .../src/notification_extension_wrapper.cpp | 48 +++++++++++++++++++ services/ans/src/notification_preferences.cpp | 9 ++++ .../src/notification_preferences_database.cpp | 12 +++++ 31 files changed, 270 insertions(+), 9 deletions(-) diff --git a/frameworks/ans/src/notification_helper.cpp b/frameworks/ans/src/notification_helper.cpp index 3f84be477..c9652dd32 100644 --- a/frameworks/ans/src/notification_helper.cpp +++ b/frameworks/ans/src/notification_helper.cpp @@ -650,5 +650,10 @@ ErrCode NotificationHelper::SetHashCodeRule(const uint32_t type) { return DelayedSingleton::GetInstance()->SetHashCodeRule(type); } + +ErrCode NotificationHelper::GetOverlayIconScaleSize(uint32_t& scaleSize) +{ + return DelayedSingleton::GetInstance()->GetOverlayIconScaleSize(scaleSize); +} } // namespace Notification } // namespace OHOS diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index b5bb444a0..03cb93dd9 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -328,6 +328,11 @@ void NotificationRequest::SetOverlayIcon(const std::shared_ptr overlayIcon_ = overlayIcon; } +void NotificationRequest::ResetOverlayIcon() const +{ + overlayIcon_ = nullptr; +} + const std::shared_ptr NotificationRequest::GetOverlayIcon() const { return overlayIcon_; diff --git a/frameworks/core/include/ans_image_util.h b/frameworks/core/include/ans_image_util.h index 350bdd187..987d92756 100644 --- a/frameworks/core/include/ans_image_util.h +++ b/frameworks/core/include/ans_image_util.h @@ -76,6 +76,7 @@ public: static bool ImageScale(const std::shared_ptr &pixelMap, int32_t width, int32_t height); + static bool HandleOverSizeOverlayIcon(const std::shared_ptr &pixelMap); /** * @brief Converts a binary string to a hexadecimal string. * diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h index 4907a4a87..e70d81fce 100644 --- a/frameworks/core/include/ans_manager_interface.h +++ b/frameworks/core/include/ans_manager_interface.h @@ -1024,6 +1024,8 @@ public: * @return Returns ERR_OK on success, others on failure. */ virtual ErrCode SetHashCodeRule(const uint32_t type) = 0; + + virtual ErrCode GetOverlayIconScaleSize(uint32_t& scaleSize) = 0; }; } // namespace Notification } // namespace OHOS diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h index 5112f229d..d6940411f 100644 --- a/frameworks/core/include/ans_manager_proxy.h +++ b/frameworks/core/include/ans_manager_proxy.h @@ -1007,6 +1007,8 @@ public: */ ErrCode SetHashCodeRule(const uint32_t type) override; + ErrCode GetOverlayIconScaleSize(uint32_t &scaleSize) override; + private: ErrCode InnerTransact(NotificationInterfaceCode code, MessageOption &flags, MessageParcel &data, MessageParcel &reply); diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index cca1b132e..f9c769edd 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.h @@ -1119,6 +1119,7 @@ private: ErrCode HandleGetNotificationRequest(MessageParcel &data, MessageParcel &reply); ErrCode HandleSetHashCodeRule(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetAllNotificationsBySlotType(MessageParcel &data, MessageParcel &reply); + ErrCode HandleGetOverlayIconScaleSize(MessageParcel &data, MessageParcel &reply); template bool WriteParcelableVector(const std::vector> &parcelableVector, MessageParcel &reply, ErrCode &result) diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index 092897c5f..cd15b4602 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -1247,6 +1247,8 @@ public: */ ErrCode SetHashCodeRule(const uint32_t type); + ErrCode GetOverlayIconScaleSize(uint32_t &scaleSize); + private: /** * @brief Gets Ans Manager proxy. diff --git a/frameworks/core/include/distributed_notification_service_ipc_interface_code.h b/frameworks/core/include/distributed_notification_service_ipc_interface_code.h index 3117c42dc..186b6480c 100644 --- a/frameworks/core/include/distributed_notification_service_ipc_interface_code.h +++ b/frameworks/core/include/distributed_notification_service_ipc_interface_code.h @@ -159,6 +159,7 @@ namespace Notification { GET_NOTIFICATION_REQUEST_BY_HASHCODE, Set_HASH_CODE_RULE, GET_ALL_NOTIFICATIONS_BY_SLOTTYPE, + GET_OVERLAY_ICON_SCALE_SIZE, }; } } diff --git a/frameworks/core/src/ans_image_util.cpp b/frameworks/core/src/ans_image_util.cpp index 601168f1c..d0a600d8a 100644 --- a/frameworks/core/src/ans_image_util.cpp +++ b/frameworks/core/src/ans_image_util.cpp @@ -16,6 +16,7 @@ #include "ans_log_wrapper.h" #include "image_packer.h" #include "image_source.h" +#include "notification_helper.h" namespace OHOS { namespace Notification { @@ -262,5 +263,29 @@ std::string AnsImageUtil::HexToBin(const std::string &strHex) return strBin; } + +bool AnsImageUtil::HandleOverSizeOverlayIcon(const std::shared_ptr &pixelMap) +{ + uint32_t ccmScaleSize = 0; + + ErrCode code = NotificationHelper::GetOverlayIconScaleSize(ccmScaleSize); + if (code != ERR_OK || ccmScaleSize == 0) { + ANS_LOGW("get overlayIcon scale size failed."); + return false; + } + ANS_LOGD("overlayIcon size before scale: %{public}d", pixelMap->GetByteCount()); + auto icon = AnsImageUtil::ImageScale(pixelMap, ccmScaleSize, ccmScaleSize); + if (!icon) { + ANS_LOGE("overlayIcon is null after scale."); + return false; + } + ANS_LOGD("overlayIcon size after scale: %{public}d", pixelMap->GetByteCount()); + auto size = static_cast(pixelMap->GetByteCount()); + if (size > MAX_ICON_SIZE) { + ANS_LOGW("overlayIcon oversize after scale."); + return false; + } + return true; +} } // namespace Notification } // namespace OHOS diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 9c55dd970..e7cdf4410 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -26,6 +26,7 @@ #include "notification_local_live_view_subscriber.h" #include "system_ability_definition.h" #include "unique_fd.h" +#include "ans_image_util.h" #include #include @@ -1454,7 +1455,10 @@ ErrCode AnsNotification::CheckImageSize(const NotificationRequest &request) auto overlayIcon = request.GetOverlayIcon(); if (overlayIcon && NotificationRequest::CheckImageOverSizeForPixelMap(overlayIcon, MAX_ICON_SIZE)) { ANS_LOGE("The size of overlay icon exceeds limit"); - return ERR_ANS_ICON_OVER_SIZE; + if (!AnsImageUtil::HandleOverSizeOverlayIcon(overlayIcon)) { + ANS_LOGE("HandleOverSizeOverlayIcon failed."); + request.ResetOverlayIcon(); + } } ErrCode err = request.CheckImageSizeForContent(); @@ -2127,5 +2131,18 @@ ErrCode AnsNotification::GetAllNotificationsBySlotType(std::vectorGetAllNotificationsBySlotType(notifications, slotType); } +ErrCode AnsNotification::GetOverlayIconScaleSize(uint32_t& scale) +{ + ANS_LOGI("GetOverlayIconScaleSize proxy called."); + HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + + sptr proxy = GetAnsManagerProxy(); + if (!proxy) { + ANS_LOGE("GetAnsManagerProxy fail."); + return ERR_ANS_SERVICE_NOT_CONNECTED; + } + return proxy->GetOverlayIconScaleSize(scale); +} + } // namespace Notification } // namespace OHOS diff --git a/frameworks/core/src/listener/ans_subscriber_proxy.cpp b/frameworks/core/src/listener/ans_subscriber_proxy.cpp index a2fa1276c..c50fad549 100644 --- a/frameworks/core/src/listener/ans_subscriber_proxy.cpp +++ b/frameworks/core/src/listener/ans_subscriber_proxy.cpp @@ -101,6 +101,11 @@ void AnsSubscriberProxy::OnConsumed( ANS_LOGE("[OnConsumed] fail: set max capacity failed."); return; } + } else { + if (!data.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_COMMON_SIZE)) { + ANS_LOGE("[OnConsumed] fail: set common max capacity failed."); + return; + } } if (!data.WriteInterfaceToken(AnsSubscriberProxy::GetDescriptor())) { ANS_LOGE("[OnConsumed] fail: write interface token failed."); @@ -191,6 +196,11 @@ void AnsSubscriberProxy::OnCanceled( ANS_LOGE("[OnCanceled] fail: set max capacity failed."); return; } + } else { + if (!data.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_COMMON_SIZE)) { + ANS_LOGE("[OnConsumed] fail: set common max capacity failed."); + return; + } } if (!data.WriteInterfaceToken(AnsSubscriberProxy::GetDescriptor())) { ANS_LOGE("[OnCanceled] fail: write interface token failed."); diff --git a/frameworks/core/src/manager/ans_manager_proxy.cpp b/frameworks/core/src/manager/ans_manager_proxy.cpp index 3a4b887b7..cb5cc05c4 100644 --- a/frameworks/core/src/manager/ans_manager_proxy.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy.cpp @@ -46,6 +46,10 @@ ErrCode AnsManagerProxy::Publish(const std::string &label, const sptr &overlayIcon); + void ResetOverlayIcon() const; + /** * @brief Obtains the overlay icon of this notification. * @@ -1603,7 +1605,7 @@ private: std::shared_ptr littleIcon_ {}; std::string littleIconType_ {}; mutable std::shared_ptr bigIcon_ {}; - std::shared_ptr overlayIcon_ {}; + mutable std::shared_ptr overlayIcon_ {}; std::shared_ptr notificationContent_ {}; std::vector> actionButtons_ {}; diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 72fdee1ae..f47607cd6 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1163,6 +1163,8 @@ public: */ ErrCode SetHashCodeRule(const uint32_t type) override; + ErrCode GetOverlayIconScaleSize(uint32_t& scaleSize) override; + protected: /** * @brief Query whether there is a agent relationship between the two apps. diff --git a/services/ans/include/notification_config_parse.h b/services/ans/include/notification_config_parse.h index d55ddd226..de4b481cb 100644 --- a/services/ans/include/notification_config_parse.h +++ b/services/ans/include/notification_config_parse.h @@ -59,6 +59,7 @@ public: void GetCollaborationFilter(); bool IsInCollaborationFilter(const std::string &bundleName, int32_t uid) const; uint32_t GetStartAbilityTimeout(); + uint32_t GetOverlayIconScaleSize() const; private: std::map defaultCurrentSlotReminder_; @@ -92,6 +93,7 @@ public: #endif constexpr static const char* CFG_KEY_COLLABORATIVE_DELETE_TYPES = "collaborativeDeleteTypes"; constexpr static const char* CFG_KEY_START_ABILITY_TIMEOUT = "startAbilityTimeout"; + constexpr static const char* CFG_KEY_OVERLAYICON_SCALE_SIZE = "overlayIconScaleSize"; }; } // namespace Notification } // namespace OHOS diff --git a/services/ans/include/notification_dialog_manager.h b/services/ans/include/notification_dialog_manager.h index 2d8b63877..2b3ef129f 100644 --- a/services/ans/include/notification_dialog_manager.h +++ b/services/ans/include/notification_dialog_manager.h @@ -39,7 +39,8 @@ enum class DialogStatus { DENY_CLICKED, DIALOG_CRASHED, DIALOG_SERVICE_DESTROYED, - REMOVE_BUNDLE + REMOVE_BUNDLE, + DIALOG_OPEN }; class NotificationDialogEventSubscriber : public EventFwk::CommonEventSubscriber { @@ -128,6 +129,7 @@ private: bool HandleOneDialogClosed(sptr bundleOption, EnabledDialogStatus status); bool HandleAllDialogsClosed(); + bool OnDialogOpen(const std::string& bundleName, const int32_t& uid); std::shared_ptr dialogEventSubscriber = nullptr; AdvancedNotificationService& ans_; diff --git a/services/ans/include/notification_extension_wrapper.h b/services/ans/include/notification_extension_wrapper.h index af1a6e457..2fc4f6ce9 100644 --- a/services/ans/include/notification_extension_wrapper.h +++ b/services/ans/include/notification_extension_wrapper.h @@ -42,6 +42,8 @@ public: typedef void (*UPDATE_BY_BUNDLE)(const std::string bundleName, int deleteType); typedef int32_t (*REMINDER_CONTROL)(const std::string &bundleName); typedef int32_t (*BANNER_CONTROL)(const std::string &bundleName); + typedef bool (*GET_PRIVILEGE_DIALOG_POPPED)(const std::string bundleName, const int32_t &userId); + typedef bool (*SET_DIALOG_OPENSUCCESS_INFO)(const std::string bundleName, const int32_t &userId); #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER typedef bool (*MODIFY_REMINDER_FLAGS)(const sptr &request); @@ -57,6 +59,8 @@ public: void UpdateByBundle(const std::string bundleName, int deleteType); int32_t ReminderControl(const std::string &bundleName); int32_t BannerControl(const std::string &bundleName); + bool GetPrivilegeDialogPopped(const std::string bundleName, const int32_t &userId); + bool SetDialogOpenSuccessInfo(const std::string &bundleName, const int32_t &userId); #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER bool ModifyReminderFlags(const sptr &request); @@ -75,6 +79,8 @@ private: UPDATE_BY_BUNDLE updateByBundle_ = nullptr; REMINDER_CONTROL reminderControl_ = nullptr; BANNER_CONTROL bannerControl_ = nullptr; + GET_PRIVILEGE_DIALOG_POPPED getPrivilegeDialogPopped_ = nullptr; + SET_DIALOG_OPENSUCCESS_INFO setDialogOpenSuccessInfo_ = nullptr; bool isRegisterDataSettingObserver = false; #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index 652203401..629989d78 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -402,6 +402,7 @@ public: int32_t SetKvToDb(const std::string &key, const std::string &value, const int32_t &userId); int32_t SetByteToDb(const std::string &key, const std::vector &value, const int32_t &userId); int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId); + int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode); int32_t GetByteFromDb(const std::string &key, std::vector &value, const int32_t &userId); int32_t GetBatchKvsFromDb( const std::string &key, std::unordered_map &values, const int32_t &userId); diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index 5e7f06230..88109d626 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -261,6 +261,7 @@ public: int32_t SetKvToDb(const std::string &key, const std::string &value, const int32_t &userId); int32_t SetByteToDb(const std::string &key, const std::vector &value, const int32_t &userId); int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId); + int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode); int32_t GetByteFromDb(const std::string &key, std::vector &value, const int32_t &userId); int32_t GetBatchKvsFromDb( const std::string &key, std::unordered_map &values, const int32_t &userId); diff --git a/services/ans/libans.map b/services/ans/libans.map index fde762ab0..7433ff4b7 100644 --- a/services/ans/libans.map +++ b/services/ans/libans.map @@ -52,6 +52,9 @@ *Subscribe*; *UpdateSlots*; *VerifyShellToken*; + *GetAdditionalConfig*; + *SetKvToDb*; + *GetKvFromDb*; local: *; }; diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 81f3ae201..a59707871 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -56,6 +56,7 @@ #include "datashare_predicates.h" #include "notification_config_parse.h" #include "advanced_notification_flow_control_service.h" +#include "notification_extension_wrapper.h" namespace OHOS { namespace Notification { @@ -1041,10 +1042,14 @@ ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string return ERROR_INTERNAL_ERROR; } if (hasPopped) { - ANS_LOGE("Has popped is true."); - message.ErrorCode(ERR_ANS_NOT_ALLOWED).Append(" Has popped"); - NotificationAnalyticsUtil::ReportModifyEvent(message); - return ERR_ANS_NOT_ALLOWED; + int32_t userId = -1; + OsAccountManagerHelper::GetInstance().GetCurrentCallingUserId(userId); + if (!EXTENTION_WRAPPER->GetPrivilegeDialogPopped(bundleOption->GetBundleName(), userId)) { + ANS_LOGE("Has popped is true."); + message.ErrorCode(ERR_ANS_NOT_ALLOWED).Append(" Has popped"); + NotificationAnalyticsUtil::ReportModifyEvent(message); + return ERR_ANS_NOT_ALLOWED; + } } if (!CreateDialogManager()) { @@ -2538,6 +2543,13 @@ ErrCode AdvancedNotificationService::PublishNotificationBySa(const sptrGetOverlayIconScaleSize(); + return ERR_OK; +} + ErrCode AdvancedNotificationService::GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) { ANS_LOGD("%{public}s", __FUNCTION__); diff --git a/services/ans/src/ans_manager_stub.cpp b/services/ans/src/ans_manager_stub.cpp index 4c7126498..9911ac542 100644 --- a/services/ans/src/ans_manager_stub.cpp +++ b/services/ans/src/ans_manager_stub.cpp @@ -457,6 +457,10 @@ int32_t AnsManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Mess result = HandleGetAllNotificationsBySlotType(data, reply); break; } + case static_cast(NotificationInterfaceCode::GET_OVERLAY_ICON_SCALE_SIZE): { + result = HandleGetOverlayIconScaleSize(data, reply); + break; + } default: { ANS_LOGE("[OnRemoteRequest] fail: unknown code!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, flags); @@ -2630,5 +2634,16 @@ ErrCode AnsManagerStub::HandleGetAllNotificationsBySlotType(MessageParcel &data, } return ERR_OK; } + +ErrCode AnsManagerStub::HandleGetOverlayIconScaleSize(MessageParcel &data, MessageParcel &reply) +{ + uint32_t scaleSize; + uint32_t errCode = GetOverlayIconScaleSize(scaleSize); + if (!reply.WriteUint32(scaleSize)) { + ANS_LOGE("[HandleGetOverlayIconScaleSize] fail: write result failed, ErrCode=%{public}d", scaleSize); + return ERR_ANS_PARCELABLE_FAILED; + } + return errCode; +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/src/common/notification_config_parse.cpp b/services/ans/src/common/notification_config_parse.cpp index 038a28a2c..0da1d4970 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -466,6 +466,30 @@ void NotificationConfigParse::GetReportTrustListConfig() return; } +uint32_t NotificationConfigParse::GetOverlayIconScaleSize() const +{ + uint32_t ret = 0; + nlohmann::json root; + std::string JsonPoint = "/"; + JsonPoint.append(CFG_KEY_NOTIFICATION_SERVICE); + if (!GetConfigJson(JsonPoint, root)) { + ANS_LOGE("Fail to get JsonPoint CCM config file."); + return 0; + } + if (!root.contains(CFG_KEY_NOTIFICATION_SERVICE)) { + ANS_LOGW("GetOverlayIconScaleSize not found jsonKey"); + return 0; + } + nlohmann::json affects = root[CFG_KEY_NOTIFICATION_SERVICE]; + if (affects.is_null() || affects.empty()) { + ANS_LOGE("GetOverlayIconScaleSize failed as invalid json value.") + return 0; + } + if (affects.contains(CFG_KEY_OVERLAYICON_SCALE_SIZE)) { + return affects[CFG_KEY_OVERLAYICON_SCALE_SIZE]; + } + return 0; +} bool NotificationConfigParse::IsReportTrustList(const std::string& bundleName) const { diff --git a/services/ans/src/notification_dialog_manager.cpp b/services/ans/src/notification_dialog_manager.cpp index ad69e9442..b93b44280 100644 --- a/services/ans/src/notification_dialog_manager.cpp +++ b/services/ans/src/notification_dialog_manager.cpp @@ -24,6 +24,8 @@ #include "notification_bundle_option.h" #include "notification_dialog.h" #include "notification_preferences.h" +#include "os_account_manager_helper.h" +#include "notification_extension_wrapper.h" #include #include @@ -133,6 +135,9 @@ ErrCode NotificationDialogManager::OnBundleEnabledStatusChanged( case DialogStatus::REMOVE_BUNDLE: result = onRemoveBundle(bundleName, uid); break; + case DialogStatus::DIALOG_OPEN: + result = OnDialogOpen(bundleName, uid); + break; default: result = false; } @@ -312,4 +317,12 @@ bool NotificationDialogManager::HandleAllDialogsClosed() return true; } +bool NotificationDialogManager::OnDialogOpen(const std::string& bundleName, const int32_t& uid) +{ + ANS_LOGD("enter"); + int32_t userId; + OsAccountManagerHelper::GetInstance().GetOsAccountLocalIdFromUid(uid, userId); + return EXTENTION_WRAPPER->SetDialogOpenSuccessInfo(bundleName, userId); +} + } // namespace OHOS::Notification diff --git a/services/ans/src/notification_extension_wrapper.cpp b/services/ans/src/notification_extension_wrapper.cpp index ac27c03ec..ce23c215e 100644 --- a/services/ans/src/notification_extension_wrapper.cpp +++ b/services/ans/src/notification_extension_wrapper.cpp @@ -25,6 +25,10 @@ #include "common_event_subscriber.h" #include "system_event_observer.h" +#ifndef SYMBOL_EXPORT +#define SYMBOL_EXPORT __attribute__ ((visibility("default"))) +#endif + namespace OHOS::Notification { const std::string EXTENTION_WRAPPER_PATH = "libans_ext.z.so"; const int32_t ACTIVE_DELETE = 0; @@ -45,6 +49,22 @@ void UpdateUnifiedGroupInfo(const std::string &key, std::shared_ptrUpdateUnifiedGroupInfo(key, groupInfo); } +SYMBOL_EXPORT void GetAdditionalConfig(const std::string &key, std::string &value) +{ + value = NotificationPreferences::GetInstance()->GetAdditionalConfig(key); + ANS_LOGD("GetAdditionalConfig SYMBOL_EXPORT valiue %{public}s", value.c_str()); +} + +SYMBOL_EXPORT int32_t SetKvToDb(const std::string &key, const std::string &value, const int32_t &userId) +{ + return NotificationPreferences::GetInstance()->SetKvToDb(key, value, userId); +} + +SYMBOL_EXPORT int32_t GetKvFromDb(const std::string &key, std::string &value, const int32_t &userId, int32_t& retCode) +{ + return NotificationPreferences::GetInstance()->GetKvFromDb(key, value, userId, retCode); +} + #ifdef __cplusplus } #endif @@ -92,6 +112,16 @@ void ExtensionWrapper::InitExtentionWrapper() initSummary_(UpdateUnifiedGroupInfo); } #endif + getPrivilegeDialogPopped_ = (GET_PRIVILEGE_DIALOG_POPPED)dlsym(extensionWrapperHandle_, "GetPrivilegeDialogPopped"); + if (getPrivilegeDialogPopped_ == nullptr) { + ANS_LOGE("extension wrapper symbol failed, error: %{public}s", dlerror()); + return; + } + setDialogOpenSuccessInfo_ = (SET_DIALOG_OPENSUCCESS_INFO)dlsym(extensionWrapperHandle_, "SetDialogOpenSuccessInfo"); + if (setDialogOpenSuccessInfo_ == nullptr) { + ANS_LOGE("extension wrapper symbol failed, error: %{public}s", dlerror()); + return; + } ANS_LOGD("extension wrapper init success"); } @@ -179,6 +209,24 @@ int32_t ExtensionWrapper::BannerControl(const std::string &bundleName) return bannerControl_(bundleName); } +bool ExtensionWrapper::GetPrivilegeDialogPopped(const std::string bundleName, const int32_t &userId) +{ + if (getPrivilegeDialogPopped_ == nullptr) { + ANS_LOGE("GetPrivilegeDialogPopped wrapper symbol failed."); + return -1; + } + return getPrivilegeDialogPopped_(bundleName, userId); +} + +bool ExtensionWrapper::SetDialogOpenSuccessInfo(const std::string& bundleName, const int32_t &userId) +{ + if (setDialogOpenSuccessInfo_ == nullptr) { + ANS_LOGE("SetDialogOpenSuccessInfo wrapper symbol failed."); + return -1; + } + return setDialogOpenSuccessInfo_(bundleName, userId); +} + #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER bool ExtensionWrapper::ModifyReminderFlags(const sptr &request) { diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 8940321bf..519b5094b 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -1264,6 +1264,15 @@ int32_t NotificationPreferences::GetKvFromDb( return preferncesDB_->GetKvFromDb(key, value, userId); } +int32_t NotificationPreferences::GetKvFromDb( + const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode) +{ + if (preferncesDB_ == nullptr) { + return ERR_ANS_SERVICE_NOT_READY; + } + return preferncesDB_->GetKvFromDb(key, value, userId, retCode); +} + int32_t NotificationPreferences::GetByteFromDb( const std::string &key, std::vector &value, const int32_t &userId) { diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index 7d472327f..2a06a6849 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -1869,6 +1869,18 @@ int32_t NotificationPreferencesDatabase::GetKvFromDb( return NativeRdb::E_OK; } +int32_t NotificationPreferencesDatabase::GetKvFromDb( + const std::string &key, std::string &value, const int32_t &userId, int32_t &retCode) +{ + if (!CheckRdbStore()) { + ANS_LOGE("RdbStore is nullptr."); + return NativeRdb::E_ERROR; + } + + retCode = rdbDataManager_->QueryData(key, value, userId); + return retCode; +} + int32_t NotificationPreferencesDatabase::GetByteFromDb( const std::string &key, std::vector &value, const int32_t &userId) { -- Gitee