From 3f0296ee4e74bd48a1dbcc622c31c67386677800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=94=90?= Date: Tue, 8 Jul 2025 10:13:55 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=87=8D=E5=90=AF=E6=9C=AA=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E5=9C=BA=E6=99=AF=20ans=E5=85=8D=E6=89=93=E6=89=B0?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢锐 --- services/ans/src/advanced_notification_publish_service.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index b21df939c..55db6891f 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -410,6 +410,7 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( case ContactPolicy::FORBID_SPECIFIED_CONTACTS: isNeedSilent = QueryContactByProfileId(phoneNumber, policy, userId); break; + } ANS_LOGI("IsNeedSilentInDoNotDisturbMode: %{public}d", isNeedSilent); return isNeedSilent; -- Gitee From b97b5622a51e774cbb5d43c817b96749d9f5f6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=94=90?= Date: Tue, 8 Jul 2025 02:25:08 +0000 Subject: [PATCH 2/6] update services/ans/src/advanced_notification_publish_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢锐 --- .../advanced_notification_publish_service.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 55db6891f..d56834218 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -398,6 +398,12 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( return 1; } } + bool isAccountVerified = true; + ErrCode account_ret = OHOS::AccountSA::OsAccountManager::IsOsAccountVerified(userId, isAccountVerified); + if (account_ret != ERR_OK) { + ANS_LOGE("IsOsAccountVerified fail."); + } + ANS_LOGI("IsOsAccountVerified isAccountVerified:%{public}d", isAccountVerified); switch (atoi(policy.c_str())) { case ContactPolicy::FORBID_EVERYONE: break; @@ -407,10 +413,19 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( case ContactPolicy::ALLOW_EXISTING_CONTACTS: case ContactPolicy::ALLOW_FAVORITE_CONTACTS: case ContactPolicy::ALLOW_SPECIFIED_CONTACTS: + if (!isAccountVerified) { + isNeedSilent = 0; + } else { + isNeedSilent = QueryContactByProfileId(phoneNumber, policy, userId); + } + break; case ContactPolicy::FORBID_SPECIFIED_CONTACTS: - isNeedSilent = QueryContactByProfileId(phoneNumber, policy, userId); + if (!isAccountVerified) { + isNeedSilent = 1; + } else { + isNeedSilent = QueryContactByProfileId(phoneNumber, policy, userId); + } break; - } ANS_LOGI("IsNeedSilentInDoNotDisturbMode: %{public}d", isNeedSilent); return isNeedSilent; -- Gitee From bb9c3c326fc02fb1258163856a4ed486a04ae035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=94=90?= Date: Tue, 8 Jul 2025 03:47:04 +0000 Subject: [PATCH 3/6] update services/ans/src/advanced_notification_publish_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢锐 --- .../src/advanced_notification_publish_service.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index d56834218..c78e04d73 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -392,8 +392,7 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( } ANS_LOGI("IsNeedSilent: policy: %{public}s, repeat: %{public}s, callerType: %{public}d", policy.c_str(), repeat_call.c_str(), callerType); - if (repeat_call == FOCUS_MODE_REPEAT_CALLERS_ENABLE && - callerType == 0 && atoi(policy.c_str()) != ContactPolicy::ALLOW_EVERYONE) { + if (repeat_call == FOCUS_MODE_REPEAT_CALLERS_ENABLE && callerType == 0 && atoi(policy.c_str()) != ContactPolicy::ALLOW_EVERYONE) { if (datashareHelper->isRepeatCall(phoneNumber)) { return 1; } @@ -413,18 +412,10 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( case ContactPolicy::ALLOW_EXISTING_CONTACTS: case ContactPolicy::ALLOW_FAVORITE_CONTACTS: case ContactPolicy::ALLOW_SPECIFIED_CONTACTS: - if (!isAccountVerified) { - isNeedSilent = 0; - } else { - isNeedSilent = QueryContactByProfileId(phoneNumber, policy, userId); - } + isNeedSilent = isAccountVerified ? QueryContactByProfileId(phoneNumber, policy, userId) : 0; break; case ContactPolicy::FORBID_SPECIFIED_CONTACTS: - if (!isAccountVerified) { - isNeedSilent = 1; - } else { - isNeedSilent = QueryContactByProfileId(phoneNumber, policy, userId); - } + isNeedSilent = isAccountVerified ? QueryContactByProfileId(phoneNumber, policy, userId) : 1; break; } ANS_LOGI("IsNeedSilentInDoNotDisturbMode: %{public}d", isNeedSilent); -- Gitee From fef86d564f7c513d50afec3f8282d425a7babdce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=94=90?= Date: Tue, 8 Jul 2025 08:17:53 +0000 Subject: [PATCH 4/6] update services/ans/src/advanced_notification_publish_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢锐 --- services/ans/src/advanced_notification_publish_service.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index c78e04d73..b23b290a1 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -392,7 +392,8 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( } ANS_LOGI("IsNeedSilent: policy: %{public}s, repeat: %{public}s, callerType: %{public}d", policy.c_str(), repeat_call.c_str(), callerType); - if (repeat_call == FOCUS_MODE_REPEAT_CALLERS_ENABLE && callerType == 0 && atoi(policy.c_str()) != ContactPolicy::ALLOW_EVERYONE) { + if (repeat_call == FOCUS_MODE_REPEAT_CALLERS_ENABLE && + callerType == 0 && atoi(policy.c_str()) != ContactPolicy::ALLOW_EVERYONE) { if (datashareHelper->isRepeatCall(phoneNumber)) { return 1; } -- Gitee From 67cd6b6e515780ae258be5a38d733ae56db16fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=94=90?= Date: Tue, 8 Jul 2025 09:09:14 +0000 Subject: [PATCH 5/6] update services/ans/src/advanced_notification_publish_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢锐 --- services/ans/src/advanced_notification_publish_service.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index b23b290a1..57d62c6b3 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -375,7 +375,6 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( ANS_LOGE("The data share helper is nullptr."); return -1; } - int isNeedSilent = 0; std::string policy; Uri policyUri(datashareHelper->GetFocusModeCallPolicyUri(userId)); @@ -403,7 +402,6 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( if (account_ret != ERR_OK) { ANS_LOGE("IsOsAccountVerified fail."); } - ANS_LOGI("IsOsAccountVerified isAccountVerified:%{public}d", isAccountVerified); switch (atoi(policy.c_str())) { case ContactPolicy::FORBID_EVERYONE: break; @@ -419,7 +417,7 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( isNeedSilent = isAccountVerified ? QueryContactByProfileId(phoneNumber, policy, userId) : 1; break; } - ANS_LOGI("IsNeedSilentInDoNotDisturbMode: %{public}d", isNeedSilent); + ANS_LOGI("CheckNeedSilent isNeedSilent:%{public}d isAccountVerified:%{public}d", isNeedSilent, isAccountVerified); return isNeedSilent; } -- Gitee From 883f9b3c2c6a402e4c4f690d2bcc36e2ecbb833f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=94=90?= Date: Tue, 8 Jul 2025 09:51:21 +0000 Subject: [PATCH 6/6] update services/ans/src/advanced_notification_publish_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢锐 --- .../ans/src/advanced_notification_publish_service.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 57d62c6b3..6c6ab20c7 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -391,11 +391,9 @@ ErrCode AdvancedNotificationService::CheckNeedSilent( } ANS_LOGI("IsNeedSilent: policy: %{public}s, repeat: %{public}s, callerType: %{public}d", policy.c_str(), repeat_call.c_str(), callerType); - if (repeat_call == FOCUS_MODE_REPEAT_CALLERS_ENABLE && - callerType == 0 && atoi(policy.c_str()) != ContactPolicy::ALLOW_EVERYONE) { - if (datashareHelper->isRepeatCall(phoneNumber)) { - return 1; - } + if (repeat_call == FOCUS_MODE_REPEAT_CALLERS_ENABLE && callerType == 0 && + atoi(policy.c_str()) != ContactPolicy::ALLOW_EVERYONE && datashareHelper->isRepeatCall(phoneNumber)) { + return 1; } bool isAccountVerified = true; ErrCode account_ret = OHOS::AccountSA::OsAccountManager::IsOsAccountVerified(userId, isAccountVerified); -- Gitee