From 260e7b0bbe918beb2b5f9ec064769a86cadee96a Mon Sep 17 00:00:00 2001 From: yuyaozhi Date: Thu, 22 Sep 2022 15:09:12 +0800 Subject: [PATCH] Fix codecheck problems of notification Signed-off-by: yuyaozhi --- frameworks/ans/src/notification.cpp | 4 ++-- .../ans_innerkits_module_publish_test.cpp | 20 +++++++++---------- .../mock/mock_bundle_manager_helper.cpp | 6 +++++- .../notification_publish_test.cpp | 2 +- .../notification_service_test.cpp | 2 +- tools/dump/src/notification_shell_command.cpp | 1 - 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/frameworks/ans/src/notification.cpp b/frameworks/ans/src/notification.cpp index 7723258b8..f368a78c2 100644 --- a/frameworks/ans/src/notification.cpp +++ b/frameworks/ans/src/notification.cpp @@ -465,10 +465,10 @@ void Notification::SetRemindType(const NotificationConstant::RemindType &reminTy std::string Notification::GenerateNotificationKey( const std::string &deviceId, int32_t userId, int32_t uid, const std::string &label, int32_t id) { - const char *KEY_SPLITER = "_"; + const char *keySpliter = "_"; std::stringstream stream; - stream << deviceId << KEY_SPLITER << userId << KEY_SPLITER << uid << KEY_SPLITER << label << KEY_SPLITER << id; + stream << deviceId << keySpliter << userId << keySpliter << uid << keySpliter << label << keySpliter << id; return stream.str(); } diff --git a/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp b/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp index 0befae437..9a242f200 100644 --- a/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp +++ b/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp @@ -74,40 +74,40 @@ const std::string CLASSIFICATION_ALARM {"alarm"}; class TestAnsSubscriber : public NotificationSubscriber { public: - virtual void OnConnected() override + void OnConnected() override { g_subscribe_mtx.unlock(); } - virtual void OnDisconnected() override + void OnDisconnected() override { g_unsubscribe_mtx.unlock(); } - virtual void OnDied() override + void OnDied() override {} - virtual void OnUpdate(const std::shared_ptr &sortingMap) override + void OnUpdate(const std::shared_ptr &sortingMap) override {} - virtual void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override {} - virtual void OnEnabledNotificationChanged( + void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override {} - virtual void OnCanceled(const std::shared_ptr &request) override + void OnCanceled(const std::shared_ptr &request) override { GTEST_LOG_(INFO) << "ANS_Interface_MT::OnCanceled request : " << request->GetNotificationRequest().Dump(); OnCanceledReceived = true; } - virtual void OnCanceled(const std::shared_ptr &request, + void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int deleteReason) override {} - virtual void OnConsumed(const std::shared_ptr &request) override + void OnConsumed(const std::shared_ptr &request) override { OnConsumedReceived = true; g_consumed_mtx.unlock(); @@ -153,7 +153,7 @@ public: } } - virtual void OnConsumed(const std::shared_ptr &request, + void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override {} diff --git a/frameworks/test/moduletest/mock/mock_bundle_manager_helper.cpp b/frameworks/test/moduletest/mock/mock_bundle_manager_helper.cpp index b4c84abd0..80609a098 100644 --- a/frameworks/test/moduletest/mock/mock_bundle_manager_helper.cpp +++ b/frameworks/test/moduletest/mock/mock_bundle_manager_helper.cpp @@ -21,6 +21,10 @@ namespace OHOS { namespace Notification { +namespace { + const int32_t DEFAULT_USERID = 1000; +} + BundleManagerHelper::BundleManagerHelper() {} @@ -42,7 +46,7 @@ bool BundleManagerHelper::IsSystemApp(int uid) int BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId) { - return 1000; + return DEFAULT_USERID; } bool BundleManagerHelper::GetBundleInfoByBundleName( diff --git a/test/bechmarktest/notification_publish_test/notification_publish_test.cpp b/test/bechmarktest/notification_publish_test/notification_publish_test.cpp index 02a348580..61b59db63 100644 --- a/test/bechmarktest/notification_publish_test/notification_publish_test.cpp +++ b/test/bechmarktest/notification_publish_test/notification_publish_test.cpp @@ -42,7 +42,7 @@ public: InitButtonRequest(); } - virtual ~BenchmarkNotificationPublish() override = default; + ~BenchmarkNotificationPublish() override = default; void SetUp(const ::benchmark::State &state) override {} diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 0f3c6001e..25c853c36 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -68,7 +68,7 @@ public: ReportAggregatesOnly(); } - virtual ~BenchmarkNotificationService() override = default; + ~BenchmarkNotificationService() override = default; void SetUp(const ::benchmark::State &state) override {} diff --git a/tools/dump/src/notification_shell_command.cpp b/tools/dump/src/notification_shell_command.cpp index b135c15c5..0906e4684 100644 --- a/tools/dump/src/notification_shell_command.cpp +++ b/tools/dump/src/notification_shell_command.cpp @@ -305,7 +305,6 @@ ErrCode NotificationShellCommand::RunSetEnableCmd() resultReceiver_.append("set notification enabled failed\n"); } return ret; - } } // namespace Notification } // namespace OHOS -- Gitee