From 7cfa476e9bfcbd006186d9116cf0615d45e863d9 Mon Sep 17 00:00:00 2001 From: zero-cyc Date: Fri, 29 Apr 2022 17:06:58 +0800 Subject: [PATCH] suport arm64 Signed-off-by: zero-cyc Change-Id: I33053fc86ded593b6f32e3039fccca01d72b966d --- .../core/common/include/ans_const_define.h | 6 +- .../ans/core/include/ans_manager_interface.h | 4 +- .../ans/core/include/ans_manager_proxy.h | 12 +- .../ans/core/include/ans_manager_stub.h | 12 +- .../ans/core/include/ans_notification.h | 4 +- .../core/include/ans_subscriber_interface.h | 2 +- .../ans/core/include/ans_subscriber_proxy.h | 2 +- .../ans/core/include/ans_subscriber_stub.h | 4 +- frameworks/ans/core/src/ans_manager_proxy.cpp | 26 ++-- frameworks/ans/core/src/ans_manager_stub.cpp | 22 +-- frameworks/ans/core/src/ans_notification.cpp | 12 +- .../ans/core/src/ans_subscriber_proxy.cpp | 4 +- .../ans/core/src/ans_subscriber_stub.cpp | 4 +- frameworks/ans/native/src/message_user.cpp | 2 +- .../notification_conversational_content.cpp | 4 +- .../ans/native/src/notification_helper.cpp | 4 +- .../ans/native/src/notification_request.cpp | 8 +- .../ans/native/src/notification_slot.cpp | 4 +- .../native/src/notification_slot_group.cpp | 12 +- .../ans/native/src/notification_sorting.cpp | 6 +- .../native/src/notification_sorting_map.cpp | 10 +- .../src/notification_subscribe_info.cpp | 2 +- .../native/src/notification_subscriber.cpp | 2 +- .../native/src/notification_user_input.cpp | 4 +- .../ans/native/src/reminder_request.cpp | 9 +- .../reminder_request_calendar_test.cpp | 2 +- .../ans_innerkits_module_publish_test.cpp | 6 +- .../ans/native/include/message_user.h | 4 +- .../native/include/notification_constant.h | 20 +-- .../ans/native/include/notification_helper.h | 4 +- .../ans/native/include/notification_slot.h | 4 +- .../ans/native/include/notification_sorting.h | 6 +- .../native/include/notification_subscriber.h | 4 +- interfaces/kits/napi/ans/include/common.h | 32 ++-- interfaces/kits/napi/ans/include/subscribe.h | 2 +- interfaces/kits/napi/ans/src/common.cpp | 12 +- interfaces/kits/napi/ans/src/get_active.cpp | 10 +- interfaces/kits/napi/ans/src/slot.cpp | 24 +-- interfaces/kits/napi/ans/src/subscribe.cpp | 16 +- .../include/advanced_notification_service.h | 22 +-- services/ans/include/bundle_manager_helper.h | 8 +- .../ans/include/notification_preferences.h | 10 +- .../notification_preferences_database.h | 26 ++-- .../include/notification_preferences_info.h | 20 +-- .../include/notification_subscriber_manager.h | 8 +- services/ans/include/reminder_timer_info.h | 2 +- .../ans/src/advanced_notification_service.cpp | 142 +++++++++--------- services/ans/src/bundle_manager_helper.cpp | 10 +- services/ans/src/notification_preferences.cpp | 13 +- .../src/notification_preferences_database.cpp | 26 ++-- .../ans/src/notification_preferences_info.cpp | 14 +- .../src/notification_subscriber_manager.cpp | 8 +- services/ans/src/system_event_observer.cpp | 2 +- .../advanced_notification_service_test.cpp | 2 +- services/ans/test/unittest/ans_ut_constant.h | 10 +- .../include/distributed_flow_control.h | 24 +-- .../src/distributed_flow_control.cpp | 11 +- .../src/distributed_preferences.cpp | 2 +- services/test/moduletest/ans_module_test.cpp | 8 +- tools/dump/include/shell_command.h | 2 +- tools/dump/src/shell_command.cpp | 4 +- 61 files changed, 351 insertions(+), 350 deletions(-) diff --git a/frameworks/ans/core/common/include/ans_const_define.h b/frameworks/ans/core/common/include/ans_const_define.h index fb7c01643..f74042b09 100644 --- a/frameworks/ans/core/common/include/ans_const_define.h +++ b/frameworks/ans/core/common/include/ans_const_define.h @@ -25,11 +25,11 @@ namespace OHOS { namespace Notification { // Max active notification number -constexpr uint32_t MAX_ACTIVE_NUM = 1000; +constexpr size_t MAX_ACTIVE_NUM = 1000; constexpr uint32_t MAX_ACTIVE_NUM_PERAPP = 100; constexpr uint32_t MAX_ACTIVE_NUM_PERSECOND = 10; -constexpr uint32_t MAX_SLOT_NUM = 5; -constexpr uint32_t MAX_SLOT_GROUP_NUM = 4; +constexpr size_t MAX_SLOT_NUM = 5; +constexpr size_t MAX_SLOT_GROUP_NUM = 4; constexpr uint32_t MAX_ICON_SIZE = 50 * 1024; constexpr uint32_t MAX_PICTURE_SIZE = 2 * 1024 * 1024; constexpr bool SUPPORT_DO_NOT_DISTRUB = true; diff --git a/frameworks/ans/core/include/ans_manager_interface.h b/frameworks/ans/core/include/ans_manager_interface.h index c55228d36..e45dccd35 100644 --- a/frameworks/ans/core/include/ans_manager_interface.h +++ b/frameworks/ans/core/include/ans_manager_interface.h @@ -165,7 +165,7 @@ public: * @param num Indicates the number of slot. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, int &num) = 0; + virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) = 0; /** * @brief Deletes multiple notification slot groups. @@ -190,7 +190,7 @@ public: * @param num Indicates the number of active notifications of the current application. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode GetActiveNotificationNums(int &num) = 0; + virtual ErrCode GetActiveNotificationNums(uint64_t &num) = 0; /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to diff --git a/frameworks/ans/core/include/ans_manager_proxy.h b/frameworks/ans/core/include/ans_manager_proxy.h index 4843289d3..e66679996 100644 --- a/frameworks/ans/core/include/ans_manager_proxy.h +++ b/frameworks/ans/core/include/ans_manager_proxy.h @@ -60,7 +60,7 @@ public: * @param label Indicates the label of the notification to cancel. * @return Returns cancel notification result. */ - ErrCode Cancel(int notificationId, const std::string &label) override; + ErrCode Cancel(int32_t notificationId, const std::string &label) override; /** * @brief Cancels all the published notifications. @@ -153,7 +153,7 @@ public: * @param num Indicates the number of slot. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetSlotNumAsBundle(const sptr &bundleOption, int &num) override; + ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; /** * @brief Deletes multiple notification slot groups. @@ -178,7 +178,7 @@ public: * @param num Indicates the number of active notifications of the current application. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetActiveNotificationNums(int &num) override; + ErrCode GetActiveNotificationNums(uint64_t &num) override; /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to @@ -252,7 +252,7 @@ public: * @param num Indicates the badge number. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SetNotificationBadgeNum(int num) override; + ErrCode SetNotificationBadgeNum(int32_t num) override; /** * @brief Obtains the importance level of this application. @@ -261,7 +261,7 @@ public: LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetBundleImportance(int &importance) override; + ErrCode GetBundleImportance(int32_t &importance) override; /** * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. @@ -296,7 +296,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveNotification( - const sptr &bundleOption, int notificationId, const std::string &label) override; + const sptr &bundleOption, int32_t notificationId, const std::string &label) override; /** * @brief Delete all notifications. diff --git a/frameworks/ans/core/include/ans_manager_stub.h b/frameworks/ans/core/include/ans_manager_stub.h index b67631694..745e7c587 100644 --- a/frameworks/ans/core/include/ans_manager_stub.h +++ b/frameworks/ans/core/include/ans_manager_stub.h @@ -74,7 +74,7 @@ public: * @param label Indicates the label of the notification to cancel. * @return Returns cancel notification result. */ - virtual ErrCode Cancel(int notificationId, const std::string &label) override; + virtual ErrCode Cancel(int32_t notificationId, const std::string &label) override; /** * @brief Cancels all the published notifications. @@ -168,7 +168,7 @@ public: * @param num Indicates the number of slot. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, int &num) override; + virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; /** * @brief Deletes multiple notification slot groups. @@ -193,7 +193,7 @@ public: * @param num Indicates the number of active notifications of the current application. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode GetActiveNotificationNums(int &num) override; + virtual ErrCode GetActiveNotificationNums(uint64_t &num) override; /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to @@ -267,7 +267,7 @@ public: * @param num Indicates the badge number. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode SetNotificationBadgeNum(int num) override; + virtual ErrCode SetNotificationBadgeNum(int32_t num) override; /** * @brief Obtains the importance level of this application. @@ -276,7 +276,7 @@ public: LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Returns ERR_OK on success, others on failure. */ - virtual ErrCode GetBundleImportance(int &importance) override; + virtual ErrCode GetBundleImportance(int32_t &importance) override; /** * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. @@ -311,7 +311,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ virtual ErrCode RemoveNotification( - const sptr &bundleOption, int notificationId, const std::string &label) override; + const sptr &bundleOption, int32_t notificationId, const std::string &label) override; /** * @brief Delete all notifications. diff --git a/frameworks/ans/core/include/ans_notification.h b/frameworks/ans/core/include/ans_notification.h index e9f3d504d..9dbc6cb5a 100644 --- a/frameworks/ans/core/include/ans_notification.h +++ b/frameworks/ans/core/include/ans_notification.h @@ -148,7 +148,7 @@ public: * @param num Indicates number of slot. * @return Returns get slot number by bundle result. */ - ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, int &num); + ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num); /** * @brief Publishes a notification. @@ -219,7 +219,7 @@ public: * @param num Indicates the number of active notifications of the current application. * @return Returns get active notification nums result. */ - ErrCode GetActiveNotificationNums(int32_t &num); + ErrCode GetActiveNotificationNums(uint64_t &num); /** * @brief Obtains active notifications of the current application in the system. diff --git a/frameworks/ans/core/include/ans_subscriber_interface.h b/frameworks/ans/core/include/ans_subscriber_interface.h index 162f4eda4..97f5a15b8 100644 --- a/frameworks/ans/core/include/ans_subscriber_interface.h +++ b/frameworks/ans/core/include/ans_subscriber_interface.h @@ -77,7 +77,7 @@ public: * @param deleteReason Indicates the delete reason. */ virtual void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, - int deleteReason) = 0; + int32_t deleteReason) = 0; /** * @brief The callback function on the notifications updated. diff --git a/frameworks/ans/core/include/ans_subscriber_proxy.h b/frameworks/ans/core/include/ans_subscriber_proxy.h index 4f08781fd..8f5fa10ea 100644 --- a/frameworks/ans/core/include/ans_subscriber_proxy.h +++ b/frameworks/ans/core/include/ans_subscriber_proxy.h @@ -69,7 +69,7 @@ public: * @param deleteReason Indicates the delete reason. */ void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, - int deleteReason) override; + int32_t deleteReason) override; /** * @brief The callback function on the notifications updated. diff --git a/frameworks/ans/core/include/ans_subscriber_stub.h b/frameworks/ans/core/include/ans_subscriber_stub.h index 33ca81e7e..678e85b3b 100644 --- a/frameworks/ans/core/include/ans_subscriber_stub.h +++ b/frameworks/ans/core/include/ans_subscriber_stub.h @@ -35,7 +35,7 @@ public: * @param option Indicates the message option. * @return Returns ERR_OK on success, others on failure. */ - virtual int OnRemoteRequest( + virtual int32_t OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; /** @@ -79,7 +79,7 @@ public: * @param deleteReason Indicates the delete reason. */ void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, - int deleteReason) override; + int32_t deleteReason) override; /** * @brief The callback function on the notifications updated. diff --git a/frameworks/ans/core/src/ans_manager_proxy.cpp b/frameworks/ans/core/src/ans_manager_proxy.cpp index 55d1f9a72..36e84d34e 100644 --- a/frameworks/ans/core/src/ans_manager_proxy.cpp +++ b/frameworks/ans/core/src/ans_manager_proxy.cpp @@ -110,7 +110,7 @@ ErrCode AnsManagerProxy::PublishToDevice(const sptr ¬ifi return result; } -ErrCode AnsManagerProxy::Cancel(int notificationId, const std::string &label) +ErrCode AnsManagerProxy::Cancel(int32_t notificationId, const std::string &label) { MessageParcel data; if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { @@ -204,7 +204,7 @@ ErrCode AnsManagerProxy::AddSlots(const std::vector> &slo return ERR_ANS_INVALID_PARAM; } - uint32_t slotsSize = slots.size(); + size_t slotsSize = slots.size(); if (slotsSize > MAX_SLOT_NUM) { ANS_LOGW("[AddSlots] fail: slotsSize over max size."); return ERR_ANS_INVALID_PARAM; @@ -297,7 +297,7 @@ ErrCode AnsManagerProxy::AddSlotGroups(std::vector> return ERR_ANS_INVALID_PARAM; } - uint32_t groupsSize = groups.size(); + size_t groupsSize = groups.size(); if (groupsSize > MAX_SLOT_GROUP_NUM) { ANS_LOGW("[AddSlotGroups] fail: groupsSize over max size."); return ERR_ANS_INVALID_PARAM; @@ -457,7 +457,7 @@ ErrCode AnsManagerProxy::GetSlotGroups(std::vector> return result; } -ErrCode AnsManagerProxy::GetSlotNumAsBundle(const sptr &bundleOption, int &num) +ErrCode AnsManagerProxy::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) { if (bundleOption == nullptr) { ANS_LOGW("[GetSlotNumAsBundle] fail: bundle is empty."); @@ -488,7 +488,7 @@ ErrCode AnsManagerProxy::GetSlotNumAsBundle(const sptr return ERR_ANS_PARCELABLE_FAILED; } - if (!reply.ReadInt32(num)) { + if (!reply.ReadUint64(num)) { ANS_LOGW("[GetShowBadgeEnabledForBundle] fail: read enabled failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -554,7 +554,7 @@ ErrCode AnsManagerProxy::GetActiveNotifications(std::vector &bundleOption, int notificationId, const std::string &label) + const sptr &bundleOption, int32_t notificationId, const std::string &label) { if (bundleOption == nullptr) { ANS_LOGW("[RemoveNotification] fail: bundle is empty."); @@ -1153,7 +1153,7 @@ ErrCode AnsManagerProxy::UpdateSlots( return ERR_ANS_INVALID_PARAM; } - uint32_t slotSize = slots.size(); + size_t slotSize = slots.size(); if (slotSize > MAX_SLOT_NUM) { ANS_LOGW("[UpdateSlots] fail: slotSize over max size."); return ERR_ANS_INVALID_PARAM; @@ -1204,7 +1204,7 @@ ErrCode AnsManagerProxy::UpdateSlotGroups( return ERR_ANS_INVALID_PARAM; } - uint32_t groupSize = groups.size(); + size_t groupSize = groups.size(); if (groupSize > MAX_SLOT_GROUP_NUM) { ANS_LOGW("[UpdateSlotGroups] fail: groupSize over max size."); return ERR_ANS_INVALID_PARAM; @@ -2353,7 +2353,7 @@ ErrCode AnsManagerProxy::InnerTransact(uint32_t code, MessageOption &flags, Mess ANS_LOGW("[InnerTransact] fail: get Remote fail code %{public}u", code); return ERR_DEAD_OBJECT; } - int err = remote->SendRequest(code, data, reply, flags); + int32_t err = remote->SendRequest(code, data, reply, flags); switch (err) { case NO_ERROR: { return ERR_OK; diff --git a/frameworks/ans/core/src/ans_manager_stub.cpp b/frameworks/ans/core/src/ans_manager_stub.cpp index 3dabf9964..9f1cef311 100644 --- a/frameworks/ans/core/src/ans_manager_stub.cpp +++ b/frameworks/ans/core/src/ans_manager_stub.cpp @@ -338,7 +338,7 @@ ErrCode AnsManagerStub::HandlePublishToDevice(MessageParcel &data, MessageParcel ErrCode AnsManagerStub::HandleCancel(MessageParcel &data, MessageParcel &reply) { - int notificationId = 0; + int32_t notificationId = 0; if (!data.ReadInt32(notificationId)) { ANS_LOGW("[HandleCancel] fail: read notificationId failed"); return ERR_ANS_PARCELABLE_FAILED; @@ -506,14 +506,14 @@ ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessagePar return ERR_ANS_PARCELABLE_FAILED; } - int num = 0; + uint64_t num = 0; ErrCode result = GetSlotNumAsBundle(bundleOption, num); if (!reply.WriteInt32(result)) { ANS_LOGW("[HandleGetSlotNumAsBundle] fail: write result failed, ErrCode=%{public}d", result); return ERR_ANS_PARCELABLE_FAILED; } - if (!reply.WriteInt32(num)) { + if (!reply.WriteUint64(num)) { ANS_LOGW("[HandleGetSlotNumAsBundle] fail: write enabled failed, ErrCode=%{public}d", result); return ERR_ANS_PARCELABLE_FAILED; } @@ -549,14 +549,14 @@ ErrCode AnsManagerStub::HandleGetActiveNotifications(MessageParcel &data, Messag ErrCode AnsManagerStub::HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply) { - int num = 0; + uint64_t num = 0; ErrCode result = GetActiveNotificationNums(num); if (!reply.WriteInt32(result)) { ANS_LOGW("[HandleGetActiveNotificationNums] fail: write result failed, ErrCode=%{public}d", result); return ERR_ANS_PARCELABLE_FAILED; } - if (!reply.WriteInt32(num)) { + if (!reply.WriteUint64(num)) { ANS_LOGW("[HandleGetActiveNotificationNums] fail: write num failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -671,7 +671,7 @@ ErrCode AnsManagerStub::HandlePublishAsBundle(MessageParcel &data, MessageParcel ErrCode AnsManagerStub::HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply) { - int num = 0; + int32_t num = 0; if (!data.ReadInt32(num)) { ANS_LOGW("[HandleSetNotificationBadgeNum] fail: read notification failed"); return ERR_ANS_PARCELABLE_FAILED; @@ -687,7 +687,7 @@ ErrCode AnsManagerStub::HandleSetNotificationBadgeNum(MessageParcel &data, Messa ErrCode AnsManagerStub::HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply) { - int importance = 0; + int32_t importance = 0; ErrCode result = GetBundleImportance(importance); if (!reply.WriteInt32(result)) { ANS_LOGW("[HandleGetBundleImportance] fail: write result failed, ErrCode=%{public}d", result); @@ -780,7 +780,7 @@ ErrCode AnsManagerStub::HandleCancelContinuousTaskNotification(MessageParcel &da return ERR_ANS_PARCELABLE_FAILED; } - int notificationId = 0; + int32_t notificationId = 0; if (!data.ReadInt32(notificationId)) { ANS_LOGW("[HandleCancelContinuousTaskNotification] fail: read notificationId failed"); return ERR_ANS_PARCELABLE_FAILED; @@ -845,7 +845,7 @@ ErrCode AnsManagerStub::HandleRemoveNotification(MessageParcel &data, MessagePar return ERR_ANS_PARCELABLE_FAILED; } - int notificationId = 0; + int32_t notificationId = 0; if (!data.ReadInt32(notificationId)) { ANS_LOGW("[HandleRemoveNotification] fail: read notificationId failed"); return ERR_ANS_PARCELABLE_FAILED; @@ -1791,7 +1791,7 @@ ErrCode AnsManagerStub::GetSlotGroups(std::vector> & return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::GetSlotNumAsBundle(const sptr &bundleOption, int &num) +ErrCode AnsManagerStub::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) { ANS_LOGW("AnsManagerStub::GetSlotNumAsBundle called!"); return ERR_INVALID_OPERATION; @@ -1809,7 +1809,7 @@ ErrCode AnsManagerStub::GetActiveNotifications(std::vectorGetSlotGroups(groups); } -ErrCode AnsNotification::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, int &num) +ErrCode AnsNotification::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num) { if (bundleOption.GetBundleName().empty()) { ANS_LOGE("Invalid bundle name."); @@ -278,7 +278,7 @@ ErrCode AnsNotification::CancelAllNotifications() return ansManagerProxy_->CancelAll(); } -ErrCode AnsNotification::GetActiveNotificationNums(int32_t &num) +ErrCode AnsNotification::GetActiveNotificationNums(uint64_t &num) { if (!GetAnsManagerProxy()) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -450,7 +450,7 @@ ErrCode AnsNotification::GetBundleImportance(NotificationSlot::NotificationLevel ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - int importanceTemp; + int32_t importanceTemp; ErrCode ret = ansManagerProxy_->GetBundleImportance(importanceTemp); if ((NotificationSlot::LEVEL_NONE <= importanceTemp) && (importanceTemp <= NotificationSlot::LEVEL_HIGH)) { importance = static_cast(importanceTemp); @@ -1097,13 +1097,11 @@ bool AnsNotification::CanPublishMediaContent(const NotificationRequest &request) } auto showActions = media->GetShownActions(); - uint32_t size = request.GetActionButtons().size(); + size_t size = request.GetActionButtons().size(); for (auto it = showActions.begin(); it != showActions.end(); ++it) { if (*it > size) { ANS_LOGE("The sequence numbers actions is: %{public}d, the assigned to added action buttons size is: " - "%{public}d.", - *it, - size); + "%{public}zu.", *it, size); return false; } } diff --git a/frameworks/ans/core/src/ans_subscriber_proxy.cpp b/frameworks/ans/core/src/ans_subscriber_proxy.cpp index 91210c31b..1cd184434 100644 --- a/frameworks/ans/core/src/ans_subscriber_proxy.cpp +++ b/frameworks/ans/core/src/ans_subscriber_proxy.cpp @@ -37,7 +37,7 @@ ErrCode AnsSubscriberProxy::InnerTransact( return ERR_DEAD_OBJECT; } - int err = remote->SendRequest(code, data, reply, flags); + int32_t err = remote->SendRequest(code, data, reply, flags); switch (err) { case NO_ERROR: { return ERR_OK; @@ -182,7 +182,7 @@ void AnsSubscriberProxy::OnCanceled(const sptr ¬ification) } void AnsSubscriberProxy::OnCanceled( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) + const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { if (notification == nullptr) { ANS_LOGW("[OnCanceled] fail: notification is nullptr."); diff --git a/frameworks/ans/core/src/ans_subscriber_stub.cpp b/frameworks/ans/core/src/ans_subscriber_stub.cpp index 745708d3c..12e81767c 100644 --- a/frameworks/ans/core/src/ans_subscriber_stub.cpp +++ b/frameworks/ans/core/src/ans_subscriber_stub.cpp @@ -163,7 +163,7 @@ ErrCode AnsSubscriberStub::HandleOnCanceledMap(MessageParcel &data, MessageParce } } - int reason = 0; + int32_t reason = 0; if (!data.ReadInt32(reason)) { ANS_LOGW("[HandleOnCanceledMap] fail: read reason failed"); return ERR_ANS_PARCELABLE_FAILED; @@ -224,7 +224,7 @@ void AnsSubscriberStub::OnCanceled(const sptr ¬ification) {} void AnsSubscriberStub::OnCanceled( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) + const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) {} void AnsSubscriberStub::OnUpdated(const sptr ¬ificationMap) diff --git a/frameworks/ans/native/src/message_user.cpp b/frameworks/ans/native/src/message_user.cpp index 385eafd0f..ce57886a2 100644 --- a/frameworks/ans/native/src/message_user.cpp +++ b/frameworks/ans/native/src/message_user.cpp @@ -212,7 +212,7 @@ bool MessageUser::ReadFromParcel(Parcel &parcel) isMachine_ = parcel.ReadBool(); isUserImportant_ = parcel.ReadBool(); - int empty = VALUE_NULL; + int32_t empty = VALUE_NULL; if (!parcel.ReadInt32(empty)) { ANS_LOGE("Failed to read VALUE"); return false; diff --git a/frameworks/ans/native/src/notification_conversational_content.cpp b/frameworks/ans/native/src/notification_conversational_content.cpp index 08f3599b7..fb8cf6685 100644 --- a/frameworks/ans/native/src/notification_conversational_content.cpp +++ b/frameworks/ans/native/src/notification_conversational_content.cpp @@ -196,7 +196,7 @@ bool NotificationConversationalContent::Marshalling(Parcel &parcel) const return false; } - if (!parcel.WriteInt32(static_cast(messages_.size()))) { + if (!parcel.WriteUint64(messages_.size())) { ANS_LOGE("Failed to write the size of messages"); return false; } @@ -254,7 +254,7 @@ bool NotificationConversationalContent::ReadFromParcel(Parcel &parcel) } messageUser_ = *pUser; - auto vsize = parcel.ReadInt32(); + auto vsize = parcel.ReadUint64(); for (auto it = 0; it < vsize; ++it) { auto valid = parcel.ReadBool(); if (!valid) { diff --git a/frameworks/ans/native/src/notification_helper.cpp b/frameworks/ans/native/src/notification_helper.cpp index 532ab1ed3..441ebb2d3 100644 --- a/frameworks/ans/native/src/notification_helper.cpp +++ b/frameworks/ans/native/src/notification_helper.cpp @@ -80,7 +80,7 @@ ErrCode NotificationHelper::GetNotificationSlotGroups(std::vector::GetInstance()->GetNotificationSlotGroups(groups); } -ErrCode NotificationHelper::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, int &num) +ErrCode NotificationHelper::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num) { return DelayedSingleton::GetInstance()->GetNotificationSlotNumAsBundle(bundleOption, num); } @@ -115,7 +115,7 @@ ErrCode NotificationHelper::CancelAllNotifications() return DelayedSingleton::GetInstance()->CancelAllNotifications(); } -ErrCode NotificationHelper::GetActiveNotificationNums(int32_t &num) +ErrCode NotificationHelper::GetActiveNotificationNums(uint64_t &num) { return DelayedSingleton::GetInstance()->GetActiveNotificationNums(num); } diff --git a/frameworks/ans/native/src/notification_request.cpp b/frameworks/ans/native/src/notification_request.cpp index fea842eca..88a2beb7f 100644 --- a/frameworks/ans/native/src/notification_request.cpp +++ b/frameworks/ans/native/src/notification_request.cpp @@ -1105,7 +1105,7 @@ bool NotificationRequest::Marshalling(Parcel &parcel) const } // write std::vector - if (!parcel.WriteInt32(static_cast(actionButtons_.size()))) { + if (!parcel.WriteUint64(actionButtons_.size())) { ANS_LOGE("Failed to write the size of actionButtons"); return false; } @@ -1117,7 +1117,7 @@ bool NotificationRequest::Marshalling(Parcel &parcel) const } } - if (!parcel.WriteInt32(static_cast(messageUsers_.size()))) { + if (!parcel.WriteUint64(messageUsers_.size())) { ANS_LOGE("Failed to write the size of messageUsers"); return false; } @@ -1337,7 +1337,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) } } - auto vsize = parcel.ReadInt32(); + auto vsize = parcel.ReadUint64(); for (auto it = 0; it < vsize; ++it) { auto member = parcel.ReadParcelable(); if (member == nullptr) { @@ -1348,7 +1348,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) actionButtons_.emplace_back(member); } - vsize = parcel.ReadInt32(); + vsize = parcel.ReadUint64(); for (auto it = 0; it < vsize; ++it) { auto member = parcel.ReadParcelable(); if (member == nullptr) { diff --git a/frameworks/ans/native/src/notification_slot.cpp b/frameworks/ans/native/src/notification_slot.cpp index 04f4c9c5a..226ab9de5 100644 --- a/frameworks/ans/native/src/notification_slot.cpp +++ b/frameworks/ans/native/src/notification_slot.cpp @@ -19,7 +19,7 @@ namespace OHOS { namespace Notification { -const int MAX_TEXT_LENGTH = 1000; +const int32_t MAX_TEXT_LENGTH = 1000; NotificationSlot::NotificationSlot(NotificationConstant::SlotType type) : sound_("") { @@ -321,7 +321,7 @@ bool NotificationSlot::ReadFromParcel(Parcel &parcel) lockScreenVisibleness_ = static_cast(parcel.ReadInt32()); groupId_ = parcel.ReadString(); - int empty = VALUE_NULL; + int32_t empty = VALUE_NULL; if (!parcel.ReadInt32(empty)) { ANS_LOGE("Failed to read int"); return false; diff --git a/frameworks/ans/native/src/notification_slot_group.cpp b/frameworks/ans/native/src/notification_slot_group.cpp index c870357e0..cb63278eb 100644 --- a/frameworks/ans/native/src/notification_slot_group.cpp +++ b/frameworks/ans/native/src/notification_slot_group.cpp @@ -19,7 +19,7 @@ namespace OHOS { namespace Notification { -const int MAX_TEXT_LENGTH = 1000; +const int32_t MAX_TEXT_LENGTH = 1000; const std::string LINE_SEPARATOR = "\n"; NotificationSlotGroup::NotificationSlotGroup() @@ -104,13 +104,13 @@ bool NotificationSlotGroup::Marshalling(Parcel &parcel) const return false; } - if (slots_.size() == 0) { - if (!parcel.WriteInt32(0)) { + if (slots_.empty()) { + if (!parcel.WriteUint64(0)) { ANS_LOGE("Failed to write the size of slots"); return false; } } else { - if (!parcel.WriteInt32(slots_.size())) { + if (!parcel.WriteUint64(slots_.size())) { ANS_LOGE("Failed to write the size of slots"); return false; } @@ -135,9 +135,9 @@ bool NotificationSlotGroup::ReadFromParcel(Parcel &parcel) id_ = parcel.ReadString(); name_ = parcel.ReadString(); description_ = parcel.ReadString(); - int32_t size = parcel.ReadInt32(); + uint64_t size = parcel.ReadUint64(); if (size) { - for (int32_t i = 0; i < size; ++i) { + for (uint64_t i = 0; i < size; ++i) { auto slot = parcel.ReadParcelable(); if (slot == nullptr) { ANS_LOGE("Failed to read slot"); diff --git a/frameworks/ans/native/src/notification_sorting.cpp b/frameworks/ans/native/src/notification_sorting.cpp index 575141dbf..78699b112 100644 --- a/frameworks/ans/native/src/notification_sorting.cpp +++ b/frameworks/ans/native/src/notification_sorting.cpp @@ -72,7 +72,7 @@ bool NotificationSorting::Marshalling(Parcel &parcel) const return false; } - if (!parcel.WriteInt32(ranking_)) { + if (!parcel.WriteUint64(ranking_)) { ANS_LOGE("Can't write ranking"); return false; } @@ -116,7 +116,7 @@ bool NotificationSorting::ReadFromParcel(Parcel &parcel) key_ = parcel.ReadString(); // read ranking_ - ranking_ = parcel.ReadInt32(); + ranking_ = parcel.ReadUint64(); // read importance_ importance_ = parcel.ReadInt32(); @@ -159,7 +159,7 @@ void NotificationSorting::SetImportance(const int32_t &importance) importance_ = importance; } -void NotificationSorting::SetRanking(const int32_t &ranking) +void NotificationSorting::SetRanking(const uint64_t &ranking) { ranking_ = ranking; } diff --git a/frameworks/ans/native/src/notification_sorting_map.cpp b/frameworks/ans/native/src/notification_sorting_map.cpp index 9e87b4e63..1263637ca 100644 --- a/frameworks/ans/native/src/notification_sorting_map.cpp +++ b/frameworks/ans/native/src/notification_sorting_map.cpp @@ -64,12 +64,12 @@ void NotificationSortingMap::SetNotificationSorting(const std::vector sortings; // read sorting num - int32_t size = 0; - parcel.ReadInt32(size); + uint64_t size = 0; + parcel.ReadUint64(size); size = (size <= MAX_ACTIVE_NUM) ? size : MAX_ACTIVE_NUM; - for (int i = 0; i < size; i++) { + for (uint64_t i = 0; i < size; i++) { // read sorting NotificationSorting *sorting = parcel.ReadParcelable(); if (sorting != nullptr) { diff --git a/frameworks/ans/native/src/notification_subscribe_info.cpp b/frameworks/ans/native/src/notification_subscribe_info.cpp index 50cd3a934..ae092ab08 100644 --- a/frameworks/ans/native/src/notification_subscribe_info.cpp +++ b/frameworks/ans/native/src/notification_subscribe_info.cpp @@ -45,7 +45,7 @@ std::vector NotificationSubscribeInfo::GetAppNames() const return appNames_; } -void NotificationSubscribeInfo::AddAppUserId(const int userId) +void NotificationSubscribeInfo::AddAppUserId(const int32_t userId) { userId_ = userId; } diff --git a/frameworks/ans/native/src/notification_subscriber.cpp b/frameworks/ans/native/src/notification_subscriber.cpp index a0865fa92..e77d7addb 100644 --- a/frameworks/ans/native/src/notification_subscriber.cpp +++ b/frameworks/ans/native/src/notification_subscriber.cpp @@ -74,7 +74,7 @@ void NotificationSubscriber::SubscriberImpl::OnCanceled(const sptr } void NotificationSubscriber::SubscriberImpl::OnCanceled( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) + const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { subscriber_.OnCanceled(std::make_shared(*notification), std::make_shared(*notificationMap), diff --git a/frameworks/ans/native/src/notification_user_input.cpp b/frameworks/ans/native/src/notification_user_input.cpp index dfd11abb9..a0e992bab 100644 --- a/frameworks/ans/native/src/notification_user_input.cpp +++ b/frameworks/ans/native/src/notification_user_input.cpp @@ -336,7 +336,7 @@ bool NotificationUserInput::Marshalling(Parcel &parcel) const return false; } - if (!parcel.WriteInt32(static_cast(permitMimeTypes_.size()))) { + if (!parcel.WriteUint64(static_cast(permitMimeTypes_.size()))) { ANS_LOGE("Failed to write the size of permitMimeTypes"); return false; } @@ -392,7 +392,7 @@ bool NotificationUserInput::ReadFromParcel(Parcel &parcel) return false; } - auto ssize = parcel.ReadInt32(); + auto ssize = parcel.ReadUint64(); for (auto it = 0; it < ssize; ++it) { std::string member {}; if (!parcel.ReadString(member)) { diff --git a/frameworks/ans/native/src/reminder_request.cpp b/frameworks/ans/native/src/reminder_request.cpp index 17390bd8c..e671a70c0 100644 --- a/frameworks/ans/native/src/reminder_request.cpp +++ b/frameworks/ans/native/src/reminder_request.cpp @@ -953,8 +953,7 @@ bool ReminderRequest::Marshalling(Parcel &parcel) const } // write map - int32_t buttonMapSize = static_cast(actionButtonMap_.size()); - if (!parcel.WriteInt32(buttonMapSize)) { + if (!parcel.WriteUint64(static_cast(actionButtonMap_.size()))) { ANSR_LOGE("Failed to write action button size"); return false; } @@ -1084,12 +1083,12 @@ bool ReminderRequest::ReadFromParcel(Parcel &parcel) slotType_ = static_cast(slotType); // read map - int32_t buttonMapSize = 0; - if (!parcel.ReadInt32(buttonMapSize)) { + uint64_t buttonMapSize = 0; + if (!parcel.ReadUint64(buttonMapSize)) { ANSR_LOGE("Failed to read buttonMapSize"); return false; } - for (int32_t i = 0; i < buttonMapSize; i++) { + for (uint64_t i = 0; i < buttonMapSize; i++) { uint8_t buttonType = static_cast(ActionButtonType::INVALID); if (!parcel.ReadUint8(buttonType)) { ANSR_LOGE("Failed to read buttonType"); diff --git a/frameworks/ans/native/test/unittest/reminder_request_calendar_test.cpp b/frameworks/ans/native/test/unittest/reminder_request_calendar_test.cpp index ff9b3415d..d7e758578 100644 --- a/frameworks/ans/native/test/unittest/reminder_request_calendar_test.cpp +++ b/frameworks/ans/native/test/unittest/reminder_request_calendar_test.cpp @@ -91,7 +91,7 @@ HWTEST_F(ReminderRequestCalendarTest, initDateTime_00100, Function | SmallTest | if (calendar == nullptr) { EXPECT_TRUE(false) << "calendar is null"; } - int firstDesignateYear = calendar->GetActualTime(ReminderRequest::TimeTransferType::YEAR, nowTime.tm_year); + int32_t firstDesignateYear = calendar->GetActualTime(ReminderRequest::TimeTransferType::YEAR, nowTime.tm_year); EXPECT_TRUE(firstDesignateYear == calendar->GetFirstDesignateYear()) << "Set first designate year error."; } 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 80c11446e..b4a60bb2b 100644 --- a/frameworks/ans/test/moduletest/ans_innerkits_module_publish_test.cpp +++ b/frameworks/ans/test/moduletest/ans_innerkits_module_publish_test.cpp @@ -40,7 +40,7 @@ bool OnConsumedReceived = false; bool OnCanceledReceived = false; bool OnWantReceived = false; const int32_t SLEEP_TIME = 5; -const int32_t ACTIVE_NUMS = 2; +const uint64_t ACTIVE_NUMS = 2; const int32_t CASE_ONE = 1; const int32_t CASE_TWO = 2; const int32_t CASE_THREE = 3; @@ -1151,7 +1151,7 @@ HWTEST_F(AnsInterfaceModulePublishTest, ANS_Interface_MT_GetActiveNotifications_ EXPECT_EQ((int)ERR_OK, (int)NotificationHelper::CancelAllNotifications()); sleep(SLEEP_TIME); EXPECT_EQ(OnCanceledReceived, true); - int countBefor = 0; + uint64_t countBefor = 0; EXPECT_EQ((int)ERR_OK, NotificationHelper::GetActiveNotificationNums(countBefor)); EXPECT_EQ(0, countBefor); std::string label1 = "Label1"; @@ -1172,7 +1172,7 @@ HWTEST_F(AnsInterfaceModulePublishTest, ANS_Interface_MT_GetActiveNotifications_ g_consumed_mtx.lock(); EXPECT_EQ(0, NotificationHelper::PublishNotification(req2)); WaitOnConsumed(); - int countAfter = 0; + uint64_t countAfter = 0; EXPECT_EQ((int)ERR_OK, NotificationHelper::GetActiveNotificationNums(countAfter)); EXPECT_EQ(ACTIVE_NUMS, countAfter); std::vector> requests; diff --git a/interfaces/innerkits/ans/native/include/message_user.h b/interfaces/innerkits/ans/native/include/message_user.h index 2d866ef44..e4f1044c2 100644 --- a/interfaces/innerkits/ans/native/include/message_user.h +++ b/interfaces/innerkits/ans/native/include/message_user.h @@ -173,9 +173,9 @@ private: bool isUserImportant_ {false}; // no object in parcel - static constexpr int VALUE_NULL = -1; + static constexpr int32_t VALUE_NULL = -1; // object exist in parcel - static constexpr int VALUE_OBJECT = 1; + static constexpr int32_t VALUE_OBJECT = 1; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_constant.h b/interfaces/innerkits/ans/native/include/notification_constant.h index 946297527..0d349c1b9 100644 --- a/interfaces/innerkits/ans/native/include/notification_constant.h +++ b/interfaces/innerkits/ans/native/include/notification_constant.h @@ -129,52 +129,52 @@ public: /** * Indicates that a notification is deleted because it is clicked. */ - static const int CLICK_REASON_DELETE = 1; + static const int32_t CLICK_REASON_DELETE = 1; /** * Indicates that a notification is deleted because the user clears it. */ - static const int CANCEL_REASON_DELETE = 2; + static const int32_t CANCEL_REASON_DELETE = 2; /** * Indicates that a notification is deleted because the user clears all notifications. */ - static const int CANCEL_ALL_REASON_DELETE = 3; + static const int32_t CANCEL_ALL_REASON_DELETE = 3; /** * Indicates that a notification is deleted because of a UI error. */ - static const int ERROR_REASON_DELETE = 4; + static const int32_t ERROR_REASON_DELETE = 4; /** * Indicates that a notification is deleted because a change has been made to the application. */ - static const int PACKAGE_CHANGED_REASON_DELETE = 5; + static const int32_t PACKAGE_CHANGED_REASON_DELETE = 5; /** * Indicates that a notification is deleted because the application context is stopped. */ - static const int USER_STOPPED_REASON_DELETE = 6; + static const int32_t USER_STOPPED_REASON_DELETE = 6; /** * Indicates that a notification is deleted because the application is banned from sending notifications. */ - static const int PACKAGE_BANNED_REASON_DELETE = 7; + static const int32_t PACKAGE_BANNED_REASON_DELETE = 7; /** * Indicates that a notification is deleted because the application cancels it. */ - static const int APP_CANCEL_REASON_DELETE = 8; + static const int32_t APP_CANCEL_REASON_DELETE = 8; /** * Indicates that a notification is deleted because the application cancels all notifications. */ - static const int APP_CANCEL_ALL_REASON_DELETE = 9; + static const int32_t APP_CANCEL_ALL_REASON_DELETE = 9; /** * Indicates that a notification is deleted for other reasons. */ - static const int APP_CANCEL_REASON_OTHER = 10; + static const int32_t APP_CANCEL_REASON_OTHER = 10; /** * The key indicates input source. diff --git a/interfaces/innerkits/ans/native/include/notification_helper.h b/interfaces/innerkits/ans/native/include/notification_helper.h index bacbee446..618ccb8b4 100644 --- a/interfaces/innerkits/ans/native/include/notification_helper.h +++ b/interfaces/innerkits/ans/native/include/notification_helper.h @@ -150,7 +150,7 @@ public: * @param num Indicates number of slot. * @return Returns get slot number by bundle result. */ - static ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, int &num); + static ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num); /** * @brief Publishes a notification. @@ -221,7 +221,7 @@ public: * @param nums Indicates the number of active notifications of the current application. * @return Returns get active notification nums result. */ - static ErrCode GetActiveNotificationNums(int32_t &num); + static ErrCode GetActiveNotificationNums(uint64_t &num); /** * @brief Obtains active notifications of the current application in the system. diff --git a/interfaces/innerkits/ans/native/include/notification_slot.h b/interfaces/innerkits/ans/native/include/notification_slot.h index be5ee0dd3..50b057cc5 100644 --- a/interfaces/innerkits/ans/native/include/notification_slot.h +++ b/interfaces/innerkits/ans/native/include/notification_slot.h @@ -358,9 +358,9 @@ private: std::vector vibrationValues_ {}; // no object in parcel - static constexpr int VALUE_NULL = -1; + static constexpr int32_t VALUE_NULL = -1; // object exist in parcel - static constexpr int VALUE_OBJECT = 1; + static constexpr int32_t VALUE_OBJECT = 1; }; } // namespace Notification } // namespace OHOS diff --git a/interfaces/innerkits/ans/native/include/notification_sorting.h b/interfaces/innerkits/ans/native/include/notification_sorting.h index 702073f7b..d904a9475 100644 --- a/interfaces/innerkits/ans/native/include/notification_sorting.h +++ b/interfaces/innerkits/ans/native/include/notification_sorting.h @@ -41,7 +41,7 @@ public: * * @return Returns the sequence number of the notification. */ - inline int32_t GetRanking() const + inline uint64_t GetRanking() const { return ranking_; }; @@ -148,7 +148,7 @@ private: void SetGroupKeyOverride(const std::string &str); void SetKey(const std::string &key); void SetImportance(const int32_t &importance); - void SetRanking(const int32_t &ranking); + void SetRanking(const uint64_t &ranking); void SetSlot(const sptr &slot); void SetVisiblenessOverride(const int32_t &visibleness); void SetDisplayBadge(const bool &isDisplayBadge); @@ -157,7 +157,7 @@ private: private: std::string key_ {}; - int32_t ranking_ {-1}; + uint64_t ranking_ {0}; int32_t importance_ {-1}; bool isDisplayBadge_ {true}; bool isHiddenNotification_ {}; diff --git a/interfaces/innerkits/ans/native/include/notification_subscriber.h b/interfaces/innerkits/ans/native/include/notification_subscriber.h index 0cc37c39e..5bf1f3b0d 100644 --- a/interfaces/innerkits/ans/native/include/notification_subscriber.h +++ b/interfaces/innerkits/ans/native/include/notification_subscriber.h @@ -46,7 +46,7 @@ public: * @param deleteReason Indicates the reason for the deletion. For details, see NotificationConstant. **/ virtual void OnCanceled(const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason) = 0; + const std::shared_ptr &sortingMap, int32_t deleteReason) = 0; /** * @brief Called back when the subscriber is connected to the Advanced Notification Service (ANS). @@ -132,7 +132,7 @@ private: void OnCanceled(const sptr ¬ification) override; void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, - int deleteReason) override; + int32_t deleteReason) override; void OnUpdated(const sptr ¬ificationMap) override; diff --git a/interfaces/kits/napi/ans/include/common.h b/interfaces/kits/napi/ans/include/common.h index 97a00d39e..9423ea43f 100644 --- a/interfaces/kits/napi/ans/include/common.h +++ b/interfaces/kits/napi/ans/include/common.h @@ -26,11 +26,11 @@ using namespace OHOS::Notification; const std::int32_t STR_MAX_SIZE = 200; const std::int32_t LONG_STR_MAX_SIZE = 1024; -const int NO_ERROR = 0; -const int ERROR = -1; -const int PARAM0 = 0; -const int PARAM1 = 1; -const int PARAM2 = 2; +const int32_t NO_ERROR = 0; +const int32_t ERROR = -1; +const int32_t PARAM0 = 0; +const int32_t PARAM1 = 1; +const int32_t PARAM2 = 2; enum class ContentType { NOTIFICATION_CONTENT_BASIC_TEXT, @@ -128,12 +128,12 @@ enum class NotificationFlagStatus { struct NotificationSubscribeInfo { std::vector bundleNames; - int userId = 0; + int32_t userId = 0; bool hasSubscribeInfo = false; }; struct NotificationKey { - int id {}; + int32_t id {}; std::string label {}; }; @@ -141,7 +141,7 @@ struct CallbackPromiseInfo { napi_ref callback = nullptr; napi_deferred deferred = nullptr; bool isCallback = false; - int errorCode = 0; + int32_t errorCode = 0; }; class Common { @@ -181,7 +181,7 @@ public: * @param errCode Indicates specified err code * @return Returns a napi value with specified error code for callback */ - static napi_value GetCallbackErrorValue(napi_env env, int errCode); + static napi_value GetCallbackErrorValue(napi_env env, int32_t errCode); /** * @brief Pads the CallbackPromiseInfo struct @@ -212,7 +212,7 @@ public: * @param result Indicates the result returned by the callback */ static void SetCallback( - const napi_env &env, const napi_ref &callbackIn, const int &errorCode, const napi_value &result); + const napi_env &env, const napi_ref &callbackIn, const int32_t &errorCode, const napi_value &result); /** * @brief Calls the callback with the result @@ -233,7 +233,7 @@ public: * @param result Indicates the result returned by the callback */ static void SetPromise( - const napi_env &env, const napi_deferred &deferred, const int &errorCode, const napi_value &result); + const napi_env &env, const napi_deferred &deferred, const int32_t &errorCode, const napi_value &result); /** * @brief Gets the returned result by the callback when an error occurs @@ -1434,7 +1434,7 @@ public: * @param outType Indicates a js reason type * @return Returns true if success, returns false otherwise */ - static bool ReasonCToJS(const int &inType, int &outType); + static bool ReasonCToJS(const int32_t &inType, int32_t &outType); /** * @brief Converts do-not-disturb type from js to native @@ -1527,10 +1527,10 @@ public: const napi_env &env, const std::shared_ptr &flags, napi_value &result); private: - static const int ARGS_ONE = 1; - static const int ARGS_TWO = 2; - static const int ONLY_CALLBACK_MAX_PARA = 1; - static const int ONLY_CALLBACK_MIN_PARA = 0; + static const int32_t ARGS_ONE = 1; + static const int32_t ARGS_TWO = 2; + static const int32_t ONLY_CALLBACK_MAX_PARA = 1; + static const int32_t ONLY_CALLBACK_MIN_PARA = 0; static std::set> wantAgent_; }; } // namespace NotificationNapi diff --git a/interfaces/kits/napi/ans/include/subscribe.h b/interfaces/kits/napi/ans/include/subscribe.h index 24f4270f0..c06a54602 100644 --- a/interfaces/kits/napi/ans/include/subscribe.h +++ b/interfaces/kits/napi/ans/include/subscribe.h @@ -42,7 +42,7 @@ public: * @param deleteReason Indicates the reason for the deletion. For details, see NotificationConstant. */ virtual void OnCanceled(const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason) override; + const std::shared_ptr &sortingMap, int32_t deleteReason) override; /** * @brief Called back when a notification is canceled. diff --git a/interfaces/kits/napi/ans/src/common.cpp b/interfaces/kits/napi/ans/src/common.cpp index d2d75ebc8..af1f158cd 100644 --- a/interfaces/kits/napi/ans/src/common.cpp +++ b/interfaces/kits/napi/ans/src/common.cpp @@ -48,7 +48,7 @@ napi_value Common::NapiGetUndefined(napi_env env) return result; } -napi_value Common::GetCallbackErrorValue(napi_env env, int errCode) +napi_value Common::GetCallbackErrorValue(napi_env env, int32_t errCode) { napi_value result = nullptr; napi_value eCode = nullptr; @@ -86,7 +86,7 @@ void Common::ReturnCallbackPromise(const napi_env &env, const CallbackPromiseInf } void Common::SetCallback( - const napi_env &env, const napi_ref &callbackIn, const int &errorCode, const napi_value &result) + const napi_env &env, const napi_ref &callbackIn, const int32_t &errorCode, const napi_value &result) { ANS_LOGI("enter"); napi_value undefined = nullptr; @@ -117,7 +117,7 @@ void Common::SetCallback( } void Common::SetPromise( - const napi_env &env, const napi_deferred &deferred, const int &errorCode, const napi_value &result) + const napi_env &env, const napi_deferred &deferred, const int32_t &errorCode, const napi_value &result) { ANS_LOGI("enter"); if (errorCode == ERR_OK) { @@ -181,7 +181,7 @@ napi_value Common::SetNotificationByDistributedOptions( napi_set_named_property(env, result, "isDistributed", value); // supportDisplayDevices?: Array - int count = 0; + uint32_t count = 0; napi_value arrSupportDisplayDevices = nullptr; napi_create_array(env, &arrSupportDisplayDevices); std::vector displayDevices = options.GetDevicesSupportDisplay(); @@ -357,7 +357,7 @@ napi_value Common::SetNotificationRequestByNumber( napi_set_named_property(env, result, "color", value); // badgeIconStyle ?: number - int badgeIconStyle = static_cast(request->GetBadgeIconStyle()); + auto badgeIconStyle = static_cast(request->GetBadgeIconStyle()); napi_create_int32(env, badgeIconStyle, &value); napi_set_named_property(env, result, "badgeIconStyle", value); @@ -541,7 +541,7 @@ napi_value Common::SetNotificationRequestByCustom( // actionButtons?: Array napi_value arr = nullptr; - int count = 0; + uint32_t count = 0; napi_create_array(env, &arr); for (auto vec : request->GetActionButtons()) { if (vec) { diff --git a/interfaces/kits/napi/ans/src/get_active.cpp b/interfaces/kits/napi/ans/src/get_active.cpp index aa6c1996b..ad798f0fa 100644 --- a/interfaces/kits/napi/ans/src/get_active.cpp +++ b/interfaces/kits/napi/ans/src/get_active.cpp @@ -23,7 +23,7 @@ struct AsyncCallbackInfoActive { CallbackPromiseInfo info; std::vector> notifications; std::vector> requests; - int32_t num = 0; + uint64_t num = 0; }; void AsyncCompleteCallbackGetAllActiveNotifications(napi_env env, napi_status status, void *data) @@ -41,7 +41,7 @@ void AsyncCompleteCallbackGetAllActiveNotifications(napi_env env, napi_status st result = Common::NapiGetNull(env); } else { napi_value arr = nullptr; - int count = 0; + int32_t count = 0; napi_create_array(env, &arr); for (auto vec : asynccallbackinfo->notifications) { if (!vec) { @@ -132,7 +132,7 @@ void AsyncCompleteCallbackGetActiveNotifications(napi_env env, napi_status statu result = Common::NapiGetNull(env); } else { napi_value arr = nullptr; - int count = 0; + int32_t count = 0; napi_create_array(env, &arr); for (auto vec : asynccallbackinfo->requests) { if (!vec) { @@ -222,7 +222,7 @@ void AsyncCompleteCallbackGetActiveNotificationCount(napi_env env, napi_status s if (asynccallbackinfo->info.errorCode != ERR_OK) { result = Common::NapiGetNull(env); } else { - napi_create_int32(env, asynccallbackinfo->num, &result); + napi_create_uint32(env, asynccallbackinfo->num, &result); } Common::ReturnCallbackPromise(env, asynccallbackinfo->info, result); if (asynccallbackinfo->info.callback != nullptr) { @@ -262,7 +262,7 @@ napi_value GetActiveNotificationCount(napi_env env, napi_callback_info info) auto asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::GetActiveNotificationNums(asynccallbackinfo->num); - ANS_LOGI("GetActiveNotificationCount count = %{public}d", asynccallbackinfo->num); + ANS_LOGI("GetActiveNotificationCount count = %{public}" PRIu64 "", asynccallbackinfo->num); }, AsyncCompleteCallbackGetActiveNotificationCount, (void *)asynccallbackinfo, diff --git a/interfaces/kits/napi/ans/src/slot.cpp b/interfaces/kits/napi/ans/src/slot.cpp index d1d24bfaa..1906f076f 100644 --- a/interfaces/kits/napi/ans/src/slot.cpp +++ b/interfaces/kits/napi/ans/src/slot.cpp @@ -17,13 +17,13 @@ namespace OHOS { namespace NotificationNapi { -const int ADD_SLOT_MAX_PARA = 2; -const int ADD_SLOTS_MAX_PARA = 2; -const int SET_SLOT_AS_BUNDLE_MAX_PARA = 3; -const int GET_SLOT_MAX_PARA = 2; -const int GET_SLOT_NUM_AS_BUNDLE_MAX_PARA = 2; -const int GET_SLOTS_AS_BUNDLE_MAX_PARA = 2; -const int REMOVE_SLOT_MAX_PARA = 2; +const int32_t ADD_SLOT_MAX_PARA = 2; +const int32_t ADD_SLOTS_MAX_PARA = 2; +const int32_t SET_SLOT_AS_BUNDLE_MAX_PARA = 3; +const int32_t GET_SLOT_MAX_PARA = 2; +const int32_t GET_SLOT_NUM_AS_BUNDLE_MAX_PARA = 2; +const int32_t GET_SLOTS_AS_BUNDLE_MAX_PARA = 2; +const int32_t REMOVE_SLOT_MAX_PARA = 2; struct ParametersInfoAddSlot { NotificationSlot slot; @@ -89,7 +89,7 @@ struct AsyncCallbackInfoGetSlotNumByBundle { napi_async_work asyncWork = nullptr; ParametersInfoGetSlotNumByBundle params; CallbackPromiseInfo info; - int num = 0; + uint64_t num = 0; }; struct AsyncCallbackInfoGetSlots { @@ -146,7 +146,7 @@ napi_value ParseParametersByAddSlot(const napi_env &env, const napi_callback_inf env, (valuetype == napi_object || valuetype == napi_number), "Wrong argument type. Object or number expected."); if (valuetype == napi_number) { paras.isAddSlotByType = true; - int slotType = 0; + int32_t slotType = 0; napi_get_value_int32(env, argv[PARAM0], &slotType); if (!Common::SlotTypeJSToC(SlotType(slotType), paras.inType)) { return nullptr; @@ -268,7 +268,7 @@ napi_value ParseParametersByGetSlot(const napi_env &env, const napi_callback_inf // argv[0]: SlotType NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); NAPI_ASSERT(env, valuetype == napi_number, "Wrong argument type. Number expected."); - int slotType = 0; + int32_t slotType = 0; napi_get_value_int32(env, argv[PARAM0], &slotType); if (!Common::SlotTypeJSToC(SlotType(slotType), paras.outType)) { return nullptr; @@ -359,7 +359,7 @@ napi_value ParseParametersByRemoveSlot( // argv[0]: SlotType NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); NAPI_ASSERT(env, valuetype == napi_number, "Wrong argument type. Number expected."); - int slotType = 0; + int32_t slotType = 0; napi_get_value_int32(env, argv[PARAM0], &slotType); if (!Common::SlotTypeJSToC(SlotType(slotType), paras.outType)) { return nullptr; @@ -654,7 +654,7 @@ napi_value GetSlotNumByBundle(napi_env env, napi_callback_info info) auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { napi_value result = nullptr; - napi_create_int32(env, asynccallbackinfo->num, &result); + napi_create_uint32(env, asynccallbackinfo->num, &result); Common::ReturnCallbackPromise(env, asynccallbackinfo->info, result); if (asynccallbackinfo->info.callback != nullptr) { napi_delete_reference(env, asynccallbackinfo->info.callback); diff --git a/interfaces/kits/napi/ans/src/subscribe.cpp b/interfaces/kits/napi/ans/src/subscribe.cpp index 3f5331021..05a0fc856 100644 --- a/interfaces/kits/napi/ans/src/subscribe.cpp +++ b/interfaces/kits/napi/ans/src/subscribe.cpp @@ -20,8 +20,8 @@ namespace OHOS { namespace NotificationNapi { -const int SUBSRIBE_MAX_PARA = 3; -const int NO_DELETE_REASON = -1; +const int32_t SUBSRIBE_MAX_PARA = 3; +const int32_t NO_DELETE_REASON = -1; const std::string CONSUME = "onConsume"; const std::string CANCEL = "onCancel"; const std::string UPDATE = "onUpdate"; @@ -39,15 +39,15 @@ struct NotificationReceiveDataWorker { std::shared_ptr sortingMap; NotificationDoNotDisturbDate date; EnabledNotificationCallbackData callbackData; - int deleteReason = 0; - int result = 0; - int disturbMode = 0; + int32_t deleteReason = 0; + int32_t result = 0; + int32_t disturbMode = 0; SubscriberInstance *subscriber = nullptr; }; napi_value SetSubscribeCallbackData(const napi_env &env, const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason, napi_value &result) + const std::shared_ptr &sortingMap, int32_t deleteReason, napi_value &result) { ANS_LOGI("enter"); if (request == nullptr) { @@ -81,7 +81,7 @@ napi_value SetSubscribeCallbackData(const napi_env &env, // reason?: number if (deleteReason != NO_DELETE_REASON) { napi_value value = nullptr; - int outReason = 0; + int32_t outReason = 0; if (!Common::ReasonCToJS(deleteReason, outReason)) { return Common::NapiGetBoolean(env, false); } @@ -184,7 +184,7 @@ void UvQueueWorkOnCanceled(uv_work_t *work, int status) } void SubscriberInstance::OnCanceled(const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason) + const std::shared_ptr &sortingMap, int32_t deleteReason) { ANS_LOGI("enter"); diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index d4064e050..cbe04c801 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -71,7 +71,7 @@ public: * @param label Indicates the label of the notification to cancel. * @return Returns cancel notification result. */ - ErrCode Cancel(int notificationId, const std::string &label) override; + ErrCode Cancel(int32_t notificationId, const std::string &label) override; /** * @brief Cancels all the published notifications. @@ -164,7 +164,7 @@ public: * @param num Indicates the number of slot. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetSlotNumAsBundle(const sptr &bundleOption, int &num) override; + ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; /** * @brief Deletes multiple notification slot groups. @@ -189,7 +189,7 @@ public: * @param num Indicates the number of active notifications of the current application. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetActiveNotificationNums(int &num) override; + ErrCode GetActiveNotificationNums(uint64_t &num) override; /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to @@ -263,7 +263,7 @@ public: * @param num Indicates the badge number. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SetNotificationBadgeNum(int num) override; + ErrCode SetNotificationBadgeNum(int32_t num) override; /** * @brief Obtains the importance level of this application. @@ -272,7 +272,7 @@ public: LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetBundleImportance(int &importance) override; + ErrCode GetBundleImportance(int32_t &importance) override; /** * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. @@ -307,7 +307,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode RemoveNotification( - const sptr &bundleOption, int notificationId, const std::string &label) override; + const sptr &bundleOption, int32_t notificationId, const std::string &label) override; /** * @brief Delete all notifications. @@ -712,7 +712,7 @@ public: void OnDistributedKvStoreDeathRecipient(); ErrCode CancelPreparedNotification( - int notificationId, const std::string &label, const sptr &bundleOption); + int32_t notificationId, const std::string &label, const sptr &bundleOption); ErrCode PrepareNotificationInfo( const sptr &request, sptr &bundleOption); ErrCode PublishPreparedNotification( @@ -730,10 +730,10 @@ private: void UpdateInNotificationList(const std::shared_ptr &record); ErrCode AssignToNotificationList(const std::shared_ptr &record); ErrCode RemoveFromNotificationList(const sptr &bundleOption, const std::string &label, - int notificationId, sptr ¬ification, bool isCancel = false); + int32_t notificationId, sptr ¬ification, bool isCancel = false); ErrCode RemoveFromNotificationList(const std::string &key, sptr ¬ification, bool isCancel = false); ErrCode RemoveFromNotificationListForDeleteAll(const std::string &key, - const int &userId, sptr ¬ification); + const int32_t &userId, sptr ¬ification); std::vector GetNotificationKeys(const sptr &bundleOption); bool IsNotificationExists(const std::string &key); void SortNotificationList(); @@ -753,11 +753,11 @@ private: ErrCode DistributedNotificationDump(std::vector &dumpInfo); #endif ErrCode SetRecentNotificationCount(const std::string arg); - void UpdateRecentNotification(sptr ¬ification, bool isDelete, int reason); + void UpdateRecentNotification(sptr ¬ification, bool isDelete, int32_t reason); void AdjustDateForDndTypeOnce(int64_t &beginDate, int64_t &endDate); bool CheckPermission(); - ErrCode PrepereContinuousTaskNotificationRequest(const sptr &request, const int &uid); + ErrCode PrepereContinuousTaskNotificationRequest(const sptr &request, const int32_t &uid); bool GetActiveUserId(int& userId); void TriggerRemoveWantAgent(const sptr &request); bool CheckApiCompatibility(const sptr &bundleOption); diff --git a/services/ans/include/bundle_manager_helper.h b/services/ans/include/bundle_manager_helper.h index d637ca3ca..12a53f37a 100644 --- a/services/ans/include/bundle_manager_helper.h +++ b/services/ans/include/bundle_manager_helper.h @@ -38,7 +38,7 @@ public: * @param uid Indicates the specified uid. * @return Returns the bundle name. */ - std::string GetBundleNameByUid(int uid); + std::string GetBundleNameByUid(int32_t uid); /** * @brief Check whether the caller is a system application base on the specified uid. @@ -46,7 +46,7 @@ public: * @param uid Indicates the specified uid. * @return Returns the check result. */ - bool IsSystemApp(int uid); + bool IsSystemApp(int32_t uid); /** * @brief Check API compatibility. @@ -63,7 +63,7 @@ public: * @param userId Indicates the user id. * @return Returns the uid. */ - int GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId); + int32_t GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId); /** * @brief Obtains the bundle info. @@ -83,7 +83,7 @@ public: * @param userId Indicates the user id. * @return Returns the check result. */ - bool GetDistributedNotificationEnabled(const std::string &bundleName, const int userId); + bool GetDistributedNotificationEnabled(const std::string &bundleName, const int32_t userId); #endif private: diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index f0dce5833..717f50261 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -144,7 +144,7 @@ public: * @param num Indicates to get slot num. * @return Return ERR_OK on success, others on failure. */ - ErrCode GetNotificationSlotsNumForBundle(const sptr &bundleOption, int &num); + ErrCode GetNotificationSlotsNumForBundle(const sptr &bundleOption, uint64_t &num); /** * @brief Get notification group in a bundle from DB. @@ -204,7 +204,7 @@ public: LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Return ERR_OK on success, others on failure. */ - ErrCode GetImportance(const sptr &bundleOption, int &importance); + ErrCode GetImportance(const sptr &bundleOption, int32_t &importance); /** * @brief Set importance in the of bunlde from DB. @@ -214,7 +214,7 @@ public: LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Return ERR_OK on success, others on failure. */ - ErrCode SetImportance(const sptr &bundleOption, const int &importance); + ErrCode SetImportance(const sptr &bundleOption, const int32_t &importance); /** * @brief Get total badge nums in the of bunlde from DB. @@ -223,7 +223,7 @@ public: * @param totalBadgeNum Indicates to get badge num. * @return Return ERR_OK on success, others on failure. */ - ErrCode GetTotalBadgeNums(const sptr &bundleOption, int &totalBadgeNum); + ErrCode GetTotalBadgeNums(const sptr &bundleOption, int32_t &totalBadgeNum); /** * @brief Set total badge nums in the of bunlde from DB. @@ -232,7 +232,7 @@ public: * @param totalBadgeNum Indicates to set badge num. * @return Return ERR_OK on success, others on failure. */ - ErrCode SetTotalBadgeNums(const sptr &bundleOption, const int num); + ErrCode SetTotalBadgeNums(const sptr &bundleOption, const int32_t num); /** * @brief Get private notification allowed in the of bunlde from DB. diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index 632c83fe4..eed550ff5 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -38,7 +38,7 @@ public: * @return Return true on success, false on failure. */ bool PutSlotsToDisturbeDB( - const std::string &bundleName, const int &bundleUid, const std::vector> &slots); + const std::string &bundleName, const int32_t &bundleUid, const std::vector> &slots); /** * @brief Put notification slot groups into disturbe DB. @@ -48,8 +48,8 @@ public: * @param groups Indicates notification groups. * @return Return true on success, false on failure. */ - bool PutGroupsToDisturbeDB( - const std::string &bundleName, const int &bundleUid, const std::vector> &groups); + bool PutGroupsToDisturbeDB(const std::string &bundleName, const int32_t &bundleUid, + const std::vector> &groups); /** * @brief Put notification bundle into disturbe DB. @@ -76,7 +76,7 @@ public: LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Return true on success, false on failure. */ - bool PutImportance(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int &importance); + bool PutImportance(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int32_t &importance); /** * @brief Put badge total nums in the of bundle into disturbe DB. @@ -85,7 +85,7 @@ public: * @param totalBadgeNum Indicates to total badge num. * @return Return true on success, false on failure. */ - bool PutTotalBadgeNums(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int &totalBadgeNum); + bool PutTotalBadgeNums(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int32_t &totalBadgeNum); /** * @brief Put private notification allowed in the of bundle into disturbe DB. @@ -190,7 +190,7 @@ private: void CloseKvStore(); bool CheckKvStore(); - bool CheckBundle(const std::string &bundleName, const int &bundleUid); + bool CheckBundle(const std::string &bundleName, const int32_t &bundleUid); bool PutBundlePropertyValueToDisturbeDB(const NotificationPreferencesInfo::BundleInfo &bundleInfo); template DistributedKv::Status PutBundlePropertyToDisturbeDB( @@ -204,9 +204,9 @@ private: bool GetRemoveGroupKeysFromDisturbeDB( const std::string &bundleKey, const std::string &groupId, std::vector &keys); - bool SlotToEntry(const std::string &bundleName, const int &bundleUid, const sptr &slot, + bool SlotToEntry(const std::string &bundleName, const int32_t &bundleUid, const sptr &slot, std::vector &entries); - bool GroupToEntry(const std::string &bundleName, const int &bundleUid, const sptr &group, + bool GroupToEntry(const std::string &bundleName, const int32_t &bundleUid, const sptr &group, std::vector &entries); void GenerateGroupEntry(const std::string &bundleKey, const sptr &group, std::vector &entries) const; @@ -219,7 +219,7 @@ private: std::string SubUniqueIdentifyFromString(const std::string &findString, const std::string &keyStr) const; std::string VectorToString(const std::vector &data) const; void StringToVector(const std::string &str, std::vector &data) const; - int StringToInt(const std::string &str) const; + int32_t StringToInt(const std::string &str) const; int64_t StringToInt64(const std::string &str) const; bool IsSlotKey(const std::string &bundleKey, const std::string &key) const; bool IsGroupKey(const std::string &bundleKey, const std::string &key) const; @@ -268,10 +268,10 @@ private: void ParseSlotEnableBypassDnd(sptr &slot, const std::string &value) const; std::string GenerateBundleLablel(const NotificationPreferencesInfo::BundleInfo &bundleInfo) const; - void GetDoNotDisturbType(NotificationPreferencesInfo &info, int userId); - void GetDoNotDisturbBeginDate(NotificationPreferencesInfo &info, int userId); - void GetDoNotDisturbEndDate(NotificationPreferencesInfo &info, int userId); - void GetEnableAllNotification(NotificationPreferencesInfo &info, int userId); + void GetDoNotDisturbType(NotificationPreferencesInfo &info, int32_t userId); + void GetDoNotDisturbBeginDate(NotificationPreferencesInfo &info, int32_t userId); + void GetDoNotDisturbEndDate(NotificationPreferencesInfo &info, int32_t userId); + void GetEnableAllNotification(NotificationPreferencesInfo &info, int32_t userId); static const std::map &, std::string &)>> diff --git a/services/ans/include/notification_preferences_info.h b/services/ans/include/notification_preferences_info.h index 54aeec006..a0d86b0b7 100644 --- a/services/ans/include/notification_preferences_info.h +++ b/services/ans/include/notification_preferences_info.h @@ -53,14 +53,14 @@ public: * * @param name Indicates the bundle importance. */ - void SetImportance(const int &level); + void SetImportance(const int32_t &level); /** * @brief Get bundle importance. * * @return Return importance. */ - int GetImportance() const; + int32_t GetImportance() const; /** * @brief Set bundle Whether to show badge. @@ -81,14 +81,14 @@ public: * * @param name Indicates the set bundle total badge num. */ - void SetBadgeTotalNum(const int &num); + void SetBadgeTotalNum(const int32_t &num); /** * @brief Get bundle total badge num. * * @return Return badge total num. */ - int GetBadgeTotalNum() const; + int32_t GetBadgeTotalNum() const; /** * @brief Set bundle Whether to private allowed. @@ -199,7 +199,7 @@ public: * * @return Return num is group size. */ - uint32_t GetGroupSize() const; + size_t GetGroupSize() const; /** * @brief Check whether to exsist slot in the of bundle. @@ -239,15 +239,15 @@ public: * @return Return true on success, false on failure. */ bool RemoveSlotGroup(const std::string &groupId); - void SetBundleUid(const int &uid); - int GetBundleUid() const; + void SetBundleUid(const int32_t &uid); + int32_t GetBundleUid() const; private: std::string bundleName_; - int uid_ = 0; - int importance_ = BUNDLE_IMPORTANCE; + int32_t uid_ = 0; + int32_t importance_ = BUNDLE_IMPORTANCE; bool isShowBadge_ = BUNDLE_SHOW_BADGE; - int badgeTotalNum_ = BUNDLE_BADGE_TOTAL_NUM; + int32_t badgeTotalNum_ = BUNDLE_BADGE_TOTAL_NUM; bool isPrivateAllowed_ = BUNDLE_PRIVATE_ALLOWED; bool isEnabledNotification_ = BUNDLE_ENABLE_NOTIFICATION; bool hasPoppedDialog_ = BUNDLE_POPPED_DIALOG; diff --git a/services/ans/include/notification_subscriber_manager.h b/services/ans/include/notification_subscriber_manager.h index c097c413e..004f5268e 100644 --- a/services/ans/include/notification_subscriber_manager.h +++ b/services/ans/include/notification_subscriber_manager.h @@ -72,8 +72,8 @@ public: * @param notificationMap Indicates the NotificationSortingMap object. * @param deleteReason Indicates the delete reason. */ - void NotifyCanceled( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason); + void NotifyCanceled(const sptr ¬ification, + const sptr ¬ificationMap, int32_t deleteReason); /** * @brief Notify all subscribers on updated. @@ -115,8 +115,8 @@ private: void NotifyConsumedInner( const sptr ¬ification, const sptr ¬ificationMap); - void NotifyCanceledInner( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason); + void NotifyCanceledInner(const sptr ¬ification, + const sptr ¬ificationMap, int32_t deleteReason); void NotifyUpdatedInner(const sptr ¬ificationMap); void NotifyDoNotDisturbDateChangedInner(const sptr &date); void NotifyEnabledNotificationChangedInner(const sptr &callbackData); diff --git a/services/ans/include/reminder_timer_info.h b/services/ans/include/reminder_timer_info.h index ee8c22640..ca8f57573 100644 --- a/services/ans/include/reminder_timer_info.h +++ b/services/ans/include/reminder_timer_info.h @@ -44,7 +44,7 @@ public: /** * Indicates the timing type. */ - void SetType(const int &type) override; + void SetType(const int32_t &type) override; /** * Indicates the repeat policy. diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 8010b6616..58d7893e1 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -67,18 +67,18 @@ constexpr int32_t NOTIFICATION_MAX_COUNT = 1024; constexpr int32_t DEFAULT_RECENT_COUNT = 16; -constexpr int HOURS_IN_ONE_DAY = 24; +constexpr int32_t HOURS_IN_ONE_DAY = 24; -constexpr int DIALOG_DEFAULT_WIDTH = 400; -constexpr int DIALOG_DEFAULT_HEIGHT = 240; -constexpr int WINDOW_DEFAULT_WIDTH = 720; -constexpr int WINDOW_DEFAULT_HEIGHT = 1280; -constexpr int UI_HALF = 2; +constexpr int32_t DIALOG_DEFAULT_WIDTH = 400; +constexpr int32_t DIALOG_DEFAULT_HEIGHT = 240; +constexpr int32_t WINDOW_DEFAULT_WIDTH = 720; +constexpr int32_t WINDOW_DEFAULT_HEIGHT = 1280; +constexpr int32_t UI_HALF = 2; struct RecentNotification { sptr notification = nullptr; bool isActive = false; - int deleteReason = 0; + int32_t deleteReason = 0; int64_t deleteTime = 0; }; } // namespace @@ -100,7 +100,7 @@ inline std::string GetClientBundleName() { std::string bundle; - int callingUid = IPCSkeleton::GetCallingUid(); + int32_t callingUid = IPCSkeleton::GetCallingUid(); std::shared_ptr bundleManager = BundleManagerHelper::GetInstance(); if (bundleManager != nullptr) { @@ -114,7 +114,7 @@ inline bool IsSystemApp() { bool isSystemApp = false; - int callingUid = IPCSkeleton::GetCallingUid(); + int32_t callingUid = IPCSkeleton::GetCallingUid(); std::shared_ptr bundleManager = BundleManagerHelper::GetInstance(); if (bundleManager != nullptr) { @@ -204,12 +204,12 @@ ErrCode PrepereNotificationRequest(const sptr &request) request->SetOwnerBundleName(bundle); request->SetCreatorBundleName(bundle); - int uid = IPCSkeleton::GetCallingUid(); - int pid = IPCSkeleton::GetCallingPid(); + int32_t uid = IPCSkeleton::GetCallingUid(); + int32_t pid = IPCSkeleton::GetCallingPid(); request->SetCreatorUid(uid); request->SetCreatorPid(pid); - int userId = SUBSCRIBE_USER_INIT; + int32_t userId = SUBSCRIBE_USER_INIT; OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, userId); request->SetCreatorUserId(userId); ErrCode result = CheckPictureSize(request); @@ -295,7 +295,7 @@ sptr AdvancedNotificationService::GenerateBundleOption if (bundle.empty()) { return nullptr; } - int uid = IPCSkeleton::GetCallingUid(); + int32_t uid = IPCSkeleton::GetCallingUid(); bundleOption = new NotificationBundleOption(bundle, uid); return bundleOption; } @@ -307,12 +307,12 @@ sptr AdvancedNotificationService::GenerateValidBundleO if (bundleOption->GetUid() <= 0) { std::shared_ptr bundleManager = BundleManagerHelper::GetInstance(); if (bundleManager != nullptr) { - int activeUserId = -1; + int32_t activeUserId = -1; if (!GetActiveUserId(activeUserId)) { ANS_LOGE("Failed to get active user id!"); return validBundleOption; } - int uid = bundleManager->GetDefaultUidByBundleName(bundleOption->GetBundleName(), activeUserId); + int32_t uid = bundleManager->GetDefaultUidByBundleName(bundleOption->GetBundleName(), activeUserId); if (uid > 0) { validBundleOption = new NotificationBundleOption(bundleOption->GetBundleName(), uid); } @@ -340,7 +340,7 @@ ErrCode AdvancedNotificationService::AssignToNotificationList(const std::shared_ } ErrCode AdvancedNotificationService::CancelPreparedNotification( - int notificationId, const std::string &label, const sptr &bundleOption) + int32_t notificationId, const std::string &label, const sptr &bundleOption) { if (bundleOption == nullptr) { return ERR_ANS_INVALID_BUNDLE; @@ -354,7 +354,7 @@ ErrCode AdvancedNotificationService::CancelPreparedNotification( } if (notification != nullptr) { - int reason = NotificationConstant::APP_CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::APP_CANCEL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -508,7 +508,7 @@ sptr AdvancedNotificationService::GenerateSortingMap() std::vector sortingList; for (auto record : notificationList_) { NotificationSorting sorting; - sorting.SetRanking((int32_t)sortingList.size()); + sorting.SetRanking(static_cast(sortingList.size())); sorting.SetKey(record->notification->GetKey()); sorting.SetSlot(record->slot); sortingList.push_back(sorting); @@ -533,7 +533,7 @@ void AdvancedNotificationService::StopFilters() } } -ErrCode AdvancedNotificationService::Cancel(int notificationId, const std::string &label) +ErrCode AdvancedNotificationService::Cancel(int32_t notificationId, const std::string &label) { ANS_LOGD("%{public}s", __FUNCTION__); sptr bundleOption = GenerateBundleOption(); @@ -565,7 +565,7 @@ ErrCode AdvancedNotificationService::CancelAll() } if (notification != nullptr) { - int reason = NotificationConstant::APP_CANCEL_ALL_REASON_DELETE; + int32_t reason = NotificationConstant::APP_CANCEL_ALL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -737,7 +737,7 @@ ErrCode AdvancedNotificationService::GetActiveNotifications(std::vectorPostSyncTask(std::bind([&]() { - int count = 0; + size_t count = 0; for (auto record : notificationList_) { if ((record->bundleOption->GetBundleName() == bundleOption->GetBundleName()) && (record->bundleOption->GetUid() == bundleOption->GetUid())) { count += 1; } } - num = count; + num = static_cast(count); })); return result; } @@ -781,7 +781,7 @@ ErrCode AdvancedNotificationService::PublishAsBundle( return ERR_INVALID_OPERATION; } -ErrCode AdvancedNotificationService::SetNotificationBadgeNum(int num) +ErrCode AdvancedNotificationService::SetNotificationBadgeNum(int32_t num) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -796,7 +796,7 @@ ErrCode AdvancedNotificationService::SetNotificationBadgeNum(int num) return result; } -ErrCode AdvancedNotificationService::GetBundleImportance(int &importance) +ErrCode AdvancedNotificationService::GetBundleImportance(int32_t &importance) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -877,7 +877,7 @@ ErrCode AdvancedNotificationService::Delete(const std::string &key) } if (notification != nullptr) { - int reason = NotificationConstant::CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::CANCEL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -922,7 +922,7 @@ ErrCode AdvancedNotificationService::DeleteByBundle(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -952,7 +952,7 @@ ErrCode AdvancedNotificationService::DeleteAll() ErrCode result = ERR_OK; handler_->PostSyncTask(std::bind([&]() { - int activeUserId = SUBSCRIBE_USER_INIT; + int32_t activeUserId = SUBSCRIBE_USER_INIT; (void)GetActiveUserId(activeUserId); std::vector keys = GetNotificationKeys(nullptr); for (auto key : keys) { @@ -967,7 +967,7 @@ ErrCode AdvancedNotificationService::DeleteAll() } if (notification->GetUserId() == activeUserId) { - int reason = NotificationConstant::CANCEL_ALL_REASON_DELETE; + int32_t reason = NotificationConstant::CANCEL_ALL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -1158,7 +1158,7 @@ ErrCode AdvancedNotificationService::GetShowBadgeEnabled(bool &enabled) } ErrCode AdvancedNotificationService::RemoveFromNotificationList(const sptr &bundleOption, - const std::string &label, int notificationId, sptr ¬ification, bool isCancel) + const std::string &label, int32_t notificationId, sptr ¬ification, bool isCancel) { for (auto record : notificationList_) { if ((record->bundleOption->GetBundleName() == bundleOption->GetBundleName()) && @@ -1207,7 +1207,7 @@ ErrCode AdvancedNotificationService::RemoveFromNotificationList( } ErrCode AdvancedNotificationService::RemoveFromNotificationListForDeleteAll( - const std::string &key, const int &userId, sptr ¬ification) + const std::string &key, const int32_t &userId, sptr ¬ification) { for (auto record : notificationList_) { if ((record->notification->GetKey() == key) && (record->notification->GetUserId() == userId)) { @@ -1395,10 +1395,10 @@ ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string return result; } - int positionX; - int positionY; - int width; - int height; + int32_t positionX; + int32_t positionY; + int32_t width; + int32_t height; bool wideScreen; GetDisplayPosition(positionX, positionY, width, height, wideScreen); @@ -1452,7 +1452,7 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForAllBundles(const return ERR_ANS_PERMISSION_DENIED; } - int userId = SUBSCRIBE_USER_INIT; + int32_t userId = SUBSCRIBE_USER_INIT; if (!GetActiveUserId(userId)) { return ERR_ANS_GET_ACTIVE_USER_FAILED; } @@ -1520,7 +1520,7 @@ ErrCode AdvancedNotificationService::IsAllowedNotify(bool &allowed) return ERR_ANS_PERMISSION_DENIED; } - int userId = SUBSCRIBE_USER_INIT; + int32_t userId = SUBSCRIBE_USER_INIT; if (!GetActiveUserId(userId)) { return ERR_ANS_GET_ACTIVE_USER_FAILED; } @@ -1551,7 +1551,7 @@ ErrCode AdvancedNotificationService::IsAllowedNotifySelf(const sptrSetCreatorUserId(userId); ANS_LOGD("%{public}s, uid=%{public}d userId=%{public}d", __FUNCTION__, uid, userId); @@ -1740,7 +1740,7 @@ ErrCode AdvancedNotificationService::CancelContinuousTaskNotification(const std: return ERR_ANS_NOT_SYSTEM_SERVICE; } - int uid = IPCSkeleton::GetCallingUid(); + int32_t uid = IPCSkeleton::GetCallingUid(); ErrCode result = ERR_OK; handler_->PostSyncTask(std::bind([&]() { sptr notification = nullptr; @@ -1754,7 +1754,7 @@ ErrCode AdvancedNotificationService::CancelContinuousTaskNotification(const std: } } if (notification != nullptr) { - int reason = NotificationConstant::APP_CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::APP_CANCEL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -1811,7 +1811,7 @@ ErrCode AdvancedNotificationService::CancelAllReminders() if (bundleOption == nullptr) { return ERR_ANS_INVALID_BUNDLE; } - int userId = -1; + int32_t userId = -1; AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(bundleOption->GetUid(), userId); auto rdm = ReminderDataManager::GetInstance(); if (rdm == nullptr) { @@ -1923,7 +1923,7 @@ ErrCode AdvancedNotificationService::DistributedNotificationDump(std::vector NOTIFICATION_MAX_COUNT)) { return ERR_ANS_INVALID_PARAM; @@ -1957,7 +1957,8 @@ int64_t AdvancedNotificationService::GetNowSysTime() return duration; } -void AdvancedNotificationService::UpdateRecentNotification(sptr ¬ification, bool isDelete, int reason) +void AdvancedNotificationService::UpdateRecentNotification(sptr ¬ification, + bool isDelete, int32_t reason) { for (auto recentNotification : recentInfo_->list) { if (recentNotification->notification->GetKey() == notification->GetKey()) { @@ -2069,7 +2070,7 @@ void AdvancedNotificationService::OnBundleRemoved(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -2153,7 +2154,7 @@ ErrCode AdvancedNotificationService::AddSlotByType(NotificationConstant::SlotTyp } ErrCode AdvancedNotificationService::RemoveNotification( - const sptr &bundleOption, int notificationId, const std::string &label) + const sptr &bundleOption, int32_t notificationId, const std::string &label) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -2202,7 +2203,7 @@ ErrCode AdvancedNotificationService::RemoveNotification( } if (notification != nullptr) { - int reason = NotificationConstant::CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::CANCEL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -2254,7 +2255,7 @@ ErrCode AdvancedNotificationService::RemoveAllNotifications(const sptrnotification != nullptr) { - int reason = NotificationConstant::CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::CANCEL_REASON_DELETE; UpdateRecentNotification(record->notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(record->notification, sortingMap, reason); @@ -2270,7 +2271,8 @@ ErrCode AdvancedNotificationService::RemoveAllNotifications(const sptr &bundleOption, int &num) +ErrCode AdvancedNotificationService::GetSlotNumAsBundle( + const sptr &bundleOption, uint64_t &num) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -2330,7 +2332,7 @@ ErrCode AdvancedNotificationService::CancelGroup(const std::string &groupName) notificationList_.remove(record); if (record->notification != nullptr) { - int reason = NotificationConstant::APP_CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::APP_CANCEL_REASON_DELETE; UpdateRecentNotification(record->notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(record->notification, sortingMap, reason); @@ -2386,7 +2388,7 @@ ErrCode AdvancedNotificationService::RemoveGroupByBundle( notificationList_.remove(record); if (record->notification != nullptr) { - int reason = NotificationConstant::CANCEL_REASON_DELETE; + int32_t reason = NotificationConstant::CANCEL_REASON_DELETE; UpdateRecentNotification(record->notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(record->notification, sortingMap, reason); @@ -2470,7 +2472,7 @@ ErrCode AdvancedNotificationService::SetDoNotDisturbDate(const sptr &request) { ANS_LOGD("%{public}s", __FUNCTION__); - int activeUserId = -1; + int32_t activeUserId = -1; if (!GetActiveUserId(activeUserId)) { ANS_LOGE("Failed to get active user id!"); return; @@ -2893,7 +2895,7 @@ void AdvancedNotificationService::OnDistributedUpdate( const std::string &deviceId, const std::string &bundleName, sptr &request) { ANS_LOGD("%{public}s", __FUNCTION__); - int activeUserId = -1; + int32_t activeUserId = -1; if (!GetActiveUserId(activeUserId)) { ANS_LOGE("Failed to get active user id!"); return; @@ -2980,7 +2982,7 @@ void AdvancedNotificationService::OnDistributedDelete( } if (notification != nullptr) { - int reason = NotificationConstant::APP_CANCEL_REASON_OTHER; + int32_t reason = NotificationConstant::APP_CANCEL_REASON_OTHER; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -2991,7 +2993,7 @@ void AdvancedNotificationService::OnDistributedDelete( ErrCode AdvancedNotificationService::GetDistributedEnableInApplicationInfo( const sptr bundleOption, bool &enable) { - int userId = SUBSCRIBE_USER_INIT; + int32_t userId = SUBSCRIBE_USER_INIT; OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(bundleOption->GetUid(), userId); if (userId >= SUBSCRIBE_USER_SYSTEM_BEGIN && userId <= SUBSCRIBE_USER_SYSTEM_END) { @@ -3006,9 +3008,9 @@ ErrCode AdvancedNotificationService::GetDistributedEnableInApplicationInfo( #endif ErrCode AdvancedNotificationService::PrepereContinuousTaskNotificationRequest( - const sptr &request, const int &uid) + const sptr &request, const int32_t &uid) { - int pid = IPCSkeleton::GetCallingPid(); + int32_t pid = IPCSkeleton::GetCallingPid(); request->SetCreatorUid(uid); request->SetCreatorPid(pid); @@ -3118,7 +3120,7 @@ ErrCode AdvancedNotificationService::DeleteAllByUser(const int32_t &userId) } if (notification->GetUserId() == userId) { - int reason = NotificationConstant::CANCEL_ALL_REASON_DELETE; + int32_t reason = NotificationConstant::CANCEL_ALL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -3205,8 +3207,8 @@ ErrCode AdvancedNotificationService::SetDoNotDisturbDateByUser(const int32_t &us default: break; } - ANS_LOGD("Before set SetDoNotDisturbDate beginDate = %{public}lld, endDate = %{public}lld", - (long long)beginDate, (long long)endDate); + ANS_LOGD("Before set SetDoNotDisturbDate beginDate = %{public}" PRId64 ", endDate = %{public}" PRId64, + beginDate, endDate); const sptr newConfig = new NotificationDoNotDisturbDate( date->GetDoNotDisturbType(), beginDate, @@ -3316,7 +3318,7 @@ void AdvancedNotificationService::OnBundleDataCleared(const sptr sortingMap = GenerateSortingMap(); NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); @@ -3343,12 +3345,12 @@ void AdvancedNotificationService::GetDisplayPosition( display->GetWidth(), display->GetHeight()); if (display->GetWidth() < display->GetHeight()) { float widthRatio = 0.75f; - int heightRatio = 5; - width = static_cast(display->GetWidth() * widthRatio); + int32_t heightRatio = 5; + width = static_cast(display->GetWidth() * widthRatio); height = display->GetHeight() / heightRatio; } else { - int widthRatio = 3; - int heightRatio = 4; + int32_t widthRatio = 3; + int32_t heightRatio = 4; wideScreen = true; width = display->GetWidth() / widthRatio; height = display->GetHeight() / heightRatio; diff --git a/services/ans/src/bundle_manager_helper.cpp b/services/ans/src/bundle_manager_helper.cpp index 037d4bb0a..c344003af 100644 --- a/services/ans/src/bundle_manager_helper.cpp +++ b/services/ans/src/bundle_manager_helper.cpp @@ -43,7 +43,7 @@ void BundleManagerHelper::OnRemoteDied(const wptr &object) Disconnect(); } -std::string BundleManagerHelper::GetBundleNameByUid(int uid) +std::string BundleManagerHelper::GetBundleNameByUid(int32_t uid) { std::string bundle; @@ -57,7 +57,7 @@ std::string BundleManagerHelper::GetBundleNameByUid(int uid) return bundle; } -bool BundleManagerHelper::IsSystemApp(int uid) +bool BundleManagerHelper::IsSystemApp(int32_t uid) { bool isSystemApp = false; @@ -131,9 +131,9 @@ void BundleManagerHelper::Disconnect() } } -int BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId) +int32_t BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId) { - int uid = -1; + int32_t uid = -1; std::lock_guard lock(connectionMutex_); @@ -150,7 +150,7 @@ int BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle, co } #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED -bool BundleManagerHelper::GetDistributedNotificationEnabled(const std::string &bundleName, const int userId) +bool BundleManagerHelper::GetDistributedNotificationEnabled(const std::string &bundleName, const int32_t userId) { std::lock_guard lock(connectionMutex_); diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index e5e0e23b0..981ba23b8 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -308,7 +308,7 @@ ErrCode NotificationPreferences::GetNotificationAllSlots( } ErrCode NotificationPreferences::GetNotificationSlotsNumForBundle( - const sptr &bundleOption, int &num) + const sptr &bundleOption, uint64_t &num) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; @@ -317,7 +317,7 @@ ErrCode NotificationPreferences::GetNotificationSlotsNumForBundle( ErrCode result = ERR_OK; NotificationPreferencesInfo::BundleInfo bundleInfo; if (preferencesInfo_.GetBundleInfo(bundleOption, bundleInfo)) { - num = static_cast(bundleInfo.GetAllSlotsSize()); + num = static_cast(bundleInfo.GetAllSlotsSize()); } else { result = ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST; } @@ -402,7 +402,7 @@ ErrCode NotificationPreferences::SetShowBadge(const sptr &bundleOption, int &importance) +ErrCode NotificationPreferences::GetImportance(const sptr &bundleOption, int32_t &importance) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; @@ -412,7 +412,7 @@ ErrCode NotificationPreferences::GetImportance(const sptr &bundleOption, const int &importance) + const sptr &bundleOption, const int32_t &importance) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; @@ -426,7 +426,7 @@ ErrCode NotificationPreferences::SetImportance( } ErrCode NotificationPreferences::GetTotalBadgeNums( - const sptr &bundleOption, int &totalBadgeNum) + const sptr &bundleOption, int32_t &totalBadgeNum) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; @@ -434,7 +434,8 @@ ErrCode NotificationPreferences::GetTotalBadgeNums( return GetBundleProperty(bundleOption, BundleType::BUNDLE_BADGE_TOTAL_NUM_TYPE, totalBadgeNum); } -ErrCode NotificationPreferences::SetTotalBadgeNums(const sptr &bundleOption, const int num) +ErrCode NotificationPreferences::SetTotalBadgeNums( + const sptr &bundleOption, const int32_t num) { if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index ad4782525..9f7826577 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -178,7 +178,7 @@ bool NotificationPreferencesDatabase::CheckKvStore() } bool NotificationPreferencesDatabase::PutSlotsToDisturbeDB( - const std::string &bundleName, const int &bundleUid, const std::vector> &slots) + const std::string &bundleName, const int32_t &bundleUid, const std::vector> &slots) { ANS_LOGD("%{public}s", __FUNCTION__); if (bundleName.empty()) { @@ -209,7 +209,7 @@ bool NotificationPreferencesDatabase::PutSlotsToDisturbeDB( } bool NotificationPreferencesDatabase::PutGroupsToDisturbeDB( - const std::string &bundleName, const int &bundleUid, const std::vector> &groups) + const std::string &bundleName, const int32_t &bundleUid, const std::vector> &groups) { if (bundleName.empty()) { ANS_LOGE("Bundle name is null."); @@ -290,7 +290,7 @@ bool NotificationPreferencesDatabase::PutShowBadge( } bool NotificationPreferencesDatabase::PutImportance( - const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int &importance) + const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int32_t &importance) { if (bundleInfo.GetBundleName().empty()) { ANS_LOGE("Bundle name is null."); @@ -308,7 +308,7 @@ bool NotificationPreferencesDatabase::PutImportance( } bool NotificationPreferencesDatabase::PutTotalBadgeNums( - const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int &totalBadgeNum) + const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int32_t &totalBadgeNum) { if (bundleInfo.GetBundleName().empty()) { ANS_LOGE("Bundle name is null."); @@ -482,7 +482,7 @@ void NotificationPreferencesDatabase::GetValueFromDisturbeDB( callback(status, value); } -bool NotificationPreferencesDatabase::CheckBundle(const std::string &bundleName, const int &bundleUid) +bool NotificationPreferencesDatabase::CheckBundle(const std::string &bundleName, const int32_t &bundleUid) { std::string bundleKeyStr = KEY_BUNDLE_LABEL + bundleName + std::to_string(bundleUid); ANS_LOGD("CheckBundle bundleKeyStr %{public}s", bundleKeyStr.c_str()); @@ -810,7 +810,7 @@ void NotificationPreferencesDatabase::GenerateEntry( entries.push_back(entry); } -bool NotificationPreferencesDatabase::SlotToEntry(const std::string &bundleName, const int &bundleUid, +bool NotificationPreferencesDatabase::SlotToEntry(const std::string &bundleName, const int32_t &bundleUid, const sptr &slot, std::vector &entries) { if (slot == nullptr) { @@ -858,7 +858,7 @@ void NotificationPreferencesDatabase::GenerateSlotEntry(const std::string &bundl entries); } -bool NotificationPreferencesDatabase::GroupToEntry(const std::string &bundleName, const int &bundleUid, +bool NotificationPreferencesDatabase::GroupToEntry(const std::string &bundleName, const int32_t &bundleUid, const sptr &group, std::vector &entries) { @@ -1025,9 +1025,9 @@ void NotificationPreferencesDatabase::StringToVector(const std::string &str, std } } -int NotificationPreferencesDatabase::StringToInt(const std::string &str) const +int32_t NotificationPreferencesDatabase::StringToInt(const std::string &str) const { - int value = 0; + int32_t value = 0; if (!str.empty()) { value = stoi(str, nullptr); } @@ -1345,7 +1345,7 @@ std::string NotificationPreferencesDatabase::GenerateBundleLablel( return bundleInfo.GetBundleName().append(std::to_string(bundleInfo.GetBundleUid())); } -void NotificationPreferencesDatabase::GetDoNotDisturbType(NotificationPreferencesInfo &info, int userId) +void NotificationPreferencesDatabase::GetDoNotDisturbType(NotificationPreferencesInfo &info, int32_t userId) { std::string key = std::string().append(KEY_DO_NOT_DISTURB_TYPE).append(KEY_UNDER_LINE).append(std::to_string(userId)); @@ -1370,7 +1370,7 @@ void NotificationPreferencesDatabase::GetDoNotDisturbType(NotificationPreference }); } -void NotificationPreferencesDatabase::GetDoNotDisturbBeginDate(NotificationPreferencesInfo &info, int userId) +void NotificationPreferencesDatabase::GetDoNotDisturbBeginDate(NotificationPreferencesInfo &info, int32_t userId) { std::string key = std::string().append(KEY_DO_NOT_DISTURB_BEGIN_DATE).append(KEY_UNDER_LINE).append(std::to_string(userId)); @@ -1394,7 +1394,7 @@ void NotificationPreferencesDatabase::GetDoNotDisturbBeginDate(NotificationPrefe }); } -void NotificationPreferencesDatabase::GetDoNotDisturbEndDate(NotificationPreferencesInfo &info, int userId) +void NotificationPreferencesDatabase::GetDoNotDisturbEndDate(NotificationPreferencesInfo &info, int32_t userId) { std::string key = std::string().append(KEY_DO_NOT_DISTURB_END_DATE).append(KEY_UNDER_LINE).append(std::to_string(userId)); @@ -1418,7 +1418,7 @@ void NotificationPreferencesDatabase::GetDoNotDisturbEndDate(NotificationPrefere }); } -void NotificationPreferencesDatabase::GetEnableAllNotification(NotificationPreferencesInfo &info, int userId) +void NotificationPreferencesDatabase::GetEnableAllNotification(NotificationPreferencesInfo &info, int32_t userId) { std::string key = std::string().append(KEY_ENABLE_ALL_NOTIFICATION).append(KEY_UNDER_LINE).append(std::to_string(userId)); diff --git a/services/ans/src/notification_preferences_info.cpp b/services/ans/src/notification_preferences_info.cpp index ce0708be9..bd2788d84 100644 --- a/services/ans/src/notification_preferences_info.cpp +++ b/services/ans/src/notification_preferences_info.cpp @@ -31,12 +31,12 @@ std::string NotificationPreferencesInfo::BundleInfo::GetBundleName() const return bundleName_; } -void NotificationPreferencesInfo::BundleInfo::SetImportance(const int &level) +void NotificationPreferencesInfo::BundleInfo::SetImportance(const int32_t &level) { importance_ = level; } -int NotificationPreferencesInfo::BundleInfo::GetImportance() const +int32_t NotificationPreferencesInfo::BundleInfo::GetImportance() const { return importance_; } @@ -51,12 +51,12 @@ bool NotificationPreferencesInfo::BundleInfo::GetIsShowBadge() const return isShowBadge_; } -void NotificationPreferencesInfo::BundleInfo::SetBadgeTotalNum(const int &num) +void NotificationPreferencesInfo::BundleInfo::SetBadgeTotalNum(const int32_t &num) { badgeTotalNum_ = num; } -int NotificationPreferencesInfo::BundleInfo::GetBadgeTotalNum() const +int32_t NotificationPreferencesInfo::BundleInfo::GetBadgeTotalNum() const { return badgeTotalNum_; } @@ -182,7 +182,7 @@ bool NotificationPreferencesInfo::BundleInfo::GetAllGroups(std::vectorGetAppUserId() == SUBSCRIBE_USER_INIT) { - int userId = SUBSCRIBE_USER_INIT; - int callingUid = IPCSkeleton::GetCallingUid(); + int32_t userId = SUBSCRIBE_USER_INIT; + int32_t callingUid = IPCSkeleton::GetCallingUid(); ErrCode ret = OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(callingUid, userId); if (ret != ERR_OK) { ANS_LOGD("Get userId failed, callingUid = <%{public}d>", callingUid); @@ -118,7 +118,7 @@ void NotificationSubscriberManager::NotifyConsumed( } void NotificationSubscriberManager::NotifyCanceled( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) + const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { if (handler_ == nullptr) { ANS_LOGE("handler is nullptr"); @@ -325,7 +325,7 @@ void NotificationSubscriberManager::NotifyConsumedInner( } void NotificationSubscriberManager::NotifyCanceledInner( - const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) + const sptr ¬ification, const sptr ¬ificationMap, int32_t deleteReason) { ANS_LOGD("%{public}s notification->GetUserId <%{public}d>", __FUNCTION__, notification->GetUserId()); int32_t recvUserId = notification->GetNotificationRequest().GetReceiverUserId(); diff --git a/services/ans/src/system_event_observer.cpp b/services/ans/src/system_event_observer.cpp index 796e085b6..8ada7d50d 100644 --- a/services/ans/src/system_event_observer.cpp +++ b/services/ans/src/system_event_observer.cpp @@ -51,7 +51,7 @@ sptr SystemEventObserver::GetBundleOption(AAFwk::Want { auto element = want.GetElement(); std::string bundleName = element.GetBundleName(); - int uid = want.GetIntParam(AppExecFwk::Constants::UID, -1); + int32_t uid = want.GetIntParam(AppExecFwk::Constants::UID, -1); sptr bundleOption = new NotificationBundleOption(bundleName, uid); if (bundleOption == nullptr) { ANS_LOGE("Failed to create bundleOption."); diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 5c5122450..26342a3f1 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -96,7 +96,7 @@ public: void OnCanceled(const std::shared_ptr &request) override {} void OnCanceled(const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason) override + const std::shared_ptr &sortingMap, int32_t deleteReason) override {} void OnConsumed(const std::shared_ptr &request) override {} diff --git a/services/ans/test/unittest/ans_ut_constant.h b/services/ans/test/unittest/ans_ut_constant.h index 8319782bc..55f5f9d7c 100644 --- a/services/ans/test/unittest/ans_ut_constant.h +++ b/services/ans/test/unittest/ans_ut_constant.h @@ -20,11 +20,11 @@ namespace OHOS { namespace Notification { -constexpr unsigned int NATIVE_TOKEN = 0; -constexpr unsigned int NON_NATIVE_TOKEN = 1; -constexpr int SYSTEM_APP_UID = 100; -constexpr int NON_SYSTEM_APP_UID = 1000; -constexpr int NON_BUNDLE_NAME_UID = 2000; +constexpr uint32_t NATIVE_TOKEN = 0; +constexpr uint32_t NON_NATIVE_TOKEN = 1; +constexpr int32_t SYSTEM_APP_UID = 100; +constexpr int32_t NON_SYSTEM_APP_UID = 1000; +constexpr int32_t NON_BUNDLE_NAME_UID = 2000; const std::string TEST_DEFUALT_BUNDLE = "bundleName"; } // namespace Notification } // namespace OHOS diff --git a/services/distributed/include/distributed_flow_control.h b/services/distributed/include/distributed_flow_control.h index 71ec01bfd..90accf6c1 100644 --- a/services/distributed/include/distributed_flow_control.h +++ b/services/distributed/include/distributed_flow_control.h @@ -31,10 +31,10 @@ public: * @param kvStoreSecondMaxinum The maximum number of calls to SingleKvStore interface per second. * @param kvStoreMinuteMaxinum The maximum number of calls to SingleKvStore interface per minute. */ - DistributedFlowControl(int kvManagerSecondMaxinum = KVMANAGER_MAXINUM_PER_SECOND, - int kvManagerMinuteMaxinum = KVMANAGER_MAXINUM_PER_MINUTE, - int kvStoreSecondMaxinum = KVSTORE_MAXINUM_PER_SECOND, - int kvStoreMinuteMaxinum = KVSTORE_MAXINUM_PER_MINUTE); + DistributedFlowControl(size_t kvManagerSecondMaxinum = KVMANAGER_MAXINUM_PER_SECOND, + size_t kvManagerMinuteMaxinum = KVMANAGER_MAXINUM_PER_MINUTE, + size_t kvStoreSecondMaxinum = KVSTORE_MAXINUM_PER_SECOND, + size_t kvStoreMinuteMaxinum = KVSTORE_MAXINUM_PER_MINUTE); /** * @brief Check if DistributedKvDataManager interface flow control can pass. @@ -61,16 +61,16 @@ public: void KvStoreFlowControlClear(void); protected: - static const int KVMANAGER_MAXINUM_PER_SECOND = 50; - static const int KVMANAGER_MAXINUM_PER_MINUTE = 500; - static const int KVSTORE_MAXINUM_PER_SECOND = 1000; - static const int KVSTORE_MAXINUM_PER_MINUTE = 10000; + static const size_t KVMANAGER_MAXINUM_PER_SECOND = 50; + static const size_t KVMANAGER_MAXINUM_PER_MINUTE = 500; + static const size_t KVSTORE_MAXINUM_PER_SECOND = 1000; + static const size_t KVSTORE_MAXINUM_PER_MINUTE = 10000; private: - int kvManagerSecondMaxinum_; - int kvManagerMinuteMaxinum_; - int kvStoreSecondMaxinum_; - int kvStoreMinuteMaxinum_; + size_t kvManagerSecondMaxinum_; + size_t kvManagerMinuteMaxinum_; + size_t kvStoreSecondMaxinum_; + size_t kvStoreMinuteMaxinum_; std::list kvDataManagerTimestampList_; std::list kvStoreTimestampList_; }; diff --git a/services/distributed/src/distributed_flow_control.cpp b/services/distributed/src/distributed_flow_control.cpp index fabe5b589..de5827102 100644 --- a/services/distributed/src/distributed_flow_control.cpp +++ b/services/distributed/src/distributed_flow_control.cpp @@ -18,7 +18,8 @@ namespace OHOS { namespace Notification { DistributedFlowControl::DistributedFlowControl( - int kvManagerSecondMaxinum, int kvManagerMinuteMaxinum, int kvStoreSecondMaxinum, int kvStoreMinuteMaxinum) + size_t kvManagerSecondMaxinum, size_t kvManagerMinuteMaxinum, size_t kvStoreSecondMaxinum, + size_t kvStoreMinuteMaxinum) : kvManagerSecondMaxinum_(kvManagerSecondMaxinum), kvManagerMinuteMaxinum_(kvManagerMinuteMaxinum), kvStoreSecondMaxinum_(kvStoreSecondMaxinum), @@ -32,12 +33,12 @@ bool DistributedFlowControl::KvManagerFlowControl(void) return now - value > std::chrono::minutes(1); }); - int listSize = kvStoreTimestampList_.size(); + size_t listSize = kvStoreTimestampList_.size(); if (listSize >= kvManagerMinuteMaxinum_) { return false; } - int count = 0; + size_t count = 0; for (auto value : kvDataManagerTimestampList_) { if (now - value > std::chrono::seconds(1)) { if (count >= kvManagerSecondMaxinum_) { @@ -60,12 +61,12 @@ bool DistributedFlowControl::KvStoreFlowControl(void) return now - value > std::chrono::minutes(1); }); - int listSize = kvStoreTimestampList_.size(); + size_t listSize = kvStoreTimestampList_.size(); if (listSize >= kvStoreMinuteMaxinum_) { return false; } - int count = 0; + size_t count = 0; for (auto value : kvStoreTimestampList_) { if (now - value > std::chrono::seconds(1)) { if (count >= kvStoreSecondMaxinum_) { diff --git a/services/distributed/src/distributed_preferences.cpp b/services/distributed/src/distributed_preferences.cpp index 76564a1e2..ba469f54d 100644 --- a/services/distributed/src/distributed_preferences.cpp +++ b/services/distributed/src/distributed_preferences.cpp @@ -59,7 +59,7 @@ bool DistributedPreferences::InitDistributedAllInfo(void) } if (resolveKey.isMainKey) { - int value = atoi(entry.value.ToString().data()); + int32_t value = atoi(entry.value.ToString().data()); preferencesInfo_->SetDistributedEnable(static_cast(value)); } else { preferencesInfo_->SetDistributedBundleEnable( diff --git a/services/test/moduletest/ans_module_test.cpp b/services/test/moduletest/ans_module_test.cpp index e8764ebcd..5c891cd2b 100644 --- a/services/test/moduletest/ans_module_test.cpp +++ b/services/test/moduletest/ans_module_test.cpp @@ -175,9 +175,9 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_002, Function | SmallTest | Level1) EXPECT_EQ((int)g_advancedNotificationService->Publish(label, req1), (int)ERR_OK); EXPECT_EQ((int)g_advancedNotificationService->Publish("testLabel1", req2), (int)ERR_OK); EXPECT_EQ((int)g_advancedNotificationService->GetActiveNotifications(notificationsReqs), (int)ERR_OK); - int num; + uint64_t num; g_advancedNotificationService->GetActiveNotificationNums(num); - EXPECT_EQ((int)num, (int)3); + EXPECT_EQ(num, 3); EXPECT_EQ((int)g_advancedNotificationService->Cancel(2, "testLabel1"), (int)ERR_OK); EXPECT_EQ((int)g_advancedNotificationService->GetAllActiveNotifications(notifications), (int)ERR_OK); EXPECT_EQ((int)notifications.size(), (int)2); @@ -1748,7 +1748,7 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0107, Function | SmallTest | Level1) // remove request g_advancedNotificationService->Delete("_0_1_testLabel_0"); g_advancedNotificationService->Delete("_0_1_testLabel_1"); - int nums = -1; + uint64_t nums = 0; g_advancedNotificationService->GetActiveNotificationNums(nums); EXPECT_EQ(nums, 0); g_advancedNotificationService->Unsubscribe(subscriber->GetImpl(), subscriberInfo); @@ -1797,7 +1797,7 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0108, Function | SmallTest | Level1) // remove request g_advancedNotificationService->DeleteAllByUser(0); - int nums = -1; + uint64_t nums = 0; g_advancedNotificationService->GetActiveNotificationNums(nums); EXPECT_EQ(nums, 0); g_advancedNotificationService->Unsubscribe(subscriber->GetImpl(), subscriberInfo); diff --git a/tools/dump/include/shell_command.h b/tools/dump/include/shell_command.h index 319c084c8..3e335aaa3 100644 --- a/tools/dump/include/shell_command.h +++ b/tools/dump/include/shell_command.h @@ -100,7 +100,7 @@ public: virtual ErrCode init() = 0; protected: - static constexpr int MIN_ARGUMENT_NUMBER = 2; + static constexpr int32_t MIN_ARGUMENT_NUMBER = 2; int argc_; char **argv_; diff --git a/tools/dump/src/shell_command.cpp b/tools/dump/src/shell_command.cpp index 215018965..4f44c8030 100644 --- a/tools/dump/src/shell_command.cpp +++ b/tools/dump/src/shell_command.cpp @@ -41,7 +41,7 @@ ShellCommand::~ShellCommand() ErrCode ShellCommand::OnCommand() { - int result = OHOS::ERR_OK; + int32_t result = OHOS::ERR_OK; auto respond = commandMap_[cmd_]; if (respond == nullptr) { resultReceiver_.append(GetCommandErrorMsg()); @@ -57,7 +57,7 @@ ErrCode ShellCommand::OnCommand() std::string ShellCommand::ExecCommand() { - int result = CreateCommandMap(); + int32_t result = CreateCommandMap(); if (result != OHOS::ERR_OK) { ANS_LOGE("failed to create command map.\n"); } -- Gitee