From ef1d72ca2503d380c753800da2aeac2422453342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E5=BF=97=E9=9B=84?= Date: Fri, 3 Jan 2025 22:06:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9D=A5=E7=94=B5=E5=8B=BF=E6=89=B0?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=85=E7=A6=81=E6=AD=A2=E8=81=94=E7=B3=BB?= =?UTF-8?q?=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 侯志雄 --- services/ans/include/advanced_datashare_helper.h | 1 + services/ans/include/advanced_notification_service.h | 1 + services/ans/src/advanced_datashare_helper.cpp | 1 + services/ans/src/advanced_notification_publish_service.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/services/ans/include/advanced_datashare_helper.h b/services/ans/include/advanced_datashare_helper.h index 7490c0ef1..c6024322a 100644 --- a/services/ans/include/advanced_datashare_helper.h +++ b/services/ans/include/advanced_datashare_helper.h @@ -29,6 +29,7 @@ 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"; } // namespace class AdvancedDatashareHelper : DelayedSingleton { diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index d025f4af9..56e10eb1c 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1224,6 +1224,7 @@ private: ALLOW_EXISTING_CONTACTS = 3, ALLOW_FAVORITE_CONTACTS = 4, ALLOW_SPECIFIED_CONTACTS = 5, + FORBID_SPECIFIED_CONTACTS = 6, }; AdvancedNotificationService(); diff --git a/services/ans/src/advanced_datashare_helper.cpp b/services/ans/src/advanced_datashare_helper.cpp index 516b55b5f..2efb1aace 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 944ec34eb..21e0ec023 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; -- Gitee From d1396e6068d93c7a20980a629a93ab4a5a2f38a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E5=BF=97=E9=9B=84?= Date: Fri, 3 Jan 2025 14:09:00 +0000 Subject: [PATCH 2/3] update services/ans/include/advanced_datashare_helper.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 侯志雄 --- services/ans/include/advanced_datashare_helper.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/ans/include/advanced_datashare_helper.h b/services/ans/include/advanced_datashare_helper.h index c6024322a..5d02e2461 100644 --- a/services/ans/include/advanced_datashare_helper.h +++ b/services/ans/include/advanced_datashare_helper.h @@ -30,6 +30,7 @@ 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 { @@ -38,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 -- Gitee From 12a5e26395ec3521afd0f0bd2e998d6458cf8124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E5=BF=97=E9=9B=84?= Date: Fri, 3 Jan 2025 14:11:26 +0000 Subject: [PATCH 3/3] update services/ans/include/advanced_notification_service.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 侯志雄 --- .../include/advanced_notification_service.h | 63 ++++++++++++------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 56e10eb1c..fa508adbd 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,6 +1216,13 @@ 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, @@ -1252,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( @@ -1262,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, @@ -1342,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); @@ -1377,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); @@ -1386,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); @@ -1404,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); @@ -1429,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, @@ -1436,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, @@ -1447,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); -- Gitee