From 1a06513b9f76c09b2c2e34981141e62227bd7f9b Mon Sep 17 00:00:00 2001 From: z00454238 Date: Fri, 6 Jun 2025 17:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E9=80=BB=E8=BE=91=20Signed-off-by:=20z004542?= =?UTF-8?q?38=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/ans/IAnsManager.idl | 2 -- frameworks/ans/src/notification_request.cpp | 5 ---- frameworks/core/include/ans_image_util.h | 2 -- frameworks/core/include/ans_notification.h | 8 ------ ..._notification_service_ipc_interface_code.h | 1 - frameworks/core/src/ans_image_util.cpp | 26 ------------------- frameworks/core/src/ans_notification.cpp | 20 +------------- .../unittest/ans_image_util_test/BUILD.gn | 3 +-- .../ans_notification_branch_test.cpp | 5 ---- interfaces/inner_api/notification_request.h | 8 +----- .../include/advanced_notification_service.h | 2 -- .../ans/include/notification_config_parse.h | 2 -- .../advanced_notification_publish_service.cpp | 7 ----- .../src/common/notification_config_parse.cpp | 25 ------------------ tools/test/mock/mock_ans_manager_stub.h | 5 ---- 15 files changed, 3 insertions(+), 118 deletions(-) diff --git a/frameworks/ans/IAnsManager.idl b/frameworks/ans/IAnsManager.idl index d7ec4e81f..87d8151ce 100644 --- a/frameworks/ans/IAnsManager.idl +++ b/frameworks/ans/IAnsManager.idl @@ -309,6 +309,4 @@ interface OHOS.Notification.IAnsManager { void SetHashCodeRule([in] unsigned int type); [macrodef NOTIFICATION_SMART_REMINDER_SUPPORTED] void RegisterSwingCallback([in] IRemoteObject swingCallback); - - void GetOverlayIconScaleSize([out] unsigned int scaleSize); } diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index a4de9d3c9..d98cbcf31 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -343,11 +343,6 @@ const std::shared_ptr NotificationRequest::GetOverlayIcon() con return overlayIcon_; } -void NotificationRequest::ResetOverlayIcon() const -{ - overlayIcon_ = nullptr; -} - void NotificationRequest::SetClassification(const std::string &classification) { classification_ = classification; diff --git a/frameworks/core/include/ans_image_util.h b/frameworks/core/include/ans_image_util.h index e87db2165..350bdd187 100644 --- a/frameworks/core/include/ans_image_util.h +++ b/frameworks/core/include/ans_image_util.h @@ -76,8 +76,6 @@ 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_notification.h b/frameworks/core/include/ans_notification.h index 18e13d5fe..e3caa8cab 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -1343,14 +1343,6 @@ public: */ ErrCode SetHashCodeRule(const uint32_t type); - /** - * @brief get the scale size of overlay icon. - * - * @param scaleSize the scale size of overlay icon. - * @return Returns ERR_OK on success, others on failure. - */ - 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 787a3a29c..1738c062c 100644 --- a/frameworks/core/include/distributed_notification_service_ipc_interface_code.h +++ b/frameworks/core/include/distributed_notification_service_ipc_interface_code.h @@ -111,7 +111,6 @@ namespace Notification { REGISTER_PUSH_CALLBACK, UNREGISTER_PUSH_CALLBACK, DISTRIBUTE_OPERATION, - GET_OVERLAY_ICON_SCALE_SIZE, // ans_subscriber_interface ON_CONNECTED, ON_DISCONNECTED, diff --git a/frameworks/core/src/ans_image_util.cpp b/frameworks/core/src/ans_image_util.cpp index c9a450484..f5c2458bb 100644 --- a/frameworks/core/src/ans_image_util.cpp +++ b/frameworks/core/src/ans_image_util.cpp @@ -16,8 +16,6 @@ #include "ans_log_wrapper.h" #include "image_packer.h" #include "image_source.h" -#include "ans_notification.h" -#include "singleton.h" namespace OHOS { namespace Notification { @@ -185,30 +183,6 @@ bool AnsImageUtil::ImageScale(const std::shared_ptr &pixelMap, return true; } -bool AnsImageUtil::HandleOverSizeOverlayIcon(const std::shared_ptr &pixelMap) -{ - uint32_t ccmScaleSize = 0; - - ErrCode code = DelayedSingleton::GetInstance()->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; -} - std::shared_ptr AnsImageUtil::CreatePixelMapByString(const std::string &imagedata) { if (imagedata.empty()) { diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 6bd054f9c..d91ca8db7 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -26,7 +26,6 @@ #include "notification_local_live_view_subscriber.h" #include "system_ability_definition.h" #include "unique_fd.h" -#include "ans_image_util.h" #include #include @@ -1599,10 +1598,7 @@ 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"); - if (!AnsImageUtil::HandleOverSizeOverlayIcon(overlayIcon)) { - ANS_LOGE("HandleOverSizeOverlayIcon failed."); - request.ResetOverlayIcon(); - } + return ERR_ANS_ICON_OVER_SIZE; } ErrCode err = request.CheckImageSizeForContent(); @@ -2360,19 +2356,6 @@ ErrCode AnsNotification::DisableNotificationFeature(const NotificationDisable &n return proxy->DisableNotificationFeature(reqPtr); } -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); -} - ErrCode AnsNotification::DistributeOperation(sptr& operationInfo, const sptr &callback) { @@ -2440,6 +2423,5 @@ ErrCode AnsNotification::GetAllNotificationsBySlotType(std::vectorGetAllNotificationsBySlotType(notifications, slotType); } - } // namespace Notification } // namespace OHOS diff --git a/frameworks/core/test/unittest/ans_image_util_test/BUILD.gn b/frameworks/core/test/unittest/ans_image_util_test/BUILD.gn index ef82e6858..ce61789ec 100644 --- a/frameworks/core/test/unittest/ans_image_util_test/BUILD.gn +++ b/frameworks/core/test/unittest/ans_image_util_test/BUILD.gn @@ -23,7 +23,6 @@ ohos_unittest("ans_image_util_test") { include_dirs = [ "${core_path}/include", "${core_path}/common/include", - "${interfaces_path}/kits/native", "../mock", ] @@ -35,7 +34,7 @@ ohos_unittest("ans_image_util_test") { "ans_image_util_unit_test.cpp", ] - deps = [ "${frameworks_module_ans_path}:ans_innerkits" ] + deps = [] external_deps = [ "ability_base:want", 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 540706e7c..42f37eca2 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 @@ -719,11 +719,6 @@ public: { return ERR_ANS_INVALID_PARAM; } - - ErrCode GetOverlayIconScaleSize(uint32_t& scaleSize) - { - return ERR_ANS_INVALID_PARAM; - } }; class AnsNotificationBranchTest : public testing::Test { diff --git a/interfaces/inner_api/notification_request.h b/interfaces/inner_api/notification_request.h index 21b6e8a32..6bf541bfe 100644 --- a/interfaces/inner_api/notification_request.h +++ b/interfaces/inner_api/notification_request.h @@ -567,12 +567,6 @@ public: */ void SetOverlayIcon(const std::shared_ptr &overlayIcon); - /** - * @brief reset the overlay icon of this notification. - * - */ - void ResetOverlayIcon() const; - /** * @brief Obtains the overlay icon of this notification. * @@ -1636,7 +1630,7 @@ private: std::shared_ptr littleIcon_ {}; std::string littleIconType_ {}; mutable std::shared_ptr bigIcon_ {}; - mutable std::shared_ptr overlayIcon_ {}; + 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 eeabb3f17..389b5bb24 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1343,8 +1343,6 @@ 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 b8ba792a4..77b9f7745 100644 --- a/services/ans/include/notification_config_parse.h +++ b/services/ans/include/notification_config_parse.h @@ -61,7 +61,6 @@ public: void GetCollaborationFilter(); bool IsInCollaborationFilter(const std::string &bundleName, int32_t uid) const; uint32_t GetStartAbilityTimeout(); - uint32_t GetOverlayIconScaleSize() const; private: std::map defaultCurrentSlotReminder_; @@ -96,7 +95,6 @@ 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/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 39c8078d1..6dabce678 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -1228,12 +1228,5 @@ ErrCode AdvancedNotificationService::SetHashCodeRule(const uint32_t type) return result; } - -ErrCode AdvancedNotificationService::GetOverlayIconScaleSize(uint32_t& scaleSize) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - scaleSize = NotificationConfigParse::GetInstance()->GetOverlayIconScaleSize(); - return ERR_OK; -} } // 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 2863c12ed..e7a444355 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -477,31 +477,6 @@ void NotificationConfigParse::GetReportTrustListConfig() return; } -uint32_t NotificationConfigParse::GetOverlayIconScaleSize() const -{ - uint32_t ret; - 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 key."); - 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 { return reporteTrustSet_.count(bundleName); diff --git a/tools/test/mock/mock_ans_manager_stub.h b/tools/test/mock/mock_ans_manager_stub.h index f886c0e74..6e602d4b5 100644 --- a/tools/test/mock/mock_ans_manager_stub.h +++ b/tools/test/mock/mock_ans_manager_stub.h @@ -701,11 +701,6 @@ public: return ERR_ANS_INVALID_PARAM; } - ErrCode GetOverlayIconScaleSize(uint32_t &scaleSize) override - { - return ERR_ANS_INVALID_PARAM; - } - private: std::string cmd_; std::string bundle_; -- Gitee