diff --git a/frameworks/ans/src/push_callback_stub.cpp b/frameworks/ans/src/push_callback_stub.cpp index 7e52eaaddb78b308c884f2bfa18f8795699fef00..bb41508d4c2b0e2b4da012cdd3727e70af64db57 100644 --- a/frameworks/ans/src/push_callback_stub.cpp +++ b/frameworks/ans/src/push_callback_stub.cpp @@ -37,7 +37,8 @@ enum PushCheckErrCode : int32_t { NETWORK_UNREACHABLE = 2, SPECIFIED_NOTIFICATIONS_FAILED = 3, SYSTEM_ERROR = 4, - OPTIONAL_PARAMETER_INVALID = 5 + OPTIONAL_PARAMETER_INVALID = 5, + PUSH_CHECK_WEAK_NETWORK = 6, }; constexpr int32_t MAX_LIVEVIEW_CONFIG_SIZE = 60; @@ -65,6 +66,9 @@ ErrCode PushCallBackStub::ConvertPushCheckCodeToErrCode(int32_t pushCheckCode) case PushCheckErrCode::OPTIONAL_PARAMETER_INVALID: errCode = ERR_ANS_PUSH_CHECK_EXTRAINFO_INVALID; break; + case PushCheckErrCode::PUSH_CHECK_WEAK_NETWORK: + errCode = ERR_ANS_CHECK_WEAK_NETWORK; + break; default: errCode = ERR_ANS_PUSH_CHECK_FAILED; break; diff --git a/frameworks/core/common/include/ans_inner_errors.h b/frameworks/core/common/include/ans_inner_errors.h index 73b138f556424265c549709c8c2bc8cc4194ffae..ec38cd9f494c618f37d46a4acf146a54c2696409 100644 --- a/frameworks/core/common/include/ans_inner_errors.h +++ b/frameworks/core/common/include/ans_inner_errors.h @@ -97,7 +97,7 @@ enum ErrorCode : uint32_t { ERR_ANS_REJECTED_WITH_DISABLE_NOTIFICATION, ERR_ANS_OPERATION_TIMEOUT, ERR_ANS_LOCAL_SUBSCRIBE_CHECK_FAILED, - ERR_ANS_BUNDLE_SLOT_EXIST, + ERR_ANS_CHECK_WEAK_NETWORK, }; enum ReminderErrorCode : uint32_t { diff --git a/services/ans/include/notification_config_parse.h b/services/ans/include/notification_config_parse.h index b5b86370c411dcfb0adf38ee3d0f26911f8d0615..4e807ab346e14564493bdf1f62d5ef9e78a4ecc7 100644 --- a/services/ans/include/notification_config_parse.h +++ b/services/ans/include/notification_config_parse.h @@ -63,6 +63,7 @@ public: void GetCollaborationFilter(); bool IsInCollaborationFilter(const std::string &bundleName, int32_t uid) const; uint32_t GetStartAbilityTimeout(); + bool CheckAppLiveViewCcm(); private: bool ParseCollaborativeDeleteTypesDevices(std::mapIsAtomicServiceNotification()) { @@ -1804,7 +1805,7 @@ ErrCode AdvancedNotificationService::HandlePushCheckFailed(const sptrsubmit_h(std::bind([&]() { + notificationSvrQueue_->submit_h(std::bind([&, response, requestId, value]() { if (response == ERR_OK) { LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->UpdateLiveViewConfig(value); return; diff --git a/services/ans/src/common/notification_config_parse.cpp b/services/ans/src/common/notification_config_parse.cpp index aae9f367aa88a9bdd269b86848c582dea70ee928..d86cb6d4b4e8aded63b46974cdad163fe8991e0b 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -451,6 +451,18 @@ uint32_t NotificationConfigParse::GetStartAbilityTimeout() return 0; } +bool NotificationConfigParse::CheckAppLiveViewCcm() +{ + nlohmann::json root; + std::string JsonPoint = "/"; + JsonPoint.append(NotificationConfigParse::APP_LIVEVIEW_PERMISSIONS); + if (!NotificationConfigParse::GetInstance()->GetConfigJson(JsonPoint, root)) { + ANS_LOGE("Failed to get JsonPoint CCM config file."); + return false; + } + return true; +} + void NotificationConfigParse::GetReportTrustListConfig() { nlohmann::json root; diff --git a/services/ans/src/utils/notification_liveview_utils.cpp b/services/ans/src/utils/notification_liveview_utils.cpp index b594a4870e758a713ddacc2f81495cfcd9608d7a..d033b3b7418dc1258bdc85fef61de2ebadaeabf3 100644 --- a/services/ans/src/utils/notification_liveview_utils.cpp +++ b/services/ans/src/utils/notification_liveview_utils.cpp @@ -20,6 +20,7 @@ #include "advanced_notification_inline.h" #include "notification_preferences.h" #include "liveview_all_scenarios_extension_wrapper.h" +#include "notification_config_parse.h" namespace OHOS { namespace Notification { @@ -93,6 +94,7 @@ bool NotificationLiveViewUtils::CheckLiveViewForBundle(const sptrGetStringParam("event"); } + ANS_LOGI("Ccm check %{public}s %{public}s.", bundleName.c_str(), event.c_str()); bool enable = false; if (LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->CheckLiveViewConfig(bundleName, event, DEFAULT_USER_ID, enable) != ERR_OK) { @@ -124,6 +126,10 @@ bool NotificationLiveViewUtils::CheckLiveViewVersion() void NotificationLiveViewUtils::NotifyLiveViewEvent(const std::string& event) { + if (!NotificationConfigParse::GetInstance()->CheckAppLiveViewCcm()) { + return; + } + ANS_LOGI("notify event %{public}s", event.c_str()); if (CheckLiveViewVersion()) { LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->NotifyLiveViewEvent(event, nullptr); @@ -133,12 +139,19 @@ void NotificationLiveViewUtils::NotifyLiveViewEvent(const std::string& event) void NotificationLiveViewUtils::NotifyLiveViewEvent(const std::string& event, const sptr& bundleInfo) { + if (!NotificationConfigParse::GetInstance()->CheckAppLiveViewCcm()) { + return; + } ANS_LOGI("notify event %{public}s", event.c_str()); LIVEVIEW_ALL_SCENARIOS_EXTENTION_WRAPPER->NotifyLiveViewEvent(event, bundleInfo); } bool NotificationLiveViewUtils::CheckLiveViewRebuild(int32_t userId) { + if (!NotificationConfigParse::GetInstance()->CheckAppLiveViewCcm()) { + return false; + } + std::lock_guard lock(eraseMutex); if (eraseFlag.find(userId) == eraseFlag.end()) { eraseFlag[userId] = ERASE_FLAG_INIT; diff --git a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp index 559a68f857fca191cbe7509678378f28c73032a6..f011432dad38c783211e2c9421a8578ceca1dab6 100644 --- a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp @@ -1388,8 +1388,6 @@ HWTEST_F(AnsBranchTest, AnsBranchTest_286002, Function | SmallTest | Level1) bundle->SetUid(NON_SYSTEM_APP_UID); result = advancedNotificationService_->SetDefaultSlotForBundle(bundle, 5, true, true); ASSERT_EQ(result, ERR_OK); - result = advancedNotificationService_->SetDefaultSlotForBundle(bundle, 5, true, true); - ASSERT_EQ(result, ERR_ANS_BUNDLE_SLOT_EXIST); } } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/notification_extension/notification_config_parse_mock.cpp b/services/ans/test/unittest/notification_extension/notification_config_parse_mock.cpp index 1d0e6cd388bf03fdd05854f85e4b9474f1690ddf..e0318e5cb4a24938f13fcb74d26bc8511e88c508 100644 --- a/services/ans/test/unittest/notification_extension/notification_config_parse_mock.cpp +++ b/services/ans/test/unittest/notification_extension/notification_config_parse_mock.cpp @@ -175,6 +175,11 @@ uint32_t NotificationConfigParse::GetStartAbilityTimeout() return MOCK_DEFAULT_REPLY_TIMEOUT; } +bool NotificationConfigParse::CheckAppLiveViewCcm() +{ + return true; +} + void NotificationConfigParse::GetReportTrustListConfig() { return;