From b89a7f5088472545bf97aa99b201eeb973a973e4 Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Sat, 18 Sep 2021 19:44:53 +0800 Subject: [PATCH 1/2] fix codex Signed-off-by: zhaoyuan17 --- frameworks/ans/core/src/ans_notification.cpp | 4 +- .../native/src/notification_action_button.cpp | 8 +- .../native/src/notification_bundle_option.cpp | 2 +- .../ans/native/src/notification_constant.cpp | 2 +- .../ans/native/src/notification_helper.cpp | 2 +- .../src/notification_long_text_content.cpp | 2 +- .../native/src/notification_media_content.cpp | 24 +--- .../src/notification_multiline_content.cpp | 4 +- .../ans/native/src/notification_request.cpp | 50 ++++---- .../ans/native/src/notification_sorting.cpp | 2 +- .../native/src/notification_user_input.cpp | 2 +- .../test/moduletest/ans_fw_module_test.cpp | 4 +- .../ans_innerkits_module_publish_test.cpp | 5 +- .../ans/native/include/notification.h | 20 ++-- .../include/notification_action_button.h | 21 ++-- .../include/notification_basic_content.h | 6 +- .../ans/native/include/notification_content.h | 4 +- .../notification_conversational_content.h | 8 +- .../notification_conversational_message.h | 10 +- .../include/notification_long_text_content.h | 6 +- .../include/notification_media_content.h | 4 +- .../include/notification_multiline_content.h | 6 +- .../include/notification_picture_content.h | 6 +- .../ans/native/include/notification_request.h | 110 +++++++++--------- .../ans/native/include/notification_slot.h | 22 ++-- .../ans/native/include/notification_sorting.h | 16 +-- .../native/include/notification_sorting_map.h | 4 +- .../include/notification_subscribe_info.h | 2 +- .../native/include/notification_subscriber.h | 6 +- .../native/include/notification_user_input.h | 14 +-- .../wantagent/include/pending_want.h | 2 +- interfaces/kits/napi/ans/include/common.h | 1 - interfaces/kits/napi/ans/src/cancel.cpp | 4 +- interfaces/kits/napi/ans/src/common.cpp | 6 +- .../kits/napi/ans/src/display_badge.cpp | 8 +- interfaces/kits/napi/ans/src/disturb_mode.cpp | 4 +- .../kits/napi/ans/src/enable_notification.cpp | 8 +- interfaces/kits/napi/ans/src/get_active.cpp | 6 +- interfaces/kits/napi/ans/src/publish.cpp | 2 +- interfaces/kits/napi/ans/src/remove.cpp | 18 +-- interfaces/kits/napi/ans/src/slot.cpp | 28 ++--- interfaces/kits/napi/ans/src/subscribe.cpp | 21 ++-- interfaces/kits/napi/ans/src/unsubscribe.cpp | 2 +- .../kits/napi/wantagent/napi_want_agent.cpp | 18 +-- .../kits/napi/wantagent/napi_want_agent.h | 2 +- .../notification_preferences_test.cpp | 6 +- 46 files changed, 249 insertions(+), 263 deletions(-) diff --git a/frameworks/ans/core/src/ans_notification.cpp b/frameworks/ans/core/src/ans_notification.cpp index fd203213c..da55aed92 100644 --- a/frameworks/ans/core/src/ans_notification.cpp +++ b/frameworks/ans/core/src/ans_notification.cpp @@ -512,7 +512,7 @@ ErrCode AnsNotification::RemoveNotification(const std::string &key) } ErrCode AnsNotification::RemoveNotification( - const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label) + const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label) { if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -572,7 +572,7 @@ ErrCode AnsNotification::GetNotificationSlotsForBundle( } ErrCode AnsNotification::UpdateNotificationSlots( - const NotificationBundleOption &bundleOption, const std::vector> &slots) + const NotificationBundleOption &bundleOption, const std::vector> &slots) { if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); diff --git a/frameworks/ans/native/src/notification_action_button.cpp b/frameworks/ans/native/src/notification_action_button.cpp index b0c004d71..4c114748e 100644 --- a/frameworks/ans/native/src/notification_action_button.cpp +++ b/frameworks/ans/native/src/notification_action_button.cpp @@ -42,7 +42,7 @@ std::shared_ptr NotificationActionButton::Create(const } std::vector> onlyInputs = mimeTypeOnlyInputs; - std::vector> textInputs{}; + std::vector> textInputs {}; for (auto &userInput : userInputs) { if (!userInput) { continue; @@ -222,7 +222,7 @@ bool NotificationActionButton::Marshalling(Parcel &parcel) const return false; } - bool valid{false}; + bool valid {false}; valid = icon_ ? true : false; if (!parcel.WriteBool(valid)) { @@ -310,7 +310,7 @@ bool NotificationActionButton::ReadFromParcel(Parcel &parcel) semanticActionButton_ = static_cast(parcel.ReadInt32()); - bool valid{false}; + bool valid {false}; valid = parcel.ReadBool(); if (valid) { @@ -342,7 +342,7 @@ bool NotificationActionButton::ReadFromParcel(Parcel &parcel) auto vsize = parcel.ReadInt32(); for (auto it = 0; it < vsize; ++it) { valid = parcel.ReadBool(); - NotificationUserInput *member{nullptr}; + NotificationUserInput *member {nullptr}; if (valid) { member = parcel.ReadParcelable(); if (nullptr == member) { diff --git a/frameworks/ans/native/src/notification_bundle_option.cpp b/frameworks/ans/native/src/notification_bundle_option.cpp index acdfc939c..b5adae94e 100644 --- a/frameworks/ans/native/src/notification_bundle_option.cpp +++ b/frameworks/ans/native/src/notification_bundle_option.cpp @@ -46,7 +46,7 @@ int32_t NotificationBundleOption::GetUid() const std::string NotificationBundleOption::Dump() { - return "NotificationBundleOption[ bundleName = " + bundleName_ +", uid = " + std::to_string(uid_) + " ]"; + return "NotificationBundleOption[ bundleName = " + bundleName_ + ", uid = " + std::to_string(uid_) + " ]"; } bool NotificationBundleOption::Marshalling(Parcel &parcel) const diff --git a/frameworks/ans/native/src/notification_constant.cpp b/frameworks/ans/native/src/notification_constant.cpp index 744dc11f6..43f23d63c 100644 --- a/frameworks/ans/native/src/notification_constant.cpp +++ b/frameworks/ans/native/src/notification_constant.cpp @@ -17,7 +17,7 @@ namespace OHOS { namespace Notification { -const std::string NotificationConstant::EXTRA_INPUTS_SOURCE{"notification_user_input_source"}; +const std::string NotificationConstant::EXTRA_INPUTS_SOURCE {"notification_user_input_source"}; } // namespace Notification } // namespace OHOS \ No newline at end of file diff --git a/frameworks/ans/native/src/notification_helper.cpp b/frameworks/ans/native/src/notification_helper.cpp index 86ea093d9..87d459c55 100644 --- a/frameworks/ans/native/src/notification_helper.cpp +++ b/frameworks/ans/native/src/notification_helper.cpp @@ -210,7 +210,7 @@ ErrCode NotificationHelper::RemoveNotification(const std::string &key) } ErrCode NotificationHelper::RemoveNotification( - const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label) + const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label) { return DelayedSingleton::GetInstance()->RemoveNotification(bundleOption, notificationId, label); } diff --git a/frameworks/ans/native/src/notification_long_text_content.cpp b/frameworks/ans/native/src/notification_long_text_content.cpp index f17afa07b..c806df2ef 100644 --- a/frameworks/ans/native/src/notification_long_text_content.cpp +++ b/frameworks/ans/native/src/notification_long_text_content.cpp @@ -19,7 +19,7 @@ namespace OHOS { namespace Notification { -const std::size_t NotificationLongTextContent::MAX_LONGTEXT_LENGTH{1024}; +const std::size_t NotificationLongTextContent::MAX_LONGTEXT_LENGTH {1024}; NotificationLongTextContent::NotificationLongTextContent(const std::string &longText) { diff --git a/frameworks/ans/native/src/notification_media_content.cpp b/frameworks/ans/native/src/notification_media_content.cpp index f6d3e65b3..d66b8bc7a 100644 --- a/frameworks/ans/native/src/notification_media_content.cpp +++ b/frameworks/ans/native/src/notification_media_content.cpp @@ -41,7 +41,7 @@ std::vector NotificationMediaContent::GetShownActions() const std::string NotificationMediaContent::Dump() { - std::string numbers{}; + std::string numbers {}; std::for_each(sequenceNumbers_.begin(), sequenceNumbers_.end(), [&numbers](int32_t num) { numbers += std::to_string(num) + " "; }); @@ -57,19 +57,6 @@ bool NotificationMediaContent::Marshalling(Parcel &parcel) const return false; } - // auto valid = avToken_ ? true : false; - // if (!parcel.WriteBool(valid)) { - // ANS_LOGE("Failed to write the flag which indicate whether avToken is null"); - // return false; - // } - - // if (valid) { - // if (!parcel.WriteParcelable(avToken_.get())) { - // ANS_LOGE("Failed to write avToken"); - // return false; - // } - // } - if (!parcel.WriteUInt32Vector(sequenceNumbers_)) { ANS_LOGE("Failed to write sequence numbers"); return false; @@ -96,15 +83,6 @@ bool NotificationMediaContent::ReadFromParcel(Parcel &parcel) return false; } - // auto valid = parcel.ReadBool(); - // if (valid) { - // avToken_ = std::shared_ptr(parcel.ReadParcelable()); - // if (!avToken_) { - // ANS_LOGE("Failed to read avToken"); - // return false; - // } - // } - if (!parcel.ReadUInt32Vector(&sequenceNumbers_)) { ANS_LOGE("Failed to read sequence numbers"); return false; diff --git a/frameworks/ans/native/src/notification_multiline_content.cpp b/frameworks/ans/native/src/notification_multiline_content.cpp index 4d0df649d..abd88be57 100644 --- a/frameworks/ans/native/src/notification_multiline_content.cpp +++ b/frameworks/ans/native/src/notification_multiline_content.cpp @@ -19,7 +19,7 @@ namespace OHOS { namespace Notification { -const std::vector::size_type NotificationMultiLineContent::MAX_LINES{7}; +const std::vector::size_type NotificationMultiLineContent::MAX_LINES {7}; void NotificationMultiLineContent::SetExpandedTitle(const std::string &exTitle) { @@ -58,7 +58,7 @@ std::vector NotificationMultiLineContent::GetAllLines() const std::string NotificationMultiLineContent::Dump() { - std::string lines{}; + std::string lines {}; std::for_each( allLines_.begin(), allLines_.end(), [&lines](const std::string &line) { lines += " " + line + ","; }); lines.pop_back(); diff --git a/frameworks/ans/native/src/notification_request.cpp b/frameworks/ans/native/src/notification_request.cpp index 02c7e1e4c..b346882bd 100644 --- a/frameworks/ans/native/src/notification_request.cpp +++ b/frameworks/ans/native/src/notification_request.cpp @@ -20,28 +20,28 @@ namespace OHOS { namespace Notification { -const std::string NotificationRequest::CLASSIFICATION_ALARM{"alarm"}; -const std::string NotificationRequest::CLASSIFICATION_CALL{"call"}; -const std::string NotificationRequest::CLASSIFICATION_EMAIL{"email"}; -const std::string NotificationRequest::CLASSIFICATION_ERROR{"err"}; -const std::string NotificationRequest::CLASSIFICATION_EVENT{"event"}; -const std::string NotificationRequest::CLASSIFICATION_MESSAGE{"msg"}; -const std::string NotificationRequest::CLASSIFICATION_NAVIGATION{"navigation"}; -const std::string NotificationRequest::CLASSIFICATION_PROGRESS{"progress"}; -const std::string NotificationRequest::CLASSIFICATION_PROMO{"promo"}; -const std::string NotificationRequest::CLASSIFICATION_RECOMMENDATION{"recommendation"}; -const std::string NotificationRequest::CLASSIFICATION_REMINDER{"reminder"}; -const std::string NotificationRequest::CLASSIFICATION_SERVICE{"service"}; -const std::string NotificationRequest::CLASSIFICATION_SOCIAL{"social"}; -const std::string NotificationRequest::CLASSIFICATION_STATUS{"status"}; -const std::string NotificationRequest::CLASSIFICATION_SYSTEM{"sys"}; -const std::string NotificationRequest::CLASSIFICATION_TRANSPORT{"transport"}; - -const uint32_t NotificationRequest::COLOR_DEFAULT{0}; - -const uint32_t NotificationRequest::COLOR_MASK{0xFF000000}; -const std::size_t NotificationRequest::MAX_USER_INPUT_HISTORY{5}; -const std::size_t NotificationRequest::MAX_ACTION_BUTTONS{3}; +const std::string NotificationRequest::CLASSIFICATION_ALARM {"alarm"}; +const std::string NotificationRequest::CLASSIFICATION_CALL {"call"}; +const std::string NotificationRequest::CLASSIFICATION_EMAIL {"email"}; +const std::string NotificationRequest::CLASSIFICATION_ERROR {"err"}; +const std::string NotificationRequest::CLASSIFICATION_EVENT {"event"}; +const std::string NotificationRequest::CLASSIFICATION_MESSAGE {"msg"}; +const std::string NotificationRequest::CLASSIFICATION_NAVIGATION {"navigation"}; +const std::string NotificationRequest::CLASSIFICATION_PROGRESS {"progress"}; +const std::string NotificationRequest::CLASSIFICATION_PROMO {"promo"}; +const std::string NotificationRequest::CLASSIFICATION_RECOMMENDATION {"recommendation"}; +const std::string NotificationRequest::CLASSIFICATION_REMINDER {"reminder"}; +const std::string NotificationRequest::CLASSIFICATION_SERVICE {"service"}; +const std::string NotificationRequest::CLASSIFICATION_SOCIAL {"social"}; +const std::string NotificationRequest::CLASSIFICATION_STATUS {"status"}; +const std::string NotificationRequest::CLASSIFICATION_SYSTEM {"sys"}; +const std::string NotificationRequest::CLASSIFICATION_TRANSPORT {"transport"}; + +const uint32_t NotificationRequest::COLOR_DEFAULT {0}; + +const uint32_t NotificationRequest::COLOR_MASK {0xFF000000}; +const std::size_t NotificationRequest::MAX_USER_INPUT_HISTORY {5}; +const std::size_t NotificationRequest::MAX_ACTION_BUTTONS {3}; NotificationRequest::NotificationRequest(int32_t notificationId) : notificationId_(notificationId) { @@ -943,12 +943,12 @@ bool NotificationRequest::Marshalling(Parcel &parcel) const if (!parcel.WriteBool(permitted_)) { ANS_LOGE("Failed to write flag indicating whether to allow the platform to \ - generate contextual NotificationActionButton objects"); + generate contextual NotificationActionButton objects"); return false; } // write objects which managed by std::shared_ptr - bool valid{false}; + bool valid {false}; valid = wantAgent_ ? true : false; if (!parcel.WriteBool(valid)) { @@ -1177,7 +1177,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) onlyLocal_ = parcel.ReadBool(); permitted_ = parcel.ReadBool(); - bool valid{false}; + bool valid {false}; valid = parcel.ReadBool(); if (valid) { diff --git a/frameworks/ans/native/src/notification_sorting.cpp b/frameworks/ans/native/src/notification_sorting.cpp index 6315d338d..0ff27d780 100644 --- a/frameworks/ans/native/src/notification_sorting.cpp +++ b/frameworks/ans/native/src/notification_sorting.cpp @@ -49,7 +49,7 @@ void NotificationSorting::SetGroupKeyOverride(const std::string &groupKeyOverrid std::string NotificationSorting::Dump() const { - std::string contents{""}; + std::string contents {""}; if (slot_ != nullptr) { contents = slot_->Dump(); } else { diff --git a/frameworks/ans/native/src/notification_user_input.cpp b/frameworks/ans/native/src/notification_user_input.cpp index e14dd2f75..0115c3ba4 100644 --- a/frameworks/ans/native/src/notification_user_input.cpp +++ b/frameworks/ans/native/src/notification_user_input.cpp @@ -321,7 +321,7 @@ bool NotificationUserInput::ReadFromParcel(Parcel &parcel) auto ssize = parcel.ReadInt32(); for (auto it = 0; it < ssize; ++it) { - std::string member{}; + std::string member {}; if (!parcel.ReadString(member)) { ANS_LOGE("Failed to read permitMimeTypes"); return false; diff --git a/frameworks/ans/test/moduletest/ans_fw_module_test.cpp b/frameworks/ans/test/moduletest/ans_fw_module_test.cpp index d5a675bb1..5d97a1a1a 100644 --- a/frameworks/ans/test/moduletest/ans_fw_module_test.cpp +++ b/frameworks/ans/test/moduletest/ans_fw_module_test.cpp @@ -1107,8 +1107,10 @@ inline std::shared_ptr MakePixelMap(int32_t width, int32_t height) int32_t rowDataSize = width * PIXEL_BYTES; uint32_t bufferSize = rowDataSize * height; void *buffer = malloc(bufferSize); + if (buffer != nullptr) { + pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, AllocatorType::HEAP_ALLOC, nullptr); + } EXPECT_NE(buffer, nullptr); - pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, AllocatorType::HEAP_ALLOC, nullptr); return pixelMap; } diff --git a/frameworks/ans/test/moduletest/ans_innerkits_module_publish_test.cpp b/frameworks/ans/test/moduletest/ans_innerkits_module_publish_test.cpp index 85404dd1b..ec2898f5b 100644 --- a/frameworks/ans/test/moduletest/ans_innerkits_module_publish_test.cpp +++ b/frameworks/ans/test/moduletest/ans_innerkits_module_publish_test.cpp @@ -514,7 +514,10 @@ HWTEST_F(AnsInterfaceModulePublishTest, ANS_Interface_MT_Publish_00100, Function int32_t rowDataSize = (PIXEL_MAP_TEST_WIDTH + 3) / 4 * 4; uint32_t bufferSize = rowDataSize * PIXEL_MAP_TEST_HEIGHT; void *buffer = malloc(bufferSize); - pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, Media::AllocatorType::HEAP_ALLOC, nullptr); + if (buffer != nullptr) { + pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, Media::AllocatorType::HEAP_ALLOC, nullptr); + } + EXPECT_NE(buffer, nullptr); req.SetBigIcon(pixelMap); req.SetLittleIcon(pixelMap); diff --git a/interfaces/innerkits/ans/native/include/notification.h b/interfaces/innerkits/ans/native/include/notification.h index 9a338eaea..e515d617a 100644 --- a/interfaces/innerkits/ans/native/include/notification.h +++ b/interfaces/innerkits/ans/native/include/notification.h @@ -220,16 +220,16 @@ private: std::string GenerateNotificationKey(int32_t uid, const std::string &label, int32_t id); private: - bool enableSound_{false}; - bool enableLight_{false}; - bool enableViration_{false}; - std::string key_{""}; - int32_t ledLightColor_{0}; - NotificationConstant::VisiblenessType lockscreenVisibleness_{NotificationConstant::VisiblenessType::NO_OVERRIDE}; - sptr request_{nullptr}; - int64_t postTime_{0}; - std::shared_ptr sound_{nullptr}; - std::vector vibrationStyle_{}; + bool enableSound_ {false}; + bool enableLight_ {false}; + bool enableViration_ {false}; + std::string key_ {""}; + int32_t ledLightColor_ {0}; + NotificationConstant::VisiblenessType lockscreenVisibleness_ {NotificationConstant::VisiblenessType::NO_OVERRIDE}; + sptr request_ {nullptr}; + int64_t postTime_ {0}; + std::shared_ptr sound_ {nullptr}; + std::vector vibrationStyle_ {}; friend class AdvancedNotificationService; friend class NotificationSlotFilter; diff --git a/interfaces/innerkits/ans/native/include/notification_action_button.h b/interfaces/innerkits/ans/native/include/notification_action_button.h index 843b87753..8cb3e3958 100644 --- a/interfaces/innerkits/ans/native/include/notification_action_button.h +++ b/interfaces/innerkits/ans/native/include/notification_action_button.h @@ -220,16 +220,17 @@ private: bool ReadFromParcel(Parcel &parcel); private: - std::shared_ptr icon_{}; - std::string title_{}; - std::shared_ptr wantAgent_{}; - std::shared_ptr extras_{}; - NotificationConstant::SemanticActionButton semanticActionButton_{ - NotificationConstant::SemanticActionButton::NONE_ACTION_BUTTON}; - bool autoCreatedReplies_{true}; - std::vector> mimeTypeOnlyUserInputs_{}; - std::vector> userInputs_{}; - bool isContextual_{false}; + std::shared_ptr icon_ {}; + std::string title_ {}; + std::shared_ptr wantAgent_ {}; + std::shared_ptr extras_ {}; + NotificationConstant::SemanticActionButton semanticActionButton_ { + NotificationConstant::SemanticActionButton::NONE_ACTION_BUTTON + }; + bool autoCreatedReplies_ {true}; + std::vector> mimeTypeOnlyUserInputs_ {}; + std::vector> userInputs_ {}; + bool isContextual_ {false}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_basic_content.h b/interfaces/innerkits/ans/native/include/notification_basic_content.h index f96de434b..c14315466 100644 --- a/interfaces/innerkits/ans/native/include/notification_basic_content.h +++ b/interfaces/innerkits/ans/native/include/notification_basic_content.h @@ -92,9 +92,9 @@ protected: virtual bool ReadFromParcel(Parcel &parcel); protected: - std::string text_{}; - std::string title_{}; - std::string additionalText_{}; + std::string text_ {}; + std::string title_ {}; + std::string additionalText_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_content.h b/interfaces/innerkits/ans/native/include/notification_content.h index 6a3733897..ea5abb8cb 100644 --- a/interfaces/innerkits/ans/native/include/notification_content.h +++ b/interfaces/innerkits/ans/native/include/notification_content.h @@ -173,8 +173,8 @@ private: bool ReadFromParcel(Parcel &parcel); private: - NotificationContent::Type contentType_{NotificationContent::Type::NONE}; - std::shared_ptr content_{}; + NotificationContent::Type contentType_ {NotificationContent::Type::NONE}; + std::shared_ptr content_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_conversational_content.h b/interfaces/innerkits/ans/native/include/notification_conversational_content.h index 9e274ed77..5b91d30e2 100644 --- a/interfaces/innerkits/ans/native/include/notification_conversational_content.h +++ b/interfaces/innerkits/ans/native/include/notification_conversational_content.h @@ -133,10 +133,10 @@ private: NotificationConversationalContent() = default; private: - MessageUser messageUser_{}; - std::string conversationTitle_{}; - bool isGroup_{false}; - MessageVector messages_{}; + MessageUser messageUser_ {}; + std::string conversationTitle_ {}; + bool isGroup_ {false}; + MessageVector messages_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_conversational_message.h b/interfaces/innerkits/ans/native/include/notification_conversational_message.h index acd2c31ec..06eb0b350 100644 --- a/interfaces/innerkits/ans/native/include/notification_conversational_message.h +++ b/interfaces/innerkits/ans/native/include/notification_conversational_message.h @@ -108,11 +108,11 @@ private: bool ReadFromParcel(Parcel &parcel); private: - int64_t arrivedTime_{0}; - std::string text_{}; - MessageUser sender_{}; - std::shared_ptr uri_{}; - std::string mimeType_{}; + int64_t arrivedTime_ {0}; + std::string text_ {}; + MessageUser sender_ {}; + std::shared_ptr uri_ {}; + std::string mimeType_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_long_text_content.h b/interfaces/innerkits/ans/native/include/notification_long_text_content.h index f0a7ffb15..b64685f5d 100644 --- a/interfaces/innerkits/ans/native/include/notification_long_text_content.h +++ b/interfaces/innerkits/ans/native/include/notification_long_text_content.h @@ -114,9 +114,9 @@ private: static const std::size_t MAX_LONGTEXT_LENGTH; private: - std::string longText_{}; - std::string expandedTitle_{}; - std::string briefText_{}; + std::string longText_ {}; + std::string expandedTitle_ {}; + std::string briefText_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_media_content.h b/interfaces/innerkits/ans/native/include/notification_media_content.h index cfc7b3be2..c725db2ae 100644 --- a/interfaces/innerkits/ans/native/include/notification_media_content.h +++ b/interfaces/innerkits/ans/native/include/notification_media_content.h @@ -99,8 +99,8 @@ protected: bool ReadFromParcel(Parcel &parcel) override; private: - std::shared_ptr avToken_{}; - std::vector sequenceNumbers_{}; + std::shared_ptr avToken_ {}; + std::vector sequenceNumbers_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_multiline_content.h b/interfaces/innerkits/ans/native/include/notification_multiline_content.h index 1bbfe05ea..485f6c1fa 100644 --- a/interfaces/innerkits/ans/native/include/notification_multiline_content.h +++ b/interfaces/innerkits/ans/native/include/notification_multiline_content.h @@ -111,9 +111,9 @@ private: static const std::vector::size_type MAX_LINES; private: - std::string expandedTitle_{}; - std::string briefText_{}; - std::vector allLines_{}; + std::string expandedTitle_ {}; + std::string briefText_ {}; + std::vector allLines_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_picture_content.h b/interfaces/innerkits/ans/native/include/notification_picture_content.h index c4abb2f45..91a3dd806 100644 --- a/interfaces/innerkits/ans/native/include/notification_picture_content.h +++ b/interfaces/innerkits/ans/native/include/notification_picture_content.h @@ -104,9 +104,9 @@ protected: bool ReadFromParcel(Parcel &parcel) override; private: - std::string expandedTitle_{}; - std::string briefText_{}; - std::shared_ptr bigPicture_{}; + std::string expandedTitle_ {}; + std::string briefText_ {}; + std::shared_ptr bigPicture_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_request.h b/interfaces/innerkits/ans/native/include/notification_request.h index a879f32d8..f3c236fe2 100644 --- a/interfaces/innerkits/ans/native/include/notification_request.h +++ b/interfaces/innerkits/ans/native/include/notification_request.h @@ -888,61 +888,61 @@ private: int64_t GetNowSysTime(); private: - int32_t notificationId_{0}; - uint32_t color_{NotificationRequest::COLOR_DEFAULT}; - int32_t badgeNumber_{0}; - int32_t progressValue_{0}; - int32_t progressMax_{0}; - int64_t createTime_{0}; - int64_t deliveryTime_{0}; - int64_t autoDeletedTime_{0}; - - pid_t creatorPid_{0}; - pid_t creatorUid_{0}; - - std::string settingsText_{}; - std::string creatorBundleName_{}; - std::string ownerBundleName_{}; - std::string groupValue_{}; - std::string statusBarText_{}; - std::string label_{}; - std::string shortcutId_{}; - std::string sortingKey_{}; - std::string classification_{}; - - NotificationConstant::SlotType slotType_{NotificationConstant::SlotType::OTHER}; - NotificationRequest::GroupAlertType groupAlertType_{NotificationRequest::GroupAlertType::ALL}; - NotificationConstant::VisiblenessType visiblenessType_{NotificationConstant::VisiblenessType::NO_OVERRIDE}; - NotificationRequest::BadgeStyle badgeStyle_{NotificationRequest::BadgeStyle::NONE}; - NotificationContent::Type notificationContentType_{NotificationContent::Type::NONE}; - - bool showDeliveryTime_{false}; - bool tapDismissed_{false}; - bool colorEnabled_{false}; - bool alertOneTime_{false}; - bool showStopwatch_{false}; - bool isCountdown_{false}; - bool inProgress_{false}; - bool groupOverview_{false}; - bool progressIndeterminate_{false}; - bool unremovable_{false}; - bool floatingIcon_{false}; - bool onlyLocal_{false}; - bool permitted_{true}; - - std::shared_ptr context_{}; - std::shared_ptr wantAgent_{}; - std::shared_ptr removalWantAgent_{}; - std::shared_ptr maxScreenWantAgent_{}; - std::shared_ptr additionalParams_{}; - std::shared_ptr littleIcon_{}; - std::shared_ptr bigIcon_{}; - std::shared_ptr notificationContent_{}; - std::shared_ptr publicNotification_{}; - - std::vector> actionButtons_{}; - std::vector> messageUsers_{}; - std::vector userInputHistory_{}; + int32_t notificationId_ {0}; + uint32_t color_ {NotificationRequest::COLOR_DEFAULT}; + int32_t badgeNumber_ {0}; + int32_t progressValue_ {0}; + int32_t progressMax_ {0}; + int64_t createTime_ {0}; + int64_t deliveryTime_ {0}; + int64_t autoDeletedTime_ {0}; + + pid_t creatorPid_ {0}; + pid_t creatorUid_ {0}; + + std::string settingsText_ {}; + std::string creatorBundleName_ {}; + std::string ownerBundleName_ {}; + std::string groupValue_ {}; + std::string statusBarText_ {}; + std::string label_ {}; + std::string shortcutId_ {}; + std::string sortingKey_ {}; + std::string classification_ {}; + + NotificationConstant::SlotType slotType_ {NotificationConstant::SlotType::OTHER}; + NotificationRequest::GroupAlertType groupAlertType_ {NotificationRequest::GroupAlertType::ALL}; + NotificationConstant::VisiblenessType visiblenessType_ {NotificationConstant::VisiblenessType::NO_OVERRIDE}; + NotificationRequest::BadgeStyle badgeStyle_ {NotificationRequest::BadgeStyle::NONE}; + NotificationContent::Type notificationContentType_ {NotificationContent::Type::NONE}; + + bool showDeliveryTime_ {false}; + bool tapDismissed_ {false}; + bool colorEnabled_ {false}; + bool alertOneTime_ {false}; + bool showStopwatch_ {false}; + bool isCountdown_ {false}; + bool inProgress_ {false}; + bool groupOverview_ {false}; + bool progressIndeterminate_ {false}; + bool unremovable_ {false}; + bool floatingIcon_ {false}; + bool onlyLocal_ {false}; + bool permitted_ {true}; + + std::shared_ptr context_ {}; + std::shared_ptr wantAgent_ {}; + std::shared_ptr removalWantAgent_ {}; + std::shared_ptr maxScreenWantAgent_ {}; + std::shared_ptr additionalParams_ {}; + std::shared_ptr littleIcon_ {}; + std::shared_ptr bigIcon_ {}; + std::shared_ptr notificationContent_ {}; + std::shared_ptr publicNotification_ {}; + + std::vector> actionButtons_ {}; + std::vector> messageUsers_ {}; + std::vector userInputHistory_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_slot.h b/interfaces/innerkits/ans/native/include/notification_slot.h index 5a82654de..f9594c65e 100644 --- a/interfaces/innerkits/ans/native/include/notification_slot.h +++ b/interfaces/innerkits/ans/native/include/notification_slot.h @@ -33,7 +33,7 @@ public: // with no banner or prompt tone LEVEL_LOW, // the notifications are displayed on the notification panel, // with no banner or prompt tone - LEVEL_DEFAULT, // the notification function is enabled and notifications are displayed + LEVEL_DEFAULT, // the notification function is enabled and notifications are displayed, // on the notification panel, with a banner and a prompt tone. LEVEL_HIGH, // the notifications are displayed on the notification panel, // with a banner and a prompt tone @@ -346,20 +346,20 @@ private: void SetName(const std::string &name); private: - std::string id_{}; - std::string name_{}; + std::string id_ {}; + std::string name_ {}; bool isLightEnabled_ {false}; bool isVibrationEnabled_ {false}; - bool isShowBadge_{true}; - bool isBypassDnd_{false}; - std::string description_{}; + bool isShowBadge_ {true}; + bool isBypassDnd_ {false}; + std::string description_ {}; int32_t lightColor_ {0}; - NotificationLevel level_{LEVEL_DEFAULT}; - NotificationConstant::SlotType type_{}; - NotificationConstant::VisiblenessType lockScreenVisibleness_{NotificationConstant::VisiblenessType::NO_OVERRIDE}; - std::string groupId_{}; + NotificationLevel level_ {LEVEL_DEFAULT}; + NotificationConstant::SlotType type_ {}; + NotificationConstant::VisiblenessType lockScreenVisibleness_ {NotificationConstant::VisiblenessType::NO_OVERRIDE}; + std::string groupId_ {}; Uri sound_; - std::vector vibrationValues_{}; + std::vector vibrationValues_ {}; // no object in parcel static constexpr int VALUE_NULL = -1; diff --git a/interfaces/innerkits/ans/native/include/notification_sorting.h b/interfaces/innerkits/ans/native/include/notification_sorting.h index 4b273f938..4be3ba5b4 100644 --- a/interfaces/innerkits/ans/native/include/notification_sorting.h +++ b/interfaces/innerkits/ans/native/include/notification_sorting.h @@ -168,14 +168,14 @@ private: bool ReadFromParcel(Parcel &parcel); private: - std::string key_{}; - int32_t ranking_{-1}; - int32_t importance_{-1}; - bool isDisplayBadge_{true}; - bool isHiddenNotification_{}; - std::string groupKeyOverride_{}; - int32_t visiblenessOverride_{}; - sptr slot_{nullptr}; + std::string key_ {}; + int32_t ranking_ {-1}; + int32_t importance_ {-1}; + bool isDisplayBadge_ {true}; + bool isHiddenNotification_ {}; + std::string groupKeyOverride_ {}; + int32_t visiblenessOverride_ {}; + sptr slot_ {nullptr}; friend class AdvancedNotificationService; }; diff --git a/interfaces/innerkits/ans/native/include/notification_sorting_map.h b/interfaces/innerkits/ans/native/include/notification_sorting_map.h index 32a8163cb..54fb3f37a 100644 --- a/interfaces/innerkits/ans/native/include/notification_sorting_map.h +++ b/interfaces/innerkits/ans/native/include/notification_sorting_map.h @@ -93,8 +93,8 @@ private: void SetNotificationSorting(const std::vector &sortingList); private: - std::vector sortedKey_{}; - std::map sortings_{}; + std::vector sortedKey_ {}; + std::map sortings_ {}; }; } // namespace Notification diff --git a/interfaces/innerkits/ans/native/include/notification_subscribe_info.h b/interfaces/innerkits/ans/native/include/notification_subscribe_info.h index 49dc6fc29..1eb370e59 100644 --- a/interfaces/innerkits/ans/native/include/notification_subscribe_info.h +++ b/interfaces/innerkits/ans/native/include/notification_subscribe_info.h @@ -94,7 +94,7 @@ private: bool ReadFromParcel(Parcel &parcel); private: - std::vector appNames_{}; + std::vector appNames_ {}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_subscriber.h b/interfaces/innerkits/ans/native/include/notification_subscriber.h index ebe13aac9..6cbdecc3e 100644 --- a/interfaces/innerkits/ans/native/include/notification_subscriber.h +++ b/interfaces/innerkits/ans/native/include/notification_subscriber.h @@ -149,9 +149,9 @@ private: public: NotificationSubscriber &subscriber_; - sptr recipient_{nullptr}; - sptr proxy_{nullptr}; - std::mutex mutex_{}; + sptr recipient_ {nullptr}; + sptr proxy_ {nullptr}; + std::mutex mutex_ {}; }; private: diff --git a/interfaces/innerkits/ans/native/include/notification_user_input.h b/interfaces/innerkits/ans/native/include/notification_user_input.h index f84d26830..1327bca96 100644 --- a/interfaces/innerkits/ans/native/include/notification_user_input.h +++ b/interfaces/innerkits/ans/native/include/notification_user_input.h @@ -265,13 +265,13 @@ private: bool ReadFromParcel(Parcel &parcel); private: - std::string inputKey_{}; - std::string tag_{}; - std::vector options_{}; - bool permitFreeFormInput_{true}; - std::set permitMimeTypes_{}; - std::shared_ptr pacMap_{}; - NotificationConstant::InputEditType editType_{NotificationConstant::InputEditType::EDIT_AUTO}; + std::string inputKey_ {}; + std::string tag_ {}; + std::vector options_ {}; + bool permitFreeFormInput_ {true}; + std::set permitMimeTypes_ {}; + std::shared_ptr pacMap_ {}; + NotificationConstant::InputEditType editType_ {NotificationConstant::InputEditType::EDIT_AUTO}; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/wantagent/include/pending_want.h b/interfaces/innerkits/wantagent/include/pending_want.h index b86b1a3cb..7ab84bd4e 100644 --- a/interfaces/innerkits/wantagent/include/pending_want.h +++ b/interfaces/innerkits/wantagent/include/pending_want.h @@ -152,7 +152,7 @@ public: * @param want An Want describing the service to be started. * @param flags May be FLAG_ONE_SHOT, FLAG_NO_CREATE, * FLAG_CANCEL_CURRENT, FLAG_UPDATE_CURRENT, - *FLAG_IMMUTABLE. + * FLAG_IMMUTABLE. * * @return Returns an existing or new PendingWant matching the given * parameters. May return null only if FLAG_NO_CREATE has been diff --git a/interfaces/kits/napi/ans/include/common.h b/interfaces/kits/napi/ans/include/common.h index 92a08e74b..17bcd5832 100644 --- a/interfaces/kits/napi/ans/include/common.h +++ b/interfaces/kits/napi/ans/include/common.h @@ -89,7 +89,6 @@ enum InputEditType { EDIT_AUTO, EDIT_DISABLED, EDIT_ENABLED }; struct NotificationSubscribeInfo { std::vector bundleNames; - // std::vector deviceIds; int userId = 0; bool hasSubscribeInfo = false; }; diff --git a/interfaces/kits/napi/ans/src/cancel.cpp b/interfaces/kits/napi/ans/src/cancel.cpp index 5264e984f..7bc7871ff 100644 --- a/interfaces/kits/napi/ans/src/cancel.cpp +++ b/interfaces/kits/napi/ans/src/cancel.cpp @@ -106,7 +106,7 @@ napi_value Cancel(napi_env env, napi_callback_info info) } AsyncCallbackInfoCancel *asynccallbackinfo = new (std::nothrow) - AsyncCallbackInfoCancel{.env = env, .asyncWork = nullptr, .id = paras.id, .label = paras.label}; + AsyncCallbackInfoCancel {.env = env, .asyncWork = nullptr, .id = paras.id, .label = paras.label}; if (!asynccallbackinfo) { return Common::JSParaError(env, paras.callback); } @@ -164,7 +164,7 @@ napi_value CancelAll(napi_env env, napi_callback_info info) } AsyncCallbackInfoCancel *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoCancel{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoCancel {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } diff --git a/interfaces/kits/napi/ans/src/common.cpp b/interfaces/kits/napi/ans/src/common.cpp index a2543c73c..e57a617a8 100644 --- a/interfaces/kits/napi/ans/src/common.cpp +++ b/interfaces/kits/napi/ans/src/common.cpp @@ -2617,7 +2617,7 @@ napi_value Common::GetNotificationSlot(const napi_env &env, const napi_value &va napi_get_value_int32(env, nobj, &inLevel); ANS_LOGI("level is: %{public}d", inLevel); - NotificationSlot::NotificationLevel outLevel{NotificationSlot::NotificationLevel::LEVEL_NONE}; + NotificationSlot::NotificationLevel outLevel {NotificationSlot::NotificationLevel::LEVEL_NONE}; if (!SlotLevelJSToC(SlotLevel(inLevel), outLevel)) { return nullptr; } @@ -2753,7 +2753,7 @@ napi_value Common::GetBundleOption(const napi_env &env, const napi_value &value, { ANS_LOGI("enter"); - bool hasProperty{false}; + bool hasProperty {false}; napi_valuetype valuetype = napi_undefined; napi_value result = nullptr; @@ -2784,7 +2784,7 @@ napi_value Common::GetNotificationKey(const napi_env &env, const napi_value &val { ANS_LOGI("enter"); - bool hasProperty{false}; + bool hasProperty {false}; napi_valuetype valuetype = napi_undefined; napi_value result = nullptr; diff --git a/interfaces/kits/napi/ans/src/display_badge.cpp b/interfaces/kits/napi/ans/src/display_badge.cpp index 129355a8f..ea42c40b0 100644 --- a/interfaces/kits/napi/ans/src/display_badge.cpp +++ b/interfaces/kits/napi/ans/src/display_badge.cpp @@ -127,13 +127,13 @@ napi_value DisplayBadge(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - EnableBadgeParams params{}; + EnableBadgeParams params {}; if (ParseParameters(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoEnableBadge *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoEnableBadge{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoEnableBadge {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } @@ -192,13 +192,13 @@ napi_value IsBadgeDisplayed(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - IsDisplayBadgeParams params{}; + IsDisplayBadgeParams params {}; if (ParseParameters(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoIsDisplayBadge *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoIsDisplayBadge{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoIsDisplayBadge {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } diff --git a/interfaces/kits/napi/ans/src/disturb_mode.cpp b/interfaces/kits/napi/ans/src/disturb_mode.cpp index 34040e313..d2b88c530 100644 --- a/interfaces/kits/napi/ans/src/disturb_mode.cpp +++ b/interfaces/kits/napi/ans/src/disturb_mode.cpp @@ -68,13 +68,13 @@ napi_value SetDoNotDisturbMode(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - DisturbModeParams params{}; + DisturbModeParams params {}; if (ParseParameters(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoDisturbMode *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoDisturbMode{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoDisturbMode {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } diff --git a/interfaces/kits/napi/ans/src/enable_notification.cpp b/interfaces/kits/napi/ans/src/enable_notification.cpp index ae680b46b..aa8c2cdcd 100644 --- a/interfaces/kits/napi/ans/src/enable_notification.cpp +++ b/interfaces/kits/napi/ans/src/enable_notification.cpp @@ -127,13 +127,13 @@ napi_value EnableNotification(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - EnableParams params{}; + EnableParams params {}; if (ParseParameters(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoEnable *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoEnable{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoEnable {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } @@ -189,13 +189,13 @@ napi_value IsNotificationEnabled(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - IsEnableParams params{}; + IsEnableParams params {}; if (ParseParameters(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoIsEnable *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoIsEnable{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoIsEnable {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } diff --git a/interfaces/kits/napi/ans/src/get_active.cpp b/interfaces/kits/napi/ans/src/get_active.cpp index d763bd058..0d6ba8c42 100644 --- a/interfaces/kits/napi/ans/src/get_active.cpp +++ b/interfaces/kits/napi/ans/src/get_active.cpp @@ -77,7 +77,7 @@ napi_value GetAllActiveNotifications(napi_env env, napi_callback_info info) } AsyncCallbackInfoActive *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoActive{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoActive {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } @@ -163,7 +163,7 @@ napi_value GetActiveNotifications(napi_env env, napi_callback_info info) } AsyncCallbackInfoActive *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoActive{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoActive {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } @@ -249,7 +249,7 @@ napi_value GetActiveNotificationCount(napi_env env, napi_callback_info info) } AsyncCallbackInfoActive *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoActive{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoActive {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } diff --git a/interfaces/kits/napi/ans/src/publish.cpp b/interfaces/kits/napi/ans/src/publish.cpp index 8dd5e880c..3c860cab9 100644 --- a/interfaces/kits/napi/ans/src/publish.cpp +++ b/interfaces/kits/napi/ans/src/publish.cpp @@ -88,7 +88,7 @@ napi_value Publish(napi_env env, napi_callback_info info) napi_value promise = nullptr; AsyncCallbackInfoPublish *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoPublish{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoPublish {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } diff --git a/interfaces/kits/napi/ans/src/remove.cpp b/interfaces/kits/napi/ans/src/remove.cpp index 8cae75ede..59b9a3dae 100644 --- a/interfaces/kits/napi/ans/src/remove.cpp +++ b/interfaces/kits/napi/ans/src/remove.cpp @@ -35,15 +35,15 @@ struct BundleAndKeyInfo { }; struct RemoveParams { - std::optional hashcode{}; - std::optional bundleAndKeyInfo{}; + std::optional hashcode {}; + std::optional bundleAndKeyInfo {}; napi_ref callback = nullptr; }; struct AsyncCallbackInfoRemove { napi_env env = nullptr; napi_async_work asyncWork = nullptr; - RemoveParams params{}; + RemoveParams params {}; CallbackPromiseInfo info; }; @@ -78,7 +78,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, } else { NAPI_ASSERT(env, argc >= REMOVE_BY_BUNDLE_AND_KEY_MIN_PARA, "Wrong number of arguments"); - BundleAndKeyInfo info{}; + BundleAndKeyInfo info {}; // argv[0]: BundleOption auto retValue = Common::GetBundleOption(env, argv[0], info.option); if (retValue == nullptr) { @@ -128,7 +128,7 @@ napi_value ParseParametersByRemoveAll(const napi_env &env, const napi_callback_i // argv[0]: callback napi_create_reference(env, argv[0], 1, ¶ms.callback); } else { - BundleAndKeyInfo info{}; + BundleAndKeyInfo info {}; // argv[0]: BundleOption auto retValue = Common::GetBundleOption(env, argv[0], info.option); NAPI_ASSERT(env, retValue != nullptr, "GetBundleOption failed."); @@ -149,13 +149,13 @@ napi_value Remove(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - RemoveParams params{}; + RemoveParams params {}; if (ParseParameters(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoRemove *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoRemove{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoRemove {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } @@ -215,13 +215,13 @@ napi_value RemoveAll(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - RemoveParams params{}; + RemoveParams params {}; if (ParseParametersByRemoveAll(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoRemove *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoRemove{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoRemove {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } diff --git a/interfaces/kits/napi/ans/src/slot.cpp b/interfaces/kits/napi/ans/src/slot.cpp index 3b493f2c6..3764f5380 100644 --- a/interfaces/kits/napi/ans/src/slot.cpp +++ b/interfaces/kits/napi/ans/src/slot.cpp @@ -421,11 +421,13 @@ napi_value AddSlot(napi_env env, napi_callback_info info) return Common::JSParaError(env, paras.callback); } - AsyncCallbackInfoAddSlot *asynccallbackinfo = new (std::nothrow) AsyncCallbackInfoAddSlot{.env = env, + AsyncCallbackInfoAddSlot *asynccallbackinfo = new (std::nothrow) AsyncCallbackInfoAddSlot { + .env = env, .asyncWork = nullptr, .slot = paras.slot, .inType = paras.inType, - .isAddSlotByType = paras.isAddSlotByType}; + .isAddSlotByType = paras.isAddSlotByType + }; if (!asynccallbackinfo) { return Common::JSParaError(env, paras.callback); } @@ -485,7 +487,7 @@ napi_value AddSlots(napi_env env, napi_callback_info info) } AsyncCallbackInfoAddSlots *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoAddSlots{.env = env, .asyncWork = nullptr, .slots = paras.slots}; + new (std::nothrow) AsyncCallbackInfoAddSlots {.env = env, .asyncWork = nullptr, .slots = paras.slots}; if (!asynccallbackinfo) { return Common::JSParaError(env, paras.callback); } @@ -535,13 +537,13 @@ napi_value SetSlotByBundle(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - ParametersInfoSetSlotByBundle params{}; + ParametersInfoSetSlotByBundle params {}; if (ParseParametersSetSlotByBundle(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoSetSlotByBundle *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoSetSlotByBundle{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoSetSlotByBundle {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } @@ -602,7 +604,7 @@ napi_value GetSlot(napi_env env, napi_callback_info info) } AsyncCallbackInfoGetSlot *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoGetSlot{.env = env, .asyncWork = nullptr, .outType = paras.outType}; + new (std::nothrow) AsyncCallbackInfoGetSlot {.env = env, .asyncWork = nullptr, .outType = paras.outType}; if (!asynccallbackinfo) { return Common::JSParaError(env, paras.callback); } @@ -668,13 +670,13 @@ napi_value GetSlotNumByBundle(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - ParametersInfoGetSlotNumByBundle params{}; + ParametersInfoGetSlotNumByBundle params {}; if (ParseParametersGetSlotNumByBundle(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoGetSlotNumByBundle *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoGetSlotNumByBundle{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoGetSlotNumByBundle {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } @@ -736,7 +738,7 @@ napi_value GetSlots(napi_env env, napi_callback_info info) } AsyncCallbackInfoGetSlots *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoGetSlots{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoGetSlots {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } @@ -815,13 +817,13 @@ napi_value GetSlotsByBundle(napi_env env, napi_callback_info info) { ANS_LOGI("enter"); - ParametersInfoGetSlotsByBundle params{}; + ParametersInfoGetSlotsByBundle params {}; if (ParseParametersGetSlotsByBundle(env, info, params) == nullptr) { return Common::JSParaError(env, params.callback); } AsyncCallbackInfoGetSlotsByBundle *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoGetSlotsByBundle{.env = env, .asyncWork = nullptr, .params = params}; + new (std::nothrow) AsyncCallbackInfoGetSlotsByBundle {.env = env, .asyncWork = nullptr, .params = params}; if (!asynccallbackinfo) { return Common::JSParaError(env, params.callback); } @@ -910,7 +912,7 @@ napi_value RemoveSlot(napi_env env, napi_callback_info info) } AsyncCallbackInfoRemoveSlot *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoRemoveSlot{.env = env, .asyncWork = nullptr, .outType = paras.outType}; + new (std::nothrow) AsyncCallbackInfoRemoveSlot {.env = env, .asyncWork = nullptr, .outType = paras.outType}; if (!asynccallbackinfo) { return Common::JSParaError(env, paras.callback); } @@ -966,7 +968,7 @@ napi_value RemoveAllSlots(napi_env env, napi_callback_info info) } AsyncCallbackInfoRemoveAllSlots *asynccallbackinfo = - new (std::nothrow) AsyncCallbackInfoRemoveAllSlots{.env = env, .asyncWork = nullptr}; + new (std::nothrow) AsyncCallbackInfoRemoveAllSlots {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } diff --git a/interfaces/kits/napi/ans/src/subscribe.cpp b/interfaces/kits/napi/ans/src/subscribe.cpp index f2bcb906e..724acd30c 100644 --- a/interfaces/kits/napi/ans/src/subscribe.cpp +++ b/interfaces/kits/napi/ans/src/subscribe.cpp @@ -209,10 +209,10 @@ void SubscriberInstance::OnCanceled(const std::shared_ptrenv, &result); int error = 0; if (!SetSubscribeCallbackData(dataWorkerData->env, - dataWorkerData->request, - dataWorkerData->sortingMap, - dataWorkerData->deleteReason, - result)) { + dataWorkerData->request, + dataWorkerData->sortingMap, + dataWorkerData->deleteReason, + result)) { result = Common::NapiGetNull(dataWorkerData->env); error = ERROR; } else { @@ -296,10 +296,10 @@ void SubscriberInstance::OnConsumed(const std::shared_ptrenv, &result); int error = 0; if (!SetSubscribeCallbackData(dataWorkerData->env, - dataWorkerData->request, - dataWorkerData->sortingMap, - NO_DELETE_REASON, - result)) { + dataWorkerData->request, + dataWorkerData->sortingMap, + NO_DELETE_REASON, + result)) { result = Common::NapiGetNull(dataWorkerData->env); error = ERROR; } else { @@ -917,8 +917,9 @@ napi_value Subscribe(napi_env env, napi_callback_info info) } ANS_LOGI("Subscribe objectInfo = %{public}p", objectInfo); - AsyncCallbackInfoSubscribe *asynccallbackinfo = new (std::nothrow) AsyncCallbackInfoSubscribe{ - .env = env, .asyncWork = nullptr, .objectInfo = objectInfo, .subscriberInfo = subscriberInfo}; + AsyncCallbackInfoSubscribe *asynccallbackinfo = new (std::nothrow) AsyncCallbackInfoSubscribe { + .env = env, .asyncWork = nullptr, .objectInfo = objectInfo, .subscriberInfo = subscriberInfo + }; if (!asynccallbackinfo) { return Common::JSParaError(env, callback); } diff --git a/interfaces/kits/napi/ans/src/unsubscribe.cpp b/interfaces/kits/napi/ans/src/unsubscribe.cpp index 659c9e59d..7e2b9bc38 100644 --- a/interfaces/kits/napi/ans/src/unsubscribe.cpp +++ b/interfaces/kits/napi/ans/src/unsubscribe.cpp @@ -73,7 +73,7 @@ napi_value Unsubscribe(napi_env env, napi_callback_info info) } AsyncCallbackInfoUnsubscribe *asynccallbackinfo = new (std::nothrow) - AsyncCallbackInfoUnsubscribe{.env = env, .asyncWork = nullptr, .objectInfo = paras.objectInfo}; + AsyncCallbackInfoUnsubscribe {.env = env, .asyncWork = nullptr, .objectInfo = paras.objectInfo}; if (!asynccallbackinfo) { return Common::JSParaError(env, paras.callback); } diff --git a/interfaces/kits/napi/wantagent/napi_want_agent.cpp b/interfaces/kits/napi/wantagent/napi_want_agent.cpp index 42c7b80fc..f5b4759c8 100644 --- a/interfaces/kits/napi/wantagent/napi_want_agent.cpp +++ b/interfaces/kits/napi/wantagent/napi_want_agent.cpp @@ -44,7 +44,7 @@ void TriggerCompleteCallBack::SetWantAgentInstance(const std::shared_ptrdata; if (dataWorkerData == nullptr) { @@ -145,7 +145,7 @@ void TriggerCompleteCallBack::OnSendFinished( dataWorker->wantAgent = triggerCompleteInfo_.wantAgent; work->data = (void *)dataWorker; int ret = - uv_queue_work(loop, work, [](uv_work_t *work) {}, TriggerCompleteCallBack::OnSendFinishedUvAfterWorkCallbacck); + uv_queue_work(loop, work, [](uv_work_t *work) {}, TriggerCompleteCallBack::OnSendFinishedUvAfterWorkCallback); if (ret != 0) { if (dataWorker != nullptr) { delete dataWorker; @@ -266,7 +266,7 @@ void NAPI_GetBundleNamePromiseCompleteCallBack(napi_env env, napi_status status, { HILOG_INFO("GetBundleName compeleted(Promise Mode)..."); AsyncGetBundleNameCallbackInfo *asyncCallbackInfo = (AsyncGetBundleNameCallbackInfo *)data; - napi_value result; + napi_value result = nullptr; napi_create_string_utf8(env, asyncCallbackInfo->bundleName.c_str(), NAPI_AUTO_LENGTH, &result); napi_resolve_deferred(asyncCallbackInfo->env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); @@ -373,9 +373,9 @@ void NAPI_GetUidWrapCompleteCallBack(napi_env env, napi_status status, void *dat HILOG_INFO("GetUid compeleted(CallBack Mode)..."); AsyncGetUidCallbackInfo *asyncCallbackInfo = (AsyncGetUidCallbackInfo *)data; napi_value result[NUMBER_OF_PARAMETERS_TWO] = {0}; - napi_value callback; - napi_value undefined; - napi_value callResult = 0; + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value callResult = nullptr; result[0] = GetCallbackErrorResult(asyncCallbackInfo->env, BUSINESS_ERROR_CODE_OK); napi_create_int32(env, asyncCallbackInfo->uid, &result[1]); @@ -394,7 +394,7 @@ void NAPI_GetUidWrapPromiseCompleteCallBack(napi_env env, napi_status status, vo { HILOG_INFO("GetUid compeleted(Promise Mode)..."); AsyncGetUidCallbackInfo *asyncCallbackInfo = (AsyncGetUidCallbackInfo *)data; - napi_value result; + napi_value result = nullptr; napi_create_int32(env, asyncCallbackInfo->uid, &result); napi_resolve_deferred(asyncCallbackInfo->env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); @@ -664,7 +664,7 @@ void NAPI_CancelWrapPromiseCompleteCallBack(napi_env env, napi_status status, vo { HILOG_INFO("Cancel compeleted(Promise Mode)..."); AsyncCancelCallbackInfo *asyncCallbackInfo = (AsyncCancelCallbackInfo *)data; - napi_value result; + napi_value result = nullptr; napi_get_null(env, &result); napi_resolve_deferred(asyncCallbackInfo->env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); @@ -942,7 +942,7 @@ void NAPI_EqualWrapPromiseCompleteCallBack(napi_env env, napi_status status, voi { HILOG_INFO("Equal compeleted(Promise Mode)..."); AsyncEqualCallbackInfo *asyncCallbackInfo = (AsyncEqualCallbackInfo *)data; - napi_value result; + napi_value result = nullptr; napi_get_boolean(env, asyncCallbackInfo->result, &result); napi_resolve_deferred(asyncCallbackInfo->env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); diff --git a/interfaces/kits/napi/wantagent/napi_want_agent.h b/interfaces/kits/napi/wantagent/napi_want_agent.h index e3df2bd07..cd3989835 100644 --- a/interfaces/kits/napi/wantagent/napi_want_agent.h +++ b/interfaces/kits/napi/wantagent/napi_want_agent.h @@ -152,7 +152,7 @@ public: private: CallbackInfo triggerCompleteInfo_; - static void OnSendFinishedUvAfterWorkCallbacck(uv_work_t *work, int status); + static void OnSendFinishedUvAfterWorkCallback(uv_work_t *work, int status); }; napi_value WantAgentInit(napi_env env, napi_value exports); diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index 510034cfa..f21215383 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -843,7 +843,7 @@ HWTEST_F(NotificationPreferencesTest, GetImportance_00100, Function | SmallTest { int importance = 1; EXPECT_EQ((int)NotificationPreferences::GetInstance().SetImportance(bundleOption_, importance), (int)ERR_OK); - int getImportance = 0;; + int getImportance = 0; EXPECT_EQ((int)NotificationPreferences::GetInstance().GetImportance(bundleOption_, getImportance), (int)ERR_OK); EXPECT_EQ(getImportance, 1); @@ -856,7 +856,7 @@ HWTEST_F(NotificationPreferencesTest, GetImportance_00100, Function | SmallTest */ HWTEST_F(NotificationPreferencesTest, GetImportance_00200, Function | SmallTest | Level1) { - int getImportance = 0;; + int getImportance = 0; EXPECT_EQ((int)NotificationPreferences::GetInstance().GetImportance(bundleEmptyOption_, getImportance), (int)ERR_ANS_INVALID_PARAM); } @@ -893,7 +893,7 @@ HWTEST_F(NotificationPreferencesTest, GetTotalBadgeNums_00100, Function | SmallT { int num = 1; NotificationPreferences::GetInstance().SetTotalBadgeNums(bundleOption_, num); - int totalBadgeNum; + int totalBadgeNum = 0; EXPECT_EQ((int)NotificationPreferences::GetInstance().GetTotalBadgeNums(bundleOption_, totalBadgeNum), (int)ERR_OK); EXPECT_EQ(totalBadgeNum, num); } -- Gitee From 4913358f3de55acd31b2f5334500831f6aa2e6b6 Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Sat, 18 Sep 2021 21:42:31 +0800 Subject: [PATCH 2/2] fix codex Signed-off-by: zhaoyuan17 --- .../kits/napi/wantagent/napi_want_agent.cpp | 31 +++++++++++-------- .../kits/napi/wantagent/napi_want_agent.h | 8 +++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/interfaces/kits/napi/wantagent/napi_want_agent.cpp b/interfaces/kits/napi/wantagent/napi_want_agent.cpp index f5b4759c8..9876c4921 100644 --- a/interfaces/kits/napi/wantagent/napi_want_agent.cpp +++ b/interfaces/kits/napi/wantagent/napi_want_agent.cpp @@ -46,6 +46,7 @@ void TriggerCompleteCallBack::SetWantAgentInstance(const std::shared_ptrdata; if (dataWorkerData == nullptr) { HILOG_INFO("TriggerReceiveDataWorker instance(uv_work_t) is nullptr"); @@ -799,8 +800,8 @@ napi_value NAPI_TriggerWrap(napi_env env, napi_callback_info info, AsyncTriggerC return ret; } -napi_value NAPI_GetTriggerInfo(napi_value argv[NUMBER_OF_PARAMETERS_THREE], size_t argc, napi_env env, - napi_callback_info info, Notification::WantAgent::TriggerInfo &triggerInfo) +napi_value NAPI_GetTriggerInfo(napi_value argv[NUMBER_OF_PARAMETERS_THREE], napi_env env, napi_callback_info info, + Notification::WantAgent::TriggerInfo &triggerInfo) { // Get triggerInfo napi_value jsTriggerInfo = argv[1]; @@ -877,7 +878,7 @@ napi_value NAPI_Trigger(napi_env env, napi_callback_info info) } Notification::WantAgent::TriggerInfo triggerInfo; - napi_value ret = NAPI_GetTriggerInfo(argv, argc, env, info, triggerInfo); + napi_value ret = NAPI_GetTriggerInfo(argv, env, info, triggerInfo); if (ret == nullptr) { return NapiGetNull(env); } @@ -1178,9 +1179,7 @@ napi_value NAPI_GetWantAgentWrap( } } -napi_value NAPI_GetWantAgentWants(napi_env env, napi_value jsWantAgentInfo, - std::vector> &wants, int32_t &operationType, int32_t &requestCode, - std::vector &wantAgentFlags, AAFwk::WantParams &extraInfo) +napi_value NAPI_GetWantAgentWants(napi_env env, napi_value jsWantAgentInfo, const WantAgentWantsParas ¶s) { napi_valuetype jsWantAgentInfoType = napi_valuetype::napi_null; NAPI_CALL(env, napi_typeof(env, jsWantAgentInfo, &jsWantAgentInfoType)); @@ -1201,15 +1200,15 @@ napi_value NAPI_GetWantAgentWants(napi_env env, napi_value jsWantAgentInfo, if (!UnwrapWant(env, jsWant, *want)) { return NapiGetNull(env); } - wants.emplace_back(want); + paras.wants.emplace_back(want); } // Get operationType - if (!UnwrapInt32ByPropertyName(env, jsWantAgentInfo, "operationType", operationType)) { + if (!UnwrapInt32ByPropertyName(env, jsWantAgentInfo, "operationType", paras.operationType)) { return NapiGetNull(env); } // Get requestCode - if (!UnwrapInt32ByPropertyName(env, jsWantAgentInfo, "requestCode", requestCode)) { + if (!UnwrapInt32ByPropertyName(env, jsWantAgentInfo, "requestCode", paras.requestCode)) { return NapiGetNull(env); } // Get wantAgentFlags @@ -1226,13 +1225,13 @@ napi_value NAPI_GetWantAgentWants(napi_env env, napi_value jsWantAgentInfo, NAPI_ASSERT(env, valuetype0 == napi_number, "Wrong argument type. Numbers expected."); int32_t value0 = 0; NAPI_CALL(env, napi_get_value_int32(env, napiWantAgentFlags, &value0)); - wantAgentFlags.emplace_back(static_cast(value0)); + paras.wantAgentFlags.emplace_back(static_cast(value0)); } } // Get extraInfo napi_value JsExtraInfo = GetPropertyValueByPropertyName(env, jsWantAgentInfo, "extraInfo", napi_object); if (JsExtraInfo != nullptr) { - if (!UnwrapWantParams(env, JsExtraInfo, extraInfo)) { + if (!UnwrapWantParams(env, JsExtraInfo, paras.extraInfo)) { return NapiGetNull(env); } } @@ -1253,8 +1252,14 @@ napi_value NAPI_GetWantAgent(napi_env env, napi_callback_info info) int32_t requestCode = -1; std::vector wantAgentFlags = {}; AAFwk::WantParams extraInfo = {}; - napi_value ret = - NAPI_GetWantAgentWants(env, jsWantAgentInfo, wants, operationType, requestCode, wantAgentFlags, extraInfo); + WantAgentWantsParas paras = { + .wants = wants, + .operationType = operationType, + .requestCode = requestCode, + .wantAgentFlags = wantAgentFlags, + .extraInfo = extraInfo, + }; + napi_value ret = NAPI_GetWantAgentWants(env, jsWantAgentInfo, paras); if (ret == nullptr) { return NapiGetNull(env); } diff --git a/interfaces/kits/napi/wantagent/napi_want_agent.h b/interfaces/kits/napi/wantagent/napi_want_agent.h index cd3989835..f8c3f8464 100644 --- a/interfaces/kits/napi/wantagent/napi_want_agent.h +++ b/interfaces/kits/napi/wantagent/napi_want_agent.h @@ -138,6 +138,14 @@ struct TriggerReceiveDataWorker { AAFwk::WantParams resultExtras; }; +struct WantAgentWantsParas { + std::vector> &wants; + int32_t &operationType; + int32_t &requestCode; + std::vector &wantAgentFlags; + AAFwk::WantParams &extraInfo; +}; + class TriggerCompleteCallBack : public CompletedCallback { public: TriggerCompleteCallBack(); -- Gitee