diff --git a/frameworks/ans/core/common/include/ans_log_wrapper.h b/frameworks/ans/core/common/include/ans_log_wrapper.h index cbcc8a923dc870f735c88a3c881e91622965cb0e..720de8d61b7a402e3e16bc31f616ea190611c550 100644 --- a/frameworks/ans/core/common/include/ans_log_wrapper.h +++ b/frameworks/ans/core/common/include/ans_log_wrapper.h @@ -40,18 +40,40 @@ public: AnsLogWrapper() = delete; ~AnsLogWrapper() = delete; + /** + * @brief Judge the level of the log. + * + * @param level Indicates the level of the log. + * @return Returns ture on passed, otherwise false. + */ static bool JudgeLevel(const AnsLogLevel &level); + /** + * @brief Set the level of the log. + * + * @param level Indicates the level of the log. + */ static void SetLogLevel(const AnsLogLevel &level) { level_ = level; } + /** + * @brief Get the level of the log. + * + * @return Indicates the level of the log. + */ static const AnsLogLevel &GetLogLevel() { return level_; } + /** + * @brief Get the brief name of the file. + * + * @param str Indicates the full name of the file. + * @return Indicates the file name. + */ static std::string GetBriefFileName(const char *str); private: diff --git a/frameworks/ans/core/include/ans_image_util.h b/frameworks/ans/core/include/ans_image_util.h index 8478efabe385a9a7db1bdbcd40722911ac1c4cdd..37ab9a58406210776b6ad14fc055f8cb311602f6 100644 --- a/frameworks/ans/core/include/ans_image_util.h +++ b/frameworks/ans/core/include/ans_image_util.h @@ -29,21 +29,61 @@ public: static const uint8_t NUM_TEN; static const size_t TWO_TIMES; + /** + * @brief Packs an image to a string. + * + * @param pixelMap Indicates the image to be packaged. + * @param format Indicates the format of the image. + * @return Returns a string. + */ static std::string PackImage( const std::shared_ptr &pixelMap, const std::string &format = IMAGE_FORMAT_JPEG); + /** + * @brief Unpacks the string to an image. + * + * @param pixelMapStr Indicates the string of image. + * @return Returns an image object. + */ static std::shared_ptr UnPackImage(const std::string &pixelMapStr); + /** + * @brief Packs an image to a file. + * + * @param pixelMap Indicates the image to be packaged. + * @param outFilePath Indicates the path of the output file. + * @param format Indicates the format of the image. + * @return Returns true if succeed; returns false otherwise. + */ static bool PackImage2File( const std::shared_ptr &pixelMap, const std::string &outFilePath, const std::string &format = IMAGE_FORMAT_JPEG); + /** + * @brief Creates an image from a file. + * + * @param inFilePath Indicates the path of the input file. + * @param format Indicates the format of the image. + * @return Returns an image object. + */ static std::shared_ptr CreatePixelMap( const std::string &inFilePath, const std::string &format = IMAGE_FORMAT_JPEG); + /** + * @brief Converts a binary string to a hexadecimal string. + * + * @param strBin Indicates the input binary string. + * @return Returns a hexadecimal string. + */ static std::string BinToHex(const std::string &strBin); + /** + * @brief Converts a hexadecimal string to a binary string. + * + * @param strHex Indicates the input hexadecimal string. + * @return Returns a binary string. + */ static std::string HexToBin(const std::string &strHex); }; } // namespace Notification diff --git a/frameworks/ans/core/include/ans_manager_death_recipient.h b/frameworks/ans/core/include/ans_manager_death_recipient.h index 671a4e33dc405b564d78839d1d6c880fc056f781..b4f76c440c44e48f1e3f4370a2555b0fee83355d 100644 --- a/frameworks/ans/core/include/ans_manager_death_recipient.h +++ b/frameworks/ans/core/include/ans_manager_death_recipient.h @@ -22,9 +22,13 @@ namespace Notification { class AnsManagerDeathRecipient : public IRemoteObject::DeathRecipient { public: AnsManagerDeathRecipient() = default; - virtual ~AnsManagerDeathRecipient() = default; + /** + * @brief The callback function on remote object died. + * + * @param remote Indicates the died object. + */ virtual void OnRemoteDied(const wptr &object) override; }; } // namespace Notification diff --git a/frameworks/ans/core/include/ans_manager_interface.h b/frameworks/ans/core/include/ans_manager_interface.h index 2f04e1eba7dfdfc426c6eb40850a61ec3f73215b..c55228d36203868b68b29b9824762eda41ca5952 100644 --- a/frameworks/ans/core/include/ans_manager_interface.h +++ b/frameworks/ans/core/include/ans_manager_interface.h @@ -35,103 +35,668 @@ namespace Notification { class IAnsManager : public IRemoteBroker { public: IAnsManager() = default; - virtual ~IAnsManager() override = default; + virtual ~IAnsManager() = default; DISALLOW_COPY_AND_MOVE(IAnsManager); DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.IAnsManager"); + /** + * @brief Publishes a notification with a specified label. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param label Indicates the label of the notification to publish. + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Publish(const std::string &label, const sptr ¬ification) = 0; + + /** + * @brief Publishes a notification on a specified remote device. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param deviceId Indicates the ID of the remote device. If this parameter is null or an empty string, + * the notification will be published on the local device. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishToDevice(const sptr ¬ification, const std::string &deviceId) = 0; + + /** + * @brief Cancels a published notification matching the specified label and notificationId. + * + * @param notificationId Indicates the ID of the notification to cancel. + * @param label Indicates the label of the notification to cancel. + * @return Returns cancel notification result. + */ virtual ErrCode Cancel(int notificationId, const std::string &label) = 0; + + /** + * @brief Cancels all the published notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelAll() = 0; + + /** + * @brief Adds a notification slot by type. + * + * @param slotType Indicates the notification slot type to be added. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) = 0; + + /** + * @brief Creates multiple notification slots. + * + * @param slots Indicates the notification slots to create. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AddSlots(const std::vector> &slots) = 0; + + /** + * @brief Deletes a created notification slot based on the slot ID. + * + * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) = 0; + + /** + * @brief Deletes all notification slots. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveAllSlots() = 0; + + /** + * @brief Creates multiple notification slot groups. + * @note The precautions for using this method are similar to those for + * AddNotificationSlotGroup(NotificationSlotGroup). + * + * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AddSlotGroups(std::vector> groups) = 0; + + /** + * @brief Queries a created notification slot. + * + * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This + * parameter must be specified. + * @param slot Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) = 0; + + /** + * @brief Obtains all notification slots of this application. + * + * @param slots Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlots(std::vector> &slots) = 0; + + /** + * @brief Queries a created notification slot group. + * + * @param groupId Indicates the ID of the slot group. + * @param group Indicates the created NotificationSlotGroup. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotGroup(const std::string &groupId, sptr &group) = 0; + + /** + * @brief Obtains a list of created notification slot groups. + * + * @param groups Indicates a list of created notification slot groups. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotGroups(std::vector> &groups) = 0; + /** + * @brief Obtains the number of slot. + * + * @param bundleOption Indicates the bundle name and uid of the application. + * @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; + /** + * @brief Deletes multiple notification slot groups. + * + * @param groupIds Indicates the IDs of the notification slot groups, which is created by + * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveSlotGroups(const std::vector &groupIds) = 0; + + /** + * @brief Obtains active notifications of the current application in the system. + * + * @param notifications Indicates active NotificationRequest objects of the current application. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetActiveNotifications(std::vector> ¬ifications) = 0; + + /** + * @brief Obtains the number of active notifications of the current application in the system. + * + * @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; + + /** + * @brief Obtains all active notifications in the current system. The caller must have system permissions to + * call this method. + * + * @param notifications Indicates all active notifications of this application. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetAllActiveNotifications(std::vector> ¬ifications) = 0; + + /** + * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method + * to obtain particular active notifications, you must have received the notifications and obtained the key + * via {Notification::GetKey()}. + * + * @param key Indicates the key array for querying corresponding active notifications. + * If this parameter is null, this method returns all active notifications in the system. + * @param notification Indicates the set of active notifications corresponding to the specified key. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSpecialActiveNotifications( const std::vector &key, std::vector> ¬ifications) = 0; + + /** + * @brief Allows another application to act as an agent to publish notifications in the name of your application + * bundle. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationAgent(const std::string &agent) = 0; + + /** + * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application if + * any; returns null otherwise. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetNotificationAgent(std::string &agent) = 0; + + /** + * @brief Checks whether your application has permission to publish notifications by calling + * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the + * given representativeBundle. + * + * @param representativeBundle Indicates the name of application bundle your application is representing. + * @param canPublish Indicates whether your application has permission to publish notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) = 0; + + /** + * @brief Publishes a notification in the name of a specified application bundle. + * @note If the notification to be published has the same ID as a published notification that has not been canceled, + * the existing notification will be replaced by the new one. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param representativeBundle Indicates the name of the application bundle that allows your application to publish + * notifications for it by calling setNotificationAgent. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishAsBundle( const sptr notification, const std::string &representativeBundle) = 0; + + /** + * @brief Sets the number of active notifications of the current application as the number to be displayed on the + * notification badge. + * + * @param num Indicates the badge number. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationBadgeNum(int num) = 0; + + /** + * @brief Obtains the importance level of this application. + * + * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, + 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) = 0; + + /** + * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. + * + * @param granted True if the application has permission; false for otherwise. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) = 0; + + /** + * @brief Set whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetPrivateNotificationsAllowed(bool allow) = 0; + + /** + * @brief Get whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) = 0; + + /** + * @brief Delete notification based on key. + * + * @param key Indicates the key to delete notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Delete(const std::string &key) = 0; + /** + * @brief Delete notification. + * + * @param bundleOption Indicates the NotificationBundleOption of the notification. + * @param notificationId Indicates the id of the notification. + * @param label Indicates the label of the notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveNotification( const sptr &bundleOption, int notificationId, const std::string &label) = 0; + /** + * @brief Delete all notifications. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveAllNotifications(const sptr &bundleOption) = 0; + /** + * @brief Remove notifications based on bundle. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DeleteByBundle(const sptr &bundleOption) = 0; + /** + * @brief Remove all notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DeleteAll() = 0; + + /** + * @brief Get all the slots corresponding to the bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotsByBundle( const sptr &bundleOption, std::vector> &slots) = 0; + + /** + * @brief Update slots according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) = 0; + + /** + * @brief Update slotgroup according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groups Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode UpdateSlotGroups( const sptr &bundleOption, const std::vector> &groups) = 0; + + /** + * @brief Allow notifications to be sent based on the deviceId. + * + * @param deviceId Indicates the device Id. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RequestEnableNotification(const std::string &deviceId) = 0; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for current bundle. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) = 0; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for all bundles. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) = 0; + + /** + * @brief Set whether to allow the specified bundle to send notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledForSpecialBundle( const std::string &deviceId, const sptr &bundleOption, bool enabled) = 0; + + /** + * @brief Sets whether the bundle allows the banner to display notification. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) = 0; + + /** + * @brief Gets whether the bundle allows the badge to display the status of notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) = 0; + + /** + * @brief Gets whether allows the badge to display the status of notifications. + * + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetShowBadgeEnabled(bool &enabled) = 0; + + /** + * @brief Subscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Subscribe(const sptr &subscriber, const sptr &info) = 0; + + /** + * @brief Unsubscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Unsubscribe( const sptr &subscriber, const sptr &info) = 0; + + /** + * @brief Obtains whether notifications are suspended. + * + * @param suspended Indicates the suspended status. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AreNotificationsSuspended(bool &suspended) = 0; + + /** + * @brief Get the notification sorting status of the current app. + * + * @param sortingMap Indicates the NotificationSortingMap object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetCurrentAppSorting(sptr &sortingMap) = 0; + + /** + * @brief Checks whether this device is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsAllowedNotify(bool &allowed) = 0; + + /** + * @brief Checks whether this application is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsAllowedNotifySelf(bool &allowed) = 0; + + /** + * @brief Checks whether notifications are allowed for a specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) = 0; + /** + * @brief Set do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetDoNotDisturbDate(const sptr &date) = 0; + + /** + * @brief Get do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetDoNotDisturbDate(sptr &date) = 0; + + /** + * @brief Get whether Do Not Disturb mode is supported. + * + * @param doesSupport Indicates the flag that supports DND mode. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) = 0; + /** + * @brief Cancel notifications according to group. + * + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelGroup(const std::string &groupName) = 0; + + /** + * @brief Delete notifications according to bundle and group. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveGroupByBundle( const sptr &bundleOption, const std::string &groupName) = 0; + /** + * @brief Gets whether distributed notification is enabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsDistributedEnabled(bool &enabled) = 0; + + /** + * @brief Sets distributed notification enabled or disabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode EnableDistributed(bool enabled) = 0; + + /** + * @brief Sets distributed notification enabled or disabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) = 0; + + /** + * @brief Sets distributed notification enabled or disabled for current bundle. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode EnableDistributedSelf(bool enabled) = 0; + + /** + * @brief Gets whether distributed notification is enabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) = 0; + + /** + * @brief Get the reminder type of the current device. + * + * @param remindType Reminder type for the device. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) = 0; + /** + * @brief Dump current running status for debuging. + * + * @param dumpOption Indicates the dump action that needs to be performed. + * @param dumpInfo Indicates the dump information. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode ShellDump(const std::string &dumpOption, std::vector &dumpInfo) = 0; + + /** + * @brief Publishes a continuous notification. + * + * @param request Notification requests that need to be posted. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishContinuousTaskNotification(const sptr &request) = 0; + + /** + * @brief Cancels a continuous notification. + * + * @param label Identifies the label of the specified notification. + * @param notificationId Identifies the id of the specified notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) = 0; + + /** + * @brief Publishes a reminder notification. + * + * @param reminder Identifies the reminder notification request that needs to be published. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishReminder(sptr &reminder) = 0; + + /** + * @brief Cancel a reminder notifications. + * + * @param reminderId Identifies the reminders id that needs to be canceled. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelReminder(const int32_t reminderId) = 0; + + /** + * @brief Get all valid reminder notifications. + * + * @param reminders Identifies the list of all valid notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetValidReminders(std::vector> &reminders) = 0; + + /** + * @brief Cancel all reminder notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelAllReminders() = 0; + + /** + * @brief Checks whether this device is support template. + * + * @param templateName Identifies the template name for searching as a condition. + * @param support Identifies the support flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) = 0; + + /** + * @brief Checks Whether the specified users is allowed to publish notifications. + * + * @param userId Identifies the user's id. + * @param allowed Identifies the allowed flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) = 0; + + /** + * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must + * have system permissions to call this method. + * + * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only + * be null or an empty string, indicating the current device. + * @param enabled Specifies whether to allow all applications to publish notifications. The value true + * indicates that notifications are allowed, and the value false indicates that notifications + * are not allowed. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) = 0; + + /** + * @brief Delete all notifications by user. + * + * @param userId Indicates the user id. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DeleteAllByUser(const int32_t &userId) = 0; + + /** + * @brief Set do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) = 0; + + /** + * @brief Get the do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) = 0; protected: diff --git a/frameworks/ans/core/include/ans_manager_proxy.h b/frameworks/ans/core/include/ans_manager_proxy.h index 5f8f568bf3ab051c9be413de7dbcbcef7c85bf23..4843289d3faa9f7eb29e39f2eb70009b3e2bb2c6 100644 --- a/frameworks/ans/core/include/ans_manager_proxy.h +++ b/frameworks/ans/core/include/ans_manager_proxy.h @@ -28,98 +28,662 @@ public: ~AnsManagerProxy() override; DISALLOW_COPY_AND_MOVE(AnsManagerProxy); + /** + * @brief Publishes a notification with a specified label. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param label Indicates the label of the notification to publish. + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Publish(const std::string &label, const sptr ¬ification) override; + + /** + * @brief Publishes a notification on a specified remote device. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param deviceId Indicates the ID of the remote device. If this parameter is null or an empty string, + * the notification will be published on the local device. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishToDevice(const sptr ¬ification, const std::string &deviceId) override; + + /** + * @brief Cancels a published notification matching the specified label and notificationId. + * + * @param notificationId Indicates the ID of the notification to cancel. + * @param label Indicates the label of the notification to cancel. + * @return Returns cancel notification result. + */ ErrCode Cancel(int notificationId, const std::string &label) override; + + /** + * @brief Cancels all the published notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelAll() override; + + /** + * @brief Adds a notification slot by type. + * + * @param slotType Indicates the notification slot type to be added. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; + + /** + * @brief Creates multiple notification slots. + * + * @param slots Indicates the notification slots to create. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AddSlots(const std::vector> &slots) override; + + /** + * @brief Deletes a created notification slot based on the slot ID. + * + * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; + + /** + * @brief Deletes all notification slots. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveAllSlots() override; + + /** + * @brief Creates multiple notification slot groups. + * @note The precautions for using this method are similar to those for + * AddNotificationSlotGroup(NotificationSlotGroup). + * + * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AddSlotGroups(std::vector> groups) override; + + /** + * @brief Queries a created notification slot. + * + * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This + * parameter must be specified. + * @param slot Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) override; + + /** + * @brief Obtains all notification slots of this application. + * + * @param slots Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlots(std::vector> &slots) override; + + /** + * @brief Queries a created notification slot group. + * + * @param groupId Indicates the ID of the slot group. + * @param group Indicates the created NotificationSlotGroup. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotGroup(const std::string &groupId, sptr &group) override; + + /** + * @brief Obtains a list of created notification slot groups. + * + * @param groups Indicates a list of created notification slot groups. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotGroups(std::vector> &groups) override; + /** + * @brief Obtains the number of slot. + * + * @param bundleOption Indicates the bundle name and uid of the application. + * @param num Indicates the number of slot. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotNumAsBundle(const sptr &bundleOption, int &num) override; + /** + * @brief Deletes multiple notification slot groups. + * + * @param groupIds Indicates the IDs of the notification slot groups, which is created by + * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveSlotGroups(const std::vector &groupIds) override; + + /** + * @brief Obtains active notifications of the current application in the system. + * + * @param notifications Indicates active NotificationRequest objects of the current application. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetActiveNotifications(std::vector> ¬ifications) override; + + /** + * @brief Obtains the number of active notifications of the current application in the system. + * + * @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; + + /** + * @brief Obtains all active notifications in the current system. The caller must have system permissions to + * call this method. + * + * @param notifications Indicates all active notifications of this application. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override; + + /** + * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method + * to obtain particular active notifications, you must have received the notifications and obtained the key + * via {Notification::GetKey()}. + * + * @param key Indicates the key array for querying corresponding active notifications. + * If this parameter is null, this method returns all active notifications in the system. + * @param notification Indicates the set of active notifications corresponding to the specified key. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSpecialActiveNotifications( const std::vector &key, std::vector> ¬ifications) override; + + /** + * @brief Allows another application to act as an agent to publish notifications in the name of your application + * bundle. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationAgent(const std::string &agent) override; + + /** + * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application if + * any; returns null otherwise. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetNotificationAgent(std::string &agent) override; + + /** + * @brief Checks whether your application has permission to publish notifications by calling + * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the + * given representativeBundle. + * + * @param representativeBundle Indicates the name of application bundle your application is representing. + * @param canPublish Indicates whether your application has permission to publish notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; + + /** + * @brief Publishes a notification in the name of a specified application bundle. + * @note If the notification to be published has the same ID as a published notification that has not been canceled, + * the existing notification will be replaced by the new one. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param representativeBundle Indicates the name of the application bundle that allows your application to publish + * notifications for it by calling setNotificationAgent. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishAsBundle( const sptr notification, const std::string &representativeBundle) override; + + /** + * @brief Sets the number of active notifications of the current application as the number to be displayed on the + * notification badge. + * + * @param num Indicates the badge number. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationBadgeNum(int num) override; + + /** + * @brief Obtains the importance level of this application. + * + * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, + 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; + + /** + * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. + * + * @param granted True if the application has permission; false for otherwise. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; + + /** + * @brief Set whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetPrivateNotificationsAllowed(bool allow) override; + + /** + * @brief Get whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetPrivateNotificationsAllowed(bool &allow) override; + /** + * @brief Delete notification. + * + * @param bundleOption Indicates the NotificationBundleOption of the notification. + * @param notificationId Indicates the id of the notification. + * @param label Indicates the label of the notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveNotification( const sptr &bundleOption, int notificationId, const std::string &label) override; + /** + * @brief Delete all notifications. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveAllNotifications(const sptr &bundleOption) override; + /** + * @brief Delete notification based on key. + * + * @param key Indicates the key to delete notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Delete(const std::string &key) override; + /** + * @brief Remove notifications based on bundle. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DeleteByBundle(const sptr &bundleOption) override; + /** + * @brief Remove all notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DeleteAll() override; + + /** + * @brief Get all the slots corresponding to the bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotsByBundle( const sptr &bundleOption, std::vector> &slots) override; + + /** + * @brief Update slots according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; + + /** + * @brief Update slotgroup according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groups Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode UpdateSlotGroups(const sptr &bundleOption, const std::vector> &groups) override; + + /** + * @brief Allow notifications to be sent based on the deviceId. + * + * @param deviceId Indicates the device Id. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RequestEnableNotification(const std::string &deviceId) override; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for current bundle. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for all bundles. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; + + /** + * @brief Set whether to allow the specified bundle to send notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledForSpecialBundle( const std::string &deviceId, const sptr &bundleOption, bool enabled) override; + + /** + * @brief Sets whether the bundle allows the banner to display notification. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) override; + + /** + * @brief Gets whether the bundle allows the badge to display the status of notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) override; + + /** + * @brief Gets whether allows the badge to display the status of notifications. + * + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetShowBadgeEnabled(bool &enabled) override; + + /** + * @brief Subscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Subscribe(const sptr &subscriber, const sptr &info) override; + + /** + * @brief Unsubscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Unsubscribe(const sptr &subscriber, const sptr &info) override; + + /** + * @brief Obtains whether notifications are suspended. + * + * @param suspended Indicates the suspended status. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AreNotificationsSuspended(bool &suspended) override; + + /** + * @brief Get the notification sorting status of the current app. + * + * @param sortingMap Indicates the NotificationSortingMap object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetCurrentAppSorting(sptr &sortingMap) override; + + /** + * @brief Checks whether this device is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsAllowedNotify(bool &allowed) override; + + /** + * @brief Checks whether this application is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsAllowedNotifySelf(bool &allowed) override; + + /** + * @brief Checks whether notifications are allowed for a specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) override; + /** + * @brief Set do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetDoNotDisturbDate(const sptr &date) override; + + /** + * @brief Get do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetDoNotDisturbDate(sptr &date) override; + + /** + * @brief Get whether Do Not Disturb mode is supported. + * + * @param doesSupport Indicates the flag that supports DND mode. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; + + /** + * @brief Cancel notifications according to group. + * + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelGroup(const std::string &groupName) override; + + /** + * @brief Delete notifications according to bundle and group. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveGroupByBundle( const sptr &bundleOption, const std::string &groupName) override; + /** + * @brief Gets whether distributed notification is enabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsDistributedEnabled(bool &enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode EnableDistributed(bool enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled for current bundle. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode EnableDistributedSelf(bool enabled) override; + + /** + * @brief Gets whether distributed notification is enabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) override; + + /** + * @brief Get the reminder type of the current device. + * + * @param remindType Reminder type for the device. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; + /** + * @brief Dump current running status for debuging. + * + * @param dumpOption Indicates the dump action that needs to be performed. + * @param dumpInfo Indicates the dump information. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode ShellDump(const std::string &dumpOption, std::vector &dumpInfo) override; + + /** + * @brief Publishes a continuous notification. + * + * @param request Notification requests that need to be posted. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishContinuousTaskNotification(const sptr &request) override; + + /** + * @brief Cancels a continuous notification. + * + * @param label Identifies the label of the specified notification. + * @param notificationId Identifies the id of the specified notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; + + /** + * @brief Checks whether this device is support template. + * + * @param templateName Identifies the template name for searching as a condition. + * @param support Identifies the support flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; + /** + * @brief Publishes a reminder notification. + * + * @param reminder Identifies the reminder notification request that needs to be published. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishReminder(sptr &reminder) override; + + /** + * @brief Cancel a reminder notifications. + * + * @param reminderId Identifies the reminders id that needs to be canceled. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelReminder(const int32_t reminderId) override; + + /** + * @brief Get all valid reminder notifications. + * + * @param reminders Identifies the list of all valid notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetValidReminders(std::vector> &reminders) override; + + /** + * @brief Cancel all reminder notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelAllReminders() override; + + /** + * @brief Checks Whether the specified users is allowed to publish notifications. + * + * @param userId Identifies the user's id. + * @param allowed Identifies the allowed flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; + + /** + * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must + * have system permissions to call this method. + * + * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only + * be null or an empty string, indicating the current device. + * @param enabled Specifies whether to allow all applications to publish notifications. The value true + * indicates that notifications are allowed, and the value false indicates that notifications + * are not allowed. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledByUser(const int32_t &userId, bool enabled) override; + + /** + * @brief Delete all notifications by user. + * + * @param userId Indicates the user id. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DeleteAllByUser(const int32_t &userId) override; + + /** + * @brief Set do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; + + /** + * @brief Get the do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; private: diff --git a/frameworks/ans/core/include/ans_manager_stub.h b/frameworks/ans/core/include/ans_manager_stub.h index ff87901abd4b3431973ed9fdbddaeef3be66e0b7..b67631694f0262757fccc1023923793ea7b6a083 100644 --- a/frameworks/ans/core/include/ans_manager_stub.h +++ b/frameworks/ans/core/include/ans_manager_stub.h @@ -30,102 +30,682 @@ public: ~AnsManagerStub() override; DISALLOW_COPY_AND_MOVE(AnsManagerStub); + /** + * @brief Handle remote request. + * + * @param data Indicates the input parcel. + * @param reply Indicates the output parcel. + * @param option Indicates the message option. + * @return Returns ERR_OK on success, others on failure. + */ virtual int OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + /** + * @brief Publishes a notification with a specified label. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param label Indicates the label of the notification to publish. + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Publish(const std::string &label, const sptr ¬ification) override; + + /** + * @brief Publishes a notification on a specified remote device. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param deviceId Indicates the ID of the remote device. If this parameter is null or an empty string, + * the notification will be published on the local device. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishToDevice( const sptr ¬ification, const std::string &deviceId) override; + + /** + * @brief Cancels a published notification matching the specified label and notificationId. + * + * @param notificationId Indicates the ID of the notification to cancel. + * @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; + + /** + * @brief Cancels all the published notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelAll() override; + + /** + * @brief Adds a notification slot by type. + * + * @param slotType Indicates the notification slot type to be added. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; + + /** + * @brief Creates multiple notification slots. + * + * @param slots Indicates the notification slots to create. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AddSlots(const std::vector> &slots) override; + + /** + * @brief Deletes a created notification slot based on the slot ID. + * + * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; + + /** + * @brief Deletes all notification slots. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveAllSlots() override; + + /** + * @brief Creates multiple notification slot groups. + * @note The precautions for using this method are similar to those for + * AddNotificationSlotGroup(NotificationSlotGroup). + * + * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AddSlotGroups(std::vector> groups) override; + + /** + * @brief Queries a created notification slot. + * + * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This + * parameter must be specified. + * @param slot Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotByType( const NotificationConstant::SlotType &slotType, sptr &slot) override; + + /** + * @brief Obtains all notification slots of this application. + * + * @param slots Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlots(std::vector> &slots) override; + + /** + * @brief Queries a created notification slot group. + * + * @param groupId Indicates the ID of the slot group. + * @param group Indicates the created NotificationSlotGroup. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotGroup(const std::string &groupId, sptr &group) override; + + /** + * @brief Obtains a list of created notification slot groups. + * + * @param groups Indicates a list of created notification slot groups. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotGroups(std::vector> &groups) override; + + /** + * @brief Obtains the number of slot. + * + * @param bundleOption Indicates the bundle name and uid of the application. + * @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; + + /** + * @brief Deletes multiple notification slot groups. + * + * @param groupIds Indicates the IDs of the notification slot groups, which is created by + * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveSlotGroups(const std::vector &groupIds) override; + + /** + * @brief Obtains active notifications of the current application in the system. + * + * @param notifications Indicates active NotificationRequest objects of the current application. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetActiveNotifications(std::vector> ¬ifications) override; + + /** + * @brief Obtains the number of active notifications of the current application in the system. + * + * @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; + + /** + * @brief Obtains all active notifications in the current system. The caller must have system permissions to + * call this method. + * + * @param notifications Indicates all active notifications of this application. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override; + + /** + * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method + * to obtain particular active notifications, you must have received the notifications and obtained the key + * via {Notification::GetKey()}. + * + * @param key Indicates the key array for querying corresponding active notifications. + * If this parameter is null, this method returns all active notifications in the system. + * @param notification Indicates the set of active notifications corresponding to the specified key. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSpecialActiveNotifications( const std::vector &key, std::vector> ¬ifications) override; + + /** + * @brief Allows another application to act as an agent to publish notifications in the name of your application + * bundle. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationAgent(const std::string &agent) override; + + /** + * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application if + * any; returns null otherwise. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetNotificationAgent(std::string &agent) override; + + /** + * @brief Checks whether your application has permission to publish notifications by calling + * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the + * given representativeBundle. + * + * @param representativeBundle Indicates the name of application bundle your application is representing. + * @param canPublish Indicates whether your application has permission to publish notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; + + /** + * @brief Publishes a notification in the name of a specified application bundle. + * @note If the notification to be published has the same ID as a published notification that has not been canceled, + * the existing notification will be replaced by the new one. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param representativeBundle Indicates the name of the application bundle that allows your application to publish + * notifications for it by calling setNotificationAgent. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishAsBundle( const sptr notification, const std::string &representativeBundle) override; + + /** + * @brief Sets the number of active notifications of the current application as the number to be displayed on the + * notification badge. + * + * @param num Indicates the badge number. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationBadgeNum(int num) override; + + /** + * @brief Obtains the importance level of this application. + * + * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, + 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; + + /** + * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. + * + * @param granted True if the application has permission; false for otherwise. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; + + /** + * @brief Set whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetPrivateNotificationsAllowed(bool allow) override; + + /** + * @brief Get whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) override; + + /** + * @brief Delete notification. + * + * @param bundleOption Indicates the NotificationBundleOption of the notification. + * @param notificationId Indicates the id of the notification. + * @param label Indicates the label of the notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveNotification( const sptr &bundleOption, int notificationId, const std::string &label) override; + + /** + * @brief Delete all notifications. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveAllNotifications(const sptr &bundleOption) override; + + /** + * @brief Delete notification based on key. + * + * @param key Indicates the key to delete notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Delete(const std::string &key) override; + + /** + * @brief Remove notifications based on bundle. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DeleteByBundle(const sptr &bundleOption) override; + + /** + * @brief Remove all notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DeleteAll() override; + + /** + * @brief Get all the slots corresponding to the bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetSlotsByBundle( const sptr &bundleOption, std::vector> &slots) override; + + /** + * @brief Update slots according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; + + /** + * @brief Update slotgroup according to bundle. + * @param bundleOption Bundle as a condition. + * @param groups Groups that needs to be updated. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode UpdateSlotGroups(const sptr &bundleOption, const std::vector> &groups) override; + + /** + * @brief Allow notifications to be sent based on the deviceId. + * + * @param deviceId Indicates the device Id. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RequestEnableNotification(const std::string &deviceId) override; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for current bundle. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for all bundles. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; + + /** + * @brief Set whether to allow the specified bundle to send notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledForSpecialBundle( const std::string &deviceId, const sptr &bundleOption, bool enabled) override; + + /** + * @brief Sets whether the bundle allows the banner to display notification. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetShowBadgeEnabledForBundle( const sptr &bundleOption, bool enabled) override; + + /** + * @brief Gets whether the bundle allows the badge to display the status of notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetShowBadgeEnabledForBundle( const sptr &bundleOption, bool &enabled) override; + + /** + * @brief Gets whether allows the badge to display the status of notifications. + * + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetShowBadgeEnabled(bool &enabled) override; + + /** + * @brief Subscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Subscribe( const sptr &subscriber, const sptr &info) override; + + /** + * @brief Unsubscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode Unsubscribe( const sptr &subscriber, const sptr &info) override; + + /** + * @brief Obtains whether notifications are suspended. + * + * @param suspended Indicates the suspended status. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode AreNotificationsSuspended(bool &suspended) override; + + /** + * @brief Get the notification sorting status of the current app. + * + * @param sortingMap Indicates the NotificationSortingMap object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetCurrentAppSorting(sptr &sortingMap) override; + + /** + * @brief Checks whether this device is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsAllowedNotify(bool &allowed) override; + + /** + * @brief Checks whether this application is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsAllowedNotifySelf(bool &allowed) override; + + /** + * @brief Checks whether notifications are allowed for a specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsSpecialBundleAllowedNotify( const sptr &bundleOption, bool &allowed) override; + /** + * @brief Set do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetDoNotDisturbDate(const sptr &date) override; + + /** + * @brief Get do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetDoNotDisturbDate(sptr &date) override; + + /** + * @brief Get whether Do Not Disturb mode is supported. + * + * @param doesSupport Indicates the flag that supports DND mode. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; + + /** + * @brief Cancel notifications according to group. + * + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelGroup(const std::string &groupName) override; + + /** + * @brief Delete notifications according to bundle and group. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode RemoveGroupByBundle( const sptr &bundleOption, const std::string &groupName) override; + /** + * @brief Gets whether distributed notification is enabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsDistributedEnabled(bool &enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode EnableDistributed(bool enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode EnableDistributedByBundle( const sptr &bundleOption, bool enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled for current bundle. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode EnableDistributedSelf(bool enabled) override; + + /** + * @brief Gets whether distributed notification is enabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsDistributedEnableByBundle( const sptr &bundleOption, bool &enabled) override; + + /** + * @brief Get the reminder type of the current device. + * + * @param remindType Reminder type for the device. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; + /** + * @brief Dump current running status for debuging. + * + * @param dumpOption Indicates the dump action that needs to be performed. + * @param dumpInfo Indicates the dump information. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode ShellDump(const std::string &dumpOption, std::vector &dumpInfo) override; + + /** + * @brief Publishes a continuous notification. + * + * @param request Notification requests that need to be posted. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishContinuousTaskNotification(const sptr &request) override; + + /** + * @brief Cancels a continuous notification. + * + * @param label Identifies the label of the specified notification. + * @param notificationId Identifies the id of the specified notification. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; + + /** + * @brief Publishes a reminder notification. + * + * @param reminder Identifies the reminder notification request that needs to be published. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode PublishReminder(sptr &reminder) override; + + /** + * @brief Cancel a reminder notifications. + * + * @param reminderId Identifies the reminders id that needs to be canceled. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelReminder(const int32_t reminderId) override; + + /** + * @brief Get all valid reminder notifications. + * + * @param reminders Identifies the list of all valid notifications. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetValidReminders(std::vector> &reminders) override; + + /** + * @brief Cancel all reminder notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode CancelAllReminders() override; + + /** + * @brief Checks whether this device is support template. + * + * @param templateName Identifies the template name for searching as a condition. + * @param support Identifies the support flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; + + /** + * @brief Checks Whether the specified users is allowed to publish notifications. + * + * @param userId Identifies the user's id. + * @param allowed Identifies the allowed flag. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; + + /** + * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must + * have system permissions to call this method. + * + * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only + * be null or an empty string, indicating the current device. + * @param enabled Specifies whether to allow all applications to publish notifications. The value true + * indicates that notifications are allowed, and the value false indicates that notifications + * are not allowed. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override; + + /** + * @brief Delete all notifications by user. + * + * @param userId Indicates the user id. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode DeleteAllByUser(const int32_t &userId) override; + + /** + * @brief Set do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; + + /** + * @brief Get the do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; private: diff --git a/frameworks/ans/core/include/ans_notification.h b/frameworks/ans/core/include/ans_notification.h index 62a01657b99ff6a36fce3f05bac9abb24f3b22c3..e9f3d504de482623b0b9ffdabbe7f3dccd2fc9e6 100644 --- a/frameworks/ans/core/include/ans_notification.h +++ b/frameworks/ans/core/include/ans_notification.h @@ -27,7 +27,7 @@ namespace Notification { class AnsNotification { public: /** - * Creates a notification slot. + * @brief Creates a notification slot. * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the @@ -42,7 +42,7 @@ public: ErrCode AddNotificationSlot(const NotificationSlot &slot); /** - * Adds a notification slot by type. + * @brief Adds a notification slot by type. * * @param slotType Indicates the notification slot type to be added. * @return Returns add notification slot result. @@ -50,7 +50,7 @@ public: ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType); /** - * Creates multiple notification slots. + * @brief Creates multiple notification slots. * * @param slots Indicates the notification slots to create. * @return Returns add notification slots result. @@ -58,7 +58,7 @@ public: ErrCode AddNotificationSlots(const std::vector &slots); /** - * Deletes a created notification slot based on the slot ID. + * @brief Deletes a created notification slot based on the slot ID. * * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot * This parameter must be specified. @@ -67,14 +67,14 @@ public: ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType); /** - * Deletes all notification slots. + * @brief Deletes all notification slots. * * @return Returns remove all slots result. */ ErrCode RemoveAllSlots(); /** - * Queries a created notification slot. + * @brief Queries a created notification slot. * * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This * parameter must be specified. @@ -84,14 +84,15 @@ public: ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr &slot); /** - * Obtains all notification slots of this application. + * @brief Obtains all notification slots of this application. + * * @param slots Indicates the created NotificationSlot. * @return Returns all notification slots of this application. */ ErrCode GetNotificationSlots(std::vector> &slots); /** - * Creates a notification slot group to which a NotificationSlot object can be bound by + * @brief Creates a notification slot group to which a NotificationSlot object can be bound by * calling NotificationSlot::SetSlotGroup(string). * @note A NotificationSlotGroup instance cannot be used directly after being initialized. * Instead, you have to call this method to create a notification slot group so that you can bind @@ -105,7 +106,7 @@ public: ErrCode AddNotificationSlotGroup(const NotificationSlotGroup &slotGroup); /** - * Creates multiple notification slot groups. + * @brief Creates multiple notification slot groups. * @note The precautions for using this method are similar to those for * AddNotificationSlotGroup(NotificationSlotGroup). * @@ -115,7 +116,7 @@ public: ErrCode AddNotificationSlotGroups(const std::vector &slotGroups); /** - * Deletes a created notification slot group based on the slot group ID. + * @brief Deletes a created notification slot group based on the slot group ID. * * @param slotGroupId Indicates the ID of the notification slot group, which is created by * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. @@ -124,7 +125,7 @@ public: ErrCode RemoveNotificationSlotGroup(const std::string &slotGroupId); /** - * Queries a created notification slot group. + * @brief Queries a created notification slot group. * * @param groupId Indicates the ID of the slot group. * @param group Indicates the created NotificationSlotGroup. @@ -133,7 +134,7 @@ public: ErrCode GetNotificationSlotGroup(const std::string &groupId, sptr &group); /** - * Obtains a list of created notification slot groups. + * @brief Obtains a list of created notification slot groups. * * @param groups Indicates a list of created notification slot groups. * @return Returns get notification slot groups result. @@ -141,7 +142,7 @@ public: ErrCode GetNotificationSlotGroups(std::vector> &groups); /** - * Obtains number of slot. + * @brief Obtains number of slot. * * @param bundleOption Indicates the bundle name and uid of the application. * @param num Indicates number of slot. @@ -150,30 +151,30 @@ public: ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, int &num); /** - * Publishes a notification. + * @brief Publishes a notification. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * * @param request Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. - * @return returns publish notification result. + * @return Returns publish notification result. */ ErrCode PublishNotification(const NotificationRequest &request); /** - * Publishes a notification with a specified label. + * @brief Publishes a notification with a specified label. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * * @param label Indicates the label of the notification to publish. * @param request Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. - * @return returns publish notification result. + * @return Returns publish notification result. */ ErrCode PublishNotification(const std::string &label, const NotificationRequest &request); /** - * Publishes a notification on a specified remote device. + * @brief Publishes a notification on a specified remote device. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * @@ -181,38 +182,39 @@ public: * This parameter must be specified. * @param deviceId Indicates the ID of the remote device. If this parameter is null or an empty string, * the notification will be published on the local device. - * @return returns publish notification result. + * @return Returns publish notification result. */ ErrCode PublishNotification(const NotificationRequest &request, const std::string &deviceId); /** - * Cancels a published notification. + * @brief Cancels a published notification. * * @param notificationId Indicates the unique notification ID in the application. * The value must be the ID of a published notification. * Otherwise, this method does not take effect. - * @return returns cancel notification result. + * @return Returns cancel notification result. */ ErrCode CancelNotification(int32_t notificationId); /** - * Cancels a published notification matching the specified label and notificationId. + * @brief Cancels a published notification matching the specified label and notificationId. * * @param label Indicates the label of the notification to cancel. * @param notificationId Indicates the ID of the notification to cancel. - * @return returns cancel notification result. + * @return Returns cancel notification result. */ ErrCode CancelNotification(const std::string &label, int32_t notificationId); /** - * Cancels all the published notifications. + * @brief Cancels all the published notifications. * @note To cancel a specified notification, see CancelNotification(int_32). - * @return returns cancel all notifications result. + * + * @return Returns cancel all notifications result. */ ErrCode CancelAllNotifications(); /** - * Obtains the number of active notifications of the current application in the system. + * @brief Obtains the number of active notifications of the current application in the system. * * @param num Indicates the number of active notifications of the current application. * @return Returns get active notification nums result. @@ -220,14 +222,15 @@ public: ErrCode GetActiveNotificationNums(int32_t &num); /** - * Obtains active notifications of the current application in the system. + * @brief Obtains active notifications of the current application in the system. + * * @param request Indicates active NotificationRequest objects of the current application. * @return Returns get active notifications result. */ ErrCode GetActiveNotifications(std::vector> &request); /** - * Obtains the map for sorting notifications of the current application. + * @brief Obtains the map for sorting notifications of the current application. * * @param sortingMap Indicates the NotificationSortingMap object for the current application. * @return Returns get current app sorting result. @@ -235,8 +238,8 @@ public: ErrCode GetCurrentAppSorting(sptr &sortingMap); /** - * Allows another application to act as an agent to publish notifications in the name of your application bundle. - * You can revoke this authorization by passing null to this method. + * @brief Allows another application to act as an agent to publish notifications in the name of your application + * bundle. You can revoke this authorization by passing null to this method. * * @param agent Indicates the name of the application bundle that can publish notifications for your application. * @return Returns set notification agent result. @@ -244,7 +247,7 @@ public: ErrCode SetNotificationAgent(const std::string &agent); /** - * Obtains the name of the application bundle that can publish notifications in the name of your application. + * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. * * @param agent Indicates the name of the application bundle that can publish notifications for your application if * any; returns null otherwise. @@ -253,7 +256,7 @@ public: ErrCode GetNotificationAgent(std::string &agent); /** - * Checks whether your application has permission to publish notifications by calling + * @brief Checks whether your application has permission to publish notifications by calling * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the * given representativeBundle. * @@ -264,7 +267,7 @@ public: ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish); /** - * Publishes a notification in the name of a specified application bundle. + * @brief Publishes a notification in the name of a specified application bundle. * @note If the notification to be published has the same ID as a published notification that has not been canceled, * the existing notification will be replaced by the new one. * @@ -277,14 +280,15 @@ public: ErrCode PublishNotificationAsBundle(const std::string &representativeBundle, const NotificationRequest &request); /** - * Sets the number of active notifications of the current application as the number to be displayed on the + * @brief Sets the number of active notifications of the current application as the number to be displayed on the * notification badge. + * * @return Returns set notification badge num result. */ ErrCode SetNotificationBadgeNum(); /** - * Sets the number to be displayed on the notification badge of the application. + * @brief Sets the number to be displayed on the notification badge of the application. * * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged. * The value 0 indicates that no badge is displayed on the application icon. @@ -294,7 +298,7 @@ public: ErrCode SetNotificationBadgeNum(int32_t num); /** - * Checks whether this application has permission to publish notifications. The caller must have + * @brief Checks whether this application has permission to publish notifications. The caller must have * system permissions to call this method. * * @param allowed True if this application has the permission; returns false otherwise @@ -303,7 +307,7 @@ public: ErrCode IsAllowedNotify(bool &allowed); /** - * Checks whether this application has permission to publish notifications. + * @brief Checks whether this application has permission to publish notifications. * * @param allowed True if this application has the permission; returns false otherwise * @return Returns is allowed notify result. @@ -311,7 +315,7 @@ public: ErrCode IsAllowedNotifySelf(bool &allowed); /** - * Allow the current application to publish notifications on a specified device. + * @brief Allows the current application to publish notifications on a specified device. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can * only be null or an empty string, indicating the current device. @@ -320,7 +324,7 @@ public: ErrCode RequestEnableNotification(std::string &deviceId); /** - * Checks whether this application is in the suspended state.Applications in this state cannot publish + * @brief Checks whether this application is in the suspended state.Applications in this state cannot publish * notifications. * * @param suspended True if this application is suspended; returns false otherwise. @@ -329,7 +333,7 @@ public: ErrCode AreNotificationsSuspended(bool &suspended); /** - * Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. + * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. * * @param hasPermission True if this application is suspended; returns false otherwise. * @return Returns has notification policy access permission. @@ -337,7 +341,7 @@ public: ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission); /** - * Obtains the importance level of this application. + * @brief Obtains the importance level of this application. * * @param importance the importance level of this application, which can be LEVEL_NONE, LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. @@ -346,7 +350,7 @@ public: ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance); /** - * Subscribes to notifications from all applications. This method can be called only by applications + * @brief Subscribes to notifications from all applications. This method can be called only by applications * with required system permissions. * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. @@ -362,7 +366,7 @@ public: ErrCode SubscribeNotification(const NotificationSubscriber &subscriber); /** - * Subscribes to all notifications based on the filtering criteria. This method can be called only + * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only * by applications with required system permissions. * @note After {subscribeInfo} is specified, a subscriber receives only the notifications that * meet the filter criteria specified by {subscribeInfo}. @@ -382,7 +386,7 @@ public: const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo); /** - * Unsubscribes from all notifications. This method can be called only by applications with required + * @brief Unsubscribes from all notifications. This method can be called only by applications with required * system permissions. * @note Generally, you subscribe to a notification by calling the * {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application @@ -399,7 +403,7 @@ public: ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber); /** - * Unsubscribes from all notifications based on the filtering criteria. This method can be called + * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called * only by applications with required system permissions. * @note A subscriber will no longer receive the notifications from specified notification sources. * @@ -412,7 +416,7 @@ public: ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo); /** - * Removes a specified removable notification of other applications. + * @brief Removes a specified removable notification of other applications. * @note Your application must have platform signature to use this method. * * @param key Indicates the key of the notification to remove. @@ -421,7 +425,7 @@ public: ErrCode RemoveNotification(const std::string &key); /** - * Removes a specified removable notification of other applications. + * @brief Removes a specified removable notification of other applications. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. @@ -433,7 +437,7 @@ public: const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label); /** - * Removes a specified removable notification of other applications. + * @brief Removes a specified removable notification of other applications. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. @@ -442,7 +446,7 @@ public: ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption); /** - * Removes all removable notifications of a specified bundle. + * @brief Removes all removable notifications of a specified bundle. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. @@ -451,14 +455,15 @@ public: ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption); /** - * Removes all removable notifications in the system. + * @brief Removes all removable notifications in the system. * @note Your application must have platform signature to use this method. + * * @return Returns remove notifications result. */ ErrCode RemoveNotifications(); /** - * Returns all notification slots belonging to the specified bundle. + * @brief Obtains all notification slots belonging to the specified bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param slots Indicates a list of notification slots. @@ -468,7 +473,7 @@ public: const NotificationBundleOption &bundleOption, std::vector> &slots); /** - * Update all notification slots for the specified bundle. + * @brief Updates all notification slots for the specified bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param slots Indicates a list of new notification slots. @@ -478,7 +483,7 @@ public: const NotificationBundleOption &bundleOption, const std::vector> &slots); /** - * Update all notification slot groups for the specified bundle. + * @brief Updates all notification slot groups for the specified bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param groups Indicates a list of new notification slot groups. @@ -488,7 +493,7 @@ public: const NotificationBundleOption &bundleOption, const std::vector> &groups); /** - * Obtains all active notifications in the current system. The caller must have system permissions to + * @brief Obtains all active notifications in the current system. The caller must have system permissions to * call this method. * * @param notification Indicates all active notifications of this application. @@ -497,7 +502,7 @@ public: ErrCode GetAllActiveNotifications(std::vector> ¬ification); /** - * Obtains the active notifications corresponding to the specified key in the system. To call this method + * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method * to obtain particular active notifications, you must have received the notifications and obtained the key * via {Notification::GetKey()}. * @@ -510,7 +515,7 @@ public: const std::vector key, std::vector> ¬ification); /** - * Checks whether a specified application has the permission to publish notifications. If bundle specifies + * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies * the current application, no permission is required for calling this method. If bundle specifies another * application, the caller must have system permissions. * @@ -521,8 +526,8 @@ public: ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed); /** - * Sets whether to allow all applications to publish notifications on a specified device. The caller must have - * system permissions to call this method. + * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must + * have system permissions to call this method. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only * be null or an empty string, indicating the current device. @@ -534,7 +539,7 @@ public: ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled); /** - * Sets whether to allow the current application to publish notifications on a specified device. The caller + * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller * must have system permissions to call this method. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can @@ -547,7 +552,7 @@ public: ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled); /** - * Sets whether to allow a specified application to publish notifications on a specified device. The caller + * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller * must have system permissions to call this method. * * @param bundleOption Indicates the bundle name and uid of the application. @@ -562,7 +567,7 @@ public: const NotificationBundleOption &bundleOption, const std::string &deviceId, bool enabled); /** - * Sets whether to allow a specified application to to show badge. + * @brief Sets whether to allow a specified application to to show badge. * * @param bundleOption Indicates the bundle name and uid of the application. * @param enabled Specifies whether to allow the given application to show badge. @@ -571,7 +576,7 @@ public: ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled); /** - * Obtains the flag that whether to allow a specified application to to show badge. + * @brief Obtains the flag that whether to allow a specified application to to show badge. * * @param bundleOption Indicates the bundle name and uid of the application. * @param enabled Specifies whether to allow the given application to show badge. @@ -580,7 +585,7 @@ public: ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled); /** - * Obtains the flag that whether to allow the current application to to show badge. + * @brief Obtains the flag that whether to allow the current application to to show badge. * * @param enabled Specifies whether to allow the given application to show badge. * @return Returns get result. @@ -588,7 +593,7 @@ public: ErrCode GetShowBadgeEnabled(bool &enabled); /** - * Cancel the notification of the specified group of this application. + * @brief Cancels the notification of the specified group of this application. * * @param groupName the specified group name. * @return Returns cancel group result. @@ -596,16 +601,16 @@ public: ErrCode CancelGroup(const std::string &groupName); /** - * Remove the notification of the specified group of the specified application. + * @brief Removes the notification of the specified group of the specified application. * * @param bundleOption Indicates the bundle name and uid of the specified application. - * @param groupName the specified group name. + * @param groupName Indicates the specified group name. * @return Returns remove group by bundle result. */ ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName); /** - * Sets the do not disturb time. + * @brief Sets the do not disturb time. * @note Your application must have system signature to call this method. * * @param doNotDisturbDate Indicates the do not disturb time to set. @@ -614,7 +619,7 @@ public: ErrCode SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate); /** - * Obtains the do not disturb time. + * @brief Obtains the do not disturb time. * @note Your application must have system signature to call this method. * * @param doNotDisturbDate Indicates the do not disturb time to get. @@ -623,7 +628,7 @@ public: ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate); /** - * Obtains the flag that whether to support do not disturb mode. + * @brief Obtains the flag that whether to support do not disturb mode. * * @param doesSupport Specifies whether to support do not disturb mode. * @return Returns check result. @@ -631,7 +636,7 @@ public: ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport); /** - * Check if the device supports distributed notification. + * @brief Checks if the device supports distributed notification. * * @param enabled True if the device supports distributed notification; false otherwise. * @return Returns is distributed enabled result. @@ -639,7 +644,7 @@ public: ErrCode IsDistributedEnabled(bool &enabled); /** - * Set whether the device supports distributed notifications. + * @brief Sets whether the device supports distributed notifications. * * @param enable Specifies whether to enable the device to support distributed notification. * The value true indicates that the device is enabled to support distributed notifications, and @@ -649,7 +654,7 @@ public: ErrCode EnableDistributed(const bool enabled); /** - * Set whether an application supports distributed notifications. + * @brief Sets whether an application supports distributed notifications. * * @param bundleOption Indicates the bundle name and uid of an application. * @param enabled Specifies whether to enable an application to support distributed notification. @@ -661,7 +666,7 @@ public: ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled); /** - * Set whether this application supports distributed notifications. + * @brief Sets whether this application supports distributed notifications. * * @param enabled Specifies whether to enable this application to support distributed notification. * The value true indicates that this application is enabled to support distributed notifications, @@ -672,7 +677,7 @@ public: ErrCode EnableDistributedSelf(const bool enabled); /** - * Check whether an application supports distributed notifications. + * @brief Checks whether an application supports distributed notifications. * * @param bundleOption Indicates the bundle name and uid of an application. * @param enabled True if the application supports distributed notification; false otherwise. @@ -681,7 +686,7 @@ public: ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled); /** - * Obtains the device remind type. + * @brief Obtains the device remind type. * @note Your application must have system signature to call this method. * * @param remindType Indicates the device remind type to get. @@ -690,7 +695,8 @@ public: ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType); /** - * Publishes a continuous task notification. + * @brief Publishes a continuous task notification. + * * @param request Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. * @return Returns publish continuous task notification result. @@ -698,7 +704,7 @@ public: ErrCode PublishContinuousTaskNotification(const NotificationRequest &request); /** - * Cancels a published continuous task notification matching the specified label and notificationId. + * @brief Cancels a published continuous task notification matching the specified label and notificationId. * * @param label Indicates the label of the continuous task notification to cancel. * @param notificationId Indicates the ID of the continuous task notification to cancel. @@ -707,7 +713,7 @@ public: ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId); /** - * Obtains whether the template is supported by the system. + * @brief Obtains whether the template is supported by the system. * * @param support whether is it a system supported template. * @return Returns check result. @@ -715,17 +721,21 @@ public: ErrCode IsSupportTemplate(const std::string &templateName, bool &support); /** - * Reset ans manager proxy when OnRemoteDied called. + * @brief Resets ans manager proxy when OnRemoteDied called. */ void ResetAnsManagerProxy(); /** - * Shell dump. + * @brief Obtains specific informations via specified dump option. + * + * @param dumpOption Indicates the specified dump option. + * @param dumpInfo Indicates the container containing informations. + * @return Returns check result. */ ErrCode ShellDump(const std::string &dumpOption, std::vector &dumpInfo); /** - * Publishes a scheduled reminder. + * @brief Publishes a scheduled reminder. * * @param reminder Indicates a reminder. * @return Returns publish result. @@ -733,21 +743,22 @@ public: ErrCode PublishReminder(ReminderRequest &reminder); /** - * Cancels a specified reminder. + * @brief Cancels a specified reminder. * + * @param reminderId Indicates reminder Id. * @return Returns cancel result. */ ErrCode CancelReminder(const int32_t reminderId); /** - * Cancels all reminders of current third part application. + * @brief Cancels all reminders of current third part application. * * @return Returns cancel result. */ ErrCode CancelAllReminders(); /** - * Obtains all valid reminder notifications set by the current application. + * @brief Obtains all valid reminder notifications set by the current application. * * @param[out] validReminders Indicates the vector to store the result. * @return Returns get valid reminders result. @@ -755,7 +766,7 @@ public: ErrCode GetValidReminders(std::vector> &validReminders); /** - * Checks whether this application has permission to publish notifications under the user. + * @brief Checks whether this application has permission to publish notifications under the user. * * @param userId Indicates the userId of the application. * @param allowed True if the application has permissions; returns false otherwise. @@ -764,7 +775,7 @@ public: ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed); /** - * Sets whether to allow all applications to publish notifications on a specified user. + * @brief Sets whether to allow all applications to publish notifications on a specified user. * The caller must have system permissions to call this method. * * @param userId Indicates the ID of the user running the application. @@ -776,7 +787,7 @@ public: ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled); /** - * Removes notifications under specified user. + * @brief Removes notifications under specified user. * @note Your application must have platform signature to use this method. * * @param userId Indicates the ID of user whose notifications are to be removed. @@ -785,7 +796,7 @@ public: ErrCode RemoveNotifications(const int32_t &userId); /** - * Sets the do not disturb time on a specified user. + * @brief Sets the do not disturb time on a specified user. * @note Your application must have system signature to call this method. * * @param userId Indicates the specific user. @@ -795,7 +806,7 @@ public: ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate); /** - * Obtains the do not disturb time on a specified user. + * @brief Obtains the do not disturb time on a specified user. * @note Your application must have system signature to call this method. * * @param userId Indicates the specific user. @@ -806,44 +817,50 @@ public: private: /** - * Get Ans Manager proxy. + * @brief Gets Ans Manager proxy. * - * @return Get Ans Manager proxy success or not + * @return Returns true if succeed; returns false otherwise. */ bool GetAnsManagerProxy(); /** - * Can Publish Media Content + * @brief Checks if the MediaContent can be published. * - * @return Can publish return true otherwise return false + * @param request Indicates the specified request. + * @return Returns true if the MediaContent can be published; returns false otherwise. */ bool CanPublishMediaContent(const NotificationRequest &request) const; /** - * Check whether the picture size exceeds the limit in PixelMap + * @brief Checks whether the picture size exceeds the limit in PixelMap. * + * @param pixelMap Indicates the specified image. + * @param maxSize Indicates the limit size. * @return Returns true if the limit size is exceeded; returns false otherwise. */ bool CheckImageOverSizeForPixelMap( const std::shared_ptr &pixelMap, uint32_t maxSize); /** - * Check whether the picture size exceeds the limit in NotificationRequest's content + * @brief Checks whether the picture size exceeds the limit in NotificationRequest's content. * - * @return the ErrCode. + * @param request Indicates the specified request. + * @return Returns the ErrCode. */ ErrCode CheckImageSizeForContent(const NotificationRequest &request); /** - * Check whether the picture size exceeds the limit + * @brief Checks whether the picture size exceeds the limit. * - * @return the ErrCode. + * @param request Indicates the specified request. + * @return Returns the ErrCode. */ ErrCode CheckImageSize(const NotificationRequest &request); /** - * Check whether the notification doesn't support distribution + * @brief Checks whether the notification doesn't support distribution. * + * @param type Indicates the specified NotificationContent::Type. * @return Returns true if the notification doesn't support distribution; returns false otherwise. */ bool IsNonDistributedNotificationType(const NotificationContent::Type &type); diff --git a/frameworks/ans/core/include/ans_subscriber_interface.h b/frameworks/ans/core/include/ans_subscriber_interface.h index 3cd9fa689c607722e1a785d09e190c95e53a15b2..162f4eda49f923cbf42925a2c7157c4cd8ebe6d1 100644 --- a/frameworks/ans/core/include/ans_subscriber_interface.h +++ b/frameworks/ans/core/include/ans_subscriber_interface.h @@ -36,16 +36,68 @@ public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.IAnsSubscriber"); + /** + * @brief The callback function for the subscriber to establish a connection. + */ virtual void OnConnected() = 0; + + /** + * @brief The callback function for subscriber disconnected. + */ virtual void OnDisconnected() = 0; + + /** + * @brief The callback function on a notification published. + * + * @param notification Indicates the consumed notification. + */ virtual void OnConsumed(const sptr ¬ification) = 0; + + /** + * @brief The callback function on a notification published. + * + * @param notification Indicates the consumed notification. + * @param notificationMap Indicates the NotificationSortingMap object. + */ virtual void OnConsumed( const sptr ¬ification, const sptr ¬ificationMap) = 0; + + /** + * @brief The callback function on a notification canceled. + * + * @param notification Indicates the canceled notification. + */ virtual void OnCanceled(const sptr ¬ification) = 0; + + /** + * @brief The callback function on a notification canceled. + * + * @param notification Indicates the canceled notification. + * @param notificationMap Indicates the NotificationSortingMap object. + * @param deleteReason Indicates the delete reason. + */ virtual void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) = 0; + + /** + * @brief The callback function on the notifications updated. + * + * @param notificationMap Indicates the NotificationSortingMap object. + */ virtual void OnUpdated(const sptr ¬ificationMap) = 0; + + /** + * @brief The callback function on the do not disturb date changed. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + */ virtual void OnDoNotDisturbDateChange(const sptr &date) = 0; + + /** + * @brief The callback function on the notification enabled flag changed. + * + * @param callbackData Indicates the EnabledNotificationCallbackData object. + */ virtual void OnEnabledNotificationChanged(const sptr &callbackData) = 0; protected: diff --git a/frameworks/ans/core/include/ans_subscriber_proxy.h b/frameworks/ans/core/include/ans_subscriber_proxy.h index 1acdacf6048b6a48761771b9160185c666418c0c..4f08781fde1e64612bfcf16f8ebfed6ab7be49ac 100644 --- a/frameworks/ans/core/include/ans_subscriber_proxy.h +++ b/frameworks/ans/core/include/ans_subscriber_proxy.h @@ -28,16 +28,68 @@ public: ~AnsSubscriberProxy() override; DISALLOW_COPY_AND_MOVE(AnsSubscriberProxy); + /** + * @brief The callback function for the subscriber to establish a connection. + */ void OnConnected() override; + + /** + * @brief The callback function for subscriber disconnected. + */ void OnDisconnected() override; + + /** + * @brief The callback function on a notification published. + * + * @param notification Indicates the consumed notification. + */ void OnConsumed(const sptr ¬ification) override; + + /** + * @brief The callback function on a notification published. + * + * @param notification Indicates the consumed notification. + * @param notificationMap Indicates the NotificationSortingMap object. + */ void OnConsumed( const sptr ¬ification, const sptr ¬ificationMap) override; + + /** + * @brief The callback function on a notification canceled. + * + * @param notification Indicates the canceled notification. + */ void OnCanceled(const sptr ¬ification) override; + + /** + * @brief The callback function on a notification canceled. + * + * @param notification Indicates the canceled notification. + * @param notificationMap Indicates the NotificationSortingMap object. + * @param deleteReason Indicates the delete reason. + */ void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) override; + + /** + * @brief The callback function on the notifications updated. + * + * @param notificationMap Indicates the NotificationSortingMap object. + */ void OnUpdated(const sptr ¬ificationMap) override; + + /** + * @brief The callback function on the do not disturb date changed. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + */ void OnDoNotDisturbDateChange(const sptr &date) override; + + /** + * @brief The callback function on the notification enabled flag changed. + * + * @param callbackData Indicates the EnabledNotificationCallbackData object. + */ void OnEnabledNotificationChanged(const sptr &callbackData) override; private: diff --git a/frameworks/ans/core/include/ans_subscriber_stub.h b/frameworks/ans/core/include/ans_subscriber_stub.h index 303c81d29726c1be2423955177493e9d7c23a8d0..33ca81e7e14db9871fbc77eab23b4390ca372d02 100644 --- a/frameworks/ans/core/include/ans_subscriber_stub.h +++ b/frameworks/ans/core/include/ans_subscriber_stub.h @@ -27,19 +27,79 @@ public: ~AnsSubscriberStub() override; DISALLOW_COPY_AND_MOVE(AnsSubscriberStub); + /** + * @brief Handle remote request. + * + * @param data Indicates the input parcel. + * @param reply Indicates the output parcel. + * @param option Indicates the message option. + * @return Returns ERR_OK on success, others on failure. + */ virtual int OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + /** + * @brief The callback function for the subscriber to establish a connection. + */ void OnConnected() override; + + /** + * @brief The callback function for subscriber disconnected. + */ void OnDisconnected() override; + + /** + * @brief The callback function on a notification published. + * + * @param notification Indicates the consumed notification. + */ void OnConsumed(const sptr ¬ification) override; + + /** + * @brief The callback function on a notification published. + * + * @param notification Indicates the consumed notification. + * @param notificationMap Indicates the NotificationSortingMap object. + */ void OnConsumed( const sptr ¬ification, const sptr ¬ificationMap) override; + + /** + * @brief The callback function on a notification canceled. + * + * @param notification Indicates the canceled notification. + */ void OnCanceled(const sptr ¬ification) override; + + /** + * @brief The callback function on a notification canceled. + * + * @param notification Indicates the canceled notification. + * @param notificationMap Indicates the NotificationSortingMap object. + * @param deleteReason Indicates the delete reason. + */ void OnCanceled(const sptr ¬ification, const sptr ¬ificationMap, int deleteReason) override; + + /** + * @brief The callback function on the notifications updated. + * + * @param notificationMap Indicates the NotificationSortingMap object. + */ void OnUpdated(const sptr ¬ificationMap) override; + + /** + * @brief The callback function on the do not disturb date changed. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + */ void OnDoNotDisturbDateChange(const sptr &date) override; + + /** + * @brief The callback function on the notification enabled flag changed. + * + * @param callbackData Indicates the EnabledNotificationCallbackData object. + */ void OnEnabledNotificationChanged(const sptr &callbackData) override; private: diff --git a/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h b/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h index ef8c340aa619f52ae091bc7069378f9e9da6153f..0d2829aae10dd7436d59eee4d69a501be4edc018 100644 --- a/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h +++ b/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h @@ -31,14 +31,14 @@ namespace AppExecFwk { class MockBundleMgrService : public BundleMgrHost { public: MockBundleMgrService() - { - } + {} ~MockBundleMgrService() {} /** * @brief Obtains the ApplicationInfo based on a given bundle name. + * * @param appName Indicates the application bundle name to be queried. * @param flag Indicates the flag used to specify information contained * in the ApplicationInfo object that will be returned. @@ -51,8 +51,10 @@ public: { return true; } + /** * @brief Obtains information about all installed applications of a specified user. + * * @param flag Indicates the flag used to specify information contained * in the ApplicationInfo objects that will be returned. * @param userId Indicates the user ID. @@ -64,8 +66,10 @@ public: { return true; } + /** * @brief Obtains the BundleInfo based on a given bundle name. + * * @param bundleName Indicates the application bundle name to be queried. * @param flag Indicates the information contained in the BundleInfo object to be returned. * @param bundleInfo Indicates the obtained BundleInfo object. @@ -77,8 +81,10 @@ public: { return true; } + /** * @brief Obtains BundleInfo of all bundles available in the system. + * * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned. * @param bundleInfos Indicates all of the obtained BundleInfo objects. * @param userId Indicates the user ID. @@ -88,9 +94,11 @@ public: const BundleFlag flag, std::vector &bundleInfos, int32_t userId) override { return true; - }; + } + /** * @brief Obtains the application UID based on the given bundle name and user ID. + * * @param bundleName Indicates the bundle name of the application. * @param userId Indicates the user ID. * @return Returns the uid if successfully obtained; returns -1 otherwise. @@ -99,8 +107,10 @@ public: { return 0; } + /** * @brief Obtains the application ID based on the given bundle name and user ID. + * * @param bundleName Indicates the bundle name of the application. * @param userId Indicates the user ID. * @return Returns the application ID if successfully obtained; returns empty string otherwise. @@ -109,8 +119,10 @@ public: { return "bundlename"; } + /** * @brief Obtains the bundle name of a specified application based on the given UID. + * * @param uid Indicates the uid. * @param bundleName Indicates the obtained bundle name. * @return Returns true if the bundle name is successfully obtained; returns false otherwise. @@ -120,8 +132,10 @@ public: bundleName = "hello"; return true; } + /** * @brief Obtains all bundle names of a specified application based on the given application UID. + * * @param uid Indicates the uid. * @param bundleNames Indicates the obtained bundle names. * @return Returns true if the bundle names is successfully obtained; returns false otherwise. @@ -131,7 +145,9 @@ public: return true; } - /* @brief Obtains the formal name associated with the given UID. + /** + * @brief Obtains the formal name associated with the given UID. + * * @param uid Indicates the uid. * @param name Indicates the obtained formal name. * @return Returns true if the formal name is successfully obtained; returns false otherwise. @@ -140,8 +156,10 @@ public: { return true; } + /** * @brief Obtains an array of all group IDs associated with a specified bundle. + * * @param bundleName Indicates the bundle name. * @param gids Indicates the group IDs associated with the specified bundle. * @return Returns true if the gids is successfully obtained; returns false otherwise. @@ -150,8 +168,10 @@ public: { return true; } + /** * @brief Obtains the type of a specified application based on the given bundle name. + * * @param bundleName Indicates the bundle name. * @return Returns "system" if the bundle is a system application; returns "third-party" otherwise. */ @@ -159,8 +179,10 @@ public: { return ""; } + /** * @brief Check whether the app is system app by it's UID. + * * @param uid Indicates the uid. * @return Returns true if the bundle is a system application; returns false otherwise. */ @@ -168,6 +190,7 @@ public: /** * @brief Obtains the BundleInfo of application bundles based on the specified metaData. + * * @param metaData Indicates the metadata to get in the bundle. * @param bundleInfos Indicates all of the obtained BundleInfo objects. * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. @@ -176,8 +199,10 @@ public: { return true; } + /** * @brief Query the AbilityInfo by the given Want. + * * @param want Indicates the information of the ability. * @param abilityInfo Indicates the obtained AbilityInfo object. * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. @@ -186,8 +211,10 @@ public: { return true; } + /** * @brief Query the AbilityInfo by ability.uri in config.json. + * * @param abilityUri Indicates the uri of the ability. * @param abilityInfo Indicates the obtained AbilityInfo object. * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. @@ -196,17 +223,21 @@ public: { return true; } + /** * @brief Obtains the BundleInfo of all keep-alive applications in the system. + * * @param bundleInfos Indicates all of the obtained BundleInfo objects. * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. */ virtual bool QueryKeepAliveBundleInfos(std::vector &bundleInfos) override { return true; - }; + } + /** * @brief Obtains information about an application bundle contained in a ohos Ability Package (HAP). + * * @param hapFilePath Indicates the absolute file path of the HAP. * @param flag Indicates the information contained in the BundleInfo object to be returned. * @param bundleInfo Indicates the obtained BundleInfo object. @@ -217,8 +248,10 @@ public: { return true; } + /** * @brief Obtain the HAP module info of a specific ability. + * * @param abilityInfo Indicates the ability. * @param hapModuleInfo Indicates the obtained HapModuleInfo object. * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. @@ -227,8 +260,10 @@ public: { return true; } + /** * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. + * * @param bundleName Indicates the bundle name. * @param want Indicates the obtained launch Want object. * @return Returns true if the launch Want object is successfully obtained; returns false otherwise. @@ -237,9 +272,11 @@ public: { return true; } + /** * @brief Confirms with the permission management module to check whether a request prompt is required for granting * a certain permission. + * * @param bundleName Indicates the name of the bundle to check. * @param permission Indicates the permission to check. * @param userId Indicates the user id. @@ -252,8 +289,10 @@ public: { return true; } + /** * @brief Checks whether the publickeys of two bundles are the same. + * * @param firstBundleName Indicates the first bundle name. * @param secondBundleName Indicates the second bundle name. * @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found; @@ -264,15 +303,19 @@ public: { return 0; } + /** * @brief Checks whether a specified bundle has been granted a specific permission. + * * @param bundleName Indicates the name of the bundle to check. * @param permission Indicates the permission to check. * @return Returns 0 if the bundle has the permission; returns -1 otherwise. */ virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override; + /** * @brief Obtains detailed information about a specified permission. + * * @param permissionName Indicates the name of the ohos permission. * @param permissionDef Indicates the object containing detailed information about the given ohos permission. * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise. @@ -281,8 +324,10 @@ public: { return true; } + /** * @brief Obtains all known permission groups in the system. + * * @param permissionDefs Indicates the list of objects containing the permission group information. * @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise. */ @@ -290,8 +335,10 @@ public: { return true; } + /** * @brief Obtains all known permission groups in the system. + * * @param permissions Indicates the permission array. * @param appNames Indicates the list of application names that have the specified permissions. * @return Returns true if the application names is successfully obtained; returns false otherwise. @@ -301,8 +348,10 @@ public: { return true; } + /** * @brief Requests a certain permission from user. + * * @param bundleName Indicates the name of the bundle to request permission. * @param permission Indicates the permission to request permission. * @param userId Indicates the user id. @@ -313,8 +362,10 @@ public: { return true; } + /** * @brief Registers a callback for listening for permission changes of all UIDs. + * * @param callback Indicates the callback method to register. * @return Returns true if this function is successfully called; returns false otherwise. */ @@ -322,8 +373,10 @@ public: { return true; } + /** * @brief Registers a callback for listening for permission changes of specified UIDs. + * * @param uids Indicates the list of UIDs whose permission changes will be monitored. * @param callback Indicates the callback method to register. * @return Returns true if this function is successfully called; returns false otherwise. @@ -333,8 +386,10 @@ public: { return true; } - /** + + /** * @brief Unregisters a specified callback for listening for permission changes. + * * @param callback Indicates the callback method to register. * @return Returns true if this function is successfully called; returns false otherwise. */ @@ -342,8 +397,10 @@ public: { return true; } + /** * @brief Obtains the FormInfo objects provided by all applications on the device. + * * @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the * device. * @return Returns true if this function is successfully called; returns false otherwise. @@ -352,8 +409,10 @@ public: { return true; } + /** * @brief Obtains the FormInfo objects provided by a specified application on the device. + * * @param bundleName Indicates the bundle name of the application. * @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the * device. @@ -366,6 +425,7 @@ public: /** * @brief Obtains the FormInfo objects provided by a specified. + * * @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the * device. * @param moduleName Indicates the module name of the application. @@ -377,8 +437,10 @@ public: { return true; } + /** * @brief Checks whether the system has a specified capability. + * * @param capName Indicates the name of the system feature to check. * @return Returns true if the given feature specified by name is available in the system; returns false otherwise. */ @@ -386,8 +448,10 @@ public: { return true; } + /** * @brief Obtains the capabilities that are available in the system. + * * @param systemCaps Indicates the list of capabilities available in the system. * @return Returns true if capabilities in the system are successfully obtained; returns false otherwise. */ @@ -395,16 +459,20 @@ public: { return true; } + /** * @brief Checks whether the current device has been started in safe mode. + * * @return Returns true if the device is in safe mode; returns false otherwise. */ virtual bool IsSafeMode() override { return true; } + /** * @brief Clears application running data of a specified application. + * * @param bundleName Indicates the bundle name of the application whose data is to be cleared. * @return Returns true if the data cleared successfully; returns false otherwise. */ @@ -412,8 +480,10 @@ public: { return true; } + /** * @brief Register the specific bundle status callback. + * * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result. * @return Returns true if this function is successfully called; returns false otherwise. */ @@ -421,8 +491,10 @@ public: { return true; } + /** * @brief Clear the specific bundle status callback. + * * @param bundleStatusCallback Indicates the callback to be cleared. * @return Returns true if this function is successfully called; returns false otherwise. */ @@ -430,16 +502,20 @@ public: { return true; } + /** * @brief Unregister all the callbacks of status changed. + * * @return Returns true if this function is successfully called; returns false otherwise. */ virtual bool UnregisterBundleStatusCallback() override { return true; } + /** * @brief Dump the bundle information with specific flags. + * * @param flag Indicates the information contained in the dump result. * @param bundleName Indicates the bundle name if needed. * @param userId Indicates the user ID. @@ -451,8 +527,10 @@ public: { return true; } + /** * @brief Checks whether a specified application is enabled. + * * @param bundleName Indicates the bundle name of the application. * @return Returns true if the application is enabled; returns false otherwise. */ @@ -460,8 +538,10 @@ public: { return true; } + /** * @brief Sets whether to enable a specified ability. + * * @param abilityInfo Indicates information about the ability to check. * @return Returns true if the ability is enabled; returns false otherwise. */ @@ -469,16 +549,20 @@ public: { return true; } + /** * @brief Obtains the interface used to install and uninstall bundles. + * * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise. */ virtual sptr GetBundleInstaller() override { return nullptr; } + /** * @brief Obtains the interface used to create or delete user. + * * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise. */ virtual sptr GetBundleUserMgr() override @@ -486,8 +570,19 @@ public: return nullptr; } + /** + * @brief Mock to set whether it is system application. + * + * @param isSystemApp Indicates the system application flag. + */ void MockSetIsSystemApp(bool isSystemApp); + /** + * @brief Get the bundle name by uid. + * + * @param uid Indicates the uid. + * @return Indicates the bundle name. + */ std::string GetBundleNameByUid(pid_t uid) { return "bundle"; diff --git a/frameworks/ans/test/moduletest/mock/include/mock_ipc_skeleton.h b/frameworks/ans/test/moduletest/mock/include/mock_ipc_skeleton.h index 7881f108a8231f3a90fef2faa6ca2266f94e4b09..4d825c97cd9ffecffc495b81f4cc548c338def19 100644 --- a/frameworks/ans/test/moduletest/mock/include/mock_ipc_skeleton.h +++ b/frameworks/ans/test/moduletest/mock/include/mock_ipc_skeleton.h @@ -24,38 +24,111 @@ public: IPCSkeleton() = default; ~IPCSkeleton() = default; - // default max is 4, only if you need a customize value + /** + * @brief Set the max number of work thread. + * Default max is 4, only if you need a customize value. + * + * @param maxThreadNum Indicates the max number of work thread + * @return Indicates the result. + */ static bool SetMaxWorkThreadNum(int maxThreadNum); - // join current thread into work loop. + /** + * @brief Join current thread into work loop. + */ static void JoinWorkThread(); - // remove current thread from work loop. + /** + * @brief Remove current thread from work loop. + */ static void StopWorkThread(); + /** + * @brief Get calling pid. + * + * @return Indicates the calling pid. + */ static int GetCallingPid(); + /** + * @brief Get calling uid. + * + * @return Indicates the calling uid. + */ static int GetCallingUid(); + /** + * @brief Get the ID of local device. + * + * @return Indicates the ID of local device. + */ static std::string GetLocalDeviceID(); + /** + * @brief Get the ID of calling device. + * + * @return Indicates the ID of calling device. + */ static std::string GetCallingDeviceID(); + /** + * @brief Whether it is locally calling. + * + * @return Return ture for calling from local, otherwise false. + */ static bool IsLocalCalling(); + /** + * @brief Get the instance. + * + * @return Indicates the instance. + */ static IPCSkeleton &GetInstance(); + /** + * @brief Get the object of context. + * + * @return Indicates the context cobject. + */ static sptr GetContextObject(); + /** + * @brief Set the object of context. + * + * @param object Indicates the context cobject. + * @return Indicates the result. + */ static bool SetContextObject(sptr &object); + /** + * @brief Flush the commands. + * + * @param object Indicates the object. + * @return Indicates the result. + */ static int FlushCommands(IRemoteObject *object); + /** + * @brief Reset calling identity. + * + * @return Indicates the result. + */ static std::string ResetCallingIdentity(); + /** + * @brief Set calling identity. + * + * @param identity Indicates the identity. + * @return Indicates the result. + */ static bool SetCallingIdentity(std::string &identity); + /** + * @brief Set calling uid. + * + * @param uid Indicates the uid. + */ static void SetCallingUid(int uid); }; -} // namespace OHOS -#endif // OHOS_IPC_IPC_SKELETON_H +} // namespace OHOS +#endif // OHOS_IPC_IPC_SKELETON_H diff --git a/frameworks/ans/test/moduletest/mock/include/mock_single_kv_store.h b/frameworks/ans/test/moduletest/mock/include/mock_single_kv_store.h index 7eb7f9788f28e4667ac467bbcfb57ee39e8b344f..a10252130331ed81ab5e50ed0bae212b4e44b4ae 100644 --- a/frameworks/ans/test/moduletest/mock/include/mock_single_kv_store.h +++ b/frameworks/ans/test/moduletest/mock/include/mock_single_kv_store.h @@ -32,85 +32,354 @@ namespace OHOS { namespace DistributedKv { class AnsTestSingleKvStore : public SingleKvStore { public: + /** + * @brief Get all entries in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntries(const Key &prefixKey, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query string. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const std::string &query, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query object. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const DataQuery &query, std::vector &entries) const override; + /** + * @brief Get ResultSet in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSet(const Key &prefixKey, std::shared_ptr &resultSet) const override; + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query string. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSetWithQuery(const std::string &query, std::shared_ptr &resultSet) const override; + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query object. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSetWithQuery(const DataQuery &query, std::shared_ptr &resultSet) const override; + /** + * @brief Close the ResultSet returned by GetResultSet. + * + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status CloseResultSet(std::shared_ptr &resultSet) override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query string. + * @param result Indicates the result. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const std::string &query, int &result) const override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query object. + * @param result Indicates the result will be returned in this parameter. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const DataQuery &query, int &result) const override; + /** + * @brief Sync store with other devices. This is an asynchronous method, + * sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUTH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @param allowedDelayMs Indicates the allowed delay milli-second to sync. default value is 0 for compatibility. + * @return Indicates the status of this Sync operation. + */ virtual Status Sync( const std::vector &deviceIds, SyncMode mode, uint32_t allowedDelayMs = 0) override; + /** + * @brief Remove the device data synced from remote. + * + * @param device Indicates the device id. + * @return Indicates the status of this remove operation. + */ virtual Status RemoveDeviceData(const std::string &device) override; + /** + * @brief Get id of this AppKvStore. + * + * @return Indicates the id of store. + */ virtual StoreId GetStoreId() const override; + /** + * @brief Delete an entry by its key. + * + * @param key Indicates the key of the entry to be deleted. + * @return Indicates the status of this delete operation. + */ virtual Status Delete(const Key &key) override; + /** + * @brief Write a pair of key and value to this store. + * + * @param key Indicates the key of this entry. Should be less than 256 bytes. key will be trimmed before store. + * @param value Indicates the value of this entry. Should be less than (1024 * 1024) bytes. + * @return Indicates the status of this put operation. + */ virtual Status Put(const Key &key, const Value &value) override; + /** + * @brief Get value from AppKvStore by its key. + * + * @param key Indicates the key of this entry. + * @param value Indicates the value will be returned in this parameter. + * @return Indicates the status of this get operation. + */ virtual Status Get(const Key &key, Value &value) override; + /** + * @brief Register change of this kvstore to a client-defined observer. + * observer->OnChange method will be called when store changes. + * One observer can subscribe more than one AppKvStore. + * + * @param subscribeType Indicates the subscribe type. + * OBSERVER_CHANGES_NATIVE means native changes of syncable kv store, + * OBSERVER_CHANGES_FOREIGN means synced data changes from remote devices, + * OBSERVER_CHANGES_ALL means both native changes and synced data changes. + * @param observer Indicates the observer to subscribe changes. + * @return Indicates the status of this subscribe operation. + */ virtual Status SubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Unregister a kvstore to an observer. + * + * @param subscribeType Indicates the subscribe type. + * Reserved parameter. Current is always SubscribeType::DEFAULT. + * @param observer Indicates the observer to unsubscribe this store. + * @return Indicates the status of this unsubscribe operation. + */ virtual Status UnSubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Register message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status RegisterSyncCallback(std::shared_ptr callback) override; + /** + * @brief Unregister message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status UnRegisterSyncCallback() override; + /** + * @brief See Put, PutBatch put a list of entries to kvstore, + * all entries will be put in a transaction, + * if entries contains invalid entry, PutBatch will all fail. + * + * @param entries Indicates the entries. + * The entries's size should be less than 128 and memory size must be less than IPC transport limit. + * @return Indicates the status of this register operation. + */ virtual Status PutBatch(const std::vector &entries) override; + /** + * @brief Delete a list of entries in the kvstore, + * delete key not exist still return success, + * key length should not be greater than 256, and can not be empty. + * If keys contains invalid key, all delete will fail. + * + * @param keys Indicates the list of keys. + * The keys memory size should not be greater than IPC transport limit, and can not be empty. + * @return Indicates the status of this register operation. + */ virtual Status DeleteBatch(const std::vector &keys) override; + /** + * @brief Start transaction. + * All changes to this kvstore will be in a same transaction and will not change the store until Commit() or + * Rollback() is called. + * Before this transaction is committed or rollbacked, all attemption to close this store will fail. + * + * @return Indicates the status of this operation. + */ virtual Status StartTransaction() override; + /** + * @brief Commit current transaction. All changes to this store will be done after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Commit() override; + /** + * @brief Rollback current transaction. + * All changes to this store during this transaction will be rollback after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Rollback() override; + /** + * @brief Set synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status SetSyncParam(const KvSyncParam &syncParam) override; + /** + * @brief Get synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status GetSyncParam(KvSyncParam &syncParam) override; + /** + * @brief Set capability parameters of this store. + * + * @param enabled Indicates the capability Enabled status. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityEnabled(bool enabled) const override; + /** + * @brief Set capability parameters of this store. + * + * @param localLabels Indicates the labels of local. + * @param remoteSupportLabels Indicates the labels of remote support. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityRange(const std::vector &localLabels, const std::vector &remoteSupportLabels) const override; + /** + * @brief Get security level. + * + * @param securityLevel Indicates the security level. + * @return Indicates the status of this operation. + */ virtual Status GetSecurityLevel(SecurityLevel &securityLevel) const override; + /** + * @brief Sync store with other devices only syncing the data which is satisfied with the condition. + * This is an asynchronous method, sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUSH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @return Indicates the status of this operation. + */ virtual Status SyncWithCondition(const std::vector &deviceIds, SyncMode mode, const DataQuery &query, std::shared_ptr syncCallback) override; + /** + * @brief Subscribe store with other devices consistently Synchronize the data which is satisfied + * with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * + * @return Indicates the status of this operation. + */ virtual Status SubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief UnSubscribe store with other devices which is satisfied with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @return Indicates the status of this UnSubscribe operation. + */ virtual Status UnsubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status GetKvStoreSnapshot(std::shared_ptr observer, std::shared_ptr &snapshot) const override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status ReleaseKvStoreSnapshot(std::shared_ptr &snapshot) override; + /** + * @brief Clear the object. + * + * @return Indicates the status of this operation. + */ Status Clear() override; public: + /** + * @brief Mock insert into kv store. + * + * @param appId Indicates the id of App. + * @param storeId Indicates the id of store. + * @param store Indicates the store. + */ static void InsertMockKvStore(AppId appId, StoreId storeId, std::shared_ptr store); + + /** + * @brief Mock remove kv store. + * + * @param appId Indicates the id of App. + * @param storeId Indicates the id of store. + */ static void RemoveMockKvStore(AppId appId, StoreId storeId); + + /** + * @brief Mock get kvStore pointer. + * + * @param appId Indicates the id of App. + * @param storeId Indicates the id of store. + * @return Indicates the kvstore. + */ static std::shared_ptr GetMockKvStorePointer(AppId appId, StoreId storeId); struct Compare { bool operator()(const Key &a, const Key &b) const @@ -119,8 +388,27 @@ public: } }; + /** + * @brief Mock insert data into kvStore. + * + * @param key Indicates the key. + * @param value Indicates the value. + */ void InsertDataToDoCallback(const Key &key, const Value &value); + + /** + * @brief Mock update data of kvStore. + * + * @param key Indicates the key. + * @param value Indicates the value. + */ void UpdateDataToDoCallback(const Key &key, const Value &value); + + /** + * @brief Mock delete data of kvStore. + * + * @param key Indicates the key. + */ void DeleteDataToDoCallback(const Key &key); protected: diff --git a/interfaces/innerkits/ans/native/include/message_user.h b/interfaces/innerkits/ans/native/include/message_user.h index 93bb564c461307f199882e29daa466fbdea647a7..2d866ef44ff63b75360b95c51f6a664d60366334 100644 --- a/interfaces/innerkits/ans/native/include/message_user.h +++ b/interfaces/innerkits/ans/native/include/message_user.h @@ -24,121 +24,123 @@ namespace OHOS { namespace Notification { class MessageUser final : public Parcelable, public NotificationJsonConvertionBase { public: - /** - * A constructor used to construct MessageUser - */ MessageUser(); - /** - * Default deconstructor used to deconstruct. - */ ~MessageUser(); /** - * Sets the key used to uniquely identify this MessageUser. - * @note Sets the key used to uniquely identify this MessageUser. - * If no key is set, the name set by SetName(string) is used to uniquely identify a MessageUser. + * @brief Sets the key used to uniquely identify this MessageUser.If no key is set, the name set by SetName(string) + * is used to uniquely identify a MessageUser. + * * @param key Indicates the key to set. */ void SetKey(const std::string &key); /** - * Obtains the key of this MessageUser. + * @brief Obtains the key of this MessageUser. * * @return Returns the key of this MessageUser. */ std::string GetKey() const; /** - * Sets the name of this MessageUser. + * @brief Sets the name of this MessageUser. + * * @name Indicates the name to set. */ void SetName(const std::string &name); /** - * Obtains the name of this MessageUser. + * @brief Obtains the name of this MessageUser. * * @return Returns the name of this MessageUser. */ std::string GetName() const; /** - * Sets the pixel map of this MessageUser. + * @brief Sets the pixel map of this MessageUser. + * * @param pixelMap Indicates the pixel map to set. */ void SetPixelMap(const std::shared_ptr &pixelMap); /** - * Obtains the pixel map of this MessageUser. + * @brief Obtains the pixel map of this MessageUser. * * @return Returns the pixel map of this MessageUser. */ const std::shared_ptr GetPixelMap() const; /** - * Sets the URI of this MessageUser. + * @brief Sets the URI of this MessageUser. + * * @param uri Indicates the URI to set. */ void SetUri(const Uri &uri); /** - * Obtains the URI of this MessageUser. + * @brief Obtains the URI of this MessageUser. * * @return Returns the URI of this MessageUser. */ Uri GetUri() const; /** - * Sets whether this MessageUser is a machine. - * @param machine Specifies whether this MessageUser is a machine. - * The value true indicates that it is, and the value false indicates not. + * @brief Sets whether this MessageUser is a machine. + * + * @param machine Specifies whether this MessageUser is a machine.The value true indicates that it is, + * and the value false indicates not. */ void SetMachine(bool machine); /** - * Checks whether this MessageUser is a machine. + * @brief Checks whether this MessageUser is a machine. * * @return Returns true if this MessageUser is a machine; returns false otherwise. */ bool IsMachine() const; /** - * Sets whether this MessageUser is important. - * @note This method can be used to denote users who frequently interact with the user of this device. - * @param userImportant Specifies whether this MessageUser is important. - * The value true indicates that it is important, and the value false indicates not. + * @brief Sets whether this MessageUser is important.This method can be used to denote users who frequently + * interact with the user of this device. + * + * @param userImportant Specifies whether this MessageUser is important.The value true indicates that it is + * important, and the value false indicates not. */ void SetUserAsImportant(bool userImportant); /** - * Checks whether this MessageUser is important. + * @brief Checks whether this MessageUser is important. * * @return Returns true if this MessageUser is important; returns false otherwise. */ bool IsUserImportant() const; /** - * Dumps a string representation of the object. + * @brief Dumps a string representation of the object. * - * @return A string representation of the object. + * @return Returns a string representation of the object. */ std::string Dump() const; /** - * Converts a MessageUser object into a Json. + * @brief Converts a MessageUser object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a MessageUser object from a Json. + * @brief Creates a MessageUser object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the MessageUser. + * @return Returns the MessageUser object. */ static MessageUser *FromJson(const nlohmann::json &jsonObject); /** - * Marshals a MessageUser object into a Parcel. + * @brief Marshals a MessageUser object into a Parcel. * * @param parcel Indicates the Parcel object for marshalling. * @return Returns true if the marshalling is successful; returns false otherwise. @@ -146,19 +148,19 @@ public: bool Marshalling(Parcel &parcel) const override; /** - * Unmarshals a MessageUser object from a Parcel. + * @brief Unmarshals a MessageUser object from a Parcel. * - * @param parcel Indicates the Parcel object for unmarshalling. + * @param parcel Indicates the parcel object. * @return Returns true if the unmarshalling is successful; returns false otherwise. */ static MessageUser *Unmarshalling(Parcel &parcel); private: /** - * Read NotificationSlot object from a Parcel. + * @brief Read NotificationSlot object from a Parcel. * - * @param parcel the parcel - * @return read from parcel success or fail + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification.h b/interfaces/innerkits/ans/native/include/notification.h index 2ad6c3ea63a69adcda78f148b19bb0e33427df06..79e022c93c6f15b3e1c594b4405ac6980a3f09e9 100644 --- a/interfaces/innerkits/ans/native/include/notification.h +++ b/interfaces/innerkits/ans/native/include/notification.h @@ -25,17 +25,17 @@ namespace Notification { class Notification final : public Parcelable { public: /** - * A constructor used to create a Notification instance by existing NotificationRequest object. + * @brief A constructor used to create a Notification instance by existing NotificationRequest object. * - * @param request the existing NotificationRequest object. + * @param request Indicates the existing NotificationRequest object. */ Notification(const sptr &request); /** - * A constructor used to create a Notification instance by existing NotificationRequest object. + * @brief A constructor used to create a Notification instance by existing NotificationRequest object. * - * @param deviceId the device id. - * @param request the existing NotificationRequest object. + * @param deviceId Indicates the device id. + * @param request Indicates the existing NotificationRequest object. */ Notification(const std::string &deviceId, const sptr &request); @@ -46,51 +46,48 @@ public: */ Notification(const Notification &other); - /** - * @brief Default destructor. - */ ~Notification(); /** * @brief Obtains whether to enable the notification light when a notification is received on the device, provided * that this device has a notification light. * - * @return Return true if led light color is set. + * @return Returns true if led light color is set. */ bool EnableLight() const; /** * @brief Obtains the sound enabled or not, set by ANS. * - * @return Return true if sound is set. + * @return Returns true if sound is set. */ bool EnableSound() const; /** * @brief Obtains the vibrate enabled or not, set by ANS. * - * @return Return true if vibrate style is set. + * @return Returns true if vibrate style is set. */ bool EnableVibrate() const; /** * @brief Obtains the bundle's name which publish this notification. * - * @return Return the bundle's name. + * @return Returns the bundle's name. */ std::string GetBundleName() const; /** * @brief Obtains the bundle's name which create this notification. * - * @return Return the creator bundle name. + * @return Returns the creator bundle name. */ std::string GetCreateBundle() const; /** * @brief Obtains the label of this notification. * - * @return Return the label. + * @return Returns the label. */ std::string GetLabel() const; @@ -100,133 +97,134 @@ public: * @return Returns the color of the notification light. */ int32_t GetLedLightColor() const; + /** * @brief Sets the notification display effect, including whether to display this notification on the lock screen, * and how it will be presented if displayed. * - * @return Return the display effect of this notification on the lock screen. + * @return Returns the display effect of this notification on the lock screen. */ NotificationConstant::VisiblenessType GetLockscreenVisibleness() const; /** * @brief The ID passed to setGroup(), or the override, or null. * - * @return string of group. + * @return Returns the string of group. */ std::string GetGroup() const; /** * @brief Obtains the id of the notification. * - * @return The id supplied to NotificationManager::Notify(int, NotificationRequest). + * @return Returns the id supplied to NotificationManager::Notify(int, NotificationRequest). */ int32_t GetId() const; /** * @brief A key for this notification record. * - * @return A unique instance key. + * @return Returns a unique instance key. */ std::string GetKey() const; /** * @brief Obtains the notificanton request set by ANS. * - * @return Return sptr. + * @return Returns NotificationRequest object. */ NotificationRequest GetNotificationRequest() const; /** * @brief Obtains the time notification was posted. * - * @return The time notificationRequest was posted. + * @return Returns the time notificationRequest was posted. */ int64_t GetPostTime() const; /** * @brief Obtains the sound uri. * - * @return Return the sound set by ANS. + * @return Returns the sound set by ANS. */ Uri GetSound() const; /** * @brief Obtains the UID of the notification creator. * - * @return Return the UID of the notification creator. + * @return Returns the UID of the notification creator. */ pid_t GetUid() const; /** * @brief Obtains the PID of the notification creator. * - * @return Return the PID of the notification creator. + * @return Returns the PID of the notification creator. */ pid_t GetPid() const; /** - * Checks whether this notification is unremovable. - * @return true if this notification is unremovable; returns false otherwise. + * @brief Checks whether this notification is unremovable. + * @return Returns true if this notification is unremovable; returns false otherwise. */ bool IsUnremovable() const; /** - * @brief Obtains the vibration style for this notifications. if + * @brief Obtains the vibration style for this notifications. * - * @return Return the vibration style. + * @return Returns the vibration style. */ std::vector GetVibrationStyle() const; /** * @brief This notification is part of a group or not. * - * @return true if this notification is part of a group. + * @return Returns true if this notification is part of a group. */ bool IsGroup() const; /** * @brief Checks whether this notification is displayed as a floating icon on top of the screen. * - * @return true if this notification is displayed as a floating icon; returns false otherwise. + * @return Returns true if this notification is displayed as a floating icon; returns false otherwise. */ bool IsFloatingIcon() const; /** * @brief Obtains the remind type of a notification. - * @return the remind type of a notification. + * @return Returns the remind type of a notification. */ NotificationConstant::RemindType GetRemindType() const; /** - * Whether to support remove allowed. - * @return Current remove allowed status. + * @brief Whether to support remove allowed. + * @return Returns the current remove allowed status. */ bool IsRemoveAllowed() const; /** - * Gets the notification source. - * @return the notification slot type. + * @brief Gets the notification source. + * @return Returns the notification slot type. */ NotificationConstant::SourceType GetSourceType() const; /** * @brief Gets the device id of the notification source. * - * @return Return the device id. + * @return Returns the device id. */ std::string GetDeviceId() const; /** * @brief Obtains the UserId of the notification creator. * - * @return Return the UserId of the notification creator. + * @return Returns the UserId of the notification creator. */ int32_t GetUserId() const; /** * @brief Dumps a string representation of the object. * - * @return A string representation of the object. + * @return Returns a string representation of the object. */ std::string Dump() const; @@ -234,7 +232,6 @@ public: * @brief Marshals a Notification object into a Parcel. * * @param parcel Indicates the Parcel object for marshalling. - * * @return Returns true if the marshalling is successful; returns false otherwise. */ bool Marshalling(Parcel &parcel) const; @@ -243,7 +240,6 @@ public: * @brief Unmarshals a Notification object from a Parcel. * * @param Indicates the Parcel object for unmarshalling. - * * @return Returns true if the unmarshalling is successful; returns false otherwise. */ static Notification *Unmarshalling(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification_action_button.h b/interfaces/innerkits/ans/native/include/notification_action_button.h index d1a14a2a226143f3b085a58b415bf43cc2b01059..d5280b57e972f78423fdc2d82d085cd4ae018746 100644 --- a/interfaces/innerkits/ans/native/include/notification_action_button.h +++ b/interfaces/innerkits/ans/native/include/notification_action_button.h @@ -28,7 +28,8 @@ namespace Notification { class NotificationActionButton : public Parcelable, public NotificationJsonConvertionBase { public: /** - * A static function used to create a NotificationActionButton instance with the input parameters passed. + * @brief A static function used to create a NotificationActionButton instance with the input parameters passed. + * * @param icon Indicates the icon to represent this NotificationActionButton. * @param title Indicates the title of this NotificationActionButton. * @param wantAgent Indicates the wantAgent to be triggered when this NotificationActionButton is triggered. @@ -40,8 +41,8 @@ public: * @param userInputs Indicates the NotificationUserInput object to add. * @param isContextual Indicates whether this NotificationActionButton is a contextual action, that is, whether this * NotificationActionButton is dependent on the notification message body. - * @return the shared_ptr object owns the created NotificationActionButton object otherwise return empty object if - * isContextual is true but icon or wantAgent is empty. + * @return Returns the shared_ptr object owns the created NotificationActionButton object otherwise returns empty + * object if isContextual is true but icon or wantAgent is empty. */ static std::shared_ptr Create(const std::shared_ptr &icon, const std::string &title, const std::shared_ptr &wantAgent, @@ -53,34 +54,36 @@ public: const std::shared_ptr &userInput = {}, bool isContextual = false); /** - * A static function used to create a NotificationActionButton instance by copying parameters from an existing - * NotificationActionButton object. + * @brief A static function used to create a NotificationActionButton instance by copying parameters from an + * existing NotificationActionButton object. + * * @param actionButton Indicates the existing NotificationActionButton object. - * @return the shared_ptr object owns the created NotificationActionButton object otherwise return empty object. + * @return Returns the shared_ptr object owns the created NotificationActionButton object otherwise returns + * empty object. */ static std::shared_ptr Create( const std::shared_ptr &actionButton); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationActionButton() = default; /** - * Obtains the icon of this NotificationActionButton. - * @return the icon of this NotificationActionButton. + * @brief Obtains the icon of this NotificationActionButton. + * + * @return Returns the icon of this NotificationActionButton. */ const std::shared_ptr GetIcon() const; /** - * Obtains the title of this NotificationActionButton. - * @return the title of this NotificationActionButton. + * @brief Obtains the title of this NotificationActionButton. + * + * @return Returns the title of this NotificationActionButton. */ std::string GetTitle() const; /** - * Obtains the WantAgent of this NotificationActionButton. - * @return the WantAgent of this NotificationActionButton. + * @brief Obtains the WantAgent of this NotificationActionButton. + * + * @return Returns the WantAgent of this NotificationActionButton. */ const std::shared_ptr GetWantAgent() const; @@ -91,121 +94,138 @@ public: void AddAdditionalData(AAFwk::WantParams &extras); /** - * Obtains the additional data included in this NotificationActionButton. - * @return the additional data included in this NotificationActionButton. + * @brief Obtains the additional data included in this NotificationActionButton. + * + * @return Returns the additional data included in this NotificationActionButton. */ const std::shared_ptr GetAdditionalData() const; /** - * Sets a semantic action for this NotificationActionButton. - * @param semanticActionButton Indicates the semantic action to add. - * For available values, see NotificationConstant::SemanticActionButton. + * @brief Sets a semantic action for this NotificationActionButton. + * + * @param semanticActionButton Indicates the semantic action to add.For available values, + * see NotificationConstant::SemanticActionButton. */ void SetSemanticActionButton(NotificationConstant::SemanticActionButton semanticActionButton); /** - * Obtains the semantic action of this NotificationActionButton. - * @return the semantic action of this NotificationActionButton, - * as enumerated in NotificationConstant::SemanticActionButton. + * @brief Obtains the semantic action of this NotificationActionButton. + * + * @return Returns the semantic action of this NotificationActionButton, as enumerated in + * NotificationConstant::SemanticActionButton. */ NotificationConstant::SemanticActionButton GetSemanticActionButton() const; /** - * Adds a NotificationUserInput object that only allows values of particular MIME types. + * @brief Adds a NotificationUserInput object that only allows values of particular MIME types. + * * @param userInput Indicates the NotificationUserInput object to add. */ void AddMimeTypeOnlyUserInput(const std::shared_ptr &userInput); /** - * Obtains the NotificationUserInput objects that only allow values of particular MIME types + * @brief Obtains the NotificationUserInput objects that only allow values of particular MIME types * when this NotificationActionButton is sent. - * @return the list of NotificationUserInput objects allowing only values of particular MIME types. + * + * @return Returns the list of NotificationUserInput objects allowing only values of particular MIME types. */ std::vector> GetMimeTypeOnlyUserInputs() const; /** - * Adds a NotificationUserInput object used to collect user input. + * @brief Adds a NotificationUserInput object used to collect user input. + * * @param userInput Indicates the NotificationUserInput object to add. */ void AddNotificationUserInput(const std::shared_ptr &userInput); /** - * Obtains the NotificationUserInput object to be collected from the user when this NotificationActionButton + * @brief Obtains the NotificationUserInput object to be collected from the user when this NotificationActionButton * is sent. - * @return the NotificationUserInput object. + * + * @return Returns the NotificationUserInput object. */ const std::shared_ptr GetUserInput() const; /** - * Sets whether to allow the platform to automatically generate possible replies and add them to + * @brief Sets whether to allow the platform to automatically generate possible replies and add them to * NotificationUserInput::getOptions(). + * * @param autoCreatedReplies Specifies whether to allow the platform to automatically generate possible replies. * The value true means to allow generated replies; and the value false means not. */ void SetAutoCreatedReplies(bool autoCreatedReplies); /** - * Checks whether the platform can automatically generate possible replies for this NotificationActionButton. - * @return true if the platform can generate replies; returns false otherwise. + * @brief Checks whether the platform can automatically generate possible replies for this NotificationActionButton. + * + * @return Returns true if the platform can generate replies; returns false otherwise. */ bool IsAutoCreatedReplies() const; /** - * Sets whether this NotificationActionButton is a contextual action, that is, whether this + * @brief Sets whether this NotificationActionButton is a contextual action, that is, whether this * NotificationActionButton is dependent on the notification message body. For example, a contextual * NotificationActionButton provides an address in the notification for users to open a map application. + * * @param isContextual Specifies whether this NotificationActionButton is a contextual action. * The value true indicates a contextual action, and the value false indicates not. */ void SetContextDependent(bool isContextual); /** - * Checks whether this NotificationActionButton is a contextual action, that is, whether this + * @brief Checks whether this NotificationActionButton is a contextual action, that is, whether this * NotificationActionButton is dependent on the notification message body. For example, a contextual * NotificationActionButton provides an address in the notification for users to open a map application. - * @return true if this NotificationActionButton is a contextual action; returns false otherwise. + * + * @return Returns true if this NotificationActionButton is a contextual action; returns false otherwise. */ bool IsContextDependent() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Converts a NotificationActionButton object into a Json. + * @brief Converts a NotificationActionButton object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationActionButton object from a Json. + * @brief Creates a NotificationActionButton object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationActionButton. + * @return Returns the NotificationActionButton. */ static NotificationActionButton *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationActionButton + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationActionButton. */ static NotificationActionButton *Unmarshalling(Parcel &parcel); private: - /** - * Default constructor used to create a NotificationActionButton instance. - */ NotificationActionButton() = default; /** - * A constructor used to create a NotificationActionButton instance with the input parameters passed. + * @brief A constructor used to create a NotificationActionButton instance with the input parameters passed. + * * @param icon Indicates the icon to represent this NotificationActionButton. * @param title Indicates the title of this NotificationActionButton. * @param wantAgent Indicates the WantAgent to be triggered when this NotificationActionButton is triggered. @@ -225,8 +245,10 @@ private: const std::shared_ptr &userInput, bool isContextual); /** - * Read a NotificationActionButton object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationActionButton object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification_basic_content.h b/interfaces/innerkits/ans/native/include/notification_basic_content.h index 65ccd08bb9656714fd3206562091063c917794be..62d860b17f18921098c0d884fad76ba53abdd81a 100644 --- a/interfaces/innerkits/ans/native/include/notification_basic_content.h +++ b/interfaces/innerkits/ans/native/include/notification_basic_content.h @@ -23,82 +23,89 @@ namespace OHOS { namespace Notification { class NotificationBasicContent : public Parcelable, public NotificationJsonConvertionBase { public: - /** - * Default deconstructor used to deconstruct. - */ virtual ~NotificationBasicContent(); /** - * Sets the additional text to be included in a notification. + * @brief Sets the additional text to be included in a notification. * The additional text is mainly a supplement to the notification text set by calling setText(std::string). * The font of the additional text is smaller than the notification text and is displayed in a separate line. + * * @param text Indicates the additional text to be included. */ virtual void SetAdditionalText(const std::string &additionalText); /** - * Obtains the additional text of a notification specified by calling setAdditionalText(std::string). - * @return the additional text of the notification. + * @brief Obtains the additional text of a notification specified by calling setAdditionalText(std::string). + * + * @return Returns the additional text of the notification. */ virtual std::string GetAdditionalText() const; /** - * Sets the text to be included in a notification. + * @brief Sets the text to be included in a notification. + * * @param text Indicates the text to be included. */ virtual void SetText(const std::string &text); /** - * Obtains the text of a notification specified by calling setText(std::string). - * @return the text of the notification. + * @brief Obtains the text of a notification specified by calling setText(std::string). + * + * @return Returns the text of the notification. */ virtual std::string GetText() const; /** - * Sets the title of a notification. + * @brief Sets the title of a notification. + * * @param title Indicates the title of the notification. */ virtual void SetTitle(const std::string &title); /** - * Obtains the title of a notification specified by calling the setTitle(std::string) method. - * @return the title of the notification. + * @brief Obtains the title of a notification specified by calling the setTitle(std::string) method. + * + * @return Returns the title of the notification. */ virtual std::string GetTitle() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ virtual std::string Dump(); /** - * Converts a NotificationBasicContent object into a Json. + * @brief Converts a NotificationBasicContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ virtual bool ToJson(nlohmann::json &jsonObject) const override; /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; protected: - /** - * Default constructor. - */ NotificationBasicContent() = default; /** - * Read data from a Parcel. - * @param parcel the parcel - * @return true if read success; returns false otherwise. + * @brief Read data from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if read success; returns false otherwise. */ virtual bool ReadFromParcel(Parcel &parcel); /** - * Creates a NotificationBasicContent object from a Json. + * @brief Creates a NotificationBasicContent object from a Json. + * * @param jsonObject Indicates the Json object. */ void ReadFromJson(const nlohmann::json &jsonObject); diff --git a/interfaces/innerkits/ans/native/include/notification_bundle_option.h b/interfaces/innerkits/ans/native/include/notification_bundle_option.h index 992bfff9e80ca583685acd1107b21892b99cef1b..a47eff340b77d8794eed0a21fe3b9d30edbd8c58 100644 --- a/interfaces/innerkits/ans/native/include/notification_bundle_option.h +++ b/interfaces/innerkits/ans/native/include/notification_bundle_option.h @@ -22,70 +22,75 @@ namespace OHOS { namespace Notification { class NotificationBundleOption : public Parcelable { public: - /** - * A default constructor used to create a NotificationBundleOption instance. - */ NotificationBundleOption() = default; /** - * A constructor used to create a NotificationBundleOption instance based on the creator bundle name and uid. + * @brief A constructor used to create a NotificationBundleOption instance based on the creator bundle name and uid. + * * @param bundleName Indicates the creator bundle name. * @param uid Indicates the creator uid. */ NotificationBundleOption(const std::string &bundleName, const int32_t uid); - /** - * Default deconstructor used to deconstruct. - */ virtual ~NotificationBundleOption(); /** - * Sets the creator bundle name. + * @brief Sets the creator bundle name. + * * @param bundleName Indicates the creator bundle name. */ void SetBundleName(const std::string &bundleName); /** - * Obtains the creator bundle name. - * @return the creator bundle name. + * @brief Obtains the creator bundle name. + * + * @return Returns the creator bundle name. */ std::string GetBundleName() const; /** - * Sets the creator uid. + * @brief Sets the creator uid. + * * @param uid Indicates the creator uid. */ void SetUid(const int32_t uid); /** - * Obtains the creator uid. - * @return the creator uid. + * @brief Obtains the creator uid. + * + * @return Returns the creator uid. */ int32_t GetUid() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel Indicates the object into the parcel + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationBundleOption + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationBundleOption */ static NotificationBundleOption *Unmarshalling(Parcel &parcel); private: /** - * Read data from a Parcel. - * @param parcel the parcel - * @return true if read success; returns false otherwise. + * @brief Read data from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if read success; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification_content.h b/interfaces/innerkits/ans/native/include/notification_content.h index 0923b9ea0401cc786f58d0faed4b2975f5019bce..425b1247f79efa159bbc2f0fd29cbadf9d883a00 100644 --- a/interfaces/innerkits/ans/native/include/notification_content.h +++ b/interfaces/innerkits/ans/native/include/notification_content.h @@ -67,59 +67,65 @@ public: }; /** - * A constructor used to create a NotificationNormalContent instance (obtained by calling GetNotificationContent()) - * and set the content type to NotificationContent::Type::BASIC_TEXT (obtained by calling GetContentType()). + * @brief A constructor used to create a NotificationNormalContent instance (obtained by calling + * GetNotificationContent()) and set the content type to NotificationContent::Type::BASIC_TEXT (obtained by calling + * GetContentType()). + * * @param normalContent Indicates the NotificationNormalContent object. */ explicit NotificationContent(const std::shared_ptr &normalContent); /** - * A constructor used to create a NotificationLongTextContent instance (obtained by calling + * @brief A constructor used to create a NotificationLongTextContent instance (obtained by calling * GetNotificationContent()) and set the content type to NotificationContent::Type::LONG_TEXT (obtained by calling * GetContentType()). + * * @param longTextContent Indicates the NotificationLongTextContent object. */ explicit NotificationContent(const std::shared_ptr &longTextContent); /** - * A constructor used to create a NotificationPictureContent instance (obtained by calling GetNotificationContent()) - * and set the content type to NotificationContent::Type::PICTURE (obtained by calling GetContentType()). + * @brief A constructor used to create a NotificationPictureContent instance (obtained by calling + * GetNotificationContent()) and set the content type to NotificationContent::Type::PICTURE (obtained by calling + * GetContentType()). + * * @param pictureContent Indicates the NotificationPictureContent object. */ explicit NotificationContent(const std::shared_ptr &pictureContent); /** - * A constructor used to create a NotificationConversationalContent instance - * (obtained by calling GetNotificationContent()) and set the content type to - * NotificationContent::Type::CONVERSATION (obtained by calling GetContentType()). + * @brief A constructor used to create a NotificationConversationalContent instance (obtained by calling + * GetNotificationContent()) and set the content type to NotificationContent::Type::CONVERSATION (obtained by + * calling GetContentType()). + * * @param conversationContent Indicates the NotificationConversationalContent object. */ explicit NotificationContent(const std::shared_ptr &conversationContent); /** - * A constructor used to create a NotificationMultiLineContent instance - * (obtained by calling GetNotificationContent()) and set the content type to - * NotificationContent::Type::MULTILINE (obtained by calling GetContentType()). + * @brief A constructor used to create a NotificationMultiLineContent instance (obtained by calling + * GetNotificationContent()) and set the content type to NotificationContent::Type::MULTILINE (obtained by calling + * GetContentType()). + * * @param multiLineContent Indicates the NotificationMultiLineContent object. */ explicit NotificationContent(const std::shared_ptr &multiLineContent); /** - * A constructor used to create a NotificationMediaContent instance - * (obtained by calling GetNotificationContent()) and set the content type to - * NotificationContent::Type::MEDIA (obtained by calling GetContentType()). + * @brief A constructor used to create a NotificationMediaContent instance (obtained by calling + * GetNotificationContent()) and set the content type to NotificationContent::Type::MEDIA (obtained by calling + * GetContentType()). + * * @param mediaContent Indicates the NotificationMediaContent object. */ explicit NotificationContent(const std::shared_ptr &mediaContent); - /** - * Default deconstructor used to deconstruct. - */ virtual ~NotificationContent(); /** - * Obtains the type value of the notification content. - * @return the type value of the current content, which can be + * @brief Obtains the type value of the notification content. + * + * @return Returns the type value of the current content, which can be * NotificationContent::Type::BASIC_TEXT, * NotificationContent::Type::LONG_TEXT, * NotificationContent::Type::PICTURE, @@ -130,8 +136,9 @@ public: NotificationContent::Type GetContentType() const; /** - * Obtains the object matching the current notification content. - * @return the content object, which can be NotificationLongTextContent, + * @brief Obtains the object matching the current notification content. + * + * @return Returns the content object, which can be NotificationLongTextContent, * NotificationNormalContent, * NotificationPictureContent, * NotificationConversationalContent, @@ -141,49 +148,62 @@ public: std::shared_ptr GetNotificationContent() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Converts a NotificationContent object into a Json. + * @brief Converts a NotificationContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationContent object from a Json. + * @brief Creates a NotificationContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationContent. + * @return Returns the NotificationContent. */ static NotificationContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel Indicates the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationContent. */ static NotificationContent *Unmarshalling(Parcel &parcel); private: - /** - * Default constructor used to create an empty NotificationContent instance. - */ NotificationContent() = default; /** - * Read data from a Parcel. - * @param parcel the parcel - * @return true if read success; returns false otherwise. + * @brief Read data from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if read success; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); + /** + * @brief Convert JSON object to NotificationContent object. + * + * @param target Indicates the NotificationContent object. + * @param jsonObject Indicates the JSON object. + * @return Returns true if the conversion is successful; returns false otherwise. + */ static bool ConvertJsonToContent(NotificationContent *target, const nlohmann::json &jsonObject); private: diff --git a/interfaces/innerkits/ans/native/include/notification_conversational_content.h b/interfaces/innerkits/ans/native/include/notification_conversational_content.h index e8e19b5073be9462d6810c2a6c4dff8eb44c2dcb..90db3cfd0238811ac48121e029b04febe8cc8c41 100644 --- a/interfaces/innerkits/ans/native/include/notification_conversational_content.h +++ b/interfaces/innerkits/ans/native/include/notification_conversational_content.h @@ -30,55 +30,58 @@ public: using MessageVector = std::vector; /** - * A constructor used to create a NotificationConversationalContent instance with the MessageUser specified. + * @brief A constructor used to create a NotificationConversationalContent instance with the MessageUser specified. + * * @param messageUser Indicates the MessageUser who sends all Message objects in this conversation-like * notification. This parameter cannot be null. */ explicit NotificationConversationalContent(const MessageUser &messageUser); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationConversationalContent() = default; /** - * Obtains the message sender to be displayed for any messages - * sent by the user in this conversation-like notification. - * @return the message sender. + * @brief Obtains the message sender to be displayed for any messages sent by the user in this conversation-like + * notification. + * + * @return Returns the message sender. */ MessageUser GetMessageUser() const; /** - * Sets the title to be displayed for the conversation. - * The title set in this method will overwrite the one set by calling setTitle(std::string). + * @brief Sets the title to be displayed for the conversation.The title set in this method will overwrite the one + * set by calling setTitle(std::string). + * * @param conversationTitle Indicates the title to be displayed for the conversation. */ void SetConversationTitle(const std::string &conversationTitle); /** - * Obtains the title to be displayed for the conversation. - * @return the title to be displayed for the conversation. + * @brief Obtains the title to be displayed for the conversation. + * + * @return Returns the title to be displayed for the conversation. */ std::string GetConversationTitle() const; /** - * Checks whether this notification represents a group conversation. - * @return true if this notification represents a group conversation; returns false otherwise. + * @brief Checks whether this notification represents a group conversation. + * + * @return Returns true if this notification represents a group conversation; returns false otherwise. */ bool IsConversationGroup() const; /** - * Sets whether this notification represents a group conversation. + * @brief Sets whether this notification represents a group conversation. * The big icon, if any, set for this notification by calling NotificationRequest::setBigIcon(PixelMap) * will be displayed only when this method is set to true. + * * @param isGroup Specifies whether this notification represents a group conversation. */ void SetConversationGroup(bool isGroup); /** - * Adds a message to this conversation-like notification based on - * the specified message content, timestamp, and MessageUser. - * All messages will be displayed in the order they are added. + * @brief Adds a message to this conversation-like notification based on the specified message content, timestamp, + * and MessageUser.All messages will be displayed in the order they are added. + * * @param text Indicates the text to be displayed as the message content. * @param timestamp Indicates the time when the message arrived. * @param sender Indicates the MessageUser who sent the message. @@ -87,60 +90,69 @@ public: const std::string &text, int64_t timestamp, const MessageUser &sender); /** - * Adds a specified message to this conversation-like notification. - * All messages will be displayed in the order they are added. + * @brief Adds a specified message to this conversation-like notification.All messages will be displayed in the + * order they are added. + * * @param message Indicates the ConversationalMessage object to add. */ void AddConversationalMessage(const MessagePtr &message); /** - * Obtains all messages included in this conversation-like notification. - * @return the list of all Message objects included. + * @brief Obtains all messages included in this conversation-like notification. + * + * @return Returns the list of all Message objects included. */ MessageVector GetAllConversationalMessages() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump() override; /** - * Converts a NotificationConversationalContent object into a Json. + * @brief Converts a NotificationConversationalContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ virtual bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationConversationalContent object from a Json. + * @brief Creates a NotificationConversationalContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationConversationalContent. + * @return Returns the NotificationConversationalContent. */ static NotificationConversationalContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel Indicates the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationConversationalContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationConversationalContent. */ static NotificationConversationalContent *Unmarshalling(Parcel &parcel); protected: /** - * Read a NotificationConversationalContent object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationConversationalContent object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel) override; private: - /** - * Default constructor used to create an empty NotificationConversationalContent instance. - */ NotificationConversationalContent() = default; private: diff --git a/interfaces/innerkits/ans/native/include/notification_conversational_message.h b/interfaces/innerkits/ans/native/include/notification_conversational_message.h index b32fe9f654eccd4066ed3ec74290e8d1e446476e..61e471ad58cb67ab53b1e68626f4537383b9e6d4 100644 --- a/interfaces/innerkits/ans/native/include/notification_conversational_message.h +++ b/interfaces/innerkits/ans/native/include/notification_conversational_message.h @@ -26,7 +26,9 @@ namespace Notification { class NotificationConversationalMessage : public Parcelable, public NotificationJsonConvertionBase { public: /** - * A constructor used to create a NotificationConversationalMessage instance with the input parameters passed. + * @brief A constructor used to create a NotificationConversationalMessage instance with the input parameters + * passed. + * * @param text Indicates the text to be displayed as the message content. This parameter cannot be null. * @param timestamp Indicates the time when the message arrived. * @param sender Indicates the MessageUser who sent the message. @@ -34,88 +36,98 @@ public: NotificationConversationalMessage( const std::string &text, int64_t timestamp, const MessageUser &sender); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationConversationalMessage() = default; /** - * Obtains the text to be displayed as the content of this message. - * @return the message content. + * @brief Obtains the text to be displayed as the content of this message. + * + * @return Returns the message content. */ std::string GetText() const; /** - * Obtains the time when this message arrived. - * @return the time when this message arrived. + * @brief Obtains the time when this message arrived. + * + * @return Returns the time when this message arrived. */ int64_t GetArrivedTime() const; /** - * Obtains the sender of this message. - * @return the message sender. + * @brief Obtains the sender of this message. + * + * @return Returns the message sender. */ MessageUser GetSender() const; /** - * Sets the MIME type and URI of this message. + * @brief Sets the MIME type and URI of this message. + * * @param mimeType Indicates the MIME type of this message. * @param uri Indicates the URI that points to the message content whose type is specified by the given MIME type. */ void SetData(const std::string &mimeType, const std::shared_ptr &uri); /** - * Obtains the MIME type of this message. - * @return the MIME type of this message. + * @brief Obtains the MIME type of this message. + * + * @return Returns the MIME type of this message. */ std::string GetMimeType() const; /** - * Obtains the URI of the message content with the specific MIME type. - * @return the URI of the message content with the specific MIME type. + * @brief Obtains the URI of the message content with the specific MIME type. + * + * @return Returns the URI of the message content with the specific MIME type. */ const std::shared_ptr GetUri() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Converts a NotificationConversationalMessage object into a Json. + * @brief Converts a NotificationConversationalMessage object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationConversationalMessage object from a Json. + * @brief Creates a NotificationConversationalMessage object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationConversationalMessage. + * @return Returns the NotificationConversationalMessage. */ static NotificationConversationalMessage *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel Indicates the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationConversationalMessage + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationConversationalMessage. */ static NotificationConversationalMessage *Unmarshalling(Parcel &parcel); private: - /** - * Default constructor used to create an empty NotificationConversationalMessage instance. - */ NotificationConversationalMessage() = default; /** - * Read a NotificationConversationalMessage object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationConversationalMessage object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification_distributed_options.h b/interfaces/innerkits/ans/native/include/notification_distributed_options.h index 56d9e65029dc002407362e75c07e88cdc12d21f3..6d0ad4c6014d5b180bc8194f1ffc40490baf5c0f 100644 --- a/interfaces/innerkits/ans/native/include/notification_distributed_options.h +++ b/interfaces/innerkits/ans/native/include/notification_distributed_options.h @@ -23,96 +23,107 @@ namespace OHOS { namespace Notification { class NotificationDistributedOptions : public Parcelable, public NotificationJsonConvertionBase { public: - /** - * Default constructor used to create a NotificationDistributedOptions instance. - */ NotificationDistributedOptions() = default; /** - * Constructor used to create a NotificationDistributedOptions instance. + * @brief Constructor used to create a NotificationDistributedOptions instance. + * * @param distribute Specifies whether a notification is distributed. - * @param dvsDisplay The devices that support display. - * @param dvsOperate The devices that support operate. + * @param dvsDisplay Indicates the devices that support display. + * @param dvsOperate Indicates the devices that support operate. */ NotificationDistributedOptions( bool distribute, const std::vector &dvsDisplay, const std::vector &dvsOperate); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationDistributedOptions() = default; /** - * Sets whether a notification is distributed. + * @brief Sets whether a notification is distributed. + * * @param distribute Specifies whether a notification is distributed. */ void SetDistributed(bool distribute); /** - * Checks whether a notification is distributed. - * @return true if the notification is distributed; returns false otherwise. + * @brief Checks whether a notification is distributed. + * + * @return Returns true if the notification is distributed; returns false otherwise. */ bool IsDistributed() const; /** - * Sets devices that support display. - * @param devices The devices that support display. + * @brief Sets devices that support display. + * + * @param devices Indicates the devices that support display. */ void SetDevicesSupportDisplay(const std::vector &devices); /** - * Obtains the devices that support display. - * @return the devices that support display. + * @brief Obtains the devices that support display. + * + * @return Returns the devices that support display. */ std::vector GetDevicesSupportDisplay() const; /** - * Sets devices that support operate. - * @param devices The devices that support operate. + * @brief Sets devices that support operate. + * + * @param devices Indicates the devices that support operate. */ void SetDevicesSupportOperate(const std::vector &devices); /** - * Obtains the devices that support operate. - * @return the devices that support operate. + * @brief Obtains the devices that support operate. + * + * @return Returns the devices that support operate. */ std::vector GetDevicesSupportOperate() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Converts a NotificationDistributedOptions object into a Json. + * @brief Converts a NotificationDistributedOptions object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationDistributedOptions object from a Json. + * @brief Creates a NotificationDistributedOptions object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationDistributedOptions. + * @return Returns the NotificationDistributedOptions. */ static NotificationDistributedOptions *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel Indicates the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationDistributedOptions + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationDistributedOptions object. */ static NotificationDistributedOptions *Unmarshalling(Parcel &parcel); private: /** - * Read a NotificationDistributedOptions object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationDistributedOptions object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification_helper.h b/interfaces/innerkits/ans/native/include/notification_helper.h index 39d14580c30f09c23328cd0c08cdb5d0edfebb31..bacbee4467353cf47e7b3f00f2736d1d56ff8582 100644 --- a/interfaces/innerkits/ans/native/include/notification_helper.h +++ b/interfaces/innerkits/ans/native/include/notification_helper.h @@ -30,7 +30,7 @@ namespace Notification { class NotificationHelper { public: /** - * Creates a notification slot. + * @brief Creates a notification slot. * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the @@ -45,7 +45,7 @@ public: static ErrCode AddNotificationSlot(const NotificationSlot &slot); /** - * Adds a notification slot by type. + * @brief Adds a notification slot by type. * * @param slotType Indicates the notification slot type to be added. * @return Returns add notification slot result. @@ -53,7 +53,7 @@ public: static ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType); /** - * Creates multiple notification slots. + * @brief Creates multiple notification slots. * * @param slots Indicates the notification slots to create. * @return Returns add notification slots result. @@ -61,7 +61,7 @@ public: static ErrCode AddNotificationSlots(const std::vector &slots); /** - * Deletes a created notification slot based on the slot ID. + * @brief Deletes a created notification slot based on the slot ID. * * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot * This parameter must be specified. @@ -70,14 +70,14 @@ public: static ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType); /** - * Deletes all notification slots. + * @brief Deletes all notification slots. * * @return Returns remove all slots result. */ static ErrCode RemoveAllSlots(); /** - * Queries a created notification slot. + * @brief Queries a created notification slot. * * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This * parameter must be specified. @@ -87,14 +87,14 @@ public: static ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr &slot); /** - * Obtains all notification slots of this application. + * @brief Obtains all notification slots of this application. * @param slots Indicates the created NotificationSlot. * @return Returns all notification slots of this application. */ static ErrCode GetNotificationSlots(std::vector> &slots); /** - * Creates a notification slot group to which a NotificationSlot object can be bound by + * @brief Creates a notification slot group to which a NotificationSlot object can be bound by * calling NotificationSlot::SetSlotGroup(string). * @note A NotificationSlotGroup instance cannot be used directly after being initialized. * Instead, you have to call this method to create a notification slot group so that you can bind @@ -108,7 +108,7 @@ public: static ErrCode AddNotificationSlotGroup(const NotificationSlotGroup &slotGroup); /** - * Creates multiple notification slot groups. + * @brief Creates multiple notification slot groups. * @note The precautions for using this method are similar to those for * AddNotificationSlotGroup(NotificationSlotGroup). * @@ -118,7 +118,7 @@ public: static ErrCode AddNotificationSlotGroups(const std::vector &slotGroups); /** - * Deletes a created notification slot group based on the slot group ID. + * @brief Deletes a created notification slot group based on the slot group ID. * * @param slotGroupId Indicates the ID of the notification slot group, which is created by * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. @@ -127,16 +127,16 @@ public: static ErrCode RemoveNotificationSlotGroup(const std::string &slotGroupId); /** - * Queries a created notification slot group. + * @brief Queries a created notification slot group. * - * @param groupId Indicates the ID of the slot group. - * @param group Indicates the created NotificationSlotGroup. + * @param groupId Indicates the ID of the slot group. + * @param group Indicates the created NotificationSlotGroup. * @return Returns get notification slot group result. */ static ErrCode GetNotificationSlotGroup(const std::string &groupId, sptr &group); /** - * Obtains a list of created notification slot groups. + * @brief Obtains a list of created notification slot groups. * * @param groups Indicates a list of created notification slot groups. * @return Returns get notification slot groups result. @@ -144,7 +144,7 @@ public: static ErrCode GetNotificationSlotGroups(std::vector> &groups); /** - * Obtains number of slot. + * @brief Obtains number of slot. * * @param bundleOption Indicates the bundle name and uid of the application. * @param num Indicates number of slot. @@ -153,7 +153,7 @@ public: static ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, int &num); /** - * Publishes a notification. + * @brief Publishes a notification. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * @@ -164,7 +164,7 @@ public: static ErrCode PublishNotification(const NotificationRequest &request); /** - * Publishes a notification with a specified label. + * @brief Publishes a notification with a specified label. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * @@ -176,7 +176,7 @@ public: static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request); /** - * Publishes a notification on a specified remote device. + * @brief Publishes a notification on a specified remote device. * @note If a notification with the same ID has been published by the current application and has not been deleted, * this method will update the notification. * @@ -189,7 +189,7 @@ public: static ErrCode PublishNotification(const NotificationRequest &request, const std::string &deviceId); /** - * Cancels a published notification. + * @brief Cancels a published notification. * * @param notificationId Indicates the unique notification ID in the application. * The value must be the ID of a published notification. @@ -199,7 +199,7 @@ public: static ErrCode CancelNotification(int32_t notificationId); /** - * Cancels a published notification matching the specified label and notificationId. + * @brief Cancels a published notification matching the specified label and notificationId. * * @param label Indicates the label of the notification to cancel. * @param notificationId Indicates the ID of the notification to cancel. @@ -208,14 +208,15 @@ public: static ErrCode CancelNotification(const std::string &label, int32_t notificationId); /** - * Cancels all the published notifications. + * @brief Cancels all the published notifications. + * * @note To cancel a specified notification, see CancelNotification(int_32). * @return Returns cancel all notifications result. */ static ErrCode CancelAllNotifications(); /** - * Obtains the number of active notifications of the current application in the system. + * @brief Obtains the number of active notifications of the current application in the system. * * @param nums Indicates the number of active notifications of the current application. * @return Returns get active notification nums result. @@ -223,14 +224,15 @@ public: static ErrCode GetActiveNotificationNums(int32_t &num); /** - * Obtains active notifications of the current application in the system. + * @brief Obtains active notifications of the current application in the system. + * * @param request Indicates active NotificationRequest objects of the current application. * @return Returns get active notifications result. */ static ErrCode GetActiveNotifications(std::vector> &request); /** - * Obtains the map for sorting notifications of the current application. + * @brief Obtains the map for sorting notifications of the current application. * * @param sortingMap Indicates the NotificationSortingMap object for the current application. * @return Returns get current app sorting result. @@ -238,7 +240,8 @@ public: static ErrCode GetCurrentAppSorting(sptr &sortingMap); /** - * Allows another application to act as an agent to publish notifications in the name of your application bundle. + * @brief Allows another application to act as an agent to publish notifications in the name of your application + * bundle. * * @param agent Indicates the name of the application bundle that can publish notifications for your application. * @return Returns set notification agent result. @@ -246,7 +249,7 @@ public: static ErrCode SetNotificationAgent(const std::string &agent); /** - * Obtains the name of the application bundle that can publish notifications in the name of your application. + * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. * * @param agent Indicates the name of the application bundle that can publish notifications for your application if * any; returns null otherwise. @@ -255,7 +258,7 @@ public: static ErrCode GetNotificationAgent(std::string &agent); /** - * Checks whether your application has permission to publish notifications by calling + * @brief Checks whether your application has permission to publish notifications by calling * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the * given representativeBundle. * @@ -266,7 +269,7 @@ public: static ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish); /** - * Publishes a notification in the name of a specified application bundle. + * @brief Publishes a notification in the name of a specified application bundle. * @note If the notification to be published has the same ID as a published notification that has not been canceled, * the existing notification will be replaced by the new one. * @@ -274,20 +277,21 @@ public: * This parameter must be specified. * @param representativeBundle Indicates the name of the application bundle that allows your application to publish * notifications for it by calling setNotificationAgent. - * @return publish notification as bundle result. + * @return Returns publish notification as bundle result. */ static ErrCode PublishNotificationAsBundle( const std::string &representativeBundle, const NotificationRequest &request); /** - * Sets the number of active notifications of the current application as the number to be displayed on the + * @brief Sets the number of active notifications of the current application as the number to be displayed on the * notification badge. + * * @return Returns set notification badge num result. */ static ErrCode SetNotificationBadgeNum(); /** - * Sets the number to be displayed on the notification badge of the application. + * @brief Sets the number to be displayed on the notification badge of the application. * * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged. * The value 0 indicates that no badge is displayed on the application icon. @@ -297,7 +301,7 @@ public: static ErrCode SetNotificationBadgeNum(int32_t num); /** - * Checks whether this application has permission to publish notifications. The caller must have + * @brief Checks whether this application has permission to publish notifications. The caller must have * system permissions to call this method. * * @param allowed True if this application has the permission; returns false otherwise @@ -306,7 +310,7 @@ public: static ErrCode IsAllowedNotify(bool &allowed); /** - * Checks whether this application has permission to publish notifications. + * @brief Checks whether this application has permission to publish notifications. * * @param allowed True if this application has the permission; returns false otherwise * @return Returns is allowed notify result. @@ -314,7 +318,7 @@ public: static ErrCode IsAllowedNotifySelf(bool &allowed); /** - * Allow the current application to publish notifications on a specified device. + * @brief Allow the current application to publish notifications on a specified device. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can * only be null or an empty string, indicating the current device. @@ -323,33 +327,33 @@ public: static ErrCode RequestEnableNotification(std::string &deviceId); /** - * Checks whether this application is in the suspended state.Applications in this state cannot publish + * @brief Checks whether this application is in the suspended state.Applications in this state cannot publish * notifications. * - * @param suspended True if this application is suspended; returns false otherwise. + * @param suspended True if this application is suspended; false otherwise. * @return Returns are notifications suspended. */ static ErrCode AreNotificationsSuspended(bool &suspended); /** - * Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. + * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. * - * @param hasPermission True if this application is suspended; returns false otherwise. + * @param hasPermission True if this application is suspended; false otherwise. * @return Returns has notification policy access permission. */ static ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission); /** - * Obtains the importance level of this application. + * @brief Obtains the importance level of this application. * - * @param importance the importance level of this application, which can be LEVEL_NONE, + * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. * @return Returns get bundle importance result */ static ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance); /** - * Subscribes to notifications from all applications. This method can be called only by applications + * @brief Subscribes to notifications from all applications. This method can be called only by applications * with required system permissions. * @note To subscribe to a notification, inherit the {NotificationSubscriber} class, override its * callback methods and create a subscriber. The subscriber will be used as a parameter of this method. @@ -365,7 +369,7 @@ public: static ErrCode SubscribeNotification(const NotificationSubscriber &subscriber); /** - * Subscribes to all notifications based on the filtering criteria. This method can be called only + * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only * by applications with required system permissions. * @note After {subscribeInfo} is specified, a subscriber receives only the notifications that * meet the filter criteria specified by {subscribeInfo}. @@ -385,7 +389,7 @@ public: const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo); /** - * Unsubscribes from all notifications. This method can be called only by applications with required + * @brief Unsubscribes from all notifications. This method can be called only by applications with required * system permissions. * @note Generally, you subscribe to a notification by calling the * {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application @@ -402,7 +406,7 @@ public: static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber); /** - * Unsubscribes from all notifications based on the filtering criteria. This method can be called + * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called * only by applications with required system permissions. * @note A subscriber will no longer receive the notifications from specified notification sources. * @@ -415,7 +419,7 @@ public: static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo); /** - * Removes a specified removable notification of other applications. + * @brief Removes a specified removable notification of other applications. * @note Your application must have platform signature to use this method. * * @param key Indicates the key of the notification to remove. @@ -424,7 +428,7 @@ public: static ErrCode RemoveNotification(const std::string &key); /** - * Removes a specified removable notification of other applications. + * @brief Removes a specified removable notification of other applications. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. @@ -436,7 +440,7 @@ public: const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label); /** - * Removes a specified removable notification of other applications. + * @brief Removes a specified removable notification of other applications. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. @@ -445,7 +449,7 @@ public: static ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption); /** - * Removes all removable notifications of a specified bundle. + * @brief Removes all removable notifications of a specified bundle. * @note Your application must have platform signature to use this method. * * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed. @@ -454,14 +458,14 @@ public: static ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption); /** - * Removes all removable notifications in the system. + * @brief Removes all removable notifications in the system. * @note Your application must have platform signature to use this method. * @return Returns remove notifications result. */ static ErrCode RemoveNotifications(); /** - * Returns all notification slots belonging to the specified bundle. + * @brief Obtains all notification slots belonging to the specified bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param slots Indicates a list of notification slots. @@ -471,7 +475,7 @@ public: const NotificationBundleOption &bundleOption, std::vector> &slots); /** - * Update all notification slots for the specified bundle. + * @brief Update all notification slots for the specified bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param slots Indicates a list of new notification slots. @@ -481,7 +485,7 @@ public: const NotificationBundleOption &bundleOption, const std::vector> &slots); /** - * Update all notification slot groups for the specified bundle. + * @brief Update all notification slot groups for the specified bundle. * * @param bundleOption Indicates the bundle name and uid of the application. * @param groups Indicates a list of new notification slot groups. @@ -491,7 +495,7 @@ public: const NotificationBundleOption &bundleOption, const std::vector> &groups); /** - * Obtains all active notifications in the current system. The caller must have system permissions to + * @brief Obtains all active notifications in the current system. The caller must have system permissions to * call this method. * * @param notification Indicates all active notifications of this application. @@ -500,31 +504,32 @@ public: static ErrCode GetAllActiveNotifications(std::vector> ¬ification); /** - * Obtains the active notifications corresponding to the specified key in the system. To call this method + * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method * to obtain particular active notifications, you must have received the notifications and obtained the key * via {Notification::GetKey()}. * * @param key Indicates the key array for querying corresponding active notifications. * If this parameter is null, this method returns all active notifications in the system. - * @return Returns the set of active notifications corresponding to the specified key. + * @param notification Indicates the set of active notifications corresponding to the specified key. + * @return Returns get all active notifications. */ static ErrCode GetAllActiveNotifications( const std::vector key, std::vector> ¬ification); /** - * Checks whether a specified application has the permission to publish notifications. If bundle specifies + * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies * the current application, no permission is required for calling this method. If bundle specifies another * application, the caller must have system permissions. * * @param bundleOption Indicates the bundle name and uid of the application. - * @param allowed True if the application has permissions; returns false otherwise. + * @param allowed True if the application has permissions; false otherwise. * @return Returns is allowed notify result. */ static ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed); /** - * Sets whether to allow all applications to publish notifications on a specified device. The caller must have - * system permissions to call this method. + * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must + * have system permissions to call this method. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only * be null or an empty string, indicating the current device. @@ -536,20 +541,20 @@ public: static ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled); /** - * Sets whether to allow the current application to publish notifications on a specified device. The caller + * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller * must have system permissions to call this method. * * @param deviceId Indicates the ID of the device running the application. At present, this parameter can * only be null or an empty string, indicating the current device. * @param enabled Specifies whether to allow the current application to publish notifications. The value * true indicates that notifications are allowed, and the value false indicates that - * notifications are not allowed. + * notifications are not allowed. * @return Returns set notifications enabled for default bundle result. */ static ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled); /** - * Sets whether to allow a specified application to publish notifications on a specified device. The caller + * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller * must have system permissions to call this method. * * @param bundleOption Indicates the bundle name and uid of the application. @@ -564,7 +569,7 @@ public: const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled); /** - * Sets whether to allow a specified application to show badge. + * @brief Sets whether to allow a specified application to show badge. * * @param bundleOption Indicates the bundle name and uid of the application. * @param enabled Specifies whether to allow the given application to show badge. @@ -573,7 +578,7 @@ public: static ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled); /** - * Obtains the flag that whether to allow a specified application to show badge. + * @brief Obtains the flag that whether to allow a specified application to show badge. * * @param bundleOption Indicates the bundle name and uid of the application. * @param enabled Specifies whether to allow the given application to show badge. @@ -582,7 +587,7 @@ public: static ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled); /** - * Obtains the flag that whether to allow the current application to show badge. + * @brief Obtains the flag that whether to allow the current application to show badge. * * @param enabled Specifies whether to allow the given application to show badge. * @return Returns get result. @@ -590,24 +595,24 @@ public: static ErrCode GetShowBadgeEnabled(bool &enabled); /** - * Cancel the notification of the specified group of this application. + * @brief Cancel the notification of the specified group of this application. * - * @param groupName the specified group name. + * @param groupName Indicates the specified group name. * @return Returns cancel group result. */ static ErrCode CancelGroup(const std::string &groupName); /** - * Remove the notification of the specified group of the specified application. + * @brief Remove the notification of the specified group of the specified application. * * @param bundleOption Indicates the bundle name and uid of the specified application. - * @param groupName the specified group name. + * @param groupName Indicates the specified group name. * @return Returns remove group by bundle result. */ static ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName); /** - * Sets the do not disturb time. + * @brief Sets the do not disturb time. * @note Your application must have system signature to call this method. * * @param doNotDisturbDate Indicates the do not disturb time to set. @@ -616,7 +621,7 @@ public: static ErrCode SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate); /** - * Obtains the do not disturb time. + * @brief Obtains the do not disturb time. * @note Your application must have system signature to call this method. * * @param doNotDisturbDate Indicates the do not disturb time to get. @@ -625,7 +630,7 @@ public: static ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate); /** - * Obtains the flag that whether to support do not disturb mode. + * @brief Obtains the flag that whether to support do not disturb mode. * * @param doesSupport Specifies whether to support do not disturb mode. * @return Returns check result. @@ -633,7 +638,7 @@ public: static ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport); /** - * Check if the device supports distributed notification. + * @brief Check if the device supports distributed notification. * * @param enabled True if the device supports distributed notification; false otherwise. * @return Returns is distributed enabled result. @@ -641,7 +646,7 @@ public: static ErrCode IsDistributedEnabled(bool &enabled); /** - * Set whether the device supports distributed notifications. + * @brief Set whether the device supports distributed notifications. * * @param enable Specifies whether to enable the device to support distributed notification. * The value true indicates that the device is enabled to support distributed notifications, and @@ -651,7 +656,7 @@ public: static ErrCode EnableDistributed(const bool enabled); /** - * Set whether an application supports distributed notifications. + * @brief Set whether an application supports distributed notifications. * * @param bundleOption Indicates the bundle name and uid of an application. * @param enabled Specifies whether to enable an application to support distributed notification. @@ -663,7 +668,7 @@ public: static ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled); /** - * Set whether this application supports distributed notifications. + * @brief Set whether this application supports distributed notifications. * * @param enabled Specifies whether to enable this application to support distributed notification. * The value true indicates that this application is enabled to support distributed notifications, @@ -674,7 +679,7 @@ public: static ErrCode EnableDistributedSelf(const bool enabled); /** - * Check whether an application supports distributed notifications. + * @brief Check whether an application supports distributed notifications. * * @param bundleOption Indicates the bundle name and uid of an application. * @param enabled True if the application supports distributed notification; false otherwise. @@ -683,7 +688,7 @@ public: static ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled); /** - * Obtains the device remind type. + * @brief Obtains the device remind type. * @note Your application must have system signature to call this method. * * @param remindType Indicates the device remind type to get. @@ -692,7 +697,7 @@ public: static ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType); /** - * Publishes a continuous task notification. + * @brief Publishes a continuous task notification. * @param request Indicates the NotificationRequest object for setting the notification content. * This parameter must be specified. * @return Returns publish continuous task notification result. @@ -700,7 +705,7 @@ public: static ErrCode PublishContinuousTaskNotification(const NotificationRequest &request); /** - * Cancels a published continuous task notification matching the specified label and notificationId. + * @brief Cancels a published continuous task notification matching the specified label and notificationId. * * @param label Indicates the label of the continuous task notification to cancel. * @param notificationId Indicates the ID of the continuous task notification to cancel. @@ -709,24 +714,24 @@ public: static ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId); /** - * Obtains whether the template is supported by the system. + * @brief Obtains whether the template is supported by the system. * - * @param support whether is it a system supported template. + * @param support Indicates whether is it a system supported template. * @return Returns check result. */ static ErrCode IsSupportTemplate(const std::string &templateName, bool &support); /** - * Checks whether this application has permission to publish notifications under the user. + * @brief Checks whether this application has permission to publish notifications under the user. * * @param userId Indicates the userId of the application. - * @param allowed True if the application has permissions; returns false otherwise. + * @param allowed True if the application has permissions; false otherwise. * @return Returns get allowed result. */ static ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed); /** - * Sets whether to allow all applications to publish notifications on a specified user. + * @brief Sets whether to allow all applications to publish notifications on a specified user. * The caller must have system permissions to call this method. * * @param userId Indicates the ID of the user running the application. @@ -738,7 +743,7 @@ public: static ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled); /** - * Removes notifications under specified user. + * @brief Removes notifications under specified user. * @note Your application must have platform signature to use this method. * * @param userId Indicates the ID of user whose notifications are to be removed. @@ -747,7 +752,7 @@ public: static ErrCode RemoveNotifications(const int32_t &userId); /** - * Sets the do not disturb time on a specified user. + * @brief Sets the do not disturb time on a specified user. * @note Your application must have system signature to call this method. * * @param userId Indicates the specific user. @@ -757,7 +762,7 @@ public: static ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate); /** - * Obtains the do not disturb time on a specified user. + * @brief Obtains the do not disturb time on a specified user. * @note Your application must have system signature to call this method. * * @param userId Indicates the specific user. diff --git a/interfaces/innerkits/ans/native/include/notification_json_convert.h b/interfaces/innerkits/ans/native/include/notification_json_convert.h index 2a6fb1683bcc312619b78acd7ee8851049432dd2..f6754941ac4f53e3fff8cf9f6d712f7d53126dc1 100644 --- a/interfaces/innerkits/ans/native/include/notification_json_convert.h +++ b/interfaces/innerkits/ans/native/include/notification_json_convert.h @@ -23,18 +23,24 @@ namespace OHOS { namespace Notification { class NotificationJsonConvertionBase { public: - /** - * Default deconstructor used to deconstruct. - */ virtual ~NotificationJsonConvertionBase() = default; + /** + * @brief Converts NotificationJsonConvertionBase object to json object. + * + * @param jsonObject Indicates the json object. + */ virtual bool ToJson(nlohmann::json &jsonObject) const = 0; }; class NotificationJsonConverter { public: /** - * Convert NotificationJsonConvertionBase object to json object. + * @brief Converts NotificationJsonConvertionBase object to json object. + * + * @param convertionBase Indicates the NotificationJsonConvertionBase object. + * @param jsonObject Indicates the json object. + * @return Returns true if the conversion is successful; returns false otherwise. */ static bool ConvertToJosn(const NotificationJsonConvertionBase *convertionBase, nlohmann::json &jsonObject) { @@ -46,6 +52,13 @@ public: return convertionBase->ToJson(jsonObject); } + /** + * @brief Converts NotificationJsonConvertionBase object to json string. + * + * @param convertionBase Indicates the NotificationJsonConvertionBase object. + * @param jsonString Indicates the json string. + * @return Returns true if the conversion is successful; returns false otherwise. + */ static bool ConvertToJosnString(const NotificationJsonConvertionBase *convertionBase, std::string &jsonString) { if (convertionBase == nullptr) { @@ -63,6 +76,12 @@ public: return true; } + /** + * @brief Converts json object to a subclass object whose base class is NotificationJsonConvertionBase. + * + * @param jsonObject Indicates the json object. + * @return Returns the subclass object. + */ template static T *ConvertFromJosn(const nlohmann::json &jsonObject) { @@ -74,6 +93,12 @@ public: return T::FromJson(jsonObject); } + /** + * @brief Converts json string to a subclass object whose base class is NotificationJsonConvertionBase. + * + * @param jsonString Indicates the json string. + * @return Returns the subclass object. + */ template static T *ConvertFromJosnString(const std::string &jsonString) { diff --git a/interfaces/innerkits/ans/native/include/notification_long_text_content.h b/interfaces/innerkits/ans/native/include/notification_long_text_content.h index 13b6ebcaf03e721727c8f1a4f0652092707e6bdd..e98b0af5aef11b6a7c0c118a63d70c8bef74f0a9 100644 --- a/interfaces/innerkits/ans/native/include/notification_long_text_content.h +++ b/interfaces/innerkits/ans/native/include/notification_long_text_content.h @@ -23,98 +23,110 @@ namespace OHOS { namespace Notification { class NotificationLongTextContent : public NotificationBasicContent { public: - /** - * Default constructor used to create a NotificationLongTextContent instance. - */ NotificationLongTextContent() = default; /** - * A constructor used to create a NotificationLongTextContent instance with the input parameter longText passed. + * @brief A constructor used to create a NotificationLongTextContent instance with the input parameter longText + * passed. + * * @param longText Indicates the long text to be included. The value contains a maximum of 1024 characters. */ explicit NotificationLongTextContent(const std::string &longText); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationLongTextContent() = default; /** - * Sets the title to be displayed when this long text notification is expanded. After this title is set, + * @brief Sets the title to be displayed when this long text notification is expanded. After this title is set, * the title set by setTitle(string) will be displayed only when this notification is in the collapsed state. + * * @param exTitle Indicates the title to be displayed when this notification is expanded. */ void SetExpandedTitle(const std::string &exTitle); /** - * Obtains the title that will be displayed for this long text notification when it is expanded. - * @return the title to be displayed when this notification is expanded. + * @brief Obtains the title that will be displayed for this long text notification when it is expanded. + * + * @return Returns the title to be displayed when this notification is expanded. */ std::string GetExpandedTitle() const; /** - * Sets the brief text to be included in a long text notification. + * @brief Sets the brief text to be included in a long text notification. * The brief text is a summary of a long text notification and is displayed in the first line of the notification. * Similar to setAdditionalText(string), the font of the brief text is also smaller than the notification text. * The positions where the brief text and additional text will display may conflict. * If both texts are set, only the additional text will be displayed. + * * @param briefText Indicates the brief text to be included. */ void SetBriefText(const std::string &briefText); /** - * Obtains the brief text of a long text notification specified by calling the setBriefText(string) method. - * @return the brief text of the long text notification. + * @brief Obtains the brief text of a long text notification specified by calling the setBriefText(string) method. + * + * @return Returns the brief text of the long text notification. */ std::string GetBriefText() const; /** - * Sets the long text to be included in a long text notification. + * @brief Sets the long text to be included in a long text notification. + * * @param longText Indicates the long text to be included. The value contains a maximum of 1024 characters. */ void SetLongText(const std::string &longText); /** - * Obtains a notification's long text, which is set by calling the setLongText(string) method. - * @return the long text. + * @brief Obtains a notification's long text, which is set by calling the setLongText(string) method. + * + * @return Returns the long text. */ std::string GetLongText() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump() override; /** - * Converts a NotificationLongTextContent object into a Json. + * @brief Converts a NotificationLongTextContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationLongTextContent object from a Json. + * @brief Creates a NotificationLongTextContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationLongTextContent. + * @return Returns the NotificationLongTextContent. */ static NotificationLongTextContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel Indicates the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationLongTextContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationLongTextContent object. */ static NotificationLongTextContent *Unmarshalling(Parcel &parcel); protected: /** - * Read a NotificationLongTextContent object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationLongTextContent object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel) override; diff --git a/interfaces/innerkits/ans/native/include/notification_media_content.h b/interfaces/innerkits/ans/native/include/notification_media_content.h index 5044fa89b3206b7065a85fb4e9d0d288523773fd..57e06ae0365d9b2d21e36fae13f83da2174e0a31 100644 --- a/interfaces/innerkits/ans/native/include/notification_media_content.h +++ b/interfaces/innerkits/ans/native/include/notification_media_content.h @@ -25,32 +25,28 @@ class AVToken; class NotificationMediaContent : public NotificationBasicContent { public: - /** - * Default constructor used to create a NotificationMediaContent instance. - */ NotificationMediaContent() = default; - /** - * Default deconstructor used to deconstruct. - */ ~NotificationMediaContent() = default; /** - * Attaches a specified AVToken to this media playback notification. + * @brief Attaches a specified AVToken to this media playback notification. * After an AVToken is attached, this notification can interact with the associated AVSession * so that users can control media playback in this notification. + * * @param avToken Indicates the AVToken to attach. */ void SetAVToken(const std::shared_ptr &avToken); /** - * Obtains the AVToken attached to this media playback notification. - * @return the AVToken attached to this notification. + * @brief Obtains the AVToken attached to this media playback notification. + * + * @return Returns the AVToken that attached to this notification. */ const std::shared_ptr GetAVToken() const; /** - * Sets up to three NotificationActionButton objects to be shown in this media playback notification. + * @brief Sets up to three NotificationActionButton objects to be shown in this media playback notification. * Before publishing this notification, you should also call * NotificationRequest::addActionButton(NotificationActionButton) to add specified NotificationActionButton objects * for this notification so that this method can take effect. The added action buttons will be assigned sequence @@ -58,53 +54,64 @@ public: * must match those assigned to added action buttons. Otherwise, the notification will fail to publish. By default, * the sequence number starts from 0. If you want to show three action buttons, the value of actions should be 0, * 1, 2. + * * @param actions Indicates the list of sequence numbers representing the NotificationActionButton objects * to be shown in this notification. */ void SetShownActions(const std::vector &actions); /** - * Obtains the list of sequence numbers representing the NotificationActionButton objects + * @brief Obtains the list of sequence numbers representing the NotificationActionButton objects * to be shown in this media playback notification. - * @return the list of the action buttons to be shown. + * + * @return Returns the list of the action buttons to be shown. */ std::vector GetShownActions() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump() override; /** - * Converts a NotificationMediaContent object into a Json. + * @brief Converts a NotificationMediaContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ virtual bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationMediaContent object from a Json. + * @brief Creates a NotificationMediaContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationMediaContent. + * @return Returns the NotificationMediaContent object. */ static NotificationMediaContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationMediaContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationMediaContent object. */ static NotificationMediaContent *Unmarshalling(Parcel &parcel); protected: /** - * Read a NotificationMediaContent object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationMediaContent object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel) override; diff --git a/interfaces/innerkits/ans/native/include/notification_multiline_content.h b/interfaces/innerkits/ans/native/include/notification_multiline_content.h index 7f0e91655289d225592102ec49b8f7aab7f5eeef..61daf92f37476c14b8199cb48bfe7bd968f11808 100644 --- a/interfaces/innerkits/ans/native/include/notification_multiline_content.h +++ b/interfaces/innerkits/ans/native/include/notification_multiline_content.h @@ -23,95 +23,105 @@ namespace OHOS { namespace Notification { class NotificationMultiLineContent : public NotificationBasicContent { public: - /** - * Default constructor used to create a NotificationMultiLineContent instance. - */ NotificationMultiLineContent() = default; - /** - * Default deconstructor used to deconstruct. - */ ~NotificationMultiLineContent() = default; /** - * Sets the title to be displayed when this multi-line notification is expanded. + * @brief Sets the title to be displayed when this multi-line notification is expanded. * After this title is set, the title set by setTitle(string) will be displayed only * when this notification is in the collapsed state. + * * @param exTitle Indicates the title to be displayed when this notification is expanded. */ void SetExpandedTitle(const std::string &exTitle); /** - * Obtains the title that will be displayed for this multi-line notification when it is expanded. - * @return the title to be displayed when this notification is expanded. + * @brief Obtains the title that will be displayed for this multi-line notification when it is expanded. + * + * @return Returns the title to be displayed when this notification is expanded. */ std::string GetExpandedTitle() const; /** - * Sets the brief text to be included in a multi-line notification. + * @brief Sets the brief text to be included in a multi-line notification. * The brief text is a summary of this multi-line notification and is displayed in the first line of * the notification. Similar to setAdditionalText(string), the font of the brief text is also * smaller than the notification text set by calling setText(string). * The positions where the brief text and additional text will display may conflict. * If both texts are set, only the additional text will be displayed. + * * @param briefText Indicates the brief text to be included. */ void SetBriefText(const std::string &briefText); /** - * Obtains the brief text that has been set by calling setBriefText(string) for this multi-line notification. - * @return the brief text of this notification. + * @brief Obtains the brief text that has been set by calling setBriefText(string) for this multi-line notification. + * + * @return Returns the brief text of this notification. */ std::string GetBriefText() const; /** - * Adds a single line of text to this notification. + * @brief Adds a single line of text to this notification. * You can call this method up to seven times to add seven lines to a notification. + * * @param oneLine Indicates the single line of text to be included. */ void AddSingleLine(const std::string &oneLine); /** - * Obtains the list of lines included in this multi-line notification. - * @return the list of lines included in this notification. + * @brief Obtains the list of lines included in this multi-line notification. + * + * @return Returns the list of lines included in this notification. */ std::vector GetAllLines() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump() override; /** - * Converts a NotificationMultiLineContent object into a Json. + * @brief Converts a NotificationMultiLineContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ virtual bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationMultiLineContent object from a Json. + * @brief Creates a NotificationMultiLineContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationMultiLineContent. + * @return Returns the NotificationMultiLineContent object. */ static NotificationMultiLineContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationMultiLineContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationMultiLineContent object. */ static NotificationMultiLineContent *Unmarshalling(Parcel &parcel); protected: /** - * Read a NotificationMultiLineContent object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationMultiLineContent object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel) override; diff --git a/interfaces/innerkits/ans/native/include/notification_normal_content.h b/interfaces/innerkits/ans/native/include/notification_normal_content.h index 6bd04ae5760fe620eef0b390e610229eb6da2403..45183b13fa827d3bc98816e72bbca61d576fe5ce 100644 --- a/interfaces/innerkits/ans/native/include/notification_normal_content.h +++ b/interfaces/innerkits/ans/native/include/notification_normal_content.h @@ -23,44 +23,46 @@ namespace OHOS { namespace Notification { class NotificationNormalContent : public NotificationBasicContent { public: - /** - * Default constructor used to create a NotificationNormalContent instance. - */ NotificationNormalContent() = default; - /** - * Default deconstructor used to deconstruct. - */ ~NotificationNormalContent() = default; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump() override; /** - * Converts a NotificationNormalContent object into a Json. + * @brief Converts a NotificationNormalContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationNormalContent object from a Json. + * @brief Creates a NotificationNormalContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationNormalContent. + * @return Returns the NotificationNormalContent object. */ static NotificationNormalContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationNormalContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationNormalContent object. */ static NotificationNormalContent *Unmarshalling(Parcel &parcel); }; diff --git a/interfaces/innerkits/ans/native/include/notification_picture_content.h b/interfaces/innerkits/ans/native/include/notification_picture_content.h index 8ed0dc54b0824b45ae92a1c2dbbd0453f8c51366..fe2e21c76488915e74397918d192817f8d0aa98b 100644 --- a/interfaces/innerkits/ans/native/include/notification_picture_content.h +++ b/interfaces/innerkits/ans/native/include/notification_picture_content.h @@ -24,93 +24,104 @@ namespace OHOS { namespace Notification { class NotificationPictureContent : public NotificationBasicContent { public: - /** - * Default constructor used to create an empty NotificationPictureContent instance. - */ NotificationPictureContent() = default; - /** - * Default deconstructor used to deconstruct. - */ ~NotificationPictureContent() = default; /** - * Sets the title to be displayed when this picture-attached notification is expanded. + * @brief Sets the title to be displayed when this picture-attached notification is expanded. * After this title is set, the title set by setTitle(string) will be displayed only * when this notification is in the collapsed state. + * * @param exTitle Indicates the title to be displayed when this notification is expanded. */ void SetExpandedTitle(const std::string &exTitle); /** - * Obtains the title that will be displayed for this picture-attached notification when it is expanded. - * @return the title to be displayed when this notification is expanded. + * @brief Obtains the title that will be displayed for this picture-attached notification when it is expanded. + * + * @return Returns the title to be displayed when this notification is expanded. */ std::string GetExpandedTitle() const; /** - * Sets the brief text to be included in a picture-attached notification. + * @brief Sets the brief text to be included in a picture-attached notification. * The brief text is a summary of a picture-attached notification and is displayed in the first line of the * notification. Similar to setAdditionalText(string), the font of the brief text is also smaller than the * notification text. The positions where the brief text and additional text will display may conflict. If both * texts are set, only the additional text will be displayed. + * * @param briefText Indicates the brief text to be included. */ void SetBriefText(const std::string &briefText); /** - * Obtains the brief text of a picture-attached notification specified by calling the setBriefText(string) method. - * @return the brief text of the picture-attached notification. + * @brief Obtains the brief text of a picture-attached notification specified by calling the setBriefText(string) + * method. + * + * @return Returns the brief text of the picture-attached notification. */ std::string GetBriefText() const; /** - * Sets the picture to be included in a notification. + * @brief Sets the picture to be included in a notification. + * * @param bigPicture Indicates the PixelMap of the picture to be included. */ void SetBigPicture(const std::shared_ptr &bigPicture); /** - * Obtains the PixelMap of the picture specified by calling the setBigPicture(PixelMap) method. - * @return the PixelMap of the picture included in the notification. + * @brief Obtains the PixelMap of the picture specified by calling the setBigPicture(PixelMap) method. + * + * @return Returns the PixelMap of the picture included in the notification. */ const std::shared_ptr GetBigPicture() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump() override; /** - * Converts a NotificationPictureContent object into a Json. + * @brief Converts a NotificationPictureContent object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ virtual bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationPictureContent object from a Json. + * @brief Creates a NotificationPictureContent object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationPictureContent. + * @return Returns the NotificationPictureContent object. */ static NotificationPictureContent *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationPictureContent + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationPictureContent object. */ static NotificationPictureContent *Unmarshalling(Parcel &parcel); protected: /** - * Read a NotificationPictureContent object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationPictureContent object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel) override; diff --git a/interfaces/innerkits/ans/native/include/notification_request.h b/interfaces/innerkits/ans/native/include/notification_request.h index 85de466d8dffa5e24eedce9f936bbefd8a21210d..b6869ac8921b9b5b5aa7fe7f91ae5281eeaba47a 100644 --- a/interfaces/innerkits/ans/native/include/notification_request.h +++ b/interfaces/innerkits/ans/native/include/notification_request.h @@ -139,198 +139,221 @@ public: static const uint32_t COLOR_DEFAULT; public: - /** - * Default constructor used to create a NotificationRequest instance. - */ NotificationRequest() = default; /** - * A constructor used to create a NotificationRequest instance with the input parameter notificationId passed. - * @param notificationId notification ID + * @brief A constructor used to create a NotificationRequest instance with the input parameter notificationId + * passed. + * + * @param notificationId Indicates notification ID. */ explicit NotificationRequest(int32_t notificationId); /** - * A constructor used to create a NotificationRequest instance by copying parameters from an existing one. - * @param other the existing object + * @brief A constructor used to create a NotificationRequest instance by copying parameters from an existing one. + * + * @param other Indicates the existing object. */ NotificationRequest(const NotificationRequest &other); /** - * A constructor used to create a NotificationRequest instance by copying parameters from an existing one. - * @param other the existing object + * @brief A constructor used to create a NotificationRequest instance by copying parameters from an existing one. + * + * @param other Indicates the existing object. */ NotificationRequest &operator=(const NotificationRequest &other); - /** - * Default deconstructor used to deconstruct. - */ virtual ~NotificationRequest(); /** - * Checks whether this notification is in progress. - * @return true if this notification is in progress; returns false otherwise. + * @brief Checks whether this notification is in progress. + * + * @return Returns true if this notification is in progress; returns false otherwise. */ bool IsInProgress() const; /** - * Sets whether this notification is in progress. + * @brief Sets whether this notification is in progress. * Users cannot directly dismiss notifications in progress because * they usually contain some ongoing background services such as music playback. + * * @param isOngoing Specifies whether this notification is in progress. */ void SetInProgress(bool isOngoing); /** - * Checks whether this notification is unremovable. - * @return true if this notification is unremovable; returns false otherwise. + * @brief Checks whether this notification is unremovable. + * + * @return Returns true if this notification is unremovable; returns false otherwise. */ bool IsUnremovable() const; /** - * Sets whether this notification is unremovable. + * @brief Sets whether this notification is unremovable. * If it is set to be unremovable, it cannot be removed by users. + * * @param isUnremovable Specifies whether this notification is unremovable. */ void SetUnremovable(bool isUnremovable); /** - * Sets the number to be displayed for this notification. + * @brief Sets the number to be displayed for this notification. + * * @param number Indicates the number to set. */ void SetBadgeNumber(int32_t number); /** - * Obtains the number to be displayed for this notification. - * @return the number to be displayed for this notification. + * @brief Obtains the number to be displayed for this notification. + * + * @return Returns the number to be displayed for this notification. */ int32_t GetBadgeNumber() const; /** - * Sets the current notification ID to uniquely identify the notification in the application. + * @brief Sets the current notification ID to uniquely identify the notification in the application. * After a notification is received, its ID is obtained by using the getNotificationId() method. + * * @param notificationId Indicates the ID of the notification to be set. */ void SetNotificationId(int32_t notificationId); /** - * Obtains the notification ID, which is unique in the current application. + * @brief Obtains the notification ID, which is unique in the current application. + * * @return the notification ID. */ int32_t GetNotificationId() const; /** - * Adds an WantAgent to this notification. - * After a notification is tapped, - * subsequent operations such as ability and common events will be triggered as set by WantAgent. + * @brief Adds an WantAgent to this notification. + * After a notification is tapped, subsequent operations such as ability and common events will be triggered as + * set by WantAgent. + * * @param wantAgent Indicates the operation triggered by tapping the notification, which can be set by * WantAgent. */ void SetWantAgent(const std::shared_ptr &wantAgent); /** - * Obtains the WantAgent contained in this notification. - * @return the WantAgent contained in this notification. + * @brief Obtains the WantAgent contained in this notification. + * + * @return Returns the WantAgent contained in this notification. */ const std::shared_ptr GetWantAgent() const; /** - * Sets an WantAgent object that is triggered when the user explicitly removes this notification. + * @brief Sets an WantAgent object that is triggered when the user explicitly removes this notification. + * * @param wantAgent Indicates the WantAgent object to be triggered. */ void SetRemovalWantAgent(const std::shared_ptr &wantAgent); /** - * Obtains the WantAgent object that is triggered when the user explicitly removes this notification. - * @return the WantAgent object to be triggered. + * @brief Obtains the WantAgent object that is triggered when the user explicitly removes this notification. + * + * @return Returns the WantAgent object to be triggered. */ const std::shared_ptr GetRemovalWantAgent() const; /** - * Sets the WantAgent to start when the device is not in use, + * @brief Sets the WantAgent to start when the device is not in use, * instead of showing this notification in the status bar. * When the device is in use, the system UI displays a pop-up notification * instead of starting the WantAgent specified by maxScreenWantAgent. * Your application must have the ohos.permission.USE_WHOLE_SCREEN permission to use this method. + * * @param wantAgent Indicates the WantAgent object containing information about the to-be-started ability that * uses the Page template. */ void SetMaxScreenWantAgent(const std::shared_ptr &wantAgent); /** - * Obtains the full-screen WantAgent set by calling setMaxScreenWantAgent(WantAgent). - * @return the full-screen WantAgent. + * @brief Obtains the full-screen WantAgent set by calling setMaxScreenWantAgent(WantAgent). + * + * @return Returns the full-screen WantAgent. */ const std::shared_ptr GetMaxScreenWantAgent() const; /** - * Sets extra parameters that are stored as key-value pairs for the notification. + * @brief Sets extra parameters that are stored as key-value pairs for the notification. + * * @param extras Indicates the WantParams object containing the extra parameters in key-value pair format. */ void SetAdditionalData(const std::shared_ptr &extras); /** - * Obtains the WantParams object set in the notification. - * @return the WantParams object. + * @brief Obtains the WantParams object set in the notification. + * + * @return Returns the WantParams object. */ const std::shared_ptr GetAdditionalData() const; /** - * Sets the time to deliver a notification. + * @brief Sets the time to deliver a notification. + * * @param deliveryTime Indicates the time in milliseconds. */ void SetDeliveryTime(int64_t deliveryTime); /** - * Obtains the time when a notification is delivered. - * @return the time in milliseconds. + * @brief Obtains the time when a notification is delivered. + * + * @return Returns the time in milliseconds. */ int64_t GetDeliveryTime() const; /** - * Checks whether the notification delivery time is displayed for this notification. - * @return true if the time is displayed; returns false otherwise. + * @brief Checks whether the notification delivery time is displayed for this notification. + * + * @return Returns true if the time is displayed; returns false otherwise. */ bool IsShowDeliveryTime() const; /** - * Sets whether to show the notification delivery time for this notification. + * @brief Sets whether to show the notification delivery time for this notification. * This method is valid only when the notification delivery time has been set by calling setDeliveryTime(int64_t). + * * @param showDeliveryTime Specifies whether to show the notification delivery time. */ void SetShowDeliveryTime(bool showDeliveryTime); /** - * Adds a NotificationActionButton to this notification. + * @brief Adds a NotificationActionButton to this notification. * An operation button is usually placed next to the notification content by the system. * Each action button must contain an icon, a title, and an WantAgent. When a notification is expanded, * a maximum of three action buttons can be displayed from left to right in the order they were added. * When the notification is collapsed, no action buttons will be displayed. + * * @param actionButton Indicates the NotificationActionButton object to add. */ void AddActionButton(const std::shared_ptr &actionButton); /** - * Obtains the list of all NotificationActionButton objects included in this notification. - * @return the list of NotificationActionButton objects. + * @brief Obtains the list of all NotificationActionButton objects included in this notification. + * + * @return Returns the list of NotificationActionButton objects. */ const std::vector> GetActionButtons() const; /** - * Clear the list of all NotificationActionButton objects included in this notification. + * @brief Clear the list of all NotificationActionButton objects included in this notification. */ void ClearActionButtons(); /** - * Checks whether the platform is allowed to generate contextual NotificationActionButton objects for this + * @brief Checks whether the platform is allowed to generate contextual NotificationActionButton objects for this * notification. - * @return true if the platform is allowed to generate contextual NotificationActionButton objects; + * + * @return Returns true if the platform is allowed to generate contextual NotificationActionButton objects; * returns false otherwise. */ bool IsPermitSystemGeneratedContextualActionButtons() const; /** - * Sets whether to allow the platform to generate contextual NotificationActionButton objects for this notification. + * @brief Sets whether to allow the platform to generate contextual NotificationActionButton objects for this + * notification. + * * @param permitted Specifies whether to allow the platform to generate contextual NotificationActionButton objects. * The default value true indicates that the platform is allowed to generate contextual action buttons, * and the value false indicates not. @@ -338,35 +361,40 @@ public: void SetPermitSystemGeneratedContextualActionButtons(bool permitted); /** - * Adds a MessageUser object and associates it with this notification. + * @brief Adds a MessageUser object and associates it with this notification. + * * @param messageUser Indicates the MessageUser object to add. */ void AddMessageUser(const std::shared_ptr &messageUser); /** - * Obtains all MessageUser objects associated with this notification. - * @return the list of MessageUser objects associated with this notification. + * @brief Obtains all MessageUser objects associated with this notification. + * + * @return Returns the list of MessageUser objects associated with this notification. */ const std::vector> GetMessageUsers() const; /** - * Checks whether this notification is set to alert only once, + * @brief Checks whether this notification is set to alert only once, * which means that sound or vibration will no longer be played * for notifications with the same ID upon their updates. - * @return true if this notification is set to alert only once; returns false otherwise. + * + * @return Returns true if this notification is set to alert only once; returns false otherwise. */ bool IsAlertOneTime() const; /** - * Sets whether to have this notification alert only once. + * @brief Sets whether to have this notification alert only once. * If a notification alerts only once, sound or vibration will no longer be played * for notifications with the same ID upon their updates after they are published. + * * @param isAlertOnce Specifies whether to have this notification alert only once. */ void SetAlertOneTime(bool isAlertOnce); /** - * Sets the time to delete a notification. + * @brief Sets the time to delete a notification. + * * @param deletedTime Indicates the time in milliseconds. * The default value is 0, indicating that the notification will not be automatically deleted. * To enable the notification to be automatically deleted, set this parameter to an integer greater than 0. @@ -374,98 +402,112 @@ public: void SetAutoDeletedTime(int64_t deletedTime); /** - * Obtains the period during which a notification is deleted. - * @return the period in milliseconds. + * @brief Obtains the period during which a notification is deleted. + * + * @return Returns the period in milliseconds. */ int64_t GetAutoDeletedTime() const; /** - * Sets the little icon of the notification. + * @brief Sets the little icon of the notification. + * * @param littleIcon Indicates the icon of the notification. */ void SetLittleIcon(const std::shared_ptr &littleIcon); /** - * Obtains the icon of the notification. - * @return the notification icon. + * @brief Obtains the icon of the notification. + * + * @return Returns the notification icon. */ const std::shared_ptr GetLittleIcon() const; /** - * Sets the large icon of this notification, which is usually displayed on the right of the notification. + * @brief Sets the large icon of this notification, which is usually displayed on the right of the notification. + * * @param bigIcon Indicates the large icon to set. It must be a PixelMap object. */ void SetBigIcon(const std::shared_ptr &bigIcon); /** - * Obtains the large icon of this notification. - * @return the large icon of this notification. + * @brief Obtains the large icon of this notification. + * + * @return Returns the large icon of this notification. */ const std::shared_ptr GetBigIcon() const; /** - * Sets the classification of this notification, which describes the purpose of this notification. + * @brief Sets the classification of this notification, which describes the purpose of this notification. * Notification classifications are used to filter and sort notifications. + * * @param classification Indicates the notification classification predefined in the system, * such as CLASSIFICATION_CALL or CLASSIFICATION_NAVIGATION etc. */ void SetClassification(const std::string &classification); /** - * Obtains the classification of this notification. - * @return the classification of this notification. + * @brief Obtains the classification of this notification. + * + * @return Returns the classification of this notification. */ std::string GetClassification() const; /** - * Sets the background color of this notification. + * @brief Sets the background color of this notification. * This method is valid only when background color has been enabled by calling setColorEnabled(bool). + * * @param color Indicates the background color to set. For details about the value range, see Color. */ void SetColor(uint32_t color); /** - * Obtains the background color of this notification. + * @brief Obtains the background color of this notification. * The return value, except for the default color COLOR_DEFAULT, * is the bitwise OR operation result of 0xFF000000 and the ARGB value set by setColor(uint32_t). - * @return the background color of this notification. + * + * @return Returns the background color of this notification. */ uint32_t GetColor() const; /** - * Checks whether background color is enabled for this notification. - * @return true if background color is enabled; returns false otherwise. + * @brief Checks whether background color is enabled for this notification. + * + * @return Returns true if background color is enabled; returns false otherwise. */ bool IsColorEnabled() const; /** - * Sets whether to enable background color for this notification. + * @brief Sets whether to enable background color for this notification. * If colorEnabled is set to true, this method takes effect only * when the notification content type has been set to NotificationRequest. * NotificationMediaContent in the NotificationRequest object through * NotificationRequest::setContent(NotificationContent) and an AVToken has been attached to * that NotificationMediaContent object through NotificationMediaContent::setAVToken(AVToken). + * * @param colorEnabled Specifies whether to enable background color. */ void SetColorEnabled(bool colorEnabled); /** - * Sets the notification content type to NotificationNormalContent, NotificationLongTextContent, + * @brief Sets the notification content type to NotificationNormalContent, NotificationLongTextContent, * or NotificationPictureContent etc. * Each content type indicates a particular notification content. + * * @param content Indicates the notification content type. */ void SetContent(const std::shared_ptr &content); /** - * Obtains the notification content set by calling the setContent(NotificationContent) method. - * @return the notification content. + * @brief Obtains the notification content set by calling the setContent(NotificationContent) method. + * + * @return Returns the notification content. */ const std::shared_ptr GetContent() const; /** - * Obtains the notification type. - * @return the type of the current notification, which can be + * @brief Obtains the notification type. + * + * @return Returns the type of the current notification, which can be * NotificationContent::Type::BASIC_TEXT, * NotificationContent::Type::LONG_TEXT, * NotificationContent::Type::PICTURE, @@ -476,52 +518,58 @@ public: NotificationContent::Type GetNotificationType() const; /** - * Checks whether the notification creation time is displayed as a countdown timer. - * @return true if the time is displayed as a countdown timer; returns false otherwise. + * @brief Checks whether the notification creation time is displayed as a countdown timer. + * + * @return Returns true if the time is displayed as a countdown timer; returns false otherwise. */ bool IsCountdownTimer() const; /** - * Sets whether to show the notification creation time as a countdown timer. + * @brief Sets whether to show the notification creation time as a countdown timer. * This method is valid only when setShowStopwatch(boolean) is set to true. + * * @param isCountDown Specifies whether to show the notification creation time as a countdown timer. */ void SetCountdownTimer(bool isCountDown); /** - * Sets the group alert type for this notification, + * @brief Sets the group alert type for this notification, * which determines how the group overview and other notifications in a group are published. * The group information must have been set by calling setGroupValue(string). * Otherwise, this method does not take effect. + * * @param type Indicates the group alert type to set. which can be GroupAlertType::ALL (default value), * GroupAlertType::OVERVIEW, or GroupAlertType::CHILD etc. */ void SetGroupAlertType(NotificationRequest::GroupAlertType type); /** - * Obtains the group alert type of this notification. - * @return the group alert type of this notification. + * @brief Obtains the group alert type of this notification. + * + * @return Returns the group alert type of this notification. */ NotificationRequest::GroupAlertType GetGroupAlertType() const; /** - * Checks whether this notification is the group overview. - * @return true if this notification is the group overview; returns false otherwise. + * @brief Checks whether this notification is the group overview. + * + * @return Returns true if this notification is the group overview; returns false otherwise. */ bool IsGroupOverview() const; /** - * Sets whether to use this notification as the overview of its group. + * @brief Sets whether to use this notification as the overview of its group. * This method helps display the notifications that are assigned the same group name by calling * setGroupName(string) as one stack in the notification bar. * Each group requires only one group overview. After a notification is set as the group overview, * it becomes invisible if another notification in the same group is published. + * * @param overView Specifies whether to set this notification as the group overview. */ void SetGroupOverview(bool overView); /** - * Sets the group information for this notification. + * @brief Sets the group information for this notification. * If no groups are set for notifications, all notifications from the same application will appear * in the notification bar as one stack with the number of stacked notifications displayed. * If notifications are grouped and there are multiple groups identified by different groupName, @@ -530,185 +578,211 @@ public: * setGroupOverview(bool), and other notifications are considered as child notifications. * Otherwise, notifications will not be displayed as one group even if they are assigned the same groupName by * calling setGroupName(string). + * * @param groupName Specifies whether to set this notification as the group overview. */ void SetGroupName(const std::string &groupName); /** - * Obtains the group information about this notification. - * @return the group information about this notification. + * @brief Obtains the group information about this notification. + * + * @return Returns the group information about this notification. */ std::string GetGroupName() const; /** - * Checks whether this notification is relevant only to the local device and cannot be displayed on remote devices. - * @return true if this notification is relevant only to the local device; returns false otherwise. + * @brief Checks whether this notification is relevant only to the local device and cannot be displayed on remote + * devices. + * + * @return Returns true if this notification is relevant only to the local device; returns false otherwise. */ bool IsOnlyLocal() const; /** - * Sets whether this notification is relevant only to the local device and cannot be displayed on remote devices. - * This method takes effect only for notifications published by calling + * @brief Sets whether this notification is relevant only to the local device and cannot be displayed on remote + * devices.This method takes effect only for notifications published by calling * NotificationHelper::publishNotification(NotificationRequest) or * NotificationHelper#publishNotification(string, NotificationRequest). * Notifications published using NotificationHelper::publishNotification(NotificationRequest, string) * in a distributed system will not be affected. + * * @param flag Specifies whether this notification can be displayed only on the local device. */ void SetOnlyLocal(bool flag); /** - * Sets the text that will be displayed as a link to the settings of the application. + * @brief Sets the text that will be displayed as a link to the settings of the application. * Calling this method is invalid if the notification content type has been set to NotificationLongTextContent * or NotificationPictureContent in the NotificationRequest object through setContent(NotificationContent). + * * @param text Indicates the text to be included. You can set it to any valid link. */ void SetSettingsText(const std::string &text); /** - * Obtains the text that will be displayed as a link to the settings of the application. - * @return the text displayed as the link to the application settings. + * @brief Obtains the text that will be displayed as a link to the settings of the application. + * + * @return Returns the text displayed as the link to the application settings. */ std::string GetSettingsText() const; /** - * Deprecated. - * Obtains the time when a notification is created. - * @return the time in milliseconds. + * @brief Deprecated. Obtains the time when a notification is created. + * + * @return Returns the time in milliseconds. */ int64_t GetCreateTime() const; /** - * Checks whether the notification creation time is displayed as a stopwatch. - * @return true if the time is displayed as a stopwatch; returns false otherwise. + * @brief Checks whether the notification creation time is displayed as a stopwatch. + * + * @return Returns true if the time is displayed as a stopwatch; returns false otherwise. */ bool IsShowStopwatch() const; /** - * Sets whether to show the notification creation time as a stopwatch. + * @brief Sets whether to show the notification creation time as a stopwatch. * This method is valid only when the notification creation time has been set by calling setDeliveryTime(int64_t). * When the notification creation time is set to be shown as a stopwatch, the interval between the current time * and the creation time set by setDeliveryTime(int64_t) is dynamically displayed for this notification * in Minutes: Seconds format. If the interval is longer than 60 minutes, it will be displayed * in Hours: Minutes: Seconds format. If this method and setShowDeliveryTime(boolean) are both set to true, only * this method takes effect, that is, the notification creation time will be shown as a stopwatch. + * * @param isShow Specifies whether to show the notification creation time as a stopwatch. */ void SetShowStopwatch(bool isShow); /** - * Sets the slot type of a notification to bind the created NotificationSlot object. + * @brief Sets the slot type of a notification to bind the created NotificationSlot object. * You can use NotificationSlot to create a slot object, * then set the notification vibration and lock screen display, and use the current method to bind the slot. * The value must be the type of an existing NotificationSlot object. + * * @param slotType Indicates the unique type of the NotificationSlot object. */ void SetSlotType(NotificationConstant::SlotType slotType); /** - * Obtains the slot type of a notification set by calling the setSlotType(string) method. - * @return the notification slot type. + * @brief Obtains the slot type of a notification set by calling the setSlotType(string) method. + * + * @return Returns the notification slot type. */ NotificationConstant::SlotType GetSlotType() const; /** - * Sets a key used for sorting notifications from the same application bundle. + * @brief Sets a key used for sorting notifications from the same application bundle. + * * @param key Indicates the key to set. */ void SetSortingKey(const std::string &key); /** - * Obtains the key used for sorting notifications from the same application bundle. - * @return the key for sorting notifications. + * @brief Obtains the key used for sorting notifications from the same application bundle. + * + * @return Returns the key for sorting notifications. */ std::string GetSortingKey() const; /** - * Sets the scrolling text to be displayed in the status bar when this notification is received. + * @brief Sets the scrolling text to be displayed in the status bar when this notification is received. + * * @param text Indicates the scrolling text to be displayed. */ void SetStatusBarText(const std::string &text); /** - * Obtains the scrolling text that will be displayed in the status bar when this notification is received. - * @return the scrolling notification text. + * @brief Obtains the scrolling text that will be displayed in the status bar when this notification is received. + * + * @return Returns the scrolling notification text. */ std::string GetStatusBarText() const; /** - * Checks whether the current notification will be automatically dismissed after being tapped. - * @return true if the notification will be automatically dismissed; returns false otherwise. + * @brief Checks whether the current notification will be automatically dismissed after being tapped. + * + * @return Returns true if the notification will be automatically dismissed; returns false otherwise. */ bool IsTapDismissed() const; /** - * Sets whether to automatically dismiss a notification after being tapped. + * @brief Sets whether to automatically dismiss a notification after being tapped. * If you set tapDismissed to true, * you must call the setWantAgent(WantAgent) method to make the settings take effect. + * * @param isDismissed Specifies whether a notification will be automatically dismissed after being tapped. */ void SetTapDismissed(bool isDismissed); /** - * Sets the notification display effect, including whether to display this notification on the lock screen, + * @brief Sets the notification display effect, including whether to display this notification on the lock screen, * and how it will be presented if displayed. * For details, see NotificationSlot::setLockscreenVisibleness(int). * If the lock screen display effect is set for a NotificationRequest object * and its associated NotificationSlot object, the display effect set in the NotificationRequest object prevails. + * * @param type Indicates the notification display effect on the lock screen. */ void SetVisibleness(NotificationConstant::VisiblenessType type); /** - * Obtains the display effect of this notification on the lock screen. - * @return the display effect of this notification on the lock screen. + * @brief Obtains the display effect of this notification on the lock screen. + * + * @return Returns the display effect of this notification on the lock screen. */ NotificationConstant::VisiblenessType GetVisibleness() const; /** - * Sets the badge icon style for this notification. + * @brief Sets the badge icon style for this notification. * This method does not take effect if the home screen does not support badge icons. + * * @param style Indicates the type of the badge icon to be displayed for this notification. * The value must be BadgeStyle::NONE, BadgeStyle::LITTLE, or BadgeStyle::BIG. */ void SetBadgeIconStyle(NotificationRequest::BadgeStyle style); /** - * Obtains the badge icon style of this notification. - * @return the badge icon style of this notification. + * @brief Obtains the badge icon style of this notification. + * + * @return Returns the badge icon style of this notification. */ NotificationRequest::BadgeStyle GetBadgeIconStyle() const; /** - * Sets the shortcut ID for this notification. + * @brief Sets the shortcut ID for this notification. * After a shortcut ID is set for a notification, the notification will be associated with the corresponding * home-screen shortcut, and the shortcut will be hidden when the Home application displays the badge or content * of the notification. + * * @param shortcutId Indicates the shortcut ID to set. */ void SetShortcutId(const std::string &shortcutId); /** - * Obtains the shortcut ID associated with this notification. - * @return the shortcut ID of this notification. + * @brief Obtains the shortcut ID associated with this notification. + * + * @return Returns the shortcut ID of this notification. */ std::string GetShortcutId() const; /** - * Sets whether this notification is displayed as a floating icon on top of the screen. + * @brief Sets whether this notification is displayed as a floating icon on top of the screen. + * * @param floatingIcon Specifies whether a notification is displayed as a floating icon on top of the screen. */ void SetFloatingIcon(bool floatingIcon); /** - * Checks whether this notification is displayed as a floating icon on top of the screen. - * @return true if this notification is displayed as a floating icon; returns false otherwise. + * @brief Checks whether this notification is displayed as a floating icon on top of the screen. + * + * @return Returns true if this notification is displayed as a floating icon; returns false otherwise. */ bool IsFloatingIcon() const; /** - * Sets how the progress bar will be displayed for this notification. + * @brief Sets how the progress bar will be displayed for this notification. * A progress bar is usually used in notification scenarios such as download. + * * @param progress Indicates the current value displayed for the notification progress bar. * @param progressMax Indicates the maximum value displayed for the notification progress bar. * @param indeterminate Specifies whether the progress bar is indeterminate. The value true indicates that @@ -717,227 +791,265 @@ public: void SetProgressBar(int32_t progress, int32_t progressMax, bool indeterminate); /** - * Obtains the maximum value displayed for the progress bar of this notification. - * @return the maximum value of the notification progress bar. + * @brief Obtains the maximum value displayed for the progress bar of this notification. + * + * @return Returns the maximum value of the notification progress bar. */ int32_t GetProgressMax() const; /** - * Obtains the current value displayed for the progress bar of this notification. - * @return the current value of the notification progress bar. + * @brief Obtains the current value displayed for the progress bar of this notification. + * + * @return Returns the current value of the notification progress bar. */ int32_t GetProgressValue() const; /** - * Checks whether the progress bar of this notification is indeterminate. - * @return true if the notification progress bar is indeterminate; returns false otherwise. + * @brief Checks whether the progress bar of this notification is indeterminate. + * + * @return Returns true if the notification progress bar is indeterminate; returns false otherwise. */ bool IsProgressIndeterminate() const; /** - * Sets the most recent NotificationUserInput records that have been sent through this notification. + * @brief Sets the most recent NotificationUserInput records that have been sent through this notification. * The most recent input must be stored in index 0, * the second most recent input must be stored in index 1, and so on. * The system displays a maximum of five inputs. + * * @param text Indicates the list of inputs to set. */ void SetNotificationUserInputHistory(const std::vector &text); /** - * Obtains the most recent NotificationUserInput records - * @return the most recent NotificationUserInput records + * @brief Obtains the most recent NotificationUserInput records. + * + * @return Returns the most recent NotificationUserInput records. */ std::vector GetNotificationUserInputHistory() const; /** - * Sets an alternative notification to be displayed on the lock screen for this notification. + * @brief Sets an alternative notification to be displayed on the lock screen for this notification. * The display effect (whether and how this alternative notification will be displayed) is subject to * the configuration in NotificationSlot::setLockscreenVisibleness(int). + * * @param other Indicates the alternative notification to be displayed on the lock screen. */ void SetPublicNotification(const std::shared_ptr &other); /** - * Obtains the alternative notification to be displayed on the lock screen for this notification. - * @return the alternative notification to be displayed on the lock screen for this notification. + * @brief Obtains the alternative notification to be displayed on the lock screen for this notification. + * + * @return Returns the alternative notification to be displayed on the lock screen for this notification. */ const std::shared_ptr GetPublicNotification() const; /** - * Obtains the unique hash code of a notification in the current application. + * @brief Obtains the unique hash code of a notification in the current application. * To obtain a valid hash code, you must have subscribed to and received the notification. * A valid notification hash code is a string composed of multiple attributes separated by an underscore (_), * including the notification ID, creator bundle name, creator UID, and owner bundle name. - * @return the hash code of the notification. + * + * @return Returns the hash code of the notification. */ std::string GetNotificationHashCode() const; /** - * Sets the bundle name of the notification owner. + * @brief Sets the bundle name of the notification owner. * The notification owner refers to the application that subscribes to the notification. - * @param ownerName the bundle name of the notification owner. + * + * @param ownerName Indicates the bundle name of the notification owner. */ void SetOwnerBundleName(const std::string &ownerName); /** - * Obtains the bundle name of the notification owner. + * @brief Obtains the bundle name of the notification owner. * The notification owner refers to the application that subscribes to the notification. - * @return the bundle name of the notification owner. + * + * @return Returns the bundle name of the notification owner. */ std::string GetOwnerBundleName() const; /** - * Sets the bundle name of the notification creator. + * @brief Sets the bundle name of the notification creator. * The notification creator refers to the application that publishes the notification. - * @param creatorName the bundle name of the notification creator. + * + * @param creatorName Indicates the bundle name of the notification creator. */ void SetCreatorBundleName(const std::string &creatorName); /** - * Obtains the bundle name of the notification creator. + * @brief Obtains the bundle name of the notification creator. * The notification creator refers to the application that publishes the notification. - * @return the bundle name of the notification creator. + * + * @return Returns the bundle name of the notification creator. */ std::string GetCreatorBundleName() const; /** - * Sets the PID of the notification creator. - * @param pid the PID of the notification creator. + * @brief Sets the PID of the notification creator. + * + * @param pid Indicates the PID of the notification creator. */ void SetCreatorPid(pid_t pid); /** - * Obtains the PID of the notification creator. - * @return the PID of the notification creator. + * @brief Obtains the PID of the notification creator. + * + * @return Returns the PID of the notification creator. */ pid_t GetCreatorPid() const; /** - * Sets the UID of the notification creator. - * @param uid the UID of the notification creator. + * @brief Sets the UID of the notification creator. + * + * @param uid Indicates the UID of the notification creator. */ void SetCreatorUid(pid_t uid); /** - * Obtains the UID of the notification creator. - * @return the UID of the notification creator. + * @brief Obtains the UID of the notification creator. + * + * @return Returns the UID of the notification creator. */ pid_t GetCreatorUid() const; /** - * Sets the label of this notification. - * @param label the label of this notification. + * @brief Sets the label of this notification. + * + * @param label Indicates the label of this notification. */ void SetLabel(const std::string &label); /** - * Obtains the label of this notification. + * @brief Obtains the label of this notification. * The label is set via NotificationHelper::publishNotification(string, NotificationRequest). * This method returns null if no specific label is set for this notification. - * @return the label of this notification. + * + * @return Returns the label of this notification. */ std::string GetLabel() const; /** - * Sets whether this notification is distributed. + * @brief Sets whether this notification is distributed. + * * @param distribute Specifies whether a notification is displayed as a floating icon on top of the screen. */ void SetDistributed(bool distribute); /** - * Sets devices that support display. - * @param devices The devices that support display. + * @brief Sets devices that support display. + * + * @param devices Indicates the devices that support display. */ void SetDevicesSupportDisplay(const std::vector &devices); /** - * Sets devices that support operate. - * @param devices The devices that support operate. + * @brief Sets devices that support operate. + * + * @param devices Indicates the devices that support operate. */ void SetDevicesSupportOperate(const std::vector &devices); /** - * Obtains the distributed Options. - * @return the distributed Options. + * @brief Obtains the distributed Options. + * + * @return Returns the distributed Options. */ NotificationDistributedOptions GetNotificationDistributedOptions() const; /** - * Sets the UserId of the notification creator. - * @param userId the UserId of the notification creator. + * @brief Sets the UserId of the notification creator. + * + * @param userId Indicates the UserId of the notification creator. */ void SetCreatorUserId(int32_t userId); /** - * Obtains the UserId of the notification creator. - * @return the UserId of the notification creator. + * @brief Obtains the UserId of the notification creator. + * + * @return Returns the UserId of the notification creator. */ int32_t GetCreatorUserId() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Returns a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Converts a NotificationRequest object into a Json. + * @brief Converts a NotificationRequest object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationRequest object from a Json. + * @brief Creates a NotificationRequest object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationRequest. + * @return Returns the NotificationRequest. */ static NotificationRequest *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a NotificationRequest object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a NotificationRequest object into a Parcel. + * + * @param parcel Indicates the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationRequest. + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationRequest. */ static NotificationRequest *Unmarshalling(Parcel &parcel); /** - * Sets the template of this notification. - * @param template the template of this notification. + * @brief Sets the template of this notification. + * + * @param template Indicates the template of this notification. */ void SetTemplate(const std::shared_ptr &templ); /** - * Obtains the Template of the notification. - * @return the Template of the notification. + * @brief Obtains the Template of the notification. + * + * @return Returns the Template of the notification. */ std::shared_ptr GetTemplate() const; /** - * Sets the flags of this notification. - * @param flags the flags of this notification. + * @brief Sets the flags of this notification. + * + * @param flags Indicates the flags of this notification. */ void SetFlags(const std::shared_ptr &flags); /** - * Obtains the flags of the notification. - * @return the flags of the notification. + * @brief Obtains the flags of the notification. + * + * @return Returns the flags of the notification. */ std::shared_ptr GetFlags() const; /** - * Sets the UserId of the notification receiver. - * @param userId the UserId of the notification receiver. + * @brief Sets the userId of the notification receiver. + * + * @param userId Indicates the userId of the notification receiver. */ void SetReceiverUserId(int32_t userId); /** - * Obtains the UserId of the notification receiver. - * @return the UserId of the notification receiver. + * @brief Obtains the userId of the notification receiver. + * + * @return Returns the userId of the notification receiver. */ int32_t GetReceiverUserId() const; @@ -959,14 +1071,17 @@ private: private: /** - * Read a NotificationRequest object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationRequest object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); /** - * Obtains the current system time in milliseconds. - * @return the current system time in milliseconds. + * @brief Obtains the current system time in milliseconds. + * + * @return Returns the current system time in milliseconds. */ int64_t GetNowSysTime(); diff --git a/interfaces/innerkits/ans/native/include/notification_slot.h b/interfaces/innerkits/ans/native/include/notification_slot.h index a82d04e9bc0cbc6e0e6abdf545865ecd24eed7ab..be5ee0dd307a4734adcee51b269a88b7f8ba6274 100644 --- a/interfaces/innerkits/ans/native/include/notification_slot.h +++ b/interfaces/innerkits/ans/native/include/notification_slot.h @@ -39,19 +39,16 @@ public: }; /** - * A constructor used to initialize the type of a NotificationSlot object. + * @brief A constructor used to initialize the type of a NotificationSlot object. * * @param type Specifies the type of the NotificationSlot object, */ NotificationSlot(NotificationConstant::SlotType type = NotificationConstant::SlotType::CUSTOM); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationSlot(); /** - * Obtains whether the notification light is enabled in a NotificationSlot object, + * @brief Obtains whether the notification light is enabled in a NotificationSlot object, * which is set by SetEnableLight(bool). * * @return Returns true if the notification light is enabled; returns false otherwise. @@ -59,7 +56,7 @@ public: bool CanEnableLight() const; /** - * Specifies whether to enable the notification light when a notification is received on the device, + * @brief Specifies whether to enable the notification light when a notification is received on the device, * provided that this device has a notification light. * @note SetEnableLight must be set before the NotificationHelper:AddNotificationSlot(NotificationSlot) method is * called. Otherwise, the settings will not take effect. @@ -71,7 +68,7 @@ public: void SetEnableLight(bool isLightEnabled); /** - * Obtains the vibration status of a NotificationSlot object, + * @brief Obtains the vibration status of a NotificationSlot object, * which is set by SetEnableVibration(bool). * * @return Returns true if vibration is enabled; returns false otherwise. @@ -79,7 +76,7 @@ public: bool CanVibrate() const; /** - * Sets whether to enable vibration when a notification is received. + * @brief Sets whether to enable vibration when a notification is received. * @note SetEnableVibration(bool) must be set before the NotificationHelper::AddNotificationSlot(NotificationSlot) * method is called. Otherwise, the settings will not take effect. * @@ -89,25 +86,25 @@ public: void SetEnableVibration(bool vibration); /** - * Obtains the description of a NotificationSlot object, which is set by SetDescription(string). + * @brief Obtains the description of a NotificationSlot object, which is set by SetDescription(string). * * @return Returns the description of the NotificationSlot object. */ std::string GetDescription() const; /** - * Sets the description for a NotificationSlot object. + * @brief Sets the description for a NotificationSlot object. * @note The setting of setDescription is effective regardless of whether a NotificationSlot object has been created * by NotificationHelper::AddNotificationSlot(NotificationSlot). * - * @param description Describes the NotificationSlot object. + * @param description describes the NotificationSlot object. * The description is visible to users and its length must not exceed 1000 characters * (the excessive part is automatically truncated). */ void SetDescription(const std::string &description); /** - * Obtains the ID of a NotificationSlot object. + * @brief Obtains the ID of a NotificationSlot object. * * @return Returns the ID of the NotificationSlot object, * which is set by NotificationSlot(string, string, NotificationLevel). @@ -115,7 +112,7 @@ public: std::string GetId() const; /** - * Obtains the color of the notification light in a NotificationSlot object, + * @brief Obtains the color of the notification light in a NotificationSlot object, * which is set by SetLedLightColor(int32_t). * * @return Returns the color of the notification light. @@ -123,7 +120,7 @@ public: int32_t GetLedLightColor() const; /** - * Sets the color of the notification light to flash when a notification is received on the device, + * @brief Sets the color of the notification light to flash when a notification is received on the device, * provided that this device has a notification light and setEnableLight is called with the value true. * @note SetLedLightColor must be set before the NotificationHelper::AddNotificationSlot(NotificationSlot) method is * called. Otherwise, the settings will not take effect. @@ -133,14 +130,14 @@ public: void SetLedLightColor(int32_t color); /** - * Obtains the level of a NotificationSlot object, which is set by SetLevel(NotificationLevel). + * @brief Obtains the level of a NotificationSlot object, which is set by SetLevel(NotificationLevel). * * @return Returns the level of the NotificationSlot object. */ NotificationLevel GetLevel() const; /** - * Sets the level of a NotificationSlot object. + * @brief Sets the level of a NotificationSlot object. * @note SetLevel must be set before the NotificationHelper::AddNotificationSlot(NotificationSlot) method is called. * Otherwise, the settings will not take effect. * @@ -150,14 +147,14 @@ public: void SetLevel(NotificationLevel level); /** - * Obtains the type of a NotificationSlot object, which is set by SetType(SlotType). + * @brief Obtains the type of a NotificationSlot object, which is set by SetType(SlotType). * * @return Returns the Type of the NotificationSlot object. */ NotificationConstant::SlotType GetType() const; /** - * Sets the type of a NotificationSlot object. + * @brief Sets the type of a NotificationSlot object. * @note Settype must be set before the NotificationHelper::AddNotificationSlot(NotificationSlot) method is called. * Otherwise, the settings will not take effect. * @@ -167,7 +164,7 @@ public: void SetType(NotificationConstant::SlotType type); /** - * Obtains the notification display effect of a NotificationSlot object on the lock screen, + * @brief Obtains the notification display effect of a NotificationSlot object on the lock screen, * which is set by SetLockscreenVisibleness(int32_t). * @note This method specifies different effects for displaying notifications on the lock screen in order to protect * user privacy. The setting takes effect only when the lock screen notifications function is enabled for an @@ -178,7 +175,7 @@ public: NotificationConstant::VisiblenessType GetLockScreenVisibleness() const; /** - * Sets whether and how to display notifications on the lock screen. + * @brief Sets whether and how to display notifications on the lock screen. * * @param visibleness Specifies the notification display effect on the lock screen, which can be set to * NO_OVERRIDE, PUBLIC, PRIVATE, or SECRET. @@ -186,14 +183,14 @@ public: void SetLockscreenVisibleness(NotificationConstant::VisiblenessType visibleness); /** - * Obtains the name of a NotificationSlot object. + * @brief Obtains the name of a NotificationSlot object. * * @return Returns the name of the NotificationSlot object, which is set by SetName(string). */ std::string GetName() const; /** - * Obtains the ID of the NotificationSlotGroup object to which this NotificationSlot object belongs, + * @brief Obtains the ID of the NotificationSlotGroup object to which this NotificationSlot object belongs, * which is set by SetSlotGroup(string). * * @return Returns the ID of the NotificationSlotGroup to which this NotificationSlot object belongs. @@ -201,9 +198,10 @@ public: std::string GetSlotGroup() const; /** - * Binds a NotificationSlot object to a specified NotificationSlotGroup. + * @brief Binds a NotificationSlot object to a specified NotificationSlotGroup. * @note SetSlotGroup must be called before the NotificationHelper::AddNotificationSlot(NotificationSlot) method is * called. Otherwise, this method will not take effect. + * * @param groupId Indicates the ID of the NotificationSlotGroup object to bind, * which must have been created by calling * NotificationHelper::AddNotificationSlotGroup(NotificationSlotGroup). @@ -211,14 +209,14 @@ public: void SetSlotGroup(const std::string &groupId); /** - * Obtains the prompt tone of a NotificationSlot object, which is set by SetSound(Uri). + * @brief Obtains the prompt tone of a NotificationSlot object, which is set by SetSound(Uri). * * @return Returns the prompt tone of the NotificationSlot object. */ Uri GetSound() const; /** - * Sets a prompt tone for a NotificationSlot object, which will be played after a notification is received. + * @brief Sets a prompt tone for a NotificationSlot object, which will be played after a notification is received. * @note SetSound must be set before the NotificationHelper:AddNotificationSlot(NotificationSlot) method is called. * Otherwise, the settings will not take effect. * @@ -227,14 +225,14 @@ public: void SetSound(const Uri &sound); /** - * Obtains the vibration style of notifications in this NotificationSlot. + * @brief Obtains the vibration style of notifications in this NotificationSlot. * * @return Returns the vibration style of this NotificationSlot. */ std::vector GetVibrationStyle() const; /** - * Sets the vibration style for notifications in this NotificationSlot. + * @brief Sets the vibration style for notifications in this NotificationSlot. * @note If an empty array or null is passed to this method, the system then calls * SetEnableVibration(bool) with the input parameter set to false. * If a valid value is passed to this method, the system calls SetEnableVibration(bool) with the input @@ -246,7 +244,7 @@ public: void SetVibrationStyle(const std::vector &vibration); /** - * Obtains whether DND mode is bypassed for a NotificationSlot object, + * @brief Obtains whether DND mode is bypassed for a NotificationSlot object, * which is set by EnableBypassDnd(bool). * * @return Returns true if DND mode is bypassed; returns false otherwise. @@ -254,7 +252,7 @@ public: bool IsEnableBypassDnd() const; /** - * Sets whether to bypass Do not disturb (DND) mode in the system. + * @brief Sets whether to bypass Do not disturb (DND) mode in the system. * @note The setting of EnableBypassDnd takes effect only when the Allow interruptions function * is enabled for an application in system notification settings. * @@ -265,7 +263,7 @@ public: void EnableBypassDnd(bool isBypassDnd); /** - * Obtains the application icon badge status of a NotificationSlot object, + * @brief Obtains the application icon badge status of a NotificationSlot object, * which is set by EnableBadge(bool). * * @return Returns true if the application icon badge is enabled; returns false otherwise. @@ -273,7 +271,7 @@ public: bool IsShowBadge() const; /** - * Sets whether to display application icon badges (digits or dots in the corner of the application icon) + * @brief Sets whether to display application icon badges (digits or dots in the corner of the application icon) * on the home screen after a notification is received. * @note EnableBadge must be set before the NotificationHelper:AddNotificationSlot(NotificationSlot) method is * called. Otherwise, the settings will not take effect. @@ -285,14 +283,14 @@ public: void EnableBadge(bool isShowBadge); /** - * Dumps a string representation of the object. + * @brief Dumps a string representation of the object. * - * @return A string representation of the object. + * @return Returns a string representation of the object. */ std::string Dump() const; /** - * Marshals a NotificationSlot object into a Parcel. + * @brief Marshals a NotificationSlot object into a Parcel. * * @param parcel Indicates the Parcel object for marshalling. * @return Returns true if the marshalling is successful; returns false otherwise. @@ -300,40 +298,40 @@ public: virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshals a NotificationSlot object from a Parcel. + * @brief Unmarshals a NotificationSlot object from a Parcel. * * @param parcel Indicates the Parcel object for unmarshalling. - * @return Returns true if the unmarshalling is successful; returns false otherwise. + * @return Returns the NotificationSlot object. */ static NotificationSlot *Unmarshalling(Parcel &parcel); private: /** - * Read NotificationSlot object from a Parcel. + * @brief Read NotificationSlot object from a Parcel. * - * @param parcel the parcel - * @return read from parcel success or fail + * @param parcel Indicates the Parcel object for unmarshalling. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); /** - * Merge the contents of vector and output a string + * @brief Merge the contents of vector and output a string * - * @param mergeVector The vector which will be merged + * @param mergeVector Indicates the vector which will be merged * @return Returns the string that has contents of the vector */ std::string MergeVectorToString(const std::vector &mergeVector) const; /** - * If string length exceed 1000 characters, the excessive part is automatically truncated. + * @brief If string length exceed 1000 characters, the excessive part is automatically truncated. * - * @param in The sting which will be truncated + * @param in Indicates the sting which will be truncated * @return Returns the string that has been truncated. */ std::string TruncateString(const std::string &in); /** - * Sets the name of a NotificationSlot object. + * @brief Sets the name of a NotificationSlot object. * @note The setting of SetName is effective regardless of whether a NotificationSlot object has been created by * NotificationHelper:AddNotificationSlot(NotificationSlot). * diff --git a/interfaces/innerkits/ans/native/include/notification_slot_group.h b/interfaces/innerkits/ans/native/include/notification_slot_group.h index 7becacaaef4e782e29809db053c3e68c82b5460e..874f9c9a00abb075d24a34d7cb4e0e49fece3df7 100644 --- a/interfaces/innerkits/ans/native/include/notification_slot_group.h +++ b/interfaces/innerkits/ans/native/include/notification_slot_group.h @@ -24,7 +24,7 @@ class NotificationSlotGroup : public Parcelable { public: /** - * A constructor used to create a NotificationSlotGroup instance with the group ID and name initialized. + * @brief A constructor used to create a NotificationSlotGroup instance with the group ID and name initialized. * * @param id Indicates the ID of the NotificationSlotGroup. * The ID must be unique and its length must not exceed 1000 characters (the excess part is automatically @@ -34,42 +34,41 @@ public: */ NotificationSlotGroup(const std::string &id, const std::string &name); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationSlotGroup(); /** - * Obtains the description of this NotificationSlotGroup object, which is set by SetDescription(string). + * @brief Obtains the description of this NotificationSlotGroup object, which is set by SetDescription(string). * * @return Returns the description of this NotificationSlotGroup. */ std::string GetDescription() const; /** - * Obtains the ID of this NotificationSlotGroup object, which is set by NotificationSlotGroup(string, string). + * @brief Obtains the ID of this NotificationSlotGroup object, which is set by + * NotificationSlotGroup(string, string). * * @return Returns the ID of this NotificationSlotGroup. */ std::string GetId() const; /** - * Obtains the name of this NotificationSlotGroup object, which is set by NotificationSlotGroup(string, string). + * @brief Obtains the name of this NotificationSlotGroup object, which is set by + * NotificationSlotGroup(string, string). * * @return Returns the name of this NotificationSlotGroup. */ std::string GetName() const; /** - * Obtains a list of notification slots bound to this NotificationSlotGroup object. + * @brief Obtains a list of notification slots bound to this NotificationSlotGroup object. * @note NotificationSlot::SetSlotGroup(string) is used to bind a notification slot to a notification slot group. - * @param slots Indicates the slots which to set to the slotgroup. * + * @param slots Indicates the slots which to set to the slotgroup. */ void SetSlots(const std::vector &slots); /** - * Sets a list of notification slots bound to this NotificationSlotGroup object. + * @brief Sets a list of notification slots bound to this NotificationSlotGroup object. * @note NotificationSlot::SetSlotGroup(string) is used to bind a notification slot to a notification slot group. * * @return Returns the list of notification slots bound to this NotificationSlotGroup. @@ -77,29 +76,29 @@ public: std::vector GetSlots() const; /** - * Checks whether this NotificationSlotGroup is disabled. + * @brief Checks whether this NotificationSlotGroup is disabled. * * @return Returns true if this NotificationSlotGroup is disabled; returns false otherwise. */ bool IsDisabled() const; /** - * Sets the description for this NotificationSlotGroup object. + * @brief Sets the description for this NotificationSlotGroup object. * - * @param description Describes this NotificationSlotGroup object. + * @param description describes this NotificationSlotGroup object. * Its length must not exceed 1000 characters (the excess part is automatically truncated). */ void SetDescription(const std::string &description); /** - * Dumps a string representation of the object. + * @brief Dumps a string representation of the object. * - * @return A string representation of the object. + * @return Returns a string representation of the object. */ std::string Dump() const; /** - * Marshals NotificationSlotGroup objects and writes them into Parcel. + * @brief Marshals NotificationSlotGroup objects and writes them into Parcel. * * @param parcel Indicates the Parcel object for marshalling. * @return Returns true if the marshalling is successful; returns false otherwise. @@ -107,33 +106,29 @@ public: virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshals a NotificationSlotGroup object from a Parcel. + * @brief Unmarshals a NotificationSlotGroup object from a Parcel. * * @param parcel Indicates the Parcel object for unmarshalling. - * @return Returns true if the unmarshalling is successful; returns false otherwise. + * @return Returns the NotificationSlotGroup object. */ static NotificationSlotGroup *Unmarshalling(Parcel &parcel); /** - * If string length exceed 1000 characters, the excessive part is automatically truncated. + * @brief If string length exceed 1000 characters, the excessive part is automatically truncated. * - * @param truncatedString The sting which will be truncated + * @param truncatedString Indicates the sting which will be truncated * @return Returns the string that has been truncated. */ std::string TruncateString(const std::string &inPutString); private: - - /** - * Default constructor used to create a NotificationSlotGroup instance. - */ NotificationSlotGroup(); /** - * Read NotificationSlotGroup object from a Parcel. + * @brief Read NotificationSlotGroup object from a Parcel. * - * @param parcel the parcel - * @return read from parcel success or fail + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/innerkits/ans/native/include/notification_sorting.h b/interfaces/innerkits/ans/native/include/notification_sorting.h index ca38d5bb09ccea4d0923959d94e70de2bc0aa396..702073f7bc02b077040d5e279ab97d59a6466e87 100644 --- a/interfaces/innerkits/ans/native/include/notification_sorting.h +++ b/interfaces/innerkits/ans/native/include/notification_sorting.h @@ -25,14 +25,8 @@ namespace OHOS { namespace Notification { class NotificationSorting final : public Parcelable { public: - /** - * @brief Default constructor used to create an empty NotificationSorting instance. - */ NotificationSorting(); - /** - * @brief Default deconstructor used to deconstruct. - */ ~NotificationSorting(); /** @@ -43,9 +37,9 @@ public: NotificationSorting(const NotificationSorting &sorting); /** - * @brief Obtains the sequence number of a notification among all the active notifications. + * @brief Obtains the sequence number of a notification among all the active notifications. * - * @return Returns the sequence number of the notification. + * @return Returns the sequence number of the notification. */ inline int32_t GetRanking() const { @@ -131,7 +125,6 @@ public: * @brief Marshals a NotificationSorting object into a Parcel. * * @param parcel Indicates the Parcel object for marshalling. - * * @return Returns true if the marshalling is successful; returns false otherwise. */ bool Marshalling(Parcel &parcel) const override; @@ -139,16 +132,15 @@ public: /** * @brief Unmarshals a NotificationSorting object from a Parcel. * - * @param Indicates the Parcel object for unmarshalling. - * - * @return Returns true if the unmarshalling is successful; returns false otherwise. + * @param parcel Indicates the Parcel object for unmarshalling. + * @return Returns the NotificationSorting object. */ static NotificationSorting *Unmarshalling(Parcel &parcel); /** - * @brief Dump sorting info + * @brief Dumps sorting info * - * @return Sorting info + * @return Returns sorting info. */ std::string Dump() const; diff --git a/interfaces/innerkits/ans/native/include/notification_sorting_map.h b/interfaces/innerkits/ans/native/include/notification_sorting_map.h index cd7d83a1204fca7f1029012bdef80d808e2bd705..8051365b5f6111909c80243cf728c4e2d6643bc3 100644 --- a/interfaces/innerkits/ans/native/include/notification_sorting_map.h +++ b/interfaces/innerkits/ans/native/include/notification_sorting_map.h @@ -23,20 +23,14 @@ namespace OHOS { namespace Notification { class NotificationSortingMap final : public Parcelable { public: - /** - * @brief Default constructor used to create an empty NotificationMap instance. - */ NotificationSortingMap(); - /** - * @brief Default deconstructor used to deconstruct. - */ ~NotificationSortingMap(); /** * @brief A constructor used to create a NotificationSortingMap instance by copying parameters from an existing one. * - * @param Indicates the NotificationSortingMap object. + * @param sortingList Indicates the NotificationSortingMap object. */ NotificationSortingMap(const std::vector &sortingList); @@ -54,9 +48,8 @@ public: * @brief Obtains NotificationSorting based on the hash codes. * * @param key Indicates the hash codes obtained by using getkey(). - * * @param sorting Indicates the sorting information about the hash codes. - * + * @return Returns true if succeed; returns false otherwise. */ bool GetNotificationSorting(const std::string &key, NotificationSorting &sorting) const; @@ -64,7 +57,6 @@ public: * @brief Marshals a NotificationSortingMap object into a Parcel. * * @param parcel Indicates the Parcel object for marshalling. - * * @return Returns true if the marshalling is successful; returns false otherwise. */ bool Marshalling(Parcel &parcel) const override; @@ -72,14 +64,15 @@ public: /** * @brief Unmarshals a NotificationSortingMap object from a Parcel. * - * @param Indicates the Parcel object for unmarshalling. + * @param parcel Indicates the Parcel object for unmarshalling. + * @return Returns the NotificationSortingMap object. */ static NotificationSortingMap *Unmarshalling(Parcel &parcel); /** - * @brief Dump sorting map info + * @brief Dumps sorting map info * - * @return Return sorting map info to string. + * @return Returns sorting map info to string. */ std::string Dump() const; diff --git a/interfaces/innerkits/ans/native/include/notification_subscribe_info.h b/interfaces/innerkits/ans/native/include/notification_subscribe_info.h index 7da904f412bc51169575290fe6375e245be6b0d2..05c5899729f007308077047d1bc589ea85f55822 100644 --- a/interfaces/innerkits/ans/native/include/notification_subscribe_info.h +++ b/interfaces/innerkits/ans/native/include/notification_subscribe_info.h @@ -22,21 +22,15 @@ namespace OHOS { namespace Notification { class NotificationSubscribeInfo final : public Parcelable { public: - /** - * @brief Default constructor used to create a instance. - */ NotificationSubscribeInfo(); - /** - * @brief Default deconstructor used to deconstruct. - */ ~NotificationSubscribeInfo(); /** * @brief A constructor used to create a NotificationSubscribeInfo instance by copying parameters from an existing * one. * - * @param Indicates the NotificationSubscribeInfo object. + * @param subscribeInfo Indicates the NotificationSubscribeInfo object. */ NotificationSubscribeInfo(const NotificationSubscribeInfo &subscribeInfo); @@ -65,7 +59,7 @@ public: std::vector GetAppNames() const; /** - * @brief application current userid. + * @brief Adds application userid. * * @param appNames Indicates the userid of application. **/ @@ -82,6 +76,7 @@ public: * @brief Marshals a NotificationSubscribeInfo object into a Parcel. * * @param parcel Indicates the Parcel object for marshalling. + * @return Returns true if the marshalling is successful; returns false otherwise. */ bool Marshalling(Parcel &parcel) const override; @@ -89,13 +84,14 @@ public: * @brief Unmarshals a NotificationSubscribeInfo object from a Parcel. * * @param parcel Indicates the Parcel object for unmarshalling. + * @return Returns the NotificationSubscribeInfo object. */ static NotificationSubscribeInfo *Unmarshalling(Parcel &parcel); /** - * @brief Dump subscribe info. + * @brief Dumps subscribe info. * - * @return Return subscribe info. + * @return Returns subscribe info. */ std::string Dump(); diff --git a/interfaces/innerkits/ans/native/include/notification_subscriber.h b/interfaces/innerkits/ans/native/include/notification_subscriber.h index 84333bb975d92a55be9726c3db1b6b19256be9a4..0cc37c39e5dccedfec1e7535533d5939918834e6 100644 --- a/interfaces/innerkits/ans/native/include/notification_subscriber.h +++ b/interfaces/innerkits/ans/native/include/notification_subscriber.h @@ -26,14 +26,8 @@ namespace OHOS { namespace Notification { class NotificationSubscriber { public: - /** - * @brief Default constructor used to create a instance. - */ NotificationSubscriber(); - /** - * @brief Default destructor. - */ virtual ~NotificationSubscriber(); /** @@ -55,7 +49,7 @@ public: const std::shared_ptr &sortingMap, int deleteReason) = 0; /** - * Called back when the subscriber is connected to the Advanced Notification Service (ANS). + * @brief Called back when the subscriber is connected to the Advanced Notification Service (ANS). **/ virtual void OnConnected() = 0; @@ -77,7 +71,7 @@ public: const std::shared_ptr &request, const std::shared_ptr &sortingMap) = 0; /** - * Called back when the subscriber is disconnected from the ANS. + * @brief Called back when the subscriber is disconnected from the ANS. **/ virtual void OnDisconnected() = 0; diff --git a/interfaces/innerkits/ans/native/include/notification_user_input.h b/interfaces/innerkits/ans/native/include/notification_user_input.h index 2e68134dcd223b881947c9a6d78c73872d89f8cf..f3e913935997e3c03d8f96471073f527a3b941b3 100644 --- a/interfaces/innerkits/ans/native/include/notification_user_input.h +++ b/interfaces/innerkits/ans/native/include/notification_user_input.h @@ -27,23 +27,26 @@ namespace Notification { class NotificationUserInput : public Parcelable, public NotificationJsonConvertionBase { public: /** - * Sets the input source of this NotificationUserInput object. + * @brief Sets the input source of this NotificationUserInput object. + * * @param want Indicates the Want to which the input result is to be added. * @param source Indicates the input source. For available values, see NotificationConstant::InputSource. */ static void SetInputsSource(AAFwk::Want &want, NotificationConstant::InputsSource source); /** - * Obtains the input source of this NotificationUserInput object. + * @brief Obtains the input source of this NotificationUserInput object. + * * @param want Indicates the Want containing the input result. - * @return the input source of this NotificationUserInput object, - * as enumerated in NotificationConstant::InputSource. + * @return Returns the input source of this NotificationUserInput object, as enumerated in + * NotificationConstant::InputSource. */ static NotificationConstant::InputsSource GetInputsSource(const AAFwk::Want &want); /** - * Adds a list of NotificationUserInput objects to a Want. This method should only be called by user input + * @brief Adds a list of NotificationUserInput objects to a Want. This method should only be called by user input * collection services when sending input results to an WantAgent. + * * @param userInputs Indicates the list of NotificationUserInput objects for which the input results are provided. * @param want Indicates the Want to which the input results are to be added. * @param additional Indicates the AAFwk::WantParams object holding the input results. @@ -53,15 +56,17 @@ public: AAFwk::Want &want, const AAFwk::WantParams &additional); /** - * Obtains the input text results from a specified Want. + * @brief Obtains the input text results from a specified Want. + * * @param want Indicates the Want object containing one or more user input results. - * @return the AAFwk::WantParams object containing the input text results. + * @return Returns the AAFwk::WantParams object containing the input text results. */ static std::shared_ptr GetInputsFromWant(const AAFwk::Want &want); /** - * Adds the given NotificationUserInput object of a specified MIME type to an Want. This method is similar to + * @brief Adds the given NotificationUserInput object of a specified MIME type to an Want. This method is similar to * addInputsToWant(NotificationUserInput, Want, AAFwk::WantParams) except that the MIME type must be specified. + * * @param userInput Indicates the NotificationUserInput object for which the input results are provided. * @param want Indicates the Want to which the input results are to be added. * @param results Indicates a map containing the MIME type and its URI result. @@ -70,27 +75,30 @@ public: const std::map> &results); /** - * Obtains the input results of a particular MIME type from a specified Want. This method is similar to + * @brief Obtains the input results of a particular MIME type from a specified Want. This method is similar to * GetInputsFromWant(Want) but uses the key of the NotificationUserInput. + * * @param want Indicates the Want object containing one or more user input results. * @param inputKey Indicates the key of the NotificationUserInput results to obtain. - * @return a map containing the MIME type and its URI result. + * @return Returns a map containing the MIME type and its URI result. */ static std::map> GetMimeInputsFromWant( const AAFwk::Want &want, const std::string &inputKey); public: /** - * A static function used to create a NotificationUserInput instance with the input parameters passed. + * @brief A static function used to create a NotificationUserInput instance with the input parameters passed. + * * @param inputKey Indicates the AAFwk::WantParams key used to identify this input * when the input is collected from the user. - * @return the shared_ptr object owns the created NotificationUserInput object otherwise return empty object if - * inputKey is empty. + * @return Returns the shared_ptr object owns the created NotificationUserInput object otherwise return empty + * object if inputKey is empty. */ static std::shared_ptr Create(const std::string &inputKey); /** - * A static function used to create a NotificationUserInput instance with the input parameters passed. + * @brief A static function used to create a NotificationUserInput instance with the input parameters passed. + * * @param inputKey Indicates the AAFwk::WantParams key used to identify this input * when the input is collected from the user. * @param tag Indicates the tag to be displayed. @@ -102,67 +110,72 @@ public: * @param additional Indicates the AAFwk::WantParams object containing the additional data. * @param editType Indicates the edit type to set. For details about available values, see * NotificationConstant::InputEditType. - * @return the shared_ptr object owns the created NotificationUserInput object otherwise return empty object if - * permitFreeFormInput is false but editType is InputEditType::EDIT_ENABLED. + * @return Returns the shared_ptr object owns the created NotificationUserInput object otherwise return empty + * object if permitFreeFormInput is false but editType is InputEditType::EDIT_ENABLED. */ static std::shared_ptr Create(const std::string &inputKey, const std::string &tag, const std::vector &options, bool permitFreeFormInput, const std::set &permitMimeTypes, const std::shared_ptr &additional, NotificationConstant::InputEditType editType); - /** - * Default deconstructor used to deconstruct. - */ ~NotificationUserInput() = default; /** - * Obtains the key of this NotificationUserInput object. - * @return the key of this NotificationUserInput object. + * @brief Obtains the key of this NotificationUserInput object. + * + * @return Returns the key of this NotificationUserInput object. */ std::string GetInputKey() const; /** - * Adds additional data to this Builder. + * @brief Adds additional data to this Builder. * The value of AAFwk::WantParams will replace the existing extras value in this Builder. + * * @param additional Indicates the AAFwk::WantParams object containing the additional data. */ void AddAdditionalData(AAFwk::WantParams &additional); /** - * Obtains the additional data included in this NotificationUserInput object. - * @return the additional data in this NotificationUserInput object. + * @brief Obtains the additional data included in this NotificationUserInput object. + * + * @return Returns the additional data in this NotificationUserInput object. */ const std::shared_ptr GetAdditionalData() const; /** - * Sets the edit type of the options provided by this NotificationUserInput object. + * @brief Sets the edit type of the options provided by this NotificationUserInput object. * The edit type determines whether an option can be edited when the user taps the option. + * * @param inputEditType Indicates the edit type to set. For details about available values, * see NotificationConstant::InputEditType. */ void SetEditType(NotificationConstant::InputEditType inputEditType); /** - * Obtains the edit type of the options provided by this NotificationUserInput object. - * @return the edit type of options. + * @brief Obtains the edit type of the options provided by this NotificationUserInput object. + * + * @return Returns the edit type of options. */ NotificationConstant::InputEditType GetEditType() const; /** - * Sets the options provided to users to satisfy user input needs. All options are displayed in a single line. - * Due to limited space, some or all of the options may be hidden if the options are too long or + * @brief Sets the options provided to users to satisfy user input needs. All options are displayed in a single + * line.Due to limited space, some or all of the options may be hidden if the options are too long or * there are too many options. + * * @param options Indicates the list of predefined options to be provided for user input. */ void SetOptions(const std::vector &options); /** - * Obtains the options provided to the user to satisfy user input needs. - * @return the list of predefined options. + * @brief Obtains the options provided to the user to satisfy user input needs. + * + * @return Returns the list of predefined options. */ std::vector GetOptions() const; /** - * Sets whether users can input values of the given MIME type. + * @brief Sets whether users can input values of the given MIME type. + * * @param mimeType Indicates the MIME type allowed. * @param doPermit Specifies whether to allow the given MIME type. * The value true means to allow it, and the value false means not. @@ -170,31 +183,36 @@ public: void SetPermitMimeTypes(const std::string &mimeType, bool doPermit); /** - * Obtains the MIME types allowed by this NotificationUserInput object. - * @return the list of allowed MIME types. + * @brief Obtains the MIME types allowed by this NotificationUserInput object. + * + * @return Returns the list of allowed MIME types. */ std::set GetPermitMimeTypes() const; /** - * Checks whether this NotificationUserInput object allows only values of particular MIME types. - * @return true if this object allows only values of particular MIME types; returns false otherwise. + * @brief Checks whether this NotificationUserInput object allows only values of particular MIME types. + * + * @return Returns true if this object allows only values of particular MIME types; returns false otherwise. */ bool IsMimeTypeOnly() const; /** - * Sets the tag to be displayed to the user when collecting this input from the user. + * @brief Sets the tag to be displayed to the user when collecting this input from the user. + * * @param tag Indicates the tag to be displayed. */ void SetTag(const std::string tag); /** - * Obtains the tag to be displayed to the user when collecting this input from the user. - * @return the tag to be displayed to the user. + * @brief Obtains the tag to be displayed to the user when collecting this input from the user. + * + * @return Returns the tag to be displayed to the user. */ std::string GetTag() const; /** - * Sets whether users can input arbitrary text values. + * @brief Sets whether users can input arbitrary text values. + * * @param permitFreeFormInput Specifies whether to allow arbitrary text values. The default value is true, * indicating that arbitrary text values are allowed. If this parameter is set to false, you must either call * SetOptions(std::vector) to set a non-null and non-empty list or call @@ -203,57 +221,65 @@ public: void SetPermitFreeFormInput(bool permitFreeFormInput); /** - * Checks whether users can provide arbitrary values for this NotificationUserInput object. - * @return true if this object allows arbitrary values; returns false otherwise. + * @brief Checks whether users can provide arbitrary values for this NotificationUserInput object. + * + * @return Returns true if this object allows arbitrary values; returns false otherwise. */ bool IsPermitFreeFormInput() const; /** - * Returns a string representation of the object. - * @return a string representation of the object. + * @brief Dumps a string representation of the object. + * + * @return Returns a string representation of the object. */ std::string Dump(); /** - * Converts a NotificationUserInput object into a Json. + * @brief Converts a NotificationUserInput object into a Json. + * * @param jsonObject Indicates the Json object. + * @return Returns true if succeed; returns false otherwise. */ bool ToJson(nlohmann::json &jsonObject) const override; /** - * Creates a NotificationUserInput object from a Json. + * @brief Creates a NotificationUserInput object from a Json. + * * @param jsonObject Indicates the Json object. - * @return the NotificationUserInput. + * @return Returns the NotificationUserInput object. */ static NotificationUserInput *FromJson(const nlohmann::json &jsonObject); /** - * Marshal a object into a Parcel. - * @param parcel the object into the parcel + * @brief Marshal a object into a Parcel. + * + * @param parcel the object into the parcel. + * @return Returns true if succeed; returns false otherwise. */ virtual bool Marshalling(Parcel &parcel) const override; /** - * Unmarshal object from a Parcel. - * @return the NotificationUserInput + * @brief Unmarshal object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns the NotificationUserInput object. */ static NotificationUserInput *Unmarshalling(Parcel &parcel); private: - /** - * Default constructor used to create a NotificationUserInput instance. - */ NotificationUserInput() = default; /** - * A constructor used to create a NotificationUserInput instance with the input parameters passed. + * @brief A constructor used to create a NotificationUserInput instance with the input parameters passed. + * * @param inputKey Indicates the AAFwk::WantParams key used to identify this input * when the input is collected from the user. */ explicit NotificationUserInput(const std::string &inputKey); /** - * A constructor used to create a NotificationUserInput instance with the input parameters passed. + * @brief A constructor used to create a NotificationUserInput instance with the input parameters passed. + * * @param inputKey Indicates the AAFwk::WantParams key used to identify this input * when the input is collected from the user. * @param tag Indicates the tag to be displayed. @@ -272,8 +298,10 @@ private: const std::shared_ptr &additional, NotificationConstant::InputEditType editType); /** - * Read a NotificationUserInput object from a Parcel. - * @param parcel the parcel + * @brief Read a NotificationUserInput object from a Parcel. + * + * @param parcel Indicates the parcel object. + * @return Returns true if succeed; returns false otherwise. */ bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/kits/napi/ans/include/common.h b/interfaces/kits/napi/ans/include/common.h index 12557ec917edc176554bbfa20ff901b1ee419a46..97a00d39eaf68880eb942bf1fb3a9437565f782f 100644 --- a/interfaces/kits/napi/ans/include/common.h +++ b/interfaces/kits/napi/ans/include/common.h @@ -146,299 +146,1383 @@ struct CallbackPromiseInfo { class Common { Common(); - ~Common(); public: + /** + * @brief Gets a napi value that is used to represent specified bool value + * + * @param env Indicates the environment that the API is invoked under + * @param isValue Indicates a bool value + * @return Returns a napi value that is used to represent specified bool value + */ static napi_value NapiGetBoolean(napi_env env, const bool &isValue); + /** + * @brief Gets the napi value that is used to represent the null object + * + * @param env Indicates the environment that the API is invoked under + * @return Returns the napi value that is used to represent the null object + */ static napi_value NapiGetNull(napi_env env); + /** + * @brief Gets the napi value that is used to represent the undefined object + * + * @param env Indicates the environment that the API is invoked under + * @return Returns the napi value that is used to represent the undefined object + */ static napi_value NapiGetUndefined(napi_env env); + /** + * @brief Gets a napi value with specified error code for callback + * + * @param env Indicates the environment that the API is invoked under + * @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); + /** + * @brief Pads the CallbackPromiseInfo struct + * + * @param env Indicates the environment that the API is invoked under + * @param callback Indicates a napi_ref for callback + * @param info Indicates the CallbackPromiseInfo struct to be padded + * @param promise Indicates the promise to be created when the callback is null + */ static void PaddingCallbackPromiseInfo( const napi_env &env, const napi_ref &callback, CallbackPromiseInfo &info, napi_value &promise); + /** + * @brief Gets the returned result by the CallbackPromiseInfo struct + * + * @param env Indicates the environment that the API is invoked under + * @param info Indicates the CallbackPromiseInfo struct + * @param result Indicates the returned result + */ static void ReturnCallbackPromise(const napi_env &env, const CallbackPromiseInfo &info, const napi_value &result); + /** + * @brief Calls the callback with the result and error code + * + * @param env Indicates the environment that the API is invoked under + * @param callbackIn Indicates the callback to be called + * @param errCode Indicates the error code returned by the callback + * @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); + /** + * @brief Calls the callback with the result + * + * @param env Indicates the environment that the API is invoked under + * @param callbackIn Indicates the callback to be called + * @param result Indicates the result returned by the callback + */ static void SetCallback( const napi_env &env, const napi_ref &callbackIn, const napi_value &result); + /** + * @brief Processes the promise with the result and error code + * + * @param env Indicates the environment that the API is invoked under + * @param deferred Indicates the deferred object whose associated promise to resolve + * @param errorCode Indicates the error code returned by the callback + * @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); + /** + * @brief Gets the returned result by the callback when an error occurs + * + * @param env Indicates the environment that the API is invoked under + * @param callback Indicates a napi_ref for callback + * @return Returns the null object + */ static napi_value JSParaError(const napi_env &env, const napi_ref &callback); + /** + * @brief Parses a single parameter for callback + * + * @param env Indicates the environment that the API is invoked under + * @param info Indicates the callback info passed into the callback function + * @param callback Indicates the napi_ref for the callback parameter + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value ParseParaOnlyCallback(const napi_env &env, const napi_callback_info &info, napi_ref &callback); + /** + * @brief Sets a js object by specified Notification object + * + * @param env Indicates the environment that the API is invoked under + * @param notification Indicates a Notification object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotification( const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); + /** + * @brief Sets a js object by specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequest( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + + /** + * @brief Sets a js object by the string obejcts of specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequestByString( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + + /** + * @brief Sets a js object by the number obejcts of specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequestByNumber( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + + /** + * @brief Sets a js object by the bool obejcts of specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequestByBool( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + + /** + * @brief Sets a js object by the WantAgent obejct of specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequestByWantAgent( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + + /** + * @brief Sets a js object by the PixelMap obejct of specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequestByPixelMap( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + + /** + * @brief Sets a js object by the custom obejcts of specified NotificationRequest object + * + * @param env Indicates the environment that the API is invoked under + * @param request Indicates a NotificationRequest object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationRequestByCustom( const napi_env &env, const OHOS::Notification::NotificationRequest *request, napi_value &result); + /** + * @brief Sets a js object by the Distributed Options object of specified Notification object + * + * @param env Indicates the environment that the API is invoked under + * @param notification Indicates a Notification object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationByDistributedOptions( const napi_env &env, const OHOS::Notification::Notification *notification, napi_value &result); + /** + * @brief Sets a js object by specified NotificationSortingMap object + * + * @param env Indicates the environment that the API is invoked under + * @param sortingMap Indicates a NotificationSortingMap object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationSortingMap( const napi_env &env, const std::shared_ptr &sortingMap, napi_value &result); + /** + * @brief Sets a js object by specified NotificationSorting object + * + * @param env Indicates the environment that the API is invoked under + * @param sorting Indicates a NotificationSorting object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationSorting( const napi_env &env, const NotificationSorting &sorting, napi_value &result); + /** + * @brief Sets a js object by specified NotificationSlot object + * + * @param env Indicates the environment that the API is invoked under + * @param slot Indicates a NotificationSlot object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationSlot(const napi_env &env, const NotificationSlot &slot, napi_value &result); + /** + * @brief Sets a js object by specified NotificationContent object + * + * @param env Indicates the environment that the API is invoked under + * @param content Indicates a NotificationContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationContent( const napi_env &env, const std::shared_ptr &content, napi_value &result); + + /** + * @brief Sets a js object by the object of specified type in specified NotificationContent object + * + * @param env Indicates the environment that the API is invoked under + * @param type Indicates the content type + * @param content Indicates a NotificationContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationContentDetailed(const napi_env &env, const ContentType &type, const std::shared_ptr &content, napi_value &result); + + /** + * @brief Sets a js NotificationBasicContent object by specified NotificationBasicContent object + * + * @param env Indicates the environment that the API is invoked under + * @param basicContent Indicates a NotificationBasicContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationBasicContent( const napi_env &env, const NotificationBasicContent *basicContent, napi_value &result); + + /** + * @brief Sets a js NotificationLongTextContent object by specified NotificationBasicContent object + * + * @param env Indicates the environment that the API is invoked under + * @param basicContent Indicates a NotificationBasicContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationLongTextContent( const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); + + /** + * @brief Sets a js NotificationPictureContent object by specified NotificationBasicContent object + * + * @param env Indicates the environment that the API is invoked under + * @param basicContent Indicates a NotificationBasicContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationPictureContent( const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); + + /** + * @brief Sets a js NotificationConversationalContent object by specified NotificationBasicContent object + * + * @param env Indicates the environment that the API is invoked under + * @param basicContent Indicates a NotificationBasicContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationConversationalContent(const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); + + /** + * @brief Sets a js NotificationMultiLineContent object by specified NotificationBasicContent object + * + * @param env Indicates the environment that the API is invoked under + * @param basicContent Indicates a NotificationBasicContent object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationMultiLineContent( const napi_env &env, NotificationBasicContent *basicContent, napi_value &result); + /** + * @brief Sets a js object by specified MessageUser object + * + * @param env Indicates the environment that the API is invoked under + * @param messageUser Indicates a MessageUser object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetMessageUser(const napi_env &env, const MessageUser &messageUser, napi_value &result); + /** + * @brief Sets a js object by specified NotificationConversationalContent object + * + * @param env Indicates the environment that the API is invoked under + * @param conversationalContent Indicates a NotificationConversationalContent object to be converted + * @param arr Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetConversationalMessages(const napi_env &env, const OHOS::Notification::NotificationConversationalContent *conversationalContent, napi_value &arr); + /** + * @brief Sets a js object by specified NotificationConversationalMessage object + * + * @param env Indicates the environment that the API is invoked under + * @param conversationalMessage Indicates a NotificationConversationalMessage object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetConversationalMessage(const napi_env &env, const std::shared_ptr &conversationalMessage, napi_value &result); + /** + * @brief Sets a js object by specified NotificationActionButton object + * + * @param env Indicates the environment that the API is invoked under + * @param actionButton Indicates a NotificationActionButton object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationActionButton( const napi_env &env, const std::shared_ptr &actionButton, napi_value &result); + + /** + * @brief Sets a js object by the extra objects of specified NotificationActionButton object + * + * @param env Indicates the environment that the API is invoked under + * @param actionButton Indicates a NotificationActionButton object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationActionButtonByExtras( const napi_env &env, const std::shared_ptr &actionButton, napi_value &result); + + /** + * @brief Sets a js object by specified NotificationUserInput object + * + * @param env Indicates the environment that the API is invoked under + * @param userInput Indicates a NotificationUserInput object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationActionButtonByUserInput( const napi_env &env, const std::shared_ptr &userInput, napi_value &result); + /** + * @brief Sets a js object by specified NotificationDoNotDisturbDate object + * + * @param env Indicates the environment that the API is invoked under + * @param date Indicates a NotificationDoNotDisturbDate object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetDoNotDisturbDate( const napi_env &env, const NotificationDoNotDisturbDate &date, napi_value &result); + /** + * @brief Sets a js object by specified EnabledNotificationCallbackData object + * + * @param env Indicates the environment that the API is invoked under + * @param date Indicates a EnabledNotificationCallbackData object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetEnabledNotificationCallbackData(const napi_env &env, const EnabledNotificationCallbackData &data, napi_value &result); + /** + * @brief Gets a NotificationSubscribeInfo object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param result Indicates a NotificationSubscribeInfo object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSubscriberInfo( const napi_env &env, const napi_value &value, NotificationSubscribeInfo &result); + /** + * @brief Gets a NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param result Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRequest( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets a NotificationRequest object by number type from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRequestByNumber( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets a NotificationRequest object by string type from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRequestByString( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets a NotificationRequest object by bool type from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRequestByBool( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets a NotificationRequest object by custom type from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRequestByCustom( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets the id of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationId(const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the slot type of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSlotType( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the isOngoing flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationIsOngoing( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the isUnremovable flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationIsUnremovable( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the delivery time of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationDeliveryTime( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the tapDismissed flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationtapDismissed( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the extra information of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationExtraInfo( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the group name of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationGroupName( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the removal WantAgent object of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRemovalWantAgent( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the max screen WantAgent object of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationMaxScreenWantAgent( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the auto deleted time of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationAutoDeletedTime( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the classification of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationClassification( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the color of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationColor(const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the colorEnabled flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationColorEnabled( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the isAlertOnce flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationIsAlertOnce( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the isStopwatch flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationIsStopwatch( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the isCountDown flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationIsCountDown( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the status bar text of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationStatusBarText( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the label of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationLabel(const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the badge icon style of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationBadgeIconStyle( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the showDeliveryTime flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationShowDeliveryTime( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets the content of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationContent( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets the WantAgent object of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationWantAgent( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets a NotificationSlot object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param slot Indicates a NotificationSlot object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSlot( const napi_env &env, const napi_value &value, NotificationSlot &slot); + + /** + * @brief Gets the string objects of NotificationSlot object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param slot Indicates a NotificationSlot object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSlotByString( const napi_env &env, const napi_value &value, NotificationSlot &slot); + + /** + * @brief Gets the bool objects of NotificationSlot object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param slot Indicates a NotificationSlot object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSlotByBool( const napi_env &env, const napi_value &value, NotificationSlot &slot); + + /** + * @brief Gets the number objects of NotificationSlot object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param slot Indicates a NotificationSlot object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSlotByNumber( const napi_env &env, const napi_value &value, NotificationSlot &slot); + + /** + * @brief Gets the vibration of NotificationSlot object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param slot Indicates a NotificationSlot object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSlotByVibration( const napi_env &env, const napi_value &value, NotificationSlot &slot); + /** + * @brief Gets the action buttons of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationActionButtons( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets a NotificationActionButton object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param actionButton Indicates a js object to be converted + * @param pActionButton Indicates a NotificationActionButton object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationActionButtonsDetailed( const napi_env &env, const napi_value &actionButton, std::shared_ptr &pActionButton); + + /** + * @brief Gets the basic information of NotificationActionButton object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param actionButton Indicates a js object to be converted + * @param pActionButton Indicates a NotificationActionButton object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationActionButtonsDetailedBasicInfo( const napi_env &env, const napi_value &actionButton, std::shared_ptr &pActionButton); + + /** + * @brief Gets the extras of NotificationActionButton object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param actionButton Indicates a js object to be converted + * @param pActionButton Indicates a NotificationActionButton object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationActionButtonsDetailedByExtras( const napi_env &env, const napi_value &actionButton, std::shared_ptr &pActionButton); + + /** + * @brief Gets the user input of NotificationActionButton object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param actionButton Indicates a js object to be converted + * @param pActionButton Indicates a NotificationActionButton object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInput( const napi_env &env, const napi_value &actionButton, std::shared_ptr &pActionButton); + + /** + * @brief Gets the input key of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByInputKey( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + + /** + * @brief Gets the tag of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByTag( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + + /** + * @brief Gets the options of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByOptions( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + + /** + * @brief Gets the permit mime types of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByPermitMimeTypes( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + + /** + * @brief Gets the permit free from input of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByPermitFreeFormInput( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + + /** + * @brief Gets the edit type of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByEditType( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + + /** + * @brief Gets the additional data of NotificationUserInput object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param userInputResult Indicates a js object to be converted + * @param userInput Indicates a NotificationUserInput object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationUserInputByAdditionalData( const napi_env &env, const napi_value &userInputResult, std::shared_ptr &userInput); + /** + * @brief Gets the small icon of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSmallIcon( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the large icon of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationLargeIcon( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets the distributed options of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationRequestDistributedOptions( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the isDistributed flag of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationIsDistributed( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the devices that support display of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSupportDisplayDevices( const napi_env &env, const napi_value &value, NotificationRequest &request); + + /** + * @brief Gets the devices that support operation of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationSupportOperateDevices( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets a content type of notification from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param type Indicates a the content type of notification from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationContentType(const napi_env &env, const napi_value &result, int32_t &type); + + /** + * @brief Gets a basic content of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationBasicContent( const napi_env &env, const napi_value &result, NotificationRequest &request); + + /** + * @brief Gets a NotificationBasicContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param basicContent Indicates a NotificationBasicContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationBasicContentDetailed( const napi_env &env, const napi_value &contentResult, std::shared_ptr basicContent); + /** + * @brief Gets a long-text content of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationLongTextContent( const napi_env &env, const napi_value &result, NotificationRequest &request); + + /** + * @brief Gets a NotificationLongTextContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param longContent Indicates a NotificationLongTextContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationLongTextContentDetailed( const napi_env &env, const napi_value &contentResult, std::shared_ptr &longContent); + /** + * @brief Gets a picture content of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationPictureContent( const napi_env &env, const napi_value &result, NotificationRequest &request); + + /** + * @brief Gets a NotificationPictureContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param pictureContent Indicates a NotificationPictureContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationPictureContentDetailed( const napi_env &env, const napi_value &contentResult, std::shared_ptr &pictureContent); + /** + * @brief Gets a conversational content of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationConversationalContent( const napi_env &env, const napi_value &result, NotificationRequest &request); + + /** + * @brief Gets the user of NotificationConversationalContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param user Indicates a MessageUser object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationConversationalContentByUser( const napi_env &env, const napi_value &contentResult, MessageUser &user); + + /** + * @brief Gets the title of NotificationConversationalContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationConversationalContentTitle( const napi_env &env, const napi_value &contentResult, std::shared_ptr &conversationalContent); + + /** + * @brief Gets the group of NotificationConversationalContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationConversationalContentGroup( const napi_env &env, const napi_value &contentResult, std::shared_ptr &conversationalContent); + + /** + * @brief Gets the messages of NotificationConversationalContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param contentResult Indicates a js object to be converted + * @param conversationalContent Indicates a NotificationConversationalContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationConversationalContentMessages( const napi_env &env, const napi_value &contentResult, std::shared_ptr &conversationalContent); + + /** + * @brief Gets a NotificationConversationalMessage object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param conversationalMessage Indicates a js object to be converted + * @param message Indicates a NotificationConversationalMessage object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetConversationalMessage( const napi_env &env, const napi_value &conversationalMessage, std::shared_ptr &message); + + /** + * @brief Gets the basic information of NotificationConversationalMessage object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param conversationalMessage Indicates a js object to be converted + * @param message Indicates a NotificationConversationalMessage object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetConversationalMessageBasicInfo( const napi_env &env, const napi_value &conversationalMessage, std::shared_ptr &message); + + /** + * @brief Gets the other information of NotificationConversationalMessage object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param conversationalMessage Indicates a js object to be converted + * @param message Indicates a NotificationConversationalMessage object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetConversationalMessageOtherInfo( const napi_env &env, const napi_value &conversationalMessage, std::shared_ptr &message); + + /** + * @brief Gets a MessageUser object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param messageUser Indicates a MessageUser object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetMessageUser(const napi_env &env, const napi_value &result, MessageUser &messageUser); + + /** + * @brief Gets a MessageUser object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param messageUser Indicates a MessageUser object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetMessageUserByString(const napi_env &env, const napi_value &result, MessageUser &messageUser); + + /** + * @brief Gets the bool objects of MessageUser object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param messageUser Indicates a MessageUser object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetMessageUserByBool(const napi_env &env, const napi_value &result, MessageUser &messageUser); + + /** + * @brief Gets the custom objects of MessageUser object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param messageUser Indicates a MessageUser object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetMessageUserByCustom(const napi_env &env, const napi_value &result, MessageUser &messageUser); + /** + * @brief Gets the multi-line content of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationMultiLineContent( const napi_env &env, const napi_value &result, NotificationRequest &request); + + /** + * @brief Gets the lines of NotificationMultiLineContent object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param result Indicates a js object to be converted + * @param multiLineContent Indicates a NotificationMultiLineContent object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationMultiLineContentLines(const napi_env &env, const napi_value &result, std::shared_ptr &multiLineContent); + /** + * @brief Gets a NotificationBundleOption object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param option Indicates a NotificationBundleOption object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetBundleOption(const napi_env &env, const napi_value &value, NotificationBundleOption &option); + /** + * @brief Gets a NotificationKey object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param key Indicates a NotificationKey object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationKey(const napi_env &env, const napi_value &value, NotificationKey &key); + /** + * @brief Converts content type from js to native + * + * @param inType Indicates a js ContentType object + * @param outType Indicates a NotificationContent object + * @return Returns true if success, returns false otherwise + */ static bool ContentTypeJSToC(const ContentType &inType, NotificationContent::Type &outType); + /** + * @brief Converts content type from native to js + * + * @param inType Indicates a NotificationContent object + * @param outType Indicates a js ContentType object + * @return Returns true if success, returns false otherwise + */ static bool ContentTypeCToJS(const NotificationContent::Type &inType, ContentType &outType); + /** + * @brief Converts slot type from js to native + * + * @param inType Indicates a native SlotType object + * @param outType Indicates a js SlotType object + * @return Returns true if success, returns false otherwise + */ static bool SlotTypeJSToC(const SlotType &inType, NotificationConstant::SlotType &outType); + /** + * @brief Converts slot type from native to js + * + * @param inType Indicates a js SlotType object + * @param outType Indicates a native SlotType object + * @return Returns true if success, returns false otherwise + */ static bool SlotTypeCToJS(const NotificationConstant::SlotType &inType, SlotType &outType); + /** + * @brief Converts slot level from js to native + * + * @param inType Indicates a native SlotLevel object + * @param outType Indicates a js NotificationLevel object + * @return Returns true if success, returns false otherwise + */ static bool SlotLevelJSToC(const SlotLevel &inLevel, NotificationSlot::NotificationLevel &outLevel); + /** + * @brief Converts slot level from native to js + * + * @param inType Indicates a js NotificationLevel object + * @param outType Indicates a native SlotLevel object + * @return Returns true if success, returns false otherwise + */ static bool SlotLevelCToJS(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel); + /** + * @brief Converts reason type from native to js + * + * @param inType Indicates a native reason type + * @param outType Indicates a js reason type + * @return Returns true if success, returns false otherwise + */ static bool ReasonCToJS(const int &inType, int &outType); + /** + * @brief Converts do-not-disturb type from js to native + * + * @param inType Indicates a js DoNotDisturbType object + * @param outType Indicates a native DoNotDisturbType object + * @return Returns true if success, returns false otherwise + */ static bool DoNotDisturbTypeJSToC(const DoNotDisturbType &inType, NotificationConstant::DoNotDisturbType &outType); + /** + * @brief Converts do-not-disturb type from native to js + * + * @param inType Indicates a native DoNotDisturbType object + * @param outType Indicates a js DoNotDisturbType object + * @return Returns true if success, returns false otherwise + */ static bool DoNotDisturbTypeCToJS(const NotificationConstant::DoNotDisturbType &inType, DoNotDisturbType &outType); + /** + * @brief Converts remind type from native to js + * + * @param inType Indicates a native RemindType object + * @param outType Indicates a js DeviceRemindType object + * @return Returns true if success, returns false otherwise + */ static bool DeviceRemindTypeCToJS(const NotificationConstant::RemindType &inType, DeviceRemindType &outType); + /** + * @brief Converts source type from native to js + * + * @param inType Indicates a native SourceType object + * @param outType Indicates a js SourceType object + * @return Returns true if success, returns false otherwise + */ static bool SourceTypeCToJS(const NotificationConstant::SourceType &inType, SourceType &outType); + /** + * @brief Creates a js object from specified WantAgent object + * + * @param env Indicates the environment that the API is invoked under + * @param agent Indicates specified WantAgent object + * @return Returns a js object from specified WantAgent object + */ static napi_value CreateWantAgentByJS(const napi_env &env, const std::shared_ptr &agent); + /** + * @brief Gets the template of NotificationRequest object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param request Indicates a NotificationRequest object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationTemplate( const napi_env &env, const napi_value &value, NotificationRequest &request); + /** + * @brief Gets a NotificationTemplate object from specified js object + * + * @param env Indicates the environment that the API is invoked under + * @param value Indicates a js object to be converted + * @param templ Indicates a NotificationTemplate object from specified js object + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value GetNotificationTemplateInfo(const napi_env &env, const napi_value &value, std::shared_ptr &templ); + /** + * @brief Sets a js object by specified NotificationTemplate object + * + * @param env Indicates the environment that the API is invoked under + * @param templ Indicates a NotificationTemplate object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationTemplateInfo( const napi_env &env, const std::shared_ptr &templ, napi_value &result); + /** + * @brief Sets a js object by specified NotificationFlags object + * + * @param env Indicates the environment that the API is invoked under + * @param flags Indicates a NotificationFlags object to be converted + * @param result Indicates a js object to be set + * @return Returns the null object if success, returns the null value otherwise + */ static napi_value SetNotificationFlags( const napi_env &env, const std::shared_ptr &flags, napi_value &result); diff --git a/interfaces/kits/napi/ans/include/subscribe.h b/interfaces/kits/napi/ans/include/subscribe.h index 26babfc735cb4341b005438c7b76b07b63cb4a82..24f4270f08652b955079a9f8c1c451925d417f7b 100644 --- a/interfaces/kits/napi/ans/include/subscribe.h +++ b/interfaces/kits/napi/ans/include/subscribe.h @@ -24,34 +24,98 @@ using namespace OHOS::Notification; class SubscriberInstance : public NotificationSubscriber { public: SubscriberInstance(); - virtual ~SubscriberInstance(); + /** + * @brief Called back when a notification is canceled. + * + * @param request Indicates the canceled NotificationRequest object. + */ virtual void OnCanceled(const std::shared_ptr &request) override; + /** + * @brief Called back when a notification is canceled. + * + * @param request Indicates the canceled NotificationRequest object. + * @param sortingMap Indicates the sorting map used by the current subscriber to obtain notification ranking + * information. + * @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; + /** + * @brief Called back when a notification is canceled. + * + * @param request Indicates the received NotificationRequest object. + */ virtual void OnConsumed(const std::shared_ptr &request) override; + /** + * @brief Called back when a notification is canceled. + * + * @param request Indicates the received NotificationRequest object. + * @param sortingMap Indicates the sorting map used by the current subscriber to obtain notification ranking + * information. + */ virtual void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override; + /** + * @brief Called back when a notification is canceled. + * + * @param sortingMap Indicates the sorting map used to obtain notification ranking information. + */ virtual void OnUpdate(const std::shared_ptr &sortingMap) override; + /** + * @brief Called back when a notification is canceled. + * + */ virtual void OnConnected() override; + /** + * @brief Called back when the subscriber is disconnected from the ANS. + * + */ virtual void OnDisconnected() override; + /** + * @brief Called back when connection to the ANS has died. + * + */ virtual void OnDied() override; + /** + * @brief Called when the Do Not Disturb mode type changes. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + */ virtual void OnDoNotDisturbDateChange(const std::shared_ptr &date) override; + /** + * @brief Called when the enabled notification changes. + * + * @param callbackData Indicates the EnabledNotificationCallbackData object. + */ virtual void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override; + /** + * @brief Sets the callback information by type. + * + * @param env Indicates the environment that the API is invoked under. + * @param type Indicates the type of callback. + * @param ref Indicates the napi_ref of callback. + */ void SetCallbackInfo(const napi_env &env, const std::string &type, const napi_ref &ref); + /** + * @brief Sets the object deleting status. + * + * @param status Indicates the deleting status. + * @return Returns true if success, returns false otherwise + */ bool SetObjectDeleting(bool status); private: diff --git a/services/ans/include/access_token_helper.h b/services/ans/include/access_token_helper.h index f73add0c9a01f4c62cf37aa368710ed18ead9d76..cc8ec8fb8b0b7fdf9f02f016141ed9fa89710e51 100644 --- a/services/ans/include/access_token_helper.h +++ b/services/ans/include/access_token_helper.h @@ -24,6 +24,13 @@ namespace OHOS { namespace Notification { class AccessTokenHelper { public: + /** + * @brief Verifies that the caller has the specified permission. + * + * @param tokenCaller The AccessTokenID of caller. + * @param permission The permission to be verified. + * @return Returns true if the caller has the specified permission, false otherwise. + */ static bool VerifyCallerPermission( const Security::AccessToken::AccessTokenID &tokenCaller, const std::string &permission); static bool VerifyNativeToken(const Security::AccessToken::AccessTokenID &callerToken); diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index d180de930c08a8bc370fc5f83c4130d1cb26083d..d4064e050c5bec831baa09f5d0e74f4e4a91f0e2 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -40,106 +40,677 @@ namespace Notification { class AdvancedNotificationService final : public AnsManagerStub { public: ~AdvancedNotificationService() override; + DISALLOW_COPY_AND_MOVE(AdvancedNotificationService); + /** + * @brief Get the instance of service. + * + * @return Returns the instance. + */ static sptr GetInstance(); // AnsManagerStub + + /** + * @brief Publishes a notification with a specified label. + * @note If a notification with the same ID has been published by the current application and has not been deleted, + * this method will update the notification. + * + * @param label Indicates the label of the notification to publish. + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Publish(const std::string &label, const sptr &request) override; + + /** + * @brief Cancels a published notification matching the specified label and notificationId. + * + * @param notificationId Indicates the ID of the notification to cancel. + * @param label Indicates the label of the notification to cancel. + * @return Returns cancel notification result. + */ ErrCode Cancel(int notificationId, const std::string &label) override; + + /** + * @brief Cancels all the published notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelAll() override; + + /** + * @brief Adds a notification slot by type. + * + * @param slotType Indicates the notification slot type to be added. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; + + /** + * @brief Creates multiple notification slots. + * + * @param slots Indicates the notification slots to create. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AddSlots(const std::vector> &slots) override; + + /** + * @brief Deletes a created notification slot based on the slot ID. + * + * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot + * This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; + + /** + * @brief Deletes all notification slots. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveAllSlots() override; + + /** + * @brief Creates multiple notification slot groups. + * @note The precautions for using this method are similar to those for + * AddNotificationSlotGroup(NotificationSlotGroup). + * + * @param groups Indicates a list of NotificationSlotGroup objects to create. This parameter cannot be null. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode AddSlotGroups(std::vector> groups) override; + + /** + * @brief Queries a created notification slot. + * + * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This + * parameter must be specified. + * @param slot Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) override; + + /** + * @brief Obtains all notification slots of this application. + * + * @param slots Indicates the created NotificationSlot. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlots(std::vector> &slots) override; + + /** + * @brief Queries a created notification slot group. + * + * @param groupId Indicates the ID of the slot group. + * @param group Indicates the created NotificationSlotGroup. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotGroup(const std::string &groupId, sptr &group) override; + + /** + * @brief Obtains a list of created notification slot groups. + * + * @param groups Indicates a list of created notification slot groups. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotGroups(std::vector> &groups) override; + + /** + * @brief Obtains the number of slot. + * + * @param bundleOption Indicates the bundle name and uid of the application. + * @param num Indicates the number of slot. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotNumAsBundle(const sptr &bundleOption, int &num) override; + + /** + * @brief Deletes multiple notification slot groups. + * + * @param groupIds Indicates the IDs of the notification slot groups, which is created by + * AddNotificationSlotGroup(NotificationSlotGroup) This parameter must be specified. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveSlotGroups(const std::vector &groupIds) override; + + /** + * @brief Obtains active notifications of the current application in the system. + * + * @param notifications Indicates active NotificationRequest objects of the current application. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetActiveNotifications(std::vector> ¬ifications) override; + + /** + * @brief Obtains the number of active notifications of the current application in the system. + * + * @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; + + /** + * @brief Obtains all active notifications in the current system. The caller must have system permissions to + * call this method. + * + * @param notifications Indicates all active notifications of this application. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override; + + /** + * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method + * to obtain particular active notifications, you must have received the notifications and obtained the key + * via {Notification::GetKey()}. + * + * @param key Indicates the key array for querying corresponding active notifications. + * If this parameter is null, this method returns all active notifications in the system. + * @param notification Indicates the set of active notifications corresponding to the specified key. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSpecialActiveNotifications( const std::vector &key, std::vector> ¬ifications) override; + + /** + * @brief Allows another application to act as an agent to publish notifications in the name of your application + * bundle. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationAgent(const std::string &agent) override; + + /** + * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. + * + * @param agent Indicates the name of the application bundle that can publish notifications for your application if + * any; returns null otherwise. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetNotificationAgent(std::string &agent) override; + + /** + * @brief Checks whether your application has permission to publish notifications by calling + * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the + * given representativeBundle. + * + * @param representativeBundle Indicates the name of application bundle your application is representing. + * @param canPublish Indicates whether your application has permission to publish notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; + + /** + * @brief Publishes a notification in the name of a specified application bundle. + * @note If the notification to be published has the same ID as a published notification that has not been canceled, + * the existing notification will be replaced by the new one. + * + * @param notification Indicates the NotificationRequest object for setting the notification content. + * This parameter must be specified. + * @param representativeBundle Indicates the name of the application bundle that allows your application to publish + * notifications for it by calling setNotificationAgent. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishAsBundle( const sptr notification, const std::string &representativeBundle) override; + + /** + * @brief Sets the number of active notifications of the current application as the number to be displayed on the + * notification badge. + * + * @param num Indicates the badge number. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationBadgeNum(int num) override; + + /** + * @brief Obtains the importance level of this application. + * + * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, + 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; + + /** + * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. + * + * @param granted True if the application has permission; false for otherwise. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; + + /** + * @brief Set whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetPrivateNotificationsAllowed(bool allow) override; + + /** + * @brief Get whether to allow private notifications. + * + * @param allow Indicates the flag that allows private notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetPrivateNotificationsAllowed(bool &allow) override; + + /** + * @brief Delete notification. + * + * @param bundleOption Indicates the NotificationBundleOption of the notification. + * @param notificationId Indicates the id of the notification. + * @param label Indicates the label of the notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveNotification( const sptr &bundleOption, int notificationId, const std::string &label) override; + + /** + * @brief Delete all notifications. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveAllNotifications(const sptr &bundleOption) override; + + /** + * @brief Delete notification based on key. + * + * @param key Indicates the key to delete notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Delete(const std::string &key) override; + + /** + * @brief Remove notifications based on bundle. + * + * @param bundleOption Indicates the NotificationBundleOption of notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DeleteByBundle(const sptr &bundleOption) override; + + /** + * @brief Remove all notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DeleteAll() override; + /** + * @brief Get all the slots corresponding to the bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetSlotsByBundle( const sptr &bundleOption, std::vector> &slots) override; + + /** + * @brief Update slots according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param slots Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode UpdateSlots( const sptr &bundleOption, const std::vector> &slots) override; + + /** + * @brief Update slotgroup according to bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groups Indicates the notification slots to be updated. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode UpdateSlotGroups(const sptr &bundleOption, const std::vector> &groups) override; + + /** + * @brief Allow notifications to be sent based on the deviceId. + * + * @param deviceId Indicates the device Id. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RequestEnableNotification(const std::string &deviceId) override; - ErrCode SetNotificationsEnabledForBundle(const std::string &bundle, bool enabled) override; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for current bundle. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; + + /** + * @brief Set whether to allow the specified deviceId to send notifications for all bundles. + * + * @param deviceId Indicates the device Id. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; + + /** + * @brief Set whether to allow the specified bundle to send notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows notification to be pulished. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledForSpecialBundle( const std::string &deviceId, const sptr &bundleOption, bool enabled) override; + + /** + * @brief Sets whether the bundle allows the banner to display notification. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) override; + + /** + * @brief Gets whether the bundle allows the badge to display the status of notifications. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) override; + + /** + * @brief Gets whether allows the badge to display the status of notifications. + * + * @param enabled Indicates the flag that allows badge to be shown. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetShowBadgeEnabled(bool &enabled) override; + + /** + * @brief Subscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Subscribe(const sptr &subscriber, const sptr &info) override; + + /** + * @brief Unsubscribes notifications. + * + * @param subscriber Indicates the subscriber. + * @param info Indicates the NotificationSubscribeInfo object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode Unsubscribe(const sptr &subscriber, const sptr &info) override; + + /** + * @brief Checks whether this device is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsAllowedNotify(bool &allowed) override; + + /** + * @brief Checks whether this application is allowed to publish notifications. + * + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsAllowedNotifySelf(bool &allowed) override; + + /** + * @brief Checks whether notifications are allowed for a specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param allowed Indicates the flag that allows notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) override; + /** + * @brief Set do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetDoNotDisturbDate(const sptr &date) override; + + /** + * @brief Get do not disturb date. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetDoNotDisturbDate(sptr &date) override; + + /** + * @brief Get whether Do Not Disturb mode is supported. + * + * @param doesSupport Indicates the flag that supports DND mode. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; + + /** + * @brief Cancel notifications according to group. + * + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelGroup(const std::string &groupName) override; + + /** + * @brief Delete notifications according to bundle and group. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param groupName Indicates the group name. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode RemoveGroupByBundle( const sptr &bundleOption, const std::string &groupName) override; + /** + * @brief Gets whether distributed notification is enabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsDistributedEnabled(bool &enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode EnableDistributed(bool enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) override; + + /** + * @brief Sets distributed notification enabled or disabled for current bundle. + * + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode EnableDistributedSelf(bool enabled) override; + + /** + * @brief Gets whether distributed notification is enabled for specific bundle. + * + * @param bundleOption Indicates the NotificationBundleOption object. + * @param enabled Indicates the enabled flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) override; + + /** + * @brief Get the reminder type of the current device. + * + * @param remindType Reminder type for the device. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; + /** + * @brief Dump current running status for debuging. + * + * @param dumpOption Indicates the dump action that needs to be performed. + * @param dumpInfo Indicates the dump information. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode ShellDump(const std::string &dumpOption, std::vector &dumpInfo) override; + + /** + * @brief Publishes a continuous notification. + * + * @param request Notification requests that need to be posted. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishContinuousTaskNotification(const sptr &request) override; + + /** + * @brief Cancels a continuous notification. + * + * @param label Identifies the label of the specified notification. + * @param notificationId Identifies the id of the specified notification. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; + + /** + * @brief Publishes a reminder notification. + * + * @param reminder Identifies the reminder notification request that needs to be published. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode PublishReminder(sptr &reminder) override; + + /** + * @brief Cancel a reminder notifications. + * + * @param reminderId Identifies the reminders id that needs to be canceled. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelReminder(const int32_t reminderId) override; + + /** + * @brief Get all valid reminder notifications. + * + * @param reminders Identifies the list of all valid notifications. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetValidReminders(std::vector> &reminders) override; + + /** + * @brief Cancel all reminder notifications. + * + * @return Returns ERR_OK on success, others on failure. + */ ErrCode CancelAllReminders() override; + + /** + * @brief Checks whether this device is support template. + * + * @param templateName Identifies the template name for searching as a condition. + * @param support Identifies the support flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; + + /** + * @brief Checks Whether the specified users is allowed to publish notifications. + * + * @param userId Identifies the user's id. + * @param allowed Identifies the allowed flag. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; + + /** + * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must + * have system permissions to call this method. + * + * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only + * be null or an empty string, indicating the current device. + * @param enabled Specifies whether to allow all applications to publish notifications. The value true + * indicates that notifications are allowed, and the value false indicates that notifications + * are not allowed. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override; + + /** + * @brief Delete all notifications by user. + * + * @param userId Indicates the user id. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode DeleteAllByUser(const int32_t &userId) override; + + /** + * @brief Set do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; + + /** + * @brief Get the do not disturb date by user. + * + * @param userId Indicates the user id. + * @param date Indicates the NotificationDoNotDisturbDate object. + * @return Returns ERR_OK on success, others on failure. + */ ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; // SystemEvent + + /** + * @brief Obtains the event of bundle removed. + * + * @param bundleOption Indicates the bundle info. + */ void OnBundleRemoved(const sptr &bundleOption); + #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED + /** + * @brief Obtains the event of turn on screen. + */ void OnScreenOn(); + + /** + * @brief Obtains the event of turn off screen. + */ void OnScreenOff(); #endif void OnResourceRemove(int32_t userId); void OnBundleDataCleared(const sptr &bundleOption); // Distributed KvStore + + /** + * @brief Obtains the death event of the Distributed KvStore service. + */ void OnDistributedKvStoreDeathRecipient(); + ErrCode CancelPreparedNotification( int notificationId, const std::string &label, const sptr &bundleOption); ErrCode PrepareNotificationInfo( diff --git a/services/ans/include/advanced_notification_service_ability.h b/services/ans/include/advanced_notification_service_ability.h index 236cdeb0e0b524be5f39088b78598af56ff47291..65e872ca4c1c7ee9e2799cdda4b408bd6d5de6f0 100644 --- a/services/ans/include/advanced_notification_service_ability.h +++ b/services/ans/include/advanced_notification_service_ability.h @@ -26,8 +26,19 @@ namespace OHOS { namespace Notification { class AdvancedNotificationServiceAbility final : public SystemAbility { public: + /** + * @brief The constructor of service ability. + * + * @param systemAbilityId Indicates the system ability id. + * @param runOnCreate Run the system ability on created. + */ AdvancedNotificationServiceAbility(const int32_t systemAbilityId, bool runOnCreate); + + /** + * @brief The deconstructor. + */ ~AdvancedNotificationServiceAbility() final; + DISALLOW_COPY_AND_MOVE(AdvancedNotificationServiceAbility); DECLARE_SYSTEM_ABILITY(AdvancedNotificationServiceAbility); diff --git a/services/ans/include/bundle_manager_helper.h b/services/ans/include/bundle_manager_helper.h index 2e5fbd57a5bda70b19a4ec9f1dfff34f13023fe2..d637ca3ca5d9e243e19a69abd0f93a6baf6f5de8 100644 --- a/services/ans/include/bundle_manager_helper.h +++ b/services/ans/include/bundle_manager_helper.h @@ -32,12 +32,57 @@ namespace OHOS { namespace Notification { class BundleManagerHelper : public DelayedSingleton { public: + /** + * @brief Obtains the bundle name base on the specified uid. + * + * @param uid Indicates the specified uid. + * @return Returns the bundle name. + */ std::string GetBundleNameByUid(int uid); + + /** + * @brief Check whether the caller is a system application base on the specified uid. + * + * @param uid Indicates the specified uid. + * @return Returns the check result. + */ bool IsSystemApp(int uid); + + /** + * @brief Check API compatibility. + * + * @param bundleOption Indicates the bundle option. + * @return Returns the check result. + */ bool CheckApiCompatibility(const sptr &bundleOption); + + /** + * @brief Obtains the default uid. + * + * @param bundle Indicates the bundle name. + * @param userId Indicates the user id. + * @return Returns the uid. + */ int GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId); + + /** + * @brief Obtains the bundle info. + * + * @param bundle Indicates the bundle name. + * @param userId Indicates the user id. + * @param bundleInfo Indicates the bundle info. + * @return Returns the uid. + */ bool GetBundleInfoByBundleName(const std::string bundle, const int32_t userId, AppExecFwk::BundleInfo &bundleInfo); + #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED + /** + * @brief Check whether the specified bundle has the distributed notification supported. + * + * @param bundleName Indicates the bundle name. + * @param userId Indicates the user id. + * @return Returns the check result. + */ bool GetDistributedNotificationEnabled(const std::string &bundleName, const int userId); #endif diff --git a/services/ans/include/distributed_kvstore_death_recipient.h b/services/ans/include/distributed_kvstore_death_recipient.h index d2287997647a093bb5fb1ffc9fa7fc3838e02206..d886d171d62813d0421a22346fea223c3a10d121 100644 --- a/services/ans/include/distributed_kvstore_death_recipient.h +++ b/services/ans/include/distributed_kvstore_death_recipient.h @@ -24,14 +24,25 @@ namespace OHOS { namespace Notification { class DistributedKvStoreDeathRecipient : public DistributedKv::KvStoreDeathRecipient { public: + /** + * @brief The constructor. + * + * @param callback Indicates the callback. + */ explicit DistributedKvStoreDeathRecipient(const std::function &callback) { callback_ = callback; } + /** + * @brief The deconstructor. + */ virtual ~DistributedKvStoreDeathRecipient() {} + /** + * @brief Obtains the death event. Inherited from DistributedKv::KvStoreDeathRecipient. + */ void OnRemoteDied() override { if (callback_ != nullptr) { diff --git a/services/ans/include/notification_filter.h b/services/ans/include/notification_filter.h index 4c229109e32e821e8895c07f879e21aff5490c91..1d98a0e1fff9695af7d92590b99c7163aff8ded8 100644 --- a/services/ans/include/notification_filter.h +++ b/services/ans/include/notification_filter.h @@ -29,9 +29,22 @@ public: INotificationFilter() {}; virtual ~INotificationFilter() {}; + /** + * @brief Start the filter. + */ virtual void OnStart() = 0; + + /** + * @brief Stop the filter. + */ virtual void OnStop() = 0; + /** + * @brief Filters the publish operation. + * + * @param record Indicates the NotificationRecord. + * @return Returns the filter result. + */ virtual ErrCode OnPublish(const std::shared_ptr &record) = 0; }; } // namespace Notification diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index df5bf790160d7eed63cc3b54f84b018f2333f5ce..f0dce58332b85473524f65f18f3ee0fde827f279 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -27,53 +27,298 @@ namespace Notification { class NotificationPreferences final { public: DISALLOW_COPY_AND_MOVE(NotificationPreferences); + + /** + * @brief Get NotificationPreferences instance object. + */ static NotificationPreferences &GetInstance(); + + /** + * @brief Add notification slots into DB. + * + * @param bundleOption Indicates bunlde info label. + * @param slots Indicates add notification slots. + * @return Return ERR_OK on success, others on failure. + */ ErrCode AddNotificationSlots( const sptr &bundleOption, const std::vector> &slots); + + /** + * @brief Add notification slot groups into DB. + * + * @param bundleOption Indicates bunlde info label. + * @param groups Indicates add notification slot groups. + * @return Return ERR_OK on success, others on failure. + */ ErrCode AddNotificationSlotGroups( const sptr &bundleOption, const std::vector> &groups); + + /** + * @brief Add notification bunle info into DB. + * + * @param bundleOption Indicates bunlde info. + * @return Return ERR_OK on success, others on failure. + */ ErrCode AddNotificationBundleProperty(const sptr &bundleOption); + + /** + * @brief Remove notification a slot in the of bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param slotType Indicates slot type. + * @return Return ERR_OK on success, others on failure. + */ ErrCode RemoveNotificationSlot( const sptr &bundleOption, const NotificationConstant::SlotType &slotType); + + /** + * @brief Remove notification all slot in the of bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @return Return ERR_OK on success, others on failure. + */ ErrCode RemoveNotificationAllSlots(const sptr &bundleOption); + + /** + * @brief Remove notification all slot in the of bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @return Return ERR_OK on success, others on failure. + */ ErrCode RemoveNotificationSlotGroups( const sptr &bundleOption, const std::vector &groupIds); + + /** + * @brief Remove notification bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @return Return ERR_OK on success, others on failure. + */ ErrCode RemoveNotificationForBundle(const sptr &bundleOption); + + /** + * @brief Update notification slot into DB. + * + * @param bundleOption Indicates bunlde info label. + * @param slot Indicates need to upadte slot. + * @return Return ERR_OK on success, others on failure. + */ ErrCode UpdateNotificationSlots( const sptr &bundleOption, const std::vector> &slot); + + /** + * @brief Update notification slot group into DB. + * + * @param bundleOption Indicates bunlde info label. + * @param slot Indicates need to upadte slot group. + * @return Return ERR_OK on success, others on failure. + */ ErrCode UpdateNotificationSlotGroups( const sptr &bundleOption, const std::vector> &groups); + + /** + * @brief Get notification slot from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param type Indicates to get slot type. + * @param slot Indicates to get slot. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationSlot(const sptr &bundleOption, const NotificationConstant::SlotType &type, sptr &slot); + + /** + * @brief Get notification all slots in a bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param slots Indicates to get slots. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationAllSlots( const sptr &bundleOption, std::vector> &slots); + + /** + * @brief Get notification slot num in a bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param num Indicates to get slot num. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationSlotsNumForBundle(const sptr &bundleOption, int &num); + + /** + * @brief Get notification group in a bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param groupId Indicates to get group id. + * @param group Indicates to get slot group. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationSlotGroup(const sptr &bundleOption, const std::string &groupId, sptr &group); + + /** + * @brief Get notification all group in a bundle from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param groups Indicates to get slot groups. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationAllSlotGroups( const sptr &bundleOption, std::vector> &groups); + + /** + * @brief Get notification all slot in a group in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param groupId Indicates to get group id. + * @param slots Indicates to get slots. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationAllSlotInSlotGroup(const sptr &bundleOption, const std::string &groupId, std::vector> &slots); + + /** + * @brief Get show badge in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param enable Indicates to whether to show badge + * @return Return ERR_OK on success, others on failure. + */ ErrCode IsShowBadge(const sptr &bundleOption, bool &enable); + + /** + * @brief Set show badge in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param enable Indicates to set show badge + * @return Return ERR_OK on success, others on failure. + */ ErrCode SetShowBadge(const sptr &bundleOption, const bool enable); + + /** + * @brief Get importance in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param importance Indicates to importance label which can be LEVEL_NONE, + 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); + + /** + * @brief Set importance in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param importance Indicates to set a importance label which can be LEVEL_NONE, + 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); + + /** + * @brief Get total badge nums in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param totalBadgeNum Indicates to get badge num. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetTotalBadgeNums(const sptr &bundleOption, int &totalBadgeNum); + + /** + * @brief Set total badge nums in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param totalBadgeNum Indicates to set badge num. + * @return Return ERR_OK on success, others on failure. + */ ErrCode SetTotalBadgeNums(const sptr &bundleOption, const int num); + + /** + * @brief Get private notification allowed in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param allow Indicates to whether to allow. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetPrivateNotificationsAllowed(const sptr &bundleOption, bool &allow); + + /** + * @brief Set private notification allowed in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param allow Indicates to set allow. + * @return Return ERR_OK on success, others on failure. + */ ErrCode SetPrivateNotificationsAllowed(const sptr &bundleOption, const bool allow); + + /** + * @brief Get private notification enable in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param enabled Indicates to whether to enable. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationsEnabledForBundle(const sptr &bundleOption, bool &enabled); + + /** + * @brief Set private notification enable in the of bunlde from DB. + * + * @param bundleOption Indicates bunlde info label. + * @param enabled Indicates to set enable. + * @return Return ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabledForBundle(const sptr &bundleOption, const bool enabled); + + /** + * @brief Get notification enable from DB. + * + * @param userId Indicates user. + * @param enabled Indicates to whether to enable. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetNotificationsEnabled(const int32_t &userId, bool &enabled); + + /** + * @brief Set notification enable from DB. + * + * @param userId Indicates user. + * @param enabled Indicates to set enable. + * @return Return ERR_OK on success, others on failure. + */ ErrCode SetNotificationsEnabled(const int32_t &userId, const bool &enabled); ErrCode GetHasPoppedDialog(const sptr &bundleOption, bool &hasPopped); ErrCode SetHasPoppedDialog(const sptr &bundleOption, bool hasPopped); + + /** + * @brief Get do not disturb date from DB. + * + * @param userId Indicates user. + * @param date Indicates to get do not disturb date. + * @return Return ERR_OK on success, others on failure. + */ ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date); + + /** + * @brief Set do not disturb date from DB. + * + * @param userId Indicates user. + * @param date Indicates to set do not disturb date. + * @return Return ERR_OK on success, others on failure. + */ ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr date); - ErrCode GetTemplateSupported(const std::string& templateName, bool &support); + ErrCode GetTemplateSupported(const std::string &templateName, bool &support); + /** + * @brief Remove all proferences info from DB. + * + * @return Return ERR_OK on success, others on failure. + */ ErrCode ClearNotificationInRestoreFactorySettings(); + /** + * @brief Death recipient. + */ void OnDistributedKvStoreDeathRecipient(); void InitSettingFromDisturbDB(); void RemoveSettings(int32_t userId); diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index 2aa7f5a4e14a2b538aa638bcd03a910aaa8ce276..632c83fe4e6242b418699a8283dfefc89b74e155 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -28,30 +28,157 @@ class NotificationPreferencesDatabase final { public: NotificationPreferencesDatabase(); ~NotificationPreferencesDatabase(); + + /** + * @brief Put notification slots into disturbe DB. + * + * @param bundleName Indicates bunlde name. + * @param bundleUid Indicates bunlde uid. + * @param slots Indicates notification slots. + * @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 int &bundleUid, const std::vector> &slots); + + /** + * @brief Put notification slot groups into disturbe DB. + * + * @param bundleName Indicates bunlde name. + * @param bundleUid Indicates bunlde uid. + * @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); + const std::string &bundleName, const int &bundleUid, const std::vector> &groups); + + /** + * @brief Put notification bundle into disturbe DB. + * + * @param bundleInfo Indicates bunlde info. + * @return Return true on success, false on failure. + */ bool PutBundlePropertyToDisturbeDB(const NotificationPreferencesInfo::BundleInfo &bundleInfo); + /** + * @brief Put show badge in the of bundle into disturbe DB. + * + * @param bundleInfo Indicates bunlde info. + * @param enable Indicates to whether show badge. + * @return Return true on success, false on failure. + */ bool PutShowBadge(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const bool &enable); + + /** + * @brief Put importance in the of bundle into disturbe DB. + * + * @param bundleInfo Indicates bunlde info. + * @param importance Indicates to importance level which can be LEVEL_NONE, + 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); + + /** + * @brief Put badge total nums in the of bundle into disturbe DB. + * + * @param bundleInfo Indicates bunlde info. + * @param totalBadgeNum Indicates to total badge num. + * @return Return true on success, false on failure. + */ bool PutTotalBadgeNums(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int &totalBadgeNum); + + /** + * @brief Put private notification allowed in the of bundle into disturbe DB. + * + * @param bundleInfo Indicates bunlde info. + * @param allow Indicates to whether to allow + * @return Return true on success, false on failure. + */ bool PutPrivateNotificationsAllowed(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const bool &allow); + + /** + * @brief Put enable notification in the of bundle into disturbe DB. + * + * @param bundleInfo Indicates bunlde info. + * @param enabled Indicates to whether to enabled + * @return Return true on success, false on failure. + */ bool PutNotificationsEnabledForBundle( const NotificationPreferencesInfo::BundleInfo &bundleInfo, const bool &enabled); + + /** + * @brief Put enable notification into disturbe DB. + * + * @param userId Indicates user. + * @param enabled Indicates to whether to enabled + * @return Return true on success, false on failure. + */ bool PutNotificationsEnabled(const int32_t &userId, const bool &enabled); bool PutHasPoppedDialog(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const bool &hasPopped); + + /** + * @brief Put do not disturbe date into disturbe DB. + * + * @param userId Indicates user. + * @param date Indicates to do not disturbe date. + * @return Return true on success, false on failure. + */ bool PutDoNotDisturbDate(const int32_t &userId, const sptr &date); + /** + * @brief Parse notification info from disturbe DB. + * + * @param info Indicates notification info. + * @return Return true on success, false on failure. + */ bool ParseFromDisturbeDB(NotificationPreferencesInfo &info); + /** + * @brief Delete all data from disturbe DB. + * + * @return Return true on success, false on failure. + */ bool RemoveAllDataFromDisturbeDB(); + + /** + * @brief Delete bundle data from disturbe DB. + * + * @param bundleKey Indicates the bundle key. + * @return Return true on success, false on failure. + */ bool RemoveBundleFromDisturbeDB(const std::string &bundleKey); + + /** + * @brief Delete slot from disturbe DB. + * + * @param bundleKey Indicates to which a bundle. + * @param type Indicates to slot type. + * @return Return true on success, false on failure. + */ bool RemoveSlotFromDisturbeDB(const std::string &bundleKey, const NotificationConstant::SlotType &type); + + /** + * @brief Delete all slots in the of bundle from disturbe DB. + * + * @param bundleKey Indicates to which a bundle. + * @return Return true on success, false on failure. + */ bool RemoveAllSlotsFromDisturbeDB(const std::string &bundleKey); + + /** + * @brief Delete some groups in the of bundle from disturbe DB. + * + * @param bundleKey Indicates to which a bundle. + * @param groupId Indicates to group id in the of bundle. + * @return Return true on success, false on failure. + */ bool RemoveGroupsFromDisturbeDB(const std::string &bundleKey, const std::vector &groupId); + /** + * @brief Deal death recipient. + * + * @return Return true on success, false on failure. + */ bool StoreDeathRecipient(); bool RemoveNotificationEnable(const int32_t userId); diff --git a/services/ans/include/notification_preferences_info.h b/services/ans/include/notification_preferences_info.h index b7af5c22c73b26e01f445e15a39628095c3a95fb..54aeec00607659c4e72208276d3111ee5ae02ec8 100644 --- a/services/ans/include/notification_preferences_info.h +++ b/services/ans/include/notification_preferences_info.h @@ -34,34 +34,210 @@ public: public: BundleInfo(); ~BundleInfo(); + /** + * @brief Set bundle name. + * + * @param name Indicates the bundle name. + */ void SetBundleName(const std::string &name); + + /** + * @brief Get bundle name. + * + * @return Return bundle name. + */ std::string GetBundleName() const; + + /** + * @brief Set bundle importance. + * + * @param name Indicates the bundle importance. + */ void SetImportance(const int &level); + + /** + * @brief Get bundle importance. + * + * @return Return importance. + */ int GetImportance() const; + + /** + * @brief Set bundle Whether to show badge. + * + * @param name Indicates the set bundle Whether to show badge. + */ void SetIsShowBadge(const bool &isShowBadge); + + /** + * @brief Get bundle Whether to show badge. + * + * @return Return true on success, false on failure. + */ bool GetIsShowBadge() const; + + /** + * @brief Set bundle total badge num. + * + * @param name Indicates the set bundle total badge num. + */ void SetBadgeTotalNum(const int &num); + + /** + * @brief Get bundle total badge num. + * + * @return Return badge total num. + */ int GetBadgeTotalNum() const; + + /** + * @brief Set bundle Whether to private allowed. + * + * @param name Indicates the set Whether to private allowed. + */ void SetIsPrivateAllowed(const bool &isPrivateAllowed); + + /** + * @brief Get bundle Whether to private allowed. + * + * @return Return true on success, false on failure. + */ bool GetIsPrivateAllowed() const; + + /** + * @brief Set bundle enable notification. + * + * @param enable Indicates the set enable notification. + */ void SetEnableNotification(const bool &enable); + + /** + * @brief Set bundle enable notification. + * + * @return Return true on success, false on failure. + */ bool GetEnableNotification() const; + void SetHasPoppedDialog(const bool &hasPopped); bool GetHasPoppedDialog() const; + + /** + * @brief Set bundle slot. + * + * @param slot Indicates the set slot. + */ void SetSlot(const sptr &slot); + + /** + * @brief Get bundle slot by type. + * + * @param type Indicates the slot type. + * @param slot Indicates the slot object. + * @return Return true on success, false on failure. + */ bool GetSlot(const NotificationConstant::SlotType &type, sptr &slot) const; + + /** + * @brief Get slots from bundle. + * + * @param slots Indicates the get slots. + * @return Return true on success, false on failure. + */ bool GetAllSlots(std::vector> &slots); + + /** + * @brief Get slot num from bundle. + * + * @return Return true on success, false on failure. + */ uint32_t GetAllSlotsSize(); + + /** + * @brief Get all slot from group in bundle. + * + * @param groupId Indicates a groupId from bundle. + * @param slots Indicates get slots from group. + * @return Return true on success, false on failure. + */ bool GetAllSlotsInGroup(const std::string &groupId, std::vector> &slots); + + /** + * @brief Get all slot from group in bundle. + * + * @param groupId Indicates a groupId from bundle. + * @param slots Indicates get slots from group. + * @return Return true on success, false on failure. + */ bool GetAllSlotsInGroup(const std::string &groupId, std::vector &slots); + + /** + * @brief Set bundle group. + * + * @param group Indicates the set group. + */ void SetGroup(const sptr &group); + + /** + * @brief Get group from bundle. + * + * @param groupId Indicates the get group id in the of bundle. + * @param group Indicates the get group. + * @return Return true on success, false on failure. + */ bool GetGroup(const std::string &groupId, sptr &group); + + /** + * @brief Get all group from bundle. + * + * @param group Indicates the get groups. + * @return Return true on success, false on failure. + */ bool GetAllGroups(std::vector> &group); + + /** + * @brief Get slot group num from bundle. + * + * @return Return num is group size. + */ uint32_t GetGroupSize() const; + + /** + * @brief Check whether to exsist slot in the of bundle. + * + * @param type Indicates the slot type. + * @return Return true on success, false on failure. + */ bool IsExsitSlot(const NotificationConstant::SlotType &type) const; + + /** + * @brief Check whether to exsist slot group in the of bundle. + * + * @param groupId Indicates the slot group id. + * @return Return true on success, false on failure. + */ bool IsExsitSlotGroup(const std::string &groupId) const; + + /** + * @brief Rremove a slot from bundle. + * + * @param type Indicates the slot type. + * @return Return true on success, false on failure. + */ bool RemoveSlot(const NotificationConstant::SlotType &type); + + /** + * @brief Remove all slots from bundle. + * + * @return Return true on success, false on failure. + */ void RemoveAllSlots(); + + /** + * @brief remove slot group from bundle. + * + * @param groupId Indicates the slot group id. + * @return Return true on success, false on failure. + */ bool RemoveSlotGroup(const std::string &groupId); void SetBundleUid(const int &uid); int GetBundleUid() const; @@ -79,20 +255,81 @@ public: std::map> groups_; }; + /* + * @brief Constructor used to create an NotificationPreferencesInfo object. + */ NotificationPreferencesInfo() {} + /** + * @brief Default destructor. + */ ~NotificationPreferencesInfo() {} + + /** + * set bundle info into preferences info. + * @param info Indicates the bundle. + */ void SetBundleInfo(const BundleInfo &info); + + /** + * get bundle info from preferences info. + * @param bundleOption Indicates the bundle info label. + * @param info Indicates the bundle info. + * @return Whether to get bundle info success. + */ bool GetBundleInfo(const sptr &bundleOption, BundleInfo &info) const; + + /** + * remove bundle info from preferences info. + * @param bundleOption Indicates the bundle info label. + * @return Whether to remove bundle info success. + */ bool RemoveBundleInfo(const sptr &bundleOption); + + /** + * whether to exsist bundle info in the of preferences info. + * @param bundleOption Indicates the bundle info label. + * @return Whether to exsist bundle info. + */ bool IsExsitBundleInfo(const sptr &bundleOption) const; + + /** + * clear bundle info in the of preferences info. + */ void ClearBundleInfo(); + + /** + * set do not disturb date into preferences info. + * @param userId Indicates userId. + * @param doNotDisturbDate Indicates do not disturb date. + * @return Whether to set do not disturb success. + */ void SetDoNotDisturbDate(const int32_t &userId, const sptr &doNotDisturbDate); + + /** + * get do not disturb date from preferences info. + * @param userId Indicates userId. + * @param doNotDisturbDate Indicates do not disturb date. + * @return Whether to get do not disturb success. + */ bool GetDoNotDisturbDate(const int32_t &userId, sptr &doNotDisturbDate) const; + + /** + * set enable all notification into preferences info. + * @param userId Indicates userId. + * @param enable Indicates whether to enable all notification. + */ void SetEnabledAllNotification(const int32_t &userId, const bool &enable); + + /** + * get enable all notification from preferences info. + * @param userId Indicates userId. + * @param enable Indicates whether to enable all notification. + * @return Whether to enable all notification success. + */ bool GetEnabledAllNotification(const int32_t &userId, bool &enable) const; void RemoveNotificationEnable(const int32_t userId); void RemoveDoNotDisturbDate(const int32_t userId); diff --git a/services/ans/include/notification_slot_filter.h b/services/ans/include/notification_slot_filter.h index 3b8978c2c581b2bf23b61f427beab1087c4aebd9..3fa6d544d6e737edd50478583d0279c1ad156d33 100644 --- a/services/ans/include/notification_slot_filter.h +++ b/services/ans/include/notification_slot_filter.h @@ -25,9 +25,22 @@ public: NotificationSlotFilter() {}; ~NotificationSlotFilter() {}; + /** + * @brief Start the filter. Inherited from INotificationFilter. + */ void OnStart() override; + + /** + * @brief Stop the filter. Inherited from INotificationFilter. + */ void OnStop() override; + /** + * @brief Filters the publish operation. Inherited from INotificationFilter. + * + * @param record Indicates the NotificationRecord. + * @return Returns the filter result. + */ ErrCode OnPublish(const std::shared_ptr &record) override; }; } // namespace Notification diff --git a/services/ans/include/notification_subscriber_manager.h b/services/ans/include/notification_subscriber_manager.h index 2bf73706e65db4d6ca52d2241abefd91c5f82379..c097c413e86f3eb700c481648df5aff0e879fae7 100644 --- a/services/ans/include/notification_subscriber_manager.h +++ b/services/ans/include/notification_subscriber_manager.h @@ -38,16 +38,64 @@ namespace OHOS { namespace Notification { class NotificationSubscriberManager : public DelayedSingleton { public: + /** + * @brief Add a subscriber. + * + * @param subscriber Indicates the IAnsSubscriber object. + * @param subscribeInfo Indicates the NotificationSubscribeInfo object. + * @return Indicates the result code. + */ ErrCode AddSubscriber(const sptr &subscriber, const sptr &subscribeInfo); + + /** + * @brief Remove a subscriber. + * + * @param subscriber Indicates the IAnsSubscriber object. + * @param subscribeInfo Indicates the NotificationSubscribeInfo object. + * @return Indicates the result code. + */ ErrCode RemoveSubscriber( const sptr &subscriber, const sptr &subscribeInfo); + /** + * @brief Notify all subscribers on counsumed. + * + * @param notification Indicates the Notification object. + * @param notificationMap Indicates the NotificationSortingMap object. + */ void NotifyConsumed(const sptr ¬ification, const sptr ¬ificationMap); + + /** + * @brief Notify all subscribers on canceled. + * + * @param notification Indicates the Notification object. + * @param notificationMap Indicates the NotificationSortingMap object. + * @param deleteReason Indicates the delete reason. + */ void NotifyCanceled( const sptr ¬ification, const sptr ¬ificationMap, int deleteReason); + + /** + * @brief Notify all subscribers on updated. + * + * @param notificationMap Indicates the NotificationSortingMap object. + */ void NotifyUpdated(const sptr ¬ificationMap); + + /** + * @brief Notify all subscribers on dnd date changed. + * + * @param date Indicates the NotificationDoNotDisturbDate object. + */ void NotifyDoNotDisturbDateChanged(const sptr &date); + void NotifyEnabledNotificationChanged(const sptr &callbackData); + + /** + * @brief Obtains the death event. + * + * @param object Indicates the death object. + */ void OnRemoteDied(const wptr &object); private: diff --git a/services/ans/include/permission_filter.h b/services/ans/include/permission_filter.h index f0610279d9ec938eeea5cd8f70484eb3b922af14..b14536da889fc09a36895e1dcd326c4ea666983b 100644 --- a/services/ans/include/permission_filter.h +++ b/services/ans/include/permission_filter.h @@ -25,9 +25,22 @@ public: PermissionFilter() {}; ~PermissionFilter() {}; + /** + * @brief Start the filter. Inherited from INotificationFilter. + */ void OnStart() override; + + /** + * @brief Stop the filter. Inherited from INotificationFilter. + */ void OnStop() override; + /** + * @brief Filters the publish operation. Inherited from INotificationFilter. + * + * @param record Indicates the NotificationRecord. + * @return Returns the filter result. + */ ErrCode OnPublish(const std::shared_ptr &record) override; }; } // namespace Notification diff --git a/services/ans/include/preferences_constant.h b/services/ans/include/preferences_constant.h index e2538daf3b3411e05a278276f3f177933c530bf1..0e132255d4ff784490a19e65f23619642a69f45b 100644 --- a/services/ans/include/preferences_constant.h +++ b/services/ans/include/preferences_constant.h @@ -18,56 +18,220 @@ namespace OHOS { namespace Notification { +/** + * Indicates that disturbe key which do not disturbe type. + */ const static std::string KEY_DO_NOT_DISTURB_TYPE = "ans_doNotDisturbType"; + +/** + * Indicates that disturbe key which do not disturbe begin date. + */ const static std::string KEY_DO_NOT_DISTURB_BEGIN_DATE = "ans_doNotDisturbBeginDate"; + +/** + * Indicates that disturbe key which do not disturbe end date. + */ const static std::string KEY_DO_NOT_DISTURB_END_DATE = "ans_doNotDisturbEndDate"; + +/** + * Indicates that disturbe key which enable all notification. + */ const static std::string KEY_ENABLE_ALL_NOTIFICATION = "ans_notificationAll"; + +/** + * Indicates that disturbe key which bundle label. + */ const static std::string KEY_BUNDLE_LABEL = "label_ans_bundle_"; + +/** + * Indicates that disturbe key which under line. + */ const static std::string KEY_UNDER_LINE = "_"; + +/** + * Indicates that disturbe key which bundle begin key. + */ const static std::string KEY_ANS_BUNDLE = "ans_bundle"; +/** + * Indicates that disturbe key which bundle name. + */ const static std::string KEY_BUNDLE_NAME = "name"; + +/** + * Indicates that disturbe key which bundle imortance. + */ const static std::string KEY_BUNDLE_IMPORTANCE = "importance"; + +/** + * Indicates that disturbe key which bundle show badge. + */ const static std::string KEY_BUNDLE_SHOW_BADGE = "showBadge"; + +/** + * Indicates that disturbe key which bundle total badge num. + */ const static std::string KEY_BUNDLE_BADGE_TOTAL_NUM = "badgeTotalNum"; + +/** + * Indicates that disturbe key which bundle private allowed. + */ const static std::string KEY_BUNDLE_PRIVATE_ALLOWED = "privateAllowed"; + +/** + * Indicates that disturbe key which bundle enable notification. + */ const static std::string KEY_BUNDLE_ENABLE_NOTIFICATION = "enabledNotification"; + +/** + * Indicates that disturbe key which bundle popped dialog. + */ const static std::string KEY_BUNDLE_POPPED_DIALOG = "poppedDialog"; + +/** + * Indicates that disturbe key which bundle uid. + */ const static std::string KEY_BUNDLE_UID = "uid"; +/** + * Indicates that disturbe key which group. + */ const static std::string KEY_GROUP = "group"; + +/** + * Indicates that disturbe key which group id. + */ const static std::string KEY_GROUP_ID = "id"; + +/** + * Indicates that disturbe key which group name. + */ const static std::string KEY_GROUP_NAME = "name"; + +/** + * Indicates that disturbe key which group description. + */ const static std::string KEY_GROUP_DESCRIPTION = "groupDescription"; + +/** + * Indicates that disturbe key which group is disable. + */ const static std::string KEY_GROUP_DISABLE = "isDisable"; +/** + * Indicates that disturbe key which slot. + */ const static std::string KEY_SLOT = "slot"; + +/** + * Indicates that disturbe key which slot type. + */ const static std::string KEY_SLOT_TYPE = "type"; + +/** + * Indicates that disturbe key which slot id. + */ const static std::string KEY_SLOT_ID = "id"; + +/** + * Indicates that disturbe key which slot group id. + */ const static std::string KEY_SLOT_GROUPID = "groupId"; + +/** + * Indicates that disturbe key which slot group name. + */ const static std::string KEY_SLOT_NAME = "name"; + +/** + * Indicates that disturbe key which slot description. + */ const static std::string KEY_SLOT_DESCRIPTION = "description"; + +/** + * Indicates that disturbe key which slot level. + */ const static std::string KEY_SLOT_LEVEL = "level"; + +/** + * Indicates that disturbe key which slot show badge. + */ const static std::string KEY_SLOT_SHOW_BADGE = "showBadge"; + +/** + * Indicates that disturbe key which slot enable light. + */ const static std::string KEY_SLOT_ENABLE_LIGHT = "enableLight"; + +/** + * Indicates that disturbe key which slot enable vibration. + */ const static std::string KEY_SLOT_ENABLE_VRBRATION = "enableVibration"; + +/** + * Indicates that disturbe key which slot led light color. + */ const static std::string KEY_SLOT_LED_LIGHT_COLOR = "ledLightColor"; + +/** + * Indicates that disturbe key which slot lockscreen visibleness. + */ const static std::string KEY_SLOT_LOCKSCREEN_VISIBLENESS = "lockscreenVisibleness"; + +/** + * Indicates that disturbe key which slot sound. + */ const static std::string KEY_SLOT_SOUND = "sound"; + +/** + * Indicates that disturbe key which slot vibration style. + */ const static std::string KEY_SLOT_VIBRATION_STYLE = "vibrationSytle"; + +/** + * Indicates that disturbe key which slot enable bypass end. + */ const static std::string KEY_SLOT_ENABLE_BYPASS_DND = "enableBypassDnd"; -// distributed database +/** + * Indicates distributed database app id. + */ const std::string APP_ID = "advanced_notification_service"; + +/** + * Indicates distributed database store id. + */ const std::string STORE_ID = "local_db"; +/** + * Default params that bundle importance is LEVEL_DEFAULT. + */ const static int BUNDLE_IMPORTANCE = 3; + +/** + * Default params that bundle badge total num is zero. + */ const static int BUNDLE_BADGE_TOTAL_NUM = 0; + +/** + * Default params that bundle private allowed is false. + */ const static int BUNDLE_PRIVATE_ALLOWED = false; + +/** + * Default params that bundle enable notification is true. + */ const static int BUNDLE_ENABLE_NOTIFICATION = true; const static int BUNDLE_POPPED_DIALOG = false; + +/** + * Default params that bundle show badge is false. + */ const static bool BUNDLE_SHOW_BADGE = false; +/** + * Indicates bundle type which used to DB store. + */ enum class BundleType { BUNDLE_NAME_TYPE = 1, BUNDLE_IMPORTANCE_TYPE, diff --git a/services/ans/include/remote_death_recipient.h b/services/ans/include/remote_death_recipient.h index 159aed72dd1380bd06293f15f5ce031faa695943..6c876bc6cc1c95b458a43f3ea495b8b4a60b1856 100644 --- a/services/ans/include/remote_death_recipient.h +++ b/services/ans/include/remote_death_recipient.h @@ -24,16 +24,27 @@ namespace OHOS { namespace Notification { class RemoteDeathRecipient : public IRemoteObject::DeathRecipient { public: + /** + * The constructor. + * @param callback Indicates the callback. + */ explicit RemoteDeathRecipient(std::function &)> callback) { callback_ = callback; } + + /** + * The deconstructor. + */ ~RemoteDeathRecipient() { callback_ = nullptr; } - // IRemoteObject::DeathRecipient + /** + * Obtains the death event. Inherited from IRemoteObject::DeathRecipient. + * @param object Indicates the death object. + */ void OnRemoteDied(const wptr &object) { if (callback_ != nullptr) { diff --git a/services/ans/include/system_event_observer.h b/services/ans/include/system_event_observer.h index db8bcaa5b81d77c5e0a025c84f67791c41be28b7..85629c59ce4ffb6f06ac0db8bdeaebd2506b9d3b 100644 --- a/services/ans/include/system_event_observer.h +++ b/services/ans/include/system_event_observer.h @@ -28,7 +28,16 @@ namespace OHOS { namespace Notification { class SystemEventObserver { public: + /** + * @brief The constructor. + * + * @param callbacks Indicates the ISystemEvent object. + */ explicit SystemEventObserver(const ISystemEvent &callbacks); + + /** + * @brief The deconstructor. + */ ~SystemEventObserver(); private: diff --git a/services/ans/include/system_event_subscriber.h b/services/ans/include/system_event_subscriber.h index 593f92b8bb6c7386a0f06251a78ee3627f4778f9..a1adbeb31c9906fb61813670b3eb5dcedcef31b5 100644 --- a/services/ans/include/system_event_subscriber.h +++ b/services/ans/include/system_event_subscriber.h @@ -24,14 +24,28 @@ namespace OHOS { namespace Notification { class SystemEventSubscriber : public EventFwk::CommonEventSubscriber { public: + /** + * @brief The constructor. + * + * @param subscribeInfo Indicates the EventFwk::CommonEventSubscribeInfo object. + * @param callback Indicates the callback. + */ SystemEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo, const std::function &callback) : EventFwk::CommonEventSubscriber(subscribeInfo), callback_(callback) {} + /** + * @brief The deconstructor. + */ ~SystemEventSubscriber() {} + /** + * @brief Obtains the death event. Inherited from EventFwk::CommonEventSubscriber. + * + * @param data Indicates the EventFwk::CommonEventData object. + */ void OnReceiveEvent(const EventFwk::CommonEventData &data) override { if (callback_ != nullptr) { diff --git a/services/ans/test/unittest/mock/include/mock_ipc_skeleton.h b/services/ans/test/unittest/mock/include/mock_ipc_skeleton.h index 9dba14229561113c7f1e8aa8261c6ef1decb2eee..56591d38ecd7f3cfda4ede0bea42982ca6a8027a 100644 --- a/services/ans/test/unittest/mock/include/mock_ipc_skeleton.h +++ b/services/ans/test/unittest/mock/include/mock_ipc_skeleton.h @@ -25,42 +25,115 @@ public: IPCSkeleton() = default; ~IPCSkeleton() = default; - // default max is 4, only if you need a customize value + /** + * @brief Set the max number of work thread. + * Default max is 4, only if you need a customize value. + * + * @param maxThreadNum Indicates the max number of work thread + * @return Indicates the result. + */ static bool SetMaxWorkThreadNum(int maxThreadNum); - // join current thread into work loop. + /** + * @brief Join current thread into work loop. + */ static void JoinWorkThread(); - // remove current thread from work loop. + /** + * @brief Remove current thread from work loop. + */ static void StopWorkThread(); + /** + * @brief Get calling pid. + * + * @return Indicates the calling pid. + */ static pid_t GetCallingPid(); + /** + * @brief Get calling uid. + * + * @return Indicates the calling uid. + */ static pid_t GetCallingUid(); - static Security::AccessToken::AccessTokenID GetCallingTokenID(); - + /** + * @brief Get the ID of local device. + * + * @return Indicates the ID of local device. + */ static std::string GetLocalDeviceID(); + static Security::AccessToken::AccessTokenID GetCallingTokenID(); + + /** + * @brief Get the ID of calling device. + * + * @return Indicates the ID of calling device. + */ static std::string GetCallingDeviceID(); + /** + * @brief Whether it is locally calling. + * + * @return Return ture for calling from local, otherwise false. + */ static bool IsLocalCalling(); + /** + * @brief Get the instance. + * + * @return Indicates the instance. + */ static IPCSkeleton &GetInstance(); + /** + * @brief Get the object of context. + * + * @return Indicates the context cobject. + */ static sptr GetContextObject(); + /** + * @brief Set the object of context. + * + * @param object Indicates the context cobject. + * @return Indicates the result. + */ static bool SetContextObject(sptr &object); + /** + * @brief Flush the commands. + * + * @param object Indicates the object. + * @return Indicates the result. + */ static int FlushCommands(IRemoteObject *object); + /** + * @brief Reset calling identity. + * + * @return Indicates the result. + */ static std::string ResetCallingIdentity(); + /** + * @brief Set calling identity. + * + * @param identity Indicates the identity. + * @return Indicates the result. + */ static bool SetCallingIdentity(std::string &identity); + /** + * @brief Set calling uid. + * + * @param uid Indicates the uid. + */ static void SetCallingUid(pid_t uid); static void SetCallingTokenID(Security::AccessToken::AccessTokenID callerToken); }; -} // namespace OHOS -#endif // OHOS_IPC_IPC_SKELETON_H +} // namespace OHOS +#endif // OHOS_IPC_IPC_SKELETON_H diff --git a/services/ans/test/unittest/mock/include/mock_single_kv_store.h b/services/ans/test/unittest/mock/include/mock_single_kv_store.h index b682e43151bbd0c60c21ec51decf5460a8b8ee01..7a08adc5d6f340e3647b689df3f5e1a378652523 100644 --- a/services/ans/test/unittest/mock/include/mock_single_kv_store.h +++ b/services/ans/test/unittest/mock/include/mock_single_kv_store.h @@ -33,81 +33,329 @@ namespace DistributedKv { // This class provides put, delete, search, sync and subscribe functions of a key-value store. class AnsTestSingleKvStore : public SingleKvStore { public: + /** + * @brief Get all entries in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntries(const Key &prefixKey, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query string. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const std::string &query, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query object. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const DataQuery &query, std::vector &entries) const override; + /** + * @brief Get ResultSet in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSet(const Key &prefixKey, std::shared_ptr &resultSet) const override; + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query string. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSetWithQuery(const std::string &query, std::shared_ptr &resultSet) const override; + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query object. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSetWithQuery(const DataQuery &query, std::shared_ptr &resultSet) const override; + /** + * @brief Close the ResultSet returned by GetResultSet. + * + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status CloseResultSet(std::shared_ptr &resultSet) override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query string. + * @param result Indicates the result. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const std::string &query, int &result) const override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query object. + * @param result Indicates the result will be returned in this parameter. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const DataQuery &query, int &result) const override; + /** + * @brief Sync store with other devices. This is an asynchronous method, + * sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUTH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @param allowedDelayMs Indicates the allowed delay milli-second to sync. default value is 0 for compatibility. + * @return Indicates the status of this Sync operation. + */ virtual Status Sync( const std::vector &deviceIds, SyncMode mode, uint32_t allowedDelayMs = 0) override; + /** + * @brief Remove the device data synced from remote. + * + * @param device Indicates the device id. + * @return Indicates the status of this remove operation. + */ virtual Status RemoveDeviceData(const std::string &device) override; + /** + * @brief Get id of this AppKvStore. + * + * @return Indicates the id of store. + */ virtual StoreId GetStoreId() const override; + /** + * @brief Delete an entry by its key. + * + * @param key Indicates the key of the entry to be deleted. + * @return Indicates the status of this delete operation. + */ virtual Status Delete(const Key &key) override; + /** + * @brief Write a pair of key and value to this store. + * + * @param key Indicates the key of this entry. Should be less than 256 bytes. key will be trimmed before store. + * @param value Indicates the value of this entry. Should be less than (1024 * 1024) bytes. + * @return Indicates the status of this put operation. + */ virtual Status Put(const Key &key, const Value &value) override; + /** + * @brief Get value from AppKvStore by its key. + * + * @param key Indicates the key of this entry. + * @param value Indicates the value will be returned in this parameter. + * @return Indicates the status of this get operation. + */ virtual Status Get(const Key &key, Value &value) override; + /** + * @brief Register change of this kvstore to a client-defined observer. + * observer->OnChange method will be called when store changes. + * One observer can subscribe more than one AppKvStore. + * + * @param subscribeType Indicates the subscribe type. + * OBSERVER_CHANGES_NATIVE means native changes of syncable kv store, + * OBSERVER_CHANGES_FOREIGN means synced data changes from remote devices, + * OBSERVER_CHANGES_ALL means both native changes and synced data changes. + * @param observer Indicates the observer to subscribe changes. + * @return Indicates the status of this subscribe operation. + */ virtual Status SubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Unregister a kvstore to an observer. + * + * @param subscribeType Indicates the subscribe type. + * Reserved parameter. Current is always SubscribeType::DEFAULT. + * @param observer Indicates the observer to unsubscribe this store. + * @return Indicates the status of this unsubscribe operation. + */ virtual Status UnSubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Register message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status RegisterSyncCallback(std::shared_ptr callback) override; + /** + * @brief Unregister message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status UnRegisterSyncCallback() override; + /** + * @brief See Put, PutBatch put a list of entries to kvstore, + * all entries will be put in a transaction, + * if entries contains invalid entry, PutBatch will all fail. + * + * @param entries Indicates the entries. + * The entries's size should be less than 128 and memory size must be less than IPC transport limit. + * @return Indicates the status of this register operation. + */ virtual Status PutBatch(const std::vector &entries) override; + /** + * @brief Delete a list of entries in the kvstore, + * delete key not exist still return success, + * key length should not be greater than 256, and can not be empty. + * If keys contains invalid key, all delete will fail. + * + * @param keys Indicates the list of keys. + * The keys memory size should not be greater than IPC transport limit, and can not be empty. + * @return Indicates the status of this register operation. + */ virtual Status DeleteBatch(const std::vector &keys) override; + /** + * @brief Start transaction. + * All changes to this kvstore will be in a same transaction and will not change the store until Commit() or + * Rollback() is called. + * Before this transaction is committed or rollbacked, all attemption to close this store will fail. + * + * @return Indicates the status of this operation. + */ virtual Status StartTransaction() override; + /** + * @brief Commit current transaction. All changes to this store will be done after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Commit() override; + /** + * @brief Rollback current transaction. + * All changes to this store during this transaction will be rollback after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Rollback() override; + /** + * @brief Set synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status SetSyncParam(const KvSyncParam &syncParam) override; + /** + * @brief Get synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status GetSyncParam(KvSyncParam &syncParam) override; + /** + * @brief Set capability parameters of this store. + * + * @param enabled Indicates the capability Enabled status. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityEnabled(bool enabled) const override; + /** + * @brief Set capability parameters of this store. + * + * @param localLabels Indicates the labels of local. + * @param remoteSupportLabels Indicates the labels of remote support. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityRange(const std::vector &localLabels, const std::vector &remoteSupportLabels) const override; + /** + * @brief Get security level. + * + * @param securityLevel Indicates the security level. + * @return Indicates the status of this operation. + */ virtual Status GetSecurityLevel(SecurityLevel &securityLevel) const override; + /** + * @brief Sync store with other devices only syncing the data which is satisfied with the condition. + * This is an asynchronous method, sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUSH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @return Indicates the status of this operation. + */ virtual Status SyncWithCondition(const std::vector &deviceIds, SyncMode mode, const DataQuery &query, std::shared_ptr syncCallback) override; + /** + * @brief Subscribe store with other devices consistently Synchronize the data which is satisfied + * with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * + * @return Indicates the status of this operation. + */ virtual Status SubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief UnSubscribe store with other devices which is satisfied with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @return Indicates the status of this UnSubscribe operation. + */ virtual Status UnsubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status GetKvStoreSnapshot(std::shared_ptr observer, std::shared_ptr &snapshot) const override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status ReleaseKvStoreSnapshot(std::shared_ptr &snapshot) override; + /** + * @brief Clear the object. + * + * @return Indicates the status of this operation. + */ Status Clear() override; + protected: KVSTORE_API virtual Status Control(KvControlCmd cmd, const KvParam &inputParam, KvParam &output) override; }; diff --git a/services/distributed/include/distributed_database.h b/services/distributed/include/distributed_database.h index 6286769a00ce929d2d378975bb0a5148bc771d2d..3508780f513574941455c6d2dadeed06dd201dab 100644 --- a/services/distributed/include/distributed_database.h +++ b/services/distributed/include/distributed_database.h @@ -34,18 +34,93 @@ class DistributedDatabase : private DistributedFlowControl { public: using Entry = DistributedKv::Entry; using DeviceInfo = DistributedKv::DeviceInfo; + + /** + * @brief The constructor. + * + * @param databaseCb Distributed notification info changed callback object. + * @param deviceCb Device connection info changed callback object. + */ DistributedDatabase( std::shared_ptr databaseCb, std::shared_ptr deviceCb); + + /** + * @brief The deconstructor. + */ ~DistributedDatabase(); + /** + * @brief Put a key-value to database. + * + * @param key Indicates the key. + * @param value Indicates the value. + * @return Whether to put key-value success. + */ bool PutToDistributedDB(const std::string &key, const std::string &value); + + /** + * @brief Get the value of its key from database. + * + * @param key Indicates the key. + * @param value Indicates the value. + * @return Whether to get key-value success. + */ bool GetFromDistributedDB(const std::string &key, std::string &value); + + /** + * @brief Get all entries which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param entries Indicates the entries will be returned in this parameter. + * @return Whether to get entries success. + */ bool GetEntriesFromDistributedDB(const std::string &prefixKey, std::vector &entries); + + /** + * @brief Delete a key-value of its key from database. + * + * @param key Indicates the key. + * @return Whether to delete key-value success. + */ bool DeleteToDistributedDB(const std::string &key); + + /** + * @brief Clear all entries which put by specified device. + * + * @param deviceId Indicates the id of specified device. + * @return Whether to clear device entries success. + */ bool ClearDataByDevice(const std::string &deviceId); + + /** + * @brief Get local device id. + * + * @param deviceId Indicates the id of local device. + * @return Whether to get device id success. + */ bool GetLocalDeviceId(std::string &deviceId); + + /** + * @brief Get local device info. + * + * @param localInfo Indicates the infomation of local device. + * @return Whether to get device infomation success. + */ bool GetLocalDeviceInfo(DeviceInfo &localInfo); + + /** + * @brief Get all devices info on the network. + * + * @param deviceList Indicates the infomation list of devices. + * @return Whether to get devices infomation success. + */ bool GetDeviceInfoList(std::vector &deviceList); + + /** + * @brief Recreate the database of distributed notification + * + * @return Whether to recreate the database success. + */ bool RecreateDistributedDB(); private: diff --git a/services/distributed/include/distributed_database_callback.h b/services/distributed/include/distributed_database_callback.h index 672b55617faa0e51359b599f86ec7175aaaff824..dde4be8a44c81a284221f1ac4e0be321de322e2f 100644 --- a/services/distributed/include/distributed_database_callback.h +++ b/services/distributed/include/distributed_database_callback.h @@ -24,13 +24,27 @@ namespace OHOS { namespace Notification { class DistributedDatabaseCallback : public DistributedKv::KvStoreObserver { public: + /** + * @brief Distributed notification Key-Value changed callback function structure. + */ struct IDatabaseChange { std::function OnInsert; std::function OnUpdate; std::function OnDelete; }; + + /** + * @brief The constructor. + * + * @param callback Key-Value changed callback. + */ explicit DistributedDatabaseCallback(const IDatabaseChange &callback); + + /** + * @brief The deconstructor. + */ ~DistributedDatabaseCallback(); + private: void OnChange(const DistributedKv::ChangeNotification &changeNotification, std::shared_ptr snapshot) override; diff --git a/services/distributed/include/distributed_device_callback.h b/services/distributed/include/distributed_device_callback.h index 33000b45604becf489bb938bade6d95f8339346f..86ac2c600f0b72f802b0615660e1d8d829aea2c2 100644 --- a/services/distributed/include/distributed_device_callback.h +++ b/services/distributed/include/distributed_device_callback.h @@ -24,11 +24,24 @@ namespace OHOS { namespace Notification { class DistributedDeviceCallback : public DistributedKv::DeviceStatusChangeListener { public: + /** + * @brief Device connection status changed callback function structure. + */ struct IDeviceChange { std::function OnConnected; std::function OnDisconnected; }; + + /** + * @brief The constructor. + * + * @param callback Device connection status changed callback. + */ explicit DistributedDeviceCallback(const IDeviceChange &callback); + + /** + * @brief The deconstructor. + */ ~DistributedDeviceCallback(); private: diff --git a/services/distributed/include/distributed_flow_control.h b/services/distributed/include/distributed_flow_control.h index 435381491d58798e95af0b2718034071acecc74e..71ec01bfd69be6393799dd8bf1ad22b0745f1a6a 100644 --- a/services/distributed/include/distributed_flow_control.h +++ b/services/distributed/include/distributed_flow_control.h @@ -23,13 +23,41 @@ namespace OHOS { namespace Notification { class DistributedFlowControl { public: + /** + * @brief The constructor. + * + * @param kvManagerSecondMaxinum The maximum number of calls to DistributedKvDataManager interface per second. + * @param kvManagerMinuteMaxinum The maximum number of calls to DistributedKvDataManager interface per minute. + * @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); + + /** + * @brief Check if DistributedKvDataManager interface flow control can pass. + * + * @return True on passed, otherwise false. + */ bool KvManagerFlowControl(void); + + /** + * @brief Check if SingleKvStore interface flow control can pass. + * + * @return True on passed, otherwise false. + */ bool KvStoreFlowControl(void); + + /** + * @brief Clear DistributedKvDataManager interface flow control count. + */ void KvManagerFlowControlClear(void); + + /** + * @brief Clear SingleKvStore interface flow control count. + */ void KvStoreFlowControlClear(void); protected: diff --git a/services/distributed/include/distributed_notification_manager.h b/services/distributed/include/distributed_notification_manager.h index edcc0a973a0436d4b231befbd1b239f26c6bfa0d..796a9a54b4d7c89c0aeade42452e9b4842c1bc51 100644 --- a/services/distributed/include/distributed_notification_manager.h +++ b/services/distributed/include/distributed_notification_manager.h @@ -32,6 +32,9 @@ namespace OHOS { namespace Notification { class DistributedNotificationManager : public DelayedSingleton { public: + /** + * @brief Distributed notification callback function for remote device. + */ struct IDistributedCallback { std::function &request)> @@ -44,17 +47,86 @@ public: OnDelete; }; + /** + * @brief Publishes a local notification to remote device. + * + * @param bundleName Indicates the bundle name of the application whose notifications are to be publish. + * @param label Indicates the label of the notifications. + * @param id Indicates the bundle uid of the application whose notifications are to be publish. + * @param request Indicates the NotificationRequest object for setting the notification content. + * @return ErrCode Returns the publish result. + */ ErrCode Publish( const std::string &bundleName, const std::string &label, int32_t id, const sptr &request); + + /** + * @brief Updates infomation of local notification to remote device. + * + * @param bundleName Indicates the bundle name of the application whose notifications are to be update. + * @param label Indicates the label of the notifications. + * @param id Indicates the bundle uid of the application whose notifications are to be update. + * @param request Indicates the NotificationRequest object for setting the notification content. + * @return ErrCode Returns the update result. + */ ErrCode Update( const std::string &bundleName, const std::string &label, int32_t id, const sptr &request); + + /** + * @brief Removes a local notification. + * + * @param bundleName Indicates the bundle name of the application whose notifications are to be remove. + * @param label Indicates the label of the notifications. + * @param id Indicates the bundle uid of the application whose notifications are to be remove. + * @return ErrCode Returns the remove result. + */ ErrCode Delete(const std::string &bundleName, const std::string &label, int32_t id); + + /** + * @brief Removes a remote notification. + * + * @param deviceId Indicates the ID of the device. + * @param bundleName Indicates the bundle name of the application whose notifications are to be remove. + * @param label Indicates the label of the notifications. + * @param id Indicates the bundle uid of the application whose notifications are to be remove. + * @return ErrCode Returns the remove result. + */ ErrCode DeleteRemoteNotification( const std::string &deviceId, const std::string &bundleName, const std::string &label, int32_t id); + + /** + * @brief Register callback of distributed notification changed. + * + * @param callback Indicates the callback structure + * @return ErrCode Returns the register result. + */ ErrCode RegisterCallback(const IDistributedCallback &callback); + + /** + * @brief Unregister Callback of Distributed notification changed. + * + * @return ErrCode Returns the unregister result. + */ ErrCode UngegisterCallback(void); + + /** + * @brief Get all distributed notification in database. + * + * @param requestList Indicates the list of NotificationRequest object for setting the notification content. + * @return ErrCode Returns Get all distributed notification result. + */ ErrCode GetCurrentDistributedNotification(std::vector> &requestList); + + /** + * @brief Get local device info. + * + * @param deviceInfo Indicates the infomation of local device. + * @return ErrCode Returns get device infomation result. + */ ErrCode GetLocalDeviceInfo(DistributedDatabase::DeviceInfo &deviceInfo); + + /** + * @brief Obtains the death event of the Distributed KvStore service. + */ ErrCode OnDistributedKvStoreDeathRecipient(); private: diff --git a/services/distributed/include/distributed_preferences.h b/services/distributed/include/distributed_preferences.h index 44d6d8991b69100e42bae83c54711b11040c14c2..4f04368882d84d916df5db877040ed9a09614af5 100644 --- a/services/distributed/include/distributed_preferences.h +++ b/services/distributed/include/distributed_preferences.h @@ -31,11 +31,53 @@ namespace OHOS { namespace Notification { class DistributedPreferences : public DelayedSingleton { public: + /** + * @brief Set whether the device supports distributed notifications. + * + * @param enable Specifies whether to enable the device to support distributed notification. + * @return Returns enable distributed result. + */ ErrCode SetDistributedEnable(bool isEnable); + + /** + * @brief Check if the device supports distributed notification. + * + * @param enabled True if the device supports distributed notification; false otherwise. + * @return Returns is distributed enabled result. + */ ErrCode GetDistributedEnable(bool &isEnable); + + /** + * @brief Set whether an application supports distributed notifications. + * + * @param bundleOption Indicates the bundle name and uid of an application. + * @param enabled Specifies whether to enable an application to support distributed notification. + * @return Returns enable distributed by bundle result. + */ ErrCode SetDistributedBundleEnable(const sptr &bundleOption, bool isEnable); + + /** + * @brief Check whether an application supports distributed notifications. + * + * @param bundleOption Indicates the bundle name and uid of an application. + * @param enabled True if the application supports distributed notification; false otherwise. + * @return Returns is distributed enabled by bundle result. + */ ErrCode GetDistributedBundleEnable(const sptr &bundleOption, bool &isEnable); + + /** + * @brief Remove the setting of whether the application supports distributed notification. + * + * @param bundleOption Indicates the bundle name and uid of an application. + * @return Returns remove the setting result. + */ ErrCode DeleteDistributedBundleInfo(const sptr &bundleOption); + + /** + * @brief Remove all distributed enabled setting info from DB. + * + * @return Returns remove the setting result. + */ ErrCode ClearDataInRestoreFactorySettings(); private: diff --git a/services/distributed/include/distributed_preferences_database.h b/services/distributed/include/distributed_preferences_database.h index 92b80d1f2d0059ebcd4d7b88d2e9feb184421a39..9668c349a0d89b02d74780d54238d3566eac5b80 100644 --- a/services/distributed/include/distributed_preferences_database.h +++ b/services/distributed/include/distributed_preferences_database.h @@ -36,10 +36,46 @@ public: DistributedPreferencesDatabase(); ~DistributedPreferencesDatabase(); + /** + * @brief Put a key-value to database. + * + * @param key Indicates the key. + * @param value Indicates the value. + * @return Whether to put key-value success. + */ bool PutToDistributedDB(const std::string &key, const std::string &value); + + /** + * @brief Get the value of its key from database. + * + * @param key Indicates key. + * @param value Indicates value. + * @return Whether to get key-value success. + */ bool GetFromDistributedDB(const std::string &key, std::string &value); + + /** + * @brief Get all entries which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param entries Indicates the entries will be returned in this parameter. + * @return Whether to get entries success. + */ bool GetEntriesFromDistributedDB(const std::string &prefixKey, std::vector &entries); + + /** + * @brief Delete a key-value of its key from database. + * + * @param key Indicates the key. + * @return Whether to delete key-value success. + */ bool DeleteToDistributedDB(const std::string &key); + + /** + * @brief Clear all data in database and Delete the database. + * + * @return Whether to clear database success. + */ bool ClearDatabase(void); private: diff --git a/services/distributed/include/distributed_preferences_info.h b/services/distributed/include/distributed_preferences_info.h index 840d3c95f2dd05b054d5837b05ce7df7c26b6a53..16288af7ea189f4e9e21c8e5a7c6271e9ba98657 100644 --- a/services/distributed/include/distributed_preferences_info.h +++ b/services/distributed/include/distributed_preferences_info.h @@ -25,10 +25,53 @@ class DistributedPreferencesInfo { public: DistributedPreferencesInfo(); ~DistributedPreferencesInfo(); + + /** + * @brief Set whether the device supports distributed notifications. + * + * @param enable Specifies whether to enable the device to support distributed notification. + */ void SetDistributedEnable(bool enable); + + /** + * @brief Check if the device supports distributed notification. + * + * @return True if the device supports distributed notification; false otherwise. + */ bool GetDistributedEnable(void); + + /** + * @brief Set whether an application supports distributed notifications. + * + * @param bundleOption Indicates the bundle name and uid of an application. + * @param enabled Specifies whether to enable an application to support distributed notification. + * @return Returns enable distributed by bundle result. + */ + + /** + * @brief Set whether an application supports distributed notifications. + * + * @param bundleName Indicates the bundle name of an application. + * @param uid Indicates the uid of an application. + * @param enable Specifies whether to enable an application to support distributed notification. + */ void SetDistributedBundleEnable(const std::string &bundleName, int32_t uid, bool enable); + + /** + * @brief Check whether an application supports distributed notifications. + * + * @param bundleName Indicates the bundle name of an application. + * @param uid Indicates the uid of an application. + * @return True if the application supports distributed notification; false otherwise. + */ bool GetDistributedBundleEnable(const std::string &bundleName, int32_t uid); + + /** + * @brief Remove the setting of whether the application supports distributed notification. + * + * @param bundleName Indicates the bundle name of an application. + * @param uid Indicates the uid of an application. + */ void DeleteDistributedBundleInfo(const std::string &bundleName, int32_t uid); private: diff --git a/services/distributed/include/distributed_screen_status_manager.h b/services/distributed/include/distributed_screen_status_manager.h index 9ac03bb99f9eca015b7a88ba2fe9df324179d461..049fe52a99ac73fc91e89383dd95479d047213fb 100644 --- a/services/distributed/include/distributed_screen_status_manager.h +++ b/services/distributed/include/distributed_screen_status_manager.h @@ -31,7 +31,20 @@ namespace Notification { class DistributedScreenStatusManager : private DistributedFlowControl, public DelayedSingleton { public: + /** + * @brief Check if any other device screen is on. + * + * @param isUsing True for any other device screen is on, otherwise false. + * @return Returns the error code. + */ ErrCode CheckRemoteDevicesIsUsing(bool &isUsing); + + /** + * @brief Set screen status of local device. + * + * @param screenOn Indicates the local device screen status. + * @return Returns the error code. + */ ErrCode SetLocalScreenStatus(bool screenOn); private: diff --git a/services/distributed/test/unittest/mock/ans_test_single_kv_store.h b/services/distributed/test/unittest/mock/ans_test_single_kv_store.h index e930fde5d0ed25e7b57f489fe447471e26ab22a7..59c53c07f65b0646066442682587d6e63272a431 100644 --- a/services/distributed/test/unittest/mock/ans_test_single_kv_store.h +++ b/services/distributed/test/unittest/mock/ans_test_single_kv_store.h @@ -33,80 +33,327 @@ namespace DistributedKv { // This class provides put, delete, search, sync and subscribe functions of a key-value store. class AnsTestSingleKvStore : public SingleKvStore { public: + /** + * @brief Get all entries in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntries(const Key &prefixKey, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query string. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const std::string &query, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query object. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const DataQuery &query, std::vector &entries) const override; + /** + * @brief Get ResultSet in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSet(const Key &prefixKey, std::shared_ptr &resultSet) const override; - virtual Status GetResultSetWithQuery( - const std::string &query, std::shared_ptr &resultSet) const override; - - virtual Status GetResultSetWithQuery( - const DataQuery &query, std::shared_ptr &resultSet) const override; - + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query string. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ + virtual Status GetResultSetWithQuery(const std::string &query, + std::shared_ptr &resultSet) const override; + + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query object. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ + virtual Status GetResultSetWithQuery(const DataQuery &query, + std::shared_ptr &resultSet) const override; + + /** + * @brief Close the ResultSet returned by GetResultSet. + * + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status CloseResultSet(std::shared_ptr &resultSet) override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query string. + * @param result Indicates the result. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const std::string &query, int &result) const override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query object. + * @param result Indicates the result will be returned in this parameter. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const DataQuery &query, int &result) const override; + /** + * @brief Sync store with other devices. This is an asynchronous method, + * sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUTH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @param allowedDelayMs Indicates the allowed delay milli-second to sync. default value is 0 for compatibility. + * @return Indicates the status of this Sync operation. + */ virtual Status Sync( const std::vector &deviceIds, SyncMode mode, uint32_t allowedDelayMs = 0) override; + /** + * @brief Remove the device data synced from remote. + * + * @param device Indicates the device id. + * @return Indicates the status of this remove operation. + */ virtual Status RemoveDeviceData(const std::string &device) override; + /** + * @brief Get id of this AppKvStore. + * + * @return Indicates the id of store. + */ virtual StoreId GetStoreId() const override; + /** + * @brief Delete an entry by its key. + * + * @param key Indicates the key of the entry to be deleted. + * @return Indicates the status of this delete operation. + */ virtual Status Delete(const Key &key) override; + /** + * @brief Write a pair of key and value to this store. + * + * @param key Indicates the key of this entry. Should be less than 256 bytes. key will be trimmed before store. + * @param value Indicates the value of this entry. Should be less than (1024 * 1024) bytes. + * @return Indicates the status of this put operation. + */ virtual Status Put(const Key &key, const Value &value) override; + /** + * @brief Get value from AppKvStore by its key. + * + * @param key Indicates the key of this entry. + * @param value Indicates the value will be returned in this parameter. + * @return Indicates the status of this get operation. + */ virtual Status Get(const Key &key, Value &value) override; + /** + * @brief Register change of this kvstore to a client-defined observer. + * observer->OnChange method will be called when store changes. + * One observer can subscribe more than one AppKvStore. + * + * @param subscribeType Indicates the subscribe type. + * OBSERVER_CHANGES_NATIVE means native changes of syncable kv store, + * OBSERVER_CHANGES_FOREIGN means synced data changes from remote devices, + * OBSERVER_CHANGES_ALL means both native changes and synced data changes. + * @param observer Indicates the observer to subscribe changes. + * @return Indicates the status of this subscribe operation. + */ virtual Status SubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Unregister a kvstore to an observer. + * + * @param subscribeType Indicates the subscribe type. + * Reserved parameter. Current is always SubscribeType::DEFAULT. + * @param observer Indicates the observer to unsubscribe this store. + * @return Indicates the status of this unsubscribe operation. + */ virtual Status UnSubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Register message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status RegisterSyncCallback(std::shared_ptr callback) override; + /** + * @brief Unregister message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status UnRegisterSyncCallback() override; + /** + * @brief See Put, PutBatch put a list of entries to kvstore, + * all entries will be put in a transaction, + * if entries contains invalid entry, PutBatch will all fail. + * + * @param entries Indicates the entries. + * The entries's size should be less than 128 and memory size must be less than IPC transport limit. + * @return Indicates the status of this register operation. + */ virtual Status PutBatch(const std::vector &entries) override; + /** + * @brief Delete a list of entries in the kvstore, + * delete key not exist still return success, + * key length should not be greater than 256, and can not be empty. + * If keys contains invalid key, all delete will fail. + * + * @param keys Indicates the list of keys. + * The keys memory size should not be greater than IPC transport limit, and can not be empty. + * @return Indicates the status of this register operation. + */ virtual Status DeleteBatch(const std::vector &keys) override; + /** + * @brief Start transaction. + * All changes to this kvstore will be in a same transaction and will not change the store until Commit() or + * Rollback() is called. + * Before this transaction is committed or rollbacked, all attemption to close this store will fail. + * + * @return Indicates the status of this operation. + */ virtual Status StartTransaction() override; + /** + * @brief Commit current transaction. All changes to this store will be done after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Commit() override; + /** + * @brief Rollback current transaction. + * All changes to this store during this transaction will be rollback after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Rollback() override; + /** + * @brief Set synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status SetSyncParam(const KvSyncParam &syncParam) override; + /** + * @brief Get synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status GetSyncParam(KvSyncParam &syncParam) override; + /** + * @brief Set capability parameters of this store. + * + * @param enabled Indicates the capability Enabled status. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityEnabled(bool enabled) const override; + /** + * @brief Set capability parameters of this store. + * + * @param localLabels Indicates the labels of local. + * @param remoteSupportLabels Indicates the labels of remote support. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityRange(const std::vector &localLabels, const std::vector &remoteSupportLabels) const override; + /** + * @brief Get security level. + * + * @param securityLevel Indicates the security level. + * @return Indicates the status of this operation. + */ virtual Status GetSecurityLevel(SecurityLevel &securityLevel) const override; + /** + * @brief Sync store with other devices only syncing the data which is satisfied with the condition. + * This is an asynchronous method, sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUSH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @return Indicates the status of this operation. + */ virtual Status SyncWithCondition(const std::vector &deviceIds, SyncMode mode, const DataQuery &query, std::shared_ptr syncCallback) override; + /** + * @brief Subscribe store with other devices consistently Synchronize the data which is satisfied + * with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * + * @return Indicates the status of this operation. + */ virtual Status SubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief UnSubscribe store with other devices which is satisfied with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @return Indicates the status of this UnSubscribe operation. + */ virtual Status UnsubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status GetKvStoreSnapshot(std::shared_ptr observer, std::shared_ptr &snapshot) const override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status ReleaseKvStoreSnapshot(std::shared_ptr &snapshot) override; + /** + * @brief Clear the object. + * + * @return Indicates the status of this operation. + */ Status Clear() override; protected: diff --git a/services/test/moduletest/mock/include/mock_bundle_manager.h b/services/test/moduletest/mock/include/mock_bundle_manager.h index fce122935b23cf45c31243fef746dcdc82f2f8f8..b914ffc20aaf366adb1a5a160b49db67e97e2ae0 100644 --- a/services/test/moduletest/mock/include/mock_bundle_manager.h +++ b/services/test/moduletest/mock/include/mock_bundle_manager.h @@ -39,6 +39,7 @@ public: /** * @brief Obtains the ApplicationInfo based on a given bundle name. + * * @param appName Indicates the application bundle name to be queried. * @param flag Indicates the flag used to specify information contained * in the ApplicationInfo object that will be returned. @@ -53,6 +54,7 @@ public: } /** * @brief Obtains information about all installed applications of a specified user. + * * @param flag Indicates the flag used to specify information contained * in the ApplicationInfo objects that will be returned. * @param userId Indicates the user ID. @@ -66,6 +68,7 @@ public: } /** * @brief Obtains the BundleInfo based on a given bundle name. + * * @param bundleName Indicates the application bundle name to be queried. * @param flag Indicates the information contained in the BundleInfo object to be returned. * @param bundleInfo Indicates the obtained BundleInfo object. @@ -79,6 +82,7 @@ public: } /** * @brief Obtains BundleInfo of all bundles available in the system. + * * @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned. * @param bundleInfos Indicates all of the obtained BundleInfo objects. * @param userId Indicates the user ID. @@ -91,6 +95,7 @@ public: }; /** * @brief Obtains the application UID based on the given bundle name and user ID. + * * @param bundleName Indicates the bundle name of the application. * @param userId Indicates the user ID. * @return Returns the uid if successfully obtained; returns -1 otherwise. @@ -101,6 +106,7 @@ public: } /** * @brief Obtains the bundle name of a specified application based on the given UID. + * * @param uid Indicates the uid. * @param bundleName Indicates the obtained bundle name. * @return Returns true if the bundle name is successfully obtained; returns false otherwise. @@ -112,6 +118,7 @@ public: } /** * @brief Obtains an array of all group IDs associated with a specified bundle. + * * @param bundleName Indicates the bundle name. * @param gids Indicates the group IDs associated with the specified bundle. * @return Returns true if the gids is successfully obtained; returns false otherwise. @@ -122,6 +129,7 @@ public: } /** * @brief Obtains the type of a specified application based on the given bundle name. + * * @param bundleName Indicates the bundle name. * @return Returns "system" if the bundle is a system application; returns "third-party" otherwise. */ @@ -131,6 +139,7 @@ public: } /** * @brief Check whether the app is system app by it's UID. + * * @param uid Indicates the uid. * @return Returns true if the bundle is a system application; returns false otherwise. */ @@ -138,6 +147,7 @@ public: /** * @brief Obtains the BundleInfo of application bundles based on the specified metaData. + * * @param metaData Indicates the metadata to get in the bundle. * @param bundleInfos Indicates all of the obtained BundleInfo objects. * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. @@ -148,6 +158,7 @@ public: } /** * @brief Query the AbilityInfo by the given Want. + * * @param want Indicates the information of the ability. * @param abilityInfo Indicates the obtained AbilityInfo object. * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. @@ -158,6 +169,7 @@ public: } /** * @brief Query the AbilityInfo by ability.uri in config.json. + * * @param abilityUri Indicates the uri of the ability. * @param abilityInfo Indicates the obtained AbilityInfo object. * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. @@ -168,6 +180,7 @@ public: } /** * @brief Obtains the BundleInfo of all keep-alive applications in the system. + * * @param bundleInfos Indicates all of the obtained BundleInfo objects. * @return Returns true if the BundleInfos is successfully obtained; returns false otherwise. */ @@ -177,6 +190,7 @@ public: }; /** * @brief Obtains information about an application bundle contained in a ohos Ability Package (HAP). + * * @param hapFilePath Indicates the absolute file path of the HAP. * @param flag Indicates the information contained in the BundleInfo object to be returned. * @param bundleInfo Indicates the obtained BundleInfo object. @@ -189,6 +203,7 @@ public: } /** * @brief Obtain the HAP module info of a specific ability. + * * @param abilityInfo Indicates the ability. * @param hapModuleInfo Indicates the obtained HapModuleInfo object. * @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise. @@ -199,6 +214,7 @@ public: } /** * @brief Obtains the Want for starting the main ability of an application based on the given bundle name. + * * @param bundleName Indicates the bundle name. * @param want Indicates the obtained launch Want object. * @return Returns true if the launch Want object is successfully obtained; returns false otherwise. @@ -210,6 +226,7 @@ public: /** * @brief Confirms with the permission management module to check whether a request prompt is required for granting * a certain permission. + * * @param bundleName Indicates the name of the bundle to check. * @param permission Indicates the permission to check. * @param userId Indicates the user id. @@ -224,6 +241,7 @@ public: } /** * @brief Checks whether the publickeys of two bundles are the same. + * * @param firstBundleName Indicates the first bundle name. * @param secondBundleName Indicates the second bundle name. * @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found; @@ -236,6 +254,7 @@ public: } /** * @brief Checks whether a specified bundle has been granted a specific permission. + * * @param bundleName Indicates the name of the bundle to check. * @param permission Indicates the permission to check. * @return Returns 0 if the bundle has the permission; returns -1 otherwise. @@ -243,6 +262,7 @@ public: virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override; /** * @brief Obtains detailed information about a specified permission. + * * @param permissionName Indicates the name of the ohos permission. * @param permissionDef Indicates the object containing detailed information about the given ohos permission. * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise. @@ -253,6 +273,7 @@ public: } /** * @brief Obtains all known permission groups in the system. + * * @param permissionDefs Indicates the list of objects containing the permission group information. * @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise. */ @@ -262,6 +283,7 @@ public: } /** * @brief Obtains all known permission groups in the system. + * * @param permissions Indicates the permission array. * @param appNames Indicates the list of application names that have the specified permissions. * @return Returns true if the application names is successfully obtained; returns false otherwise. @@ -273,6 +295,7 @@ public: } /** * @brief Requests a certain permission from user. + * * @param bundleName Indicates the name of the bundle to request permission. * @param permission Indicates the permission to request permission. * @param userId Indicates the user id. @@ -285,6 +308,7 @@ public: } /** * @brief Checks whether the system has a specified capability. + * * @param capName Indicates the name of the system feature to check. * @return Returns true if the given feature specified by name is available in the system; returns false otherwise. */ @@ -294,6 +318,7 @@ public: } /** * @brief Obtains the capabilities that are available in the system. + * * @param systemCaps Indicates the list of capabilities available in the system. * @return Returns true if capabilities in the system are successfully obtained; returns false otherwise. */ @@ -303,6 +328,7 @@ public: } /** * @brief Checks whether the current device has been started in safe mode. + * * @return Returns true if the device is in safe mode; returns false otherwise. */ virtual bool IsSafeMode() override @@ -311,6 +337,7 @@ public: } /** * @brief Clears application running data of a specified application. + * * @param bundleName Indicates the bundle name of the application whose data is to be cleared. * @return Returns true if the data cleared successfully; returns false otherwise. */ @@ -320,6 +347,7 @@ public: } /** * @brief Register the specific bundle status callback. + * * @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result. * @return Returns true if this function is successfully called; returns false otherwise. */ @@ -329,6 +357,7 @@ public: } /** * @brief Clear the specific bundle status callback. + * * @param bundleStatusCallback Indicates the callback to be cleared. * @return Returns true if this function is successfully called; returns false otherwise. */ @@ -338,6 +367,7 @@ public: } /** * @brief Unregister all the callbacks of status changed. + * * @return Returns true if this function is successfully called; returns false otherwise. */ virtual bool UnregisterBundleStatusCallback() override @@ -346,6 +376,7 @@ public: } /** * @brief Dump the bundle informations with specific flags. + * * @param flag Indicates the information contained in the dump result. * @param bundleName Indicates the bundle name if needed. * @param userId Indicates the user ID. @@ -359,6 +390,7 @@ public: } /** * @brief Checks whether a specified application is enabled. + * * @param bundleName Indicates the bundle name of the application. * @return Returns true if the application is enabled; returns false otherwise. */ @@ -368,6 +400,7 @@ public: } /** * @brief Obtains the interface used to install and uninstall bundles. + * * @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise. */ virtual sptr GetBundleInstaller() override @@ -376,6 +409,7 @@ public: } /** * @brief Obtains the interface used to create or delete user. + * * @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise. */ virtual sptr GetBundleUserMgr() override @@ -383,6 +417,11 @@ public: return nullptr; } + /** + * @brief Set whether the bundle is systemapp. + * + * @param isSystemApp Indicates the system app flag. + */ void MockSetIsSystemApp(bool isSystemApp); private: diff --git a/services/test/moduletest/mock/include/mock_single_kv_store.h b/services/test/moduletest/mock/include/mock_single_kv_store.h index bea39c9cf98070da721c49c234bc69328c1a0f0c..fe9de6ba2e63f32b7c411028060e5583d4ab213b 100644 --- a/services/test/moduletest/mock/include/mock_single_kv_store.h +++ b/services/test/moduletest/mock/include/mock_single_kv_store.h @@ -33,81 +33,329 @@ namespace DistributedKv { // This class provides put, delete, search, sync and subscribe functions of a key-value store. class AnsTestSingleKvStore : public SingleKvStore { public: + /** + * @brief Get all entries in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntries(const Key &prefixKey, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query string. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const std::string &query, std::vector &entries) const override; + /** + * @brief Get all entries in this store by query. + * + * @param query Indicates the query object. + * @param entries Indicates the entries. + * @return Indicates the status of this GetEntries operation. + */ virtual Status GetEntriesWithQuery(const DataQuery &query, std::vector &entries) const override; + /** + * @brief Get ResultSet in this store which key start with prefixKey. + * + * @param perfixkey Indicates the prefix to be searched. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSet(const Key &prefixKey, std::shared_ptr &resultSet) const override; + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query string. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSetWithQuery(const std::string &query, std::shared_ptr &resultSet) const override; + /** + * @brief Get ResultSet in this store by Query. + * + * @param query Indicates the query object. + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this GetResultSet operation. + */ virtual Status GetResultSetWithQuery(const DataQuery &query, std::shared_ptr &resultSet) const override; + /** + * @brief Close the ResultSet returned by GetResultSet. + * + * @param resultSet Indicates the resultSet. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status CloseResultSet(std::shared_ptr &resultSet) override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query string. + * @param result Indicates the result. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const std::string &query, int &result) const override; + /** + * @brief Get the number of result by query. + * + * @param query Indicates the query object. + * @param result Indicates the result will be returned in this parameter. + * @return Indicates the status of this CloseResultSet operation. + */ virtual Status GetCountWithQuery(const DataQuery &query, int &result) const override; + /** + * @brief Sync store with other devices. This is an asynchronous method, + * sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUTH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @param allowedDelayMs Indicates the allowed delay milli-second to sync. default value is 0 for compatibility. + * @return Indicates the status of this Sync operation. + */ virtual Status Sync( const std::vector &deviceIds, SyncMode mode, uint32_t allowedDelayMs = 0) override; + /** + * @brief Remove the device data synced from remote. + * + * @param device Indicates the device id. + * @return Indicates the status of this remove operation. + */ virtual Status RemoveDeviceData(const std::string &device) override; + /** + * @brief Get id of this AppKvStore. + * + * @return Indicates the id of store. + */ virtual StoreId GetStoreId() const override; + /** + * @brief Delete an entry by its key. + * + * @param key Indicates the key of the entry to be deleted. + * @return Indicates the status of this delete operation. + */ virtual Status Delete(const Key &key) override; + /** + * @brief Write a pair of key and value to this store. + * + * @param key Indicates the key of this entry. Should be less than 256 bytes. key will be trimmed before store. + * @param value Indicates the value of this entry. Should be less than (1024 * 1024) bytes. + * @return Indicates the status of this put operation. + */ virtual Status Put(const Key &key, const Value &value) override; + /** + * @brief Get value from AppKvStore by its key. + * + * @param key Indicates the key of this entry. + * @param value Indicates the value will be returned in this parameter. + * @return Indicates the status of this get operation. + */ virtual Status Get(const Key &key, Value &value) override; + /** + * @brief Register change of this kvstore to a client-defined observer. + * observer->OnChange method will be called when store changes. + * One observer can subscribe more than one AppKvStore. + * + * @param subscribeType Indicates the subscribe type. + * OBSERVER_CHANGES_NATIVE means native changes of syncable kv store, + * OBSERVER_CHANGES_FOREIGN means synced data changes from remote devices, + * OBSERVER_CHANGES_ALL means both native changes and synced data changes. + * @param observer Indicates the observer to subscribe changes. + * @return Indicates the status of this subscribe operation. + */ virtual Status SubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Unregister a kvstore to an observer. + * + * @param subscribeType Indicates the subscribe type. + * Reserved parameter. Current is always SubscribeType::DEFAULT. + * @param observer Indicates the observer to unsubscribe this store. + * @return Indicates the status of this unsubscribe operation. + */ virtual Status UnSubscribeKvStore(SubscribeType subscribeType, std::shared_ptr observer) override; + /** + * @brief Register message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status RegisterSyncCallback(std::shared_ptr callback) override; + /** + * @brief Unregister message for sync operation. + * + * @param callback Indicates the callback to register. + * @return Indicates the status of this register operation. + */ virtual Status UnRegisterSyncCallback() override; + /** + * @brief See Put, PutBatch put a list of entries to kvstore, + * all entries will be put in a transaction, + * if entries contains invalid entry, PutBatch will all fail. + * + * @param entries Indicates the entries. + * The entries's size should be less than 128 and memory size must be less than IPC transport limit. + * @return Indicates the status of this register operation. + */ virtual Status PutBatch(const std::vector &entries) override; + /** + * @brief Delete a list of entries in the kvstore, + * delete key not exist still return success, + * key length should not be greater than 256, and can not be empty. + * If keys contains invalid key, all delete will fail. + * + * @param keys Indicates the list of keys. + * The keys memory size should not be greater than IPC transport limit, and can not be empty. + * @return Indicates the status of this register operation. + */ virtual Status DeleteBatch(const std::vector &keys) override; + /** + * @brief Start transaction. + * All changes to this kvstore will be in a same transaction and will not change the store until Commit() or + * Rollback() is called. + * Before this transaction is committed or rollbacked, all attemption to close this store will fail. + * + * @return Indicates the status of this operation. + */ virtual Status StartTransaction() override; + /** + * @brief Commit current transaction. All changes to this store will be done after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Commit() override; + /** + * @brief Rollback current transaction. + * All changes to this store during this transaction will be rollback after calling this method. + * Any calling of this method outside a transaction will fail. + * + * @return Indicates the status of this operation. + */ virtual Status Rollback() override; + /** + * @brief Set synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status SetSyncParam(const KvSyncParam &syncParam) override; + /** + * @brief Get synchronization parameters of this store. + * + * @param syncParam Indicates the sync policy parameter. + * @return Indicates the status of this operation. + */ virtual Status GetSyncParam(KvSyncParam &syncParam) override; + /** + * @brief Set capability parameters of this store. + * + * @param enabled Indicates the capability Enabled status. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityEnabled(bool enabled) const override; + /** + * @brief Set capability parameters of this store. + * + * @param localLabels Indicates the labels of local. + * @param remoteSupportLabels Indicates the labels of remote support. + * @return Indicates the status of this operation. + */ virtual Status SetCapabilityRange(const std::vector &localLabels, const std::vector &remoteSupportLabels) const override; + /** + * @brief Get security level. + * + * @param securityLevel Indicates the security level. + * @return Indicates the status of this operation. + */ virtual Status GetSecurityLevel(SecurityLevel &securityLevel) const override; + /** + * @brief Sync store with other devices only syncing the data which is satisfied with the condition. + * This is an asynchronous method, sync will fail if there is a syncing operation in progress. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @param mode Indicates the sync mode, can be set to SyncMode::PUSH, SyncMode::PULL and SyncMode::PUSH_PULL. + * PUSH_PULL will firstly push all not-local store to listed devices, then pull these stores back. + * @return Indicates the status of this operation. + */ virtual Status SyncWithCondition(const std::vector &deviceIds, SyncMode mode, const DataQuery &query, std::shared_ptr syncCallback) override; + /** + * @brief Subscribe store with other devices consistently Synchronize the data which is satisfied + * with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * + * @return Indicates the status of this operation. + */ virtual Status SubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief UnSubscribe store with other devices which is satisfied with the condition. + * + * @param deviceIds Indicates the device list to sync, this is network id from soft bus. + * @param query Indicates the query condition. + * @return Indicates the status of this UnSubscribe operation. + */ virtual Status UnsubscribeWithQuery(const std::vector &deviceIds, const DataQuery &query) override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status GetKvStoreSnapshot(std::shared_ptr observer, std::shared_ptr &snapshot) const override; + /** + * @brief Release snapshot created by calling GetKvStoreSnapshot. + * + * @return Indicates the status of this operation. + */ Status ReleaseKvStoreSnapshot(std::shared_ptr &snapshot) override; + /** + * @brief Clear the object. + * + * @return Indicates the status of this operation. + */ Status Clear() override; + protected: KVSTORE_API virtual Status Control(KvControlCmd cmd, const KvParam &inputParam, KvParam &output) override; }; diff --git a/test/resource/notificationfuzztest/include/notificationfuzzconfigparser.h b/test/resource/notificationfuzztest/include/notificationfuzzconfigparser.h index d0a492b1dc35f126b1547211ebc80856c4f78afb..bee6ada540c8d240dd2fb5ab2ae8f9215478f4a0 100644 --- a/test/resource/notificationfuzztest/include/notificationfuzzconfigparser.h +++ b/test/resource/notificationfuzztest/include/notificationfuzzconfigparser.h @@ -33,6 +33,12 @@ struct FuzzTestData { class NotificationFuzzConfigParser { public: + /** + * @brief Loads interface list from the configuration file. + * + * @param path The path of configuration file. + * @param ftd Records the configuration file. + */ void ParseFromFile4FuzzTest(const std::string &path, FuzzTestData &ftd) const { std::cout << __func__ << std::endl; diff --git a/test/resource/notificationfuzztest/include/notificationfuzztestmanager.h b/test/resource/notificationfuzztest/include/notificationfuzztestmanager.h index cce89899fc0c3754f415a68d1d0dafe1f4f39c6d..e1c48e64b3249c9ef0241e254f4e5a8ac43b1d9b 100644 --- a/test/resource/notificationfuzztest/include/notificationfuzztestmanager.h +++ b/test/resource/notificationfuzztest/include/notificationfuzztestmanager.h @@ -24,8 +24,18 @@ namespace Notification { class NotificationFuzzTestManager { public: using Ptr = std::shared_ptr; + + /** + * @brief Default deconstructor used to deconstruct. + */ ~NotificationFuzzTestManager() {} + + /** + * @brief Obtains the instance of the fuzz test. + * + * @return Returns the instance of the fuzz test. + */ static Ptr GetInstance() { if (instance == nullptr) { @@ -35,6 +45,9 @@ public: return instance; } + /** + * @brief Starts the fuzz test. + */ void StartFuzzTest(); private: diff --git a/test/resource/notificationfuzztest/include/notificationgetparam.h b/test/resource/notificationfuzztest/include/notificationgetparam.h index 367878f8072bf9cecfc80c9bd26eebe51584125a..873d64e3adec0db685a4c1ef282469f3a81a38e1 100644 --- a/test/resource/notificationfuzztest/include/notificationgetparam.h +++ b/test/resource/notificationfuzztest/include/notificationgetparam.h @@ -144,54 +144,120 @@ std::shared_ptr GetParamNotifi OHOS::Notification::NotificationConstant::DoNotDisturbType GetParamDoNotDisturbType(); class TestRemoteObject : public IRemoteObject { public: + /** + * @brief Default constructor used to construct. + */ TestRemoteObject(); + + /** + * @brief Default deconstructor used to deconstruct. + */ ~TestRemoteObject(); + /** + * @brief Override GetObjectRefCount. + * + * @return Returns a fixed value of type int_32. + */ int32_t GetObjectRefCount() override { return 0; } + /** + * @brief Override SendRequest. + * + * @param code The uint32_t type input parameter. + * @param data The MessageParcel type input parameter. + * @param reply The MessageOption type input parameter. + * @param option The MessageOption type input parameter. + * @return Returns a fixed value of type int. + */ int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override { return 0; } + /** + * @brief Override IsProxyObject. + * + * @return Returns a fixed value of type bool. + */ bool IsProxyObject() const override { return true; } + /** + * @brief Override CheckObjectLegality. + * + * @return Returns a fixed value of type bool. + */ bool CheckObjectLegality() const override { return true; } + /** + * @brief Override AddDeathRecipient. + * + * @param recipient The DeathRecipient type point input parameter. + * @return Returns a fixed value of type bool. + */ bool AddDeathRecipient(const sptr &recipient) override { return true; } + /** + * @brief Override RemoveDeathRecipient. + * + * @param recipient The DeathRecipient type point input parameter. + * @return Returns a fixed value of type bool. + */ bool RemoveDeathRecipient(const sptr &recipient) override { return true; } + /** + * @brief Override Marshalling. + * + * @param parcel The Parcel type input parameter. + * @return Returns a fixed value of type bool. + */ bool Marshalling(Parcel &parcel) const override { return true; } + /** + * @brief Override AsInterface. + * + * @return Returns a null pointer. + */ sptr AsInterface() override { return nullptr; } + /** + * @brief Override Dump. + * + * @param fd The int type input parameter. + * @param args The u16string type vector input parameter. + * @return Returns a fixed value of type int. + */ int Dump(int fd, const std::vector &args) override { return 0; } + /** + * @brief Override GetObjectDescriptor + * + * @return Returns a random value of type u16string. + */ std::u16string GetObjectDescriptor() const { std::u16string descriptor = std::u16string(); @@ -201,44 +267,118 @@ public: class TestIBundleStatusCallback : public OHOS::AppExecFwk::IBundleStatusCallback { public: + /** + * @brief Default constructor used to construct. + */ TestIBundleStatusCallback() {} + + /** + * @brief Override OnBundleStateChanged. + * + * @param installType The uint8_t type input parameter. + * @param resultCode The int32_t type input parameter. + * @param resultMsg The string type input parameter. + * @param bundleName The string type input parameter. + */ void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg, const std::string &bundleName) override {} + + /** + * @brief Default deconstructor used to deconstruct. + */ virtual ~TestIBundleStatusCallback() {} }; class TestAnsSubscriber : public OHOS::Notification::NotificationSubscriber { public: + /** + * @brief Default constructor used to create subscriber. + */ TestAnsSubscriber() {} + + /** + * @brief Default deconstructor used to deconstruct. + */ ~TestAnsSubscriber() {} + + /** + * @brief Override OnConnected. + */ void OnConnected() override { std::cout << "TestAnsSubscriber OnConnected" << std::endl; mutex.unlock(); } + + /** + * @brief Override OnDisconnected. + */ void OnDisconnected() override { std::cout << "TestAnsSubscriber OnDisconnected" << std::endl; mutex.unlock(); } + + /** + * @brief Override OnDied. + */ void OnDied() override {} + + /** + * @brief Override OnUpdate. + * + * @param sortingMap The NotificationSortingMap type point input parameter. + */ void OnUpdate(const std::shared_ptr &sortingMap) override {} + + /** + * @brief Override OnDoNotDisturbDateChange. + * + * @param date The NotificationDoNotDisturbDate type point input parameter. + */ void OnDoNotDisturbDateChange(const std::shared_ptr &date) override {} + + /** + * @brief Override OnCanceled. + * + * @param request The Notification type point input parameter. + */ void OnCanceled(const std::shared_ptr &request) override {} + + /** + * @brief Override OnCanceled. + * + * @param request The Notification type point input parameter. + * @param request The NotificationSortingMap type point input parameter. + * @param deleteReason The int type input parameter. + */ void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int deleteReason) override {} + + /** + * @brief Override OnConsumed. + * + * @param request The Notification type point input parameter. + */ void OnConsumed(const std::shared_ptr &request) override {} + + /** + * @brief Override OnConsumed. + * + * @param request The Notification type point input parameter. + * @param sortingMap The NotificationSortingMap type point input parameter. + */ void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override {} @@ -255,37 +395,99 @@ class TestCompletedCallback : public OHOS::AbilityRuntime::WantAgent::CompletedC class TestCancelListener : public OHOS::AbilityRuntime::WantAgent::CancelListener { public: + /** + * @brief Override OnCancelled. + */ void OnCancelled(int resultCode) override {} }; class TestOnPermissionChangedCallback : public OHOS::AppExecFwk::OnPermissionChangedCallback { public: + /** + * @brief Override OnChanged. + * + * @param uid Records the uid. + */ void OnChanged(const int32_t uid) override {} }; class TestAbilityLifecycleCallbacks : public OHOS::AppExecFwk::AbilityLifecycleCallbacks { public: + /** + * @brief Default constructor used to construct. + */ TestAbilityLifecycleCallbacks() = default; + + /** + * @brief Default deconstructor used to deconstruct. + */ virtual ~TestAbilityLifecycleCallbacks() = default; + + /** + * @brief Override OnAbilityStart. + * + * @param ability The ability to records the start state. + */ virtual void OnAbilityStart(const std::shared_ptr &ability) {} + + /** + * @brief Override OnAbilityInactive. + * + * @param ability The ability to records the inactive state. + */ virtual void OnAbilityInactive(const std::shared_ptr &ability) {} + + /** + * @brief Override OnAbilityBackground. + * + * @param ability The ability to records the background state. + */ virtual void OnAbilityBackground(const std::shared_ptr &ability) {} + + /** + * @brief Override OnAbilityForeground. + * + * @param ability The ability to records the foreground state. + */ virtual void OnAbilityForeground(const std::shared_ptr &ability) {} + + /** + * @brief Override OnAbilityActive. + * + * @param ability The ability to records the active state. + */ virtual void OnAbilityActive(const std::shared_ptr &ability) {} + + /** + * @brief Override OnAbilityStop. + * + * @param ability The ability to records the stop state. + */ virtual void OnAbilityStop(const std::shared_ptr &ability) {} + + /** + * @brief Override OnAbilitySaveState. + * + * @param outState Output status. + */ virtual void OnAbilitySaveState(const OHOS::AppExecFwk::PacMap &outState) {} }; class WantSender : public OHOS::AAFwk::WantSenderStub { public: + /** + * @brief Override Send. + * + * @param senderInfo Sender information. + */ void Send(OHOS::AAFwk::SenderInfo &senderInfo) override {} }; diff --git a/tools/dump/include/notification_shell_command.h b/tools/dump/include/notification_shell_command.h index 26fc5199e25195ffb6f9dacbaedf1ce9eb993a78..2d481dc3d8d7233c5349690bc831fc08d9f883d9 100644 --- a/tools/dump/include/notification_shell_command.h +++ b/tools/dump/include/notification_shell_command.h @@ -23,7 +23,17 @@ namespace OHOS { namespace Notification { class NotificationShellCommand : public OHOS::Notification::ShellCommand { public: + /** + * @brief The constructor. + * + * @param argc Indicates the count of arguments. + * @param argv Indicates the arguments. + */ NotificationShellCommand(int argc, char *argv[]); + + /** + * @brief The deconstructor. + */ ~NotificationShellCommand() override {}; private: diff --git a/tools/dump/include/shell_command.h b/tools/dump/include/shell_command.h index 00c14fdbe5afe0c5075af15a7ba23df05ef26154..319c084c82f8d47bce738ff29af3c86e4f5c55f4 100644 --- a/tools/dump/include/shell_command.h +++ b/tools/dump/include/shell_command.h @@ -27,17 +27,76 @@ namespace OHOS { namespace Notification { class ShellCommand { public: + /** + * @brief Constructor. + * + * @param argc Indicates the count of arguments. + * @param argv Indicates the arguments. + * @param name Indicates the tool name. + */ ShellCommand(int argc, char *argv[], std::string name); + + /** + * @brief Destructor. + */ virtual ~ShellCommand(); + /** + * @brief Process the command. + * + * @return Indicates the command result code. + */ ErrCode OnCommand(); + + /** + * @brief Execute the command. + * + * @return Indicates the output text. + */ std::string ExecCommand(); + + /** + * @brief Get the error message of the command. + * + * @return Indicates the error message. + */ std::string GetCommandErrorMsg() const; + + /** + * @brief Get the error message of the unknown option. + * + * @param unknownOption Indicates the unknown option. + * @return Indicates the error message. + */ std::string GetUnknownOptionMsg(std::string &unknownOption) const; + + /** + * @brief Get the message from the code. + * + * @param code Indicates the code. + * @return Indicates the message. + */ std::string GetMessageFromCode(const int32_t code) const; + /** + * @brief Create the command map. + * + * @return Indicates the result code. + */ virtual ErrCode CreateCommandMap() = 0; + + /** + * @brief Create the message map. + * + * @return Indicates the result code. + */ virtual ErrCode CreateMessageMap() = 0; + + /** + * @brief The initialize function. + * + * @return Indicates the result code. + */ virtual ErrCode init() = 0; protected: