diff --git a/services/ans/include/advanced_datashare_helper.h b/services/ans/include/advanced_datashare_helper.h index 7490c0ef1a90a9394929e74f0dbd6d413fb70c13..5d02e246195047a8ffd7298122088a7557b07600 100644 --- a/services/ans/include/advanced_datashare_helper.h +++ b/services/ans/include/advanced_datashare_helper.h @@ -29,6 +29,8 @@ constexpr const char *KEY_FOCUS_MODE_ENABLE = "focus_mode_enable"; constexpr const char *KEY_FOCUS_MODE_PROFILE = "focus_mode_profile"; constexpr const char *KEY_FOCUS_MODE_CALL_MESSAGE_POLICY = "focus_mode_call_message_policy"; constexpr const char *KEY_FOCUS_MODE_REPEAT_CALLERS_ENABLE = "focus_mode_repeate_callers_enable"; +constexpr const char *KEY_INTELLIGENT_SCENE_DATA = "intelligent_scene_data"; +constexpr const char *KEY_INTELLIGENT_URI = "intelligent_uri"; } // namespace class AdvancedDatashareHelper : DelayedSingleton { @@ -37,22 +39,28 @@ public: ~AdvancedDatashareHelper() = default; bool Query(Uri &uri, const std::string &key, std::string &value); bool isRepeatCall(const std::string &phoneNumber); - ErrCode QueryContact(Uri &uri, const std::string &phoneNumber, const std::string &policy); + ErrCode QueryContact(Uri &uri, const std::string &phoneNumber, + const std::string &policy, const std::string &profileId); std::string GetFocusModeEnableUri(const int32_t &userId) const; std::string GetFocusModeProfileUri(const int32_t &userId) const; std::string GetFocusModeCallPolicyUri(const int32_t &userId) const; std::string GetFocusModeRepeatCallUri(const int32_t &userId) const; + std::string GetIntelligentUri(); std::string GetUnifiedGroupEnableUri() const; private: enum ContactPolicy { ALLOW_FAVORITE_CONTACTS = 4, ALLOW_SPECIFIED_CONTACTS = 5, + FORBID_SPECIFIED_CONTACTS = 6, }; std::shared_ptr CreateDataShareHelper(); std::shared_ptr CreateContactDataShareHelper(std::string uri); - bool dealWithContactResult(std::shared_ptr helper, - std::shared_ptr resultSet, const std::string &policy); + std::shared_ptr CreateIntelligentDataShareHelper(std::string uri); + std::shared_ptr GetContactResultSet(Uri &uri, + const std::string &phoneNumber, const std::string &policy, const std::string &profileId); + bool dealWithContactResult(std::shared_ptr resultSet, const std::string &policy); + std::string GetIntelligentData(const std::string &uri, const std::string &key); }; } // namespace Notification } // namespace OHOS diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index d025f4af93a61a25c4b4f9fb2b1351069b77f79e..fa508adbdcc7e4a91efc0c838a9f64a2229e91be 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -17,10 +17,10 @@ #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_ADVANCED_NOTIFICATION_SERVICE_H #include -#include #include #include #include +#include #include "event_handler.h" #include "event_runner.h" @@ -964,7 +964,7 @@ public: ErrCode SetDistributedEnabledByBundle(const sptr &bundleOption, const std::string &deviceType, const bool enabled) override; - /** + /* * @brief Get whether to allow a specified application to publish notifications cross * device collaboration. The caller must have system permissions to call this method. * @@ -1162,24 +1162,29 @@ public: void ResetDistributedEnabled(); - ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override; - void UpdateCloneBundleInfo(const NotificationCloneBundleInfo cloneBundleInfo); - void TryStartReminderAgentService(); + /** + * @brief Update notification timer by uid + * + * @param uid uid. + * @param isPaused if paused + * @return Returns ERR_OK on success, others on failure. + */ + ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override; - static sptr GenerateBundleOption(); - static sptr GenerateValidBundleOption(const sptr &bundleOption); + void TryStartReminderAgentService(); ErrCode DisableNotificationFeature(const sptr ¬ificationDisable) override; bool IsDisableNotification(const std::string &bundleName); - bool IsNeedToControllerByDisableNotification(const sptr &request); + bool IsDisableNotification(const sptr &request); void SetAndPublishSubscriberExistFlag(const std::string& deviceType, bool existFlag); ErrCode RemoveAllNotificationsByBundleName(const std::string &bundleName, int32_t reason); - + static sptr GenerateBundleOption(); + static sptr GenerateValidBundleOption(const sptr &bundleOption); protected: /** * @brief Query whether there is a agent relationship between the two apps. @@ -1203,13 +1208,6 @@ private: size_t recentCount = 16; }; - struct SoundPermissionInfo { - std::set bundleName_; - std::atomic needUpdateCache_ = true; - bool allPackage_ = false; - std::mutex dbMutex_; - }; - enum UploadStatus { CREATE, FIRST_UPDATE_TIME_OUT, @@ -1218,12 +1216,20 @@ private: FINISH }; + struct SoundPermissionInfo { + std::set bundleName_; + std::atomic needUpdateCache_ = true; + bool allPackage_ = false; + std::mutex dbMutex_; + }; + enum ContactPolicy { FORBID_EVERYONE = 1, ALLOW_EVERYONE = 2, ALLOW_EXISTING_CONTACTS = 3, ALLOW_FAVORITE_CONTACTS = 4, ALLOW_SPECIFIED_CONTACTS = 5, + FORBID_SPECIFIED_CONTACTS = 6, }; AdvancedNotificationService(); @@ -1251,6 +1257,7 @@ private: std::shared_ptr GetFromDelayedNotificationList( const int32_t ownerUid, const int32_t notificationId); std::vector GetNotificationKeys(const sptr &bundleOption); + std::vector GetNotificationKeysByBundle(const sptr &bundleOption); bool IsNotificationExists(const std::string &key); void SortNotificationList(); static bool NotificationCompare( @@ -1261,7 +1268,6 @@ private: std::string TimeToString(int64_t time); int64_t GetNowSysTime(); - void ExtendDumpForFlags(std::shared_ptr, std::stringstream &stream); ErrCode ActiveNotificationDump(const std::string& bundle, int32_t userId, int32_t recvUserId, std::vector &dumpInfo); ErrCode RecentNotificationDump(const std::string& bundle, int32_t userId, int32_t recvUserId, @@ -1341,6 +1347,12 @@ private: void SendNotificationsOnCanceled(std::vector> ¬ifications, const sptr ¬ificationMap, int32_t deleteReason); void SetAgentNotification(sptr& notificationRequest, std::string& bundleName); + ErrCode IsAllowedNotifyForBundle(const sptr &bundleOption, bool &allowed); + void AddLiveViewSubscriber(); + void EraseLiveViewSubsciber(const std::string &bundleName); + bool GetLiveViewSubscribeState(const std::string &bundleName); + bool CheckLocalLiveViewSubscribed(const sptr &request); + bool CheckLocalLiveViewAllowed(const sptr &request); static bool GetBundleInfoByNotificationBundleOption( const sptr &bundleOption, AppExecFwk::BundleInfo &bundleInfo); @@ -1376,6 +1388,7 @@ private: void CancelArchiveTimer(const std::shared_ptr &record); ErrCode StartAutoDeletedTimer(const std::shared_ptr &record); void ProcForDeleteLiveView(const std::shared_ptr &record); + ErrCode IsAllowedGetNotificationByFilter(const std::shared_ptr &record); void QueryDoNotDisturbProfile(const int32_t &userId, std::string &enable, std::string &profileId); void CheckDoNotDisturbProfile(const std::shared_ptr &record); void ReportDoNotDisturbModeChanged(const int32_t &userId, std::string &enable); @@ -1385,7 +1398,6 @@ private: int32_t notificationId, int32_t uid, const std::string &label, const std::string &bundleName); std::shared_ptr MakeNotificationRecord( const sptr &request, const sptr &bundleOption); - ErrCode IsAllowedNotifyForBundle(const sptr &bundleOption, bool &allowed); void FillActionButtons(const sptr &request); ErrCode IsAllowedGetNotificationByFilter(const std::shared_ptr &record, const sptr &bundleOption); @@ -1403,16 +1415,15 @@ private: bool IsDuplicateMsg(const std::string &uniqueKey); void DeleteDuplicateMsgs(const sptr &bundleOption); ErrCode PublishRemoveDuplicateEvent(const std::shared_ptr &record); - ErrCode UpdateSlotAuthInfo(const std::shared_ptr &record); std::vector GetBundlesOfActiveUser(); - void RemoveNotificationList(const std::shared_ptr &record); + ErrCode UpdateSlotAuthInfo(const std::shared_ptr &record); void FillLockScreenPicture(const sptr &newRequest, const sptr &oldRequest); + ErrCode CancelAsBundleWithAgent( + const sptr &bundleOption, const int32_t id, const std::string &label, int32_t userId); static ErrCode SetLockScreenPictureToDb(const sptr &request); static ErrCode GetLockScreenPictureFromDb(NotificationRequest *request); void RemoveDoNotDisturbProfileTrustList(const sptr &bundleOption); - ErrCode DeleteAllByUserInner(const int32_t &userId, int32_t reason, bool isAsync = false); - ErrCode RemoveAllNotificationsInner(const sptr &bundleOption, int32_t reason); ErrCode AssignValidNotificationSlot(const std::shared_ptr &record, const sptr &bundleOption); ErrCode UpdateSlotReminderModeBySlotFlags(const sptr &bundle, uint32_t slotFlags); @@ -1428,6 +1439,9 @@ private: ErrCode StartPublishDelayedNotification(const std::shared_ptr &record); void StartPublishDelayedNotificationTimeOut(const int32_t ownerUid, const int32_t notificationId); void UpdateRecordByOwner(const std::shared_ptr &record, bool isSystemApp); + ErrCode DeleteAllByUserInner(const int32_t &userId, int32_t reason, bool isAsync = false); + ErrCode RemoveAllNotificationsInner(const sptr &bundleOption, int32_t reason); + void RemoveNotificationList(const std::shared_ptr &record); void StartFinishTimerForUpdate(const std::shared_ptr &record, uint64_t process); ErrCode CheckLongTermLiveView(const sptr &request, const std::string &key); void ExcuteCancelGroupCancel(const sptr& bundleOption, @@ -1435,9 +1449,12 @@ private: ErrCode ExcuteCancelAll(const sptr& bundleOption, const int32_t reason); ErrCode ExcuteDelete(const std::string &key, const int32_t removeReason); ErrCode CheckNeedSilent(const std::string &phoneNumber, int32_t callerType, int32_t userId); + ErrCode QueryContactByProfileId(const std::string &uri, const std::string &phoneNumber, + const std::string &policy, int32_t userId); uint32_t GetDefaultSlotFlags(const sptr &request); bool IsSystemUser(int32_t userId); - ErrCode CollaboratePublish(const sptr &request); + ErrCode OnRecoverLiveView(const std::vector &keys); + ErrCode CollaboratePublish(const sptr &request); void SetCollaborateReminderFlag(const sptr &request); ErrCode SetEnabledForBundleSlotInner(const sptr &bundleOption, const sptr &bundle, @@ -1446,7 +1463,6 @@ private: const sptr &slot, const sptr &bundle, bool enabled, bool isForceControl); - ErrCode OnRecoverLiveView(const std::vector &keys); void HandleUpdateLiveViewNotificationTimer(const int32_t uid, const bool isPaused); void CancelWantAgent(const sptr ¬ification); void CancelOnceWantAgent(const std::shared_ptr &wantAgent); diff --git a/services/ans/src/advanced_datashare_helper.cpp b/services/ans/src/advanced_datashare_helper.cpp index 516b55b5f8e4a8498a3b82e46e41aadc1e7918b1..2efb1aace95a6d276149c8cf151f41f43231a733 100644 --- a/services/ans/src/advanced_datashare_helper.cpp +++ b/services/ans/src/advanced_datashare_helper.cpp @@ -15,6 +15,7 @@ #include "advanced_datashare_helper.h" +#include "ans_const_define.h" #include "ans_log_wrapper.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 944ec34eb8ab9f24e26452d4b5f6d24f93447fcc..21e0ec0232e57f2bc422f74d18db5d22080716af 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -2020,6 +2020,7 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( case ContactPolicy::ALLOW_EXISTING_CONTACTS: case ContactPolicy::ALLOW_FAVORITE_CONTACTS: case ContactPolicy::ALLOW_SPECIFIED_CONTACTS: + case ContactPolicy::FORBID_SPECIFIED_CONTACTS: Uri uri(CONTACT_DATA); isNeedSilent = datashareHelper->QueryContact(uri, phoneNumber, policy); break;