diff --git a/frameworks/ans/core/src/ans_notification.cpp b/frameworks/ans/core/src/ans_notification.cpp index fd203213c202c492ecdb789650e26e762fd990a8..da55aed922b6b05cde374cecffb495014c3ce17e 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 b0c004d71acf98861ccac1a48fb0dbd8c376a337..4c114748e9b228046097642cf7370bd35c27e103 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 acdfc939c52ab417da2cb34933ab6d92073e72e3..b5adae94ec9affbf19a620b61aafe74774d14544 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 744dc11f61a87dbcb02f6a481c664448e55bdf99..43f23d63c8a35e2e66e8127514e0c116ae88c98f 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 86ea093d9aa8230df5744fd492f6bd0099e5b391..87d459c55ee5651eacefdcb4f55d24fb702e5a41 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 f17afa07b8ac74e9d010ee6fca666b60ed651d24..c806df2ef08e8d4b0b8f9ce4d178a063e6a6fa55 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 f6d3e65b3290b46ccbb925cf94dce901b1832517..d66b8bc7afe9bfa8e7a3fd5a76941fcfcdf234b5 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 4d0df649db1c693bfd780287d79d1ef067b85d24..abd88be57d106dc3bfc618f0535c91dc021ed089 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 02c7e1e4cf0defffcc243703cbf49de3cadcd2c5..b346882bd29d7610a742ace62a989255f200dec2 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 6315d338d4bdff27b44464daa88b386415a13b79..0ff27d780b079bb00ea7cfa9404d36a7b35d8109 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 e14dd2f75e9062072b6b8a30926a80a6bc4f2641..0115c3ba4c5d7adc8128dc664ed24807d1fa498c 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 d5a675bb113d9ec4f0a8c98f5a0e640568d27874..5d97a1a1a316651d0af4e03ee9a916c04fcb5a59 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 85404dd1ba96fcdb2650f370bc1efcc8cb55085b..ec2898f5b865c827a00cdc2731099254016a1dda 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 9a338eaea51762a53cdf5e694c9a8e2ef1d86359..e515d617a8815d1caa940dcbd4ddf3c7ecbd807b 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 843b87753b2ee636efd0efd0d740ec5e40ff6a38..8cb3e395888b9720dc344278ecb2dce5fdcb7edb 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 f96de434bf797d8905fa7f7df4f74c0cd2a73b6f..c1431546697e83a004948cab225b29ec5abb6d33 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 6a3733897f50d4be034d5a580ca44a5e92ed83ce..ea5abb8cb46c1cc96be69c90dd52ddde594e7183 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 9e274ed77f1a6acea617825b68d42509850cd7dc..5b91d30e264ee6ad7793eb963362bf62a4d7f76c 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 acd2c31ec0f2e11fe7462a9f44bb4ca1f60a912f..06eb0b35099019017ec21cc517f66279f31be73a 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 f0a7ffb1552e4949309dbd3e842cb20516450741..b64685f5d696c5718b4f4a1d2cb8d1ab29ba07df 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 cfc7b3be27de4b8ed8fad3679f33421afcf8c9fd..c725db2ae3a58fb83a66b68f7e3870db281aa686 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 1bbfe05ea420b78fbfe6826a53a9693f427f34e6..485f6c1fa0495f9809af61cfdac29cde6494a20f 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 c4abb2f4573e6b477dec75aa262ce151067b6a4f..91a3dd8062ddbc1416321d7185543ce9832f0502 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 a879f32d8032da13254fc6d49dde313d5a1fb487..f3c236fe22628b691af798f95c9ea3bf295ef4e5 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 5a82654defffab83ad155a8ed2acff14ad635951..f9594c65ed63fcb13ac8283ed93f92e63d6abebd 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 4b273f93862e9799d4d321f9bb9a9f3c4e0aa59f..4be3ba5b49bffb0943175e61a489ee84780aacfd 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 32a8163cb800fe8f7a0d2b853b095882ef2b4383..54fb3f37a083a13d8310287230204f13db90946d 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 49dc6fc294dcd96ead39070705bccae9f1d97602..1eb370e590ea1e33718589e546d77e48caab852b 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 ebe13aac993630a354e40f1d81bedf72bbd554a6..6cbdecc3e3d64e0801dd1ca3f028fd451a4bca61 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 f84d26830231b3b4e61694326d1f04140a589c1d..1327bca968d9fd37054852492c00e3fe9c0c05c4 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 b86b1a3cb5699f47b659ed5940cb2feffe6ff6a9..7ab84bd4ee814dd9eb1cfcb9e67b3c4e4933d8c1 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 92a08e74b15d9c1caebd8576d3a117c880cd786b..17bcd58326fdd0cfbb049482de22e1e8df942926 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 5264e984fa929a82ca024c7ee836410d3b5f048c..7bc7871ffd069955e3264be9a8e70767b247e7d7 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 a2543c73c8737c78b19d8c58cd9780afcd07922f..e57a617a8ca39f8196e0abe0572a578159626af8 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 129355a8fccb3091b7b8b08f7e7ce26332a20898..ea42c40b0ceabdd8351341aee1defa767656dcd5 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 34040e313a80d2d5f6f898b63b143ffff6dd03ed..d2b88c530288ae23d1cb4f59247c58ccdfc90f13 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 ae680b46bde0c98d239659d9d4addf0450ebf38f..aa8c2cdcd2350b067d49f544a3f67203c64b414b 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 d763bd05899dcec401dafd17fe1ad18e4724619c..0d6ba8c4222b07703359bb523051a6e7e096650d 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 8dd5e880c3ce4188a59a97f4db6e765bd6d027d2..3c860cab93386e6461945300a1dadb939456d6a0 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 8cae75ede33dee9c3d921e827e6f6f80676db105..59b9a3dae34736a55b4e0f660549ae5170ede2d6 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 3b493f2c67bd29da0b3573cc61136132c0576f66..3764f5380b0a30d434eef2789dac27f79c1ff48f 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 f2bcb906e99d503b77ad48a0f115c0c51968c256..724acd30cf781db619f73859b346e4887151de7d 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 659c9e59dd459c776990fbf5e5b5dcddbc2489d9..7e2b9bc384a268e090fd9b8930accd1db5dc4766 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 42c7b80fcf54aa6611059a671e132447ef922fbe..9876c492188dc7aad2d81e343345d1750cd3c12a 100644 --- a/interfaces/kits/napi/wantagent/napi_want_agent.cpp +++ b/interfaces/kits/napi/wantagent/napi_want_agent.cpp @@ -44,8 +44,9 @@ void TriggerCompleteCallBack::SetWantAgentInstance(const std::shared_ptrdata; if (dataWorkerData == nullptr) { HILOG_INFO("TriggerReceiveDataWorker instance(uv_work_t) is nullptr"); @@ -145,7 +146,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 +267,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 +374,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 +395,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 +665,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); @@ -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); } @@ -942,7 +943,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); @@ -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 e3df2bd0772587bb68b040a533223cd131e849f6..f8c3f84646f19c6a887f1b814610db9aa61de72a 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(); @@ -152,7 +160,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 510034cfa2efa726b2df99dfa80dc76ba088f6e5..f2121538389d08dec54c8bb30f75ccbf7caf4f39 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); }