From d9c5a1d0a820a40ee460f2cb9b93e772d09bb80b Mon Sep 17 00:00:00 2001 From: heguokai Date: Mon, 24 Mar 2025 16:23:39 +0800 Subject: [PATCH 1/3] log change Signed-off-by: heguokai --- frameworks/ans/src/notification.cpp | 2 +- .../ans/src/notification_button_option.cpp | 2 +- .../src/notification_live_view_content.cpp | 2 +- .../ans/src/notification_operation_info.cpp | 18 +++--- frameworks/ans/src/notification_request.cpp | 20 +++--- frameworks/ans/src/notification_slot.cpp | 4 +- frameworks/ans/src/notification_sorting.cpp | 2 +- .../ans/src/notification_subscriber.cpp | 2 +- frameworks/ans/src/push_callback_stub.cpp | 6 +- .../cj/ffi/src/notification_manager_ffi.cpp | 6 +- .../cj/ffi/src/notification_manager_impl.cpp | 10 +-- frameworks/cj/ffi/src/notification_utils.cpp | 18 +++--- frameworks/core/src/ans_image_util.cpp | 18 +++--- frameworks/core/src/ans_notification.cpp | 4 +- .../src/listener/ans_subscriber_listener.cpp | 26 ++++---- .../src/listener/ans_subscriber_proxy.cpp | 4 +- .../core/src/listener/ans_subscriber_stub.cpp | 22 +++---- .../manager/ans_manager_death_recipient.cpp | 4 +- .../core/src/manager/ans_manager_proxy.cpp | 4 +- .../src/manager/ans_manager_proxy_slot.cpp | 12 ++-- .../src/manager/ans_manager_proxy_utils.cpp | 2 +- frameworks/js/napi/src/cancel.cpp | 20 +++--- frameworks/js/napi/src/common.cpp | 4 +- .../js/napi/src/common_convert_content.cpp | 4 +- .../js/napi/src/common_convert_liveview.cpp | 6 +- .../js/napi/src/common_convert_request.cpp | 12 ++-- .../js/napi/src/disable_notification.cpp | 2 +- frameworks/js/napi/src/display_badge.cpp | 14 ++-- frameworks/js/napi/src/distributed.cpp | 6 +- .../src/distributed_operation_callback.cpp | 8 +-- frameworks/js/napi/src/disturb_mode.cpp | 14 ++-- .../js/napi/src/enable_notification.cpp | 12 ++-- .../src/manager/napi_disable_notification.cpp | 8 ++- .../src/manager/napi_distributed_enable.cpp | 22 +++---- .../src/manager/napi_enable_notification.cpp | 8 +-- .../js/napi/src/manager/napi_get_active.cpp | 6 +- .../napi/src/manager/napi_push_callback.cpp | 2 +- .../js/napi/src/manager/napi_remove_group.cpp | 8 +-- .../js/napi/src/manager/napi_sync_config.cpp | 8 +-- frameworks/js/napi/src/publish.cpp | 26 ++++---- frameworks/js/napi/src/reminder/publish.cpp | 42 ++++++------ .../js/napi/src/reminder/reminder_common.cpp | 64 +++++++++---------- frameworks/js/napi/src/remove.cpp | 26 ++++---- .../reminder/src/reminder_request_factory.cpp | 4 +- .../reminder/src/reminder_request_timer.cpp | 8 +-- .../src/reminder_service_load_callback.cpp | 2 +- interfaces/ndk/src/notification.cpp | 2 +- ...nced_notification_flow_control_service.cpp | 2 +- .../advanced_notification_publish_service.cpp | 2 +- .../ans/src/advanced_notification_service.cpp | 20 +++--- .../ans/src/advanced_notification_utils.cpp | 6 +- services/ans/src/ans_manager_stub.cpp | 32 +++++----- services/ans/src/bundle_manager_helper.cpp | 2 +- .../src/clone/notification_clone_manager.cpp | 16 ++--- .../common/notification_analytics_util.cpp | 8 +-- .../src/common/notification_config_parse.cpp | 10 +-- .../add_do_not_disturb_profiles.cpp | 2 +- .../get_do_not_disturb_profile.cpp | 4 +- .../remove_do_not_disturb_profiles.cpp | 2 +- .../set_do_not_disturb_date.cpp | 2 +- .../distributed_device_manager.cpp | 2 +- .../distributed_extension_service.cpp | 20 +++--- .../notification_operation_service.cpp | 2 +- .../smart_reminder_center.cpp | 6 +- .../src/reminder_swing_decision_center.cpp | 2 +- .../ans/src/utils/notifictaion_load_utils.cpp | 2 +- .../src/reminder_config_change_observer.cpp | 2 +- .../reminder/src/reminder_data_manager.cpp | 4 +- .../src/reminder_data_manager_inner.cpp | 16 ++--- 69 files changed, 346 insertions(+), 344 deletions(-) diff --git a/frameworks/ans/src/notification.cpp b/frameworks/ans/src/notification.cpp index de8e4950f..4377d7d03 100644 --- a/frameworks/ans/src/notification.cpp +++ b/frameworks/ans/src/notification.cpp @@ -315,7 +315,7 @@ bool Notification::MarshallingString(Parcel &parcel) const bool Notification::MarshallingInt32(Parcel &parcel) const { if (!parcel.WriteInt32(ledLightColor_)) { - ANS_LOGE("Can't write ledLigthColor"); + ANS_LOGE("Can't write ledLightColor"); return false; } diff --git a/frameworks/ans/src/notification_button_option.cpp b/frameworks/ans/src/notification_button_option.cpp index f125e02cb..5e2437a22 100644 --- a/frameworks/ans/src/notification_button_option.cpp +++ b/frameworks/ans/src/notification_button_option.cpp @@ -74,7 +74,7 @@ NotificationButtonOption *NotificationButtonOption::FromJson(const nlohmann::jso bool NotificationButtonOption::Marshalling(Parcel &parcel) const { if (!parcel.WriteString(buttonName_)) { - ANS_LOGE("Failed to write title"); + ANS_LOGE("Failed to write buttonName"); return false; } diff --git a/frameworks/ans/src/notification_live_view_content.cpp b/frameworks/ans/src/notification_live_view_content.cpp index dbac5cc7e..cda062ac7 100644 --- a/frameworks/ans/src/notification_live_view_content.cpp +++ b/frameworks/ans/src/notification_live_view_content.cpp @@ -220,7 +220,7 @@ bool NotificationLiveViewContent::Marshalling(Parcel &parcel) const } if (valid) { if (!parcel.WriteParcelable(extraInfo_.get())) { - ANS_LOGE("Failed to write additionalParams"); + ANS_LOGE("Failed to write extraInfo"); return false; } } diff --git a/frameworks/ans/src/notification_operation_info.cpp b/frameworks/ans/src/notification_operation_info.cpp index d02c30f2e..692e01622 100644 --- a/frameworks/ans/src/notification_operation_info.cpp +++ b/frameworks/ans/src/notification_operation_info.cpp @@ -88,27 +88,27 @@ std::string NotificationOperationInfo::Dump() bool NotificationOperationInfo::Marshalling(Parcel &parcel) const { if (!parcel.WriteString(actionName_)) { - ANS_LOGE("Failed to write action name"); + ANS_LOGE("Failed to write actionName"); return false; } if (!parcel.WriteString(userInput_)) { - ANS_LOGE("Failed to write user input"); + ANS_LOGE("Failed to write userInput"); return false; } if (!parcel.WriteString(hashCode_)) { - ANS_LOGE("Failed to write user input"); + ANS_LOGE("Failed to write hashCode"); return false; } if (!parcel.WriteString(eventId_)) { - ANS_LOGE("Failed to write user input"); + ANS_LOGE("Failed to write eventId"); return false; } if (!parcel.WriteInt32(static_cast(operationType_))) { - ANS_LOGE("Failed to write user input"); + ANS_LOGE("Failed to write operationType"); return false; } @@ -118,22 +118,22 @@ bool NotificationOperationInfo::Marshalling(Parcel &parcel) const bool NotificationOperationInfo::ReadFromParcel(Parcel &parcel) { if (!parcel.ReadString(actionName_)) { - ANS_LOGE("Failed to read action name"); + ANS_LOGE("Failed to read actionName"); return false; } if (!parcel.ReadString(userInput_)) { - ANS_LOGE("Failed to read user input"); + ANS_LOGE("Failed to read userInput"); return false; } if (!parcel.ReadString(hashCode_)) { - ANS_LOGE("Failed to read action name"); + ANS_LOGE("Failed to read hashCode"); return false; } if (!parcel.ReadString(eventId_)) { - ANS_LOGE("Failed to read user input"); + ANS_LOGE("Failed to read eventId"); return false; } diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index a7b01c4c9..e76f44e56 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -236,7 +236,7 @@ void NotificationRequest::SetIsAgentNotification(bool isAgent) void NotificationRequest::AddMessageUser(const std::shared_ptr &messageUser) { if (!messageUser) { - ANS_LOGI("messageUser can not be null"); + ANS_LOG("messageUser can not be null"); return; } @@ -364,20 +364,20 @@ bool NotificationRequest::IsColorEnabled() const // no valid content if (!notificationContent_) { - ANS_LOGI("no valid notification content"); + ANS_LOGE("no valid notification content"); return false; } // not a media content if (NotificationContent::Type::MEDIA != notificationContentType_) { - ANS_LOGI("not a media notification content"); + ANS_LOGE("not a media notification content"); return false; } auto basicContent = notificationContent_->GetNotificationContent(); auto mediaContent = std::static_pointer_cast(basicContent); if (!mediaContent->GetAVToken()) { - ANS_LOGI("AVToken has not been attached"); + ANS_LOGE("AVToken has not been attached"); return false; } @@ -1136,7 +1136,7 @@ bool NotificationRequest::Marshalling(Parcel &parcel) const } if (!parcel.WriteString(distributedHashCode_)) { - ANS_LOGE("Failed to write sound"); + ANS_LOGE("Failed to write distributedHashCode"); return false; } @@ -1618,7 +1618,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) int32_t slotTypeValue = parcel.ReadInt32(); if (slotTypeValue < 0 || slotTypeValue >= static_cast(NotificationConstant::SlotType::ILLEGAL_TYPE)) { - ANS_LOGE("Invalid slot type value :%{public}d. It should be in [0 , %{public}d).", + ANS_LOGE("Invalid SlotType:%{public}d. It should be in [0 , %{public}d).", slotTypeValue, static_cast(NotificationConstant::SlotType::ILLEGAL_TYPE)); return false; } @@ -1626,7 +1626,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) int32_t groupAlertTypeValue = parcel.ReadInt32(); if (groupAlertTypeValue < 0 || groupAlertTypeValue >= static_cast(NotificationRequest::GroupAlertType::ILLEGAL_TYPE)) { - ANS_LOGE("Invalid groupAlert type value :%{public}d. It should be in [0 , %{public}d).", + ANS_LOGE("Invalid GroupAlertType:%{public}d. It should be in [0 , %{public}d).", groupAlertTypeValue, static_cast(NotificationRequest::GroupAlertType::ILLEGAL_TYPE)); return false; } @@ -1634,14 +1634,14 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) int32_t visiblenessTypeValue = parcel.ReadInt32(); if (visiblenessTypeValue < 0 || visiblenessTypeValue >= static_cast(NotificationConstant::VisiblenessType::ILLEGAL_TYPE)) { - ANS_LOGE("Invalid visibleness type value :%{public}d. It should be in [0 , %{public}d).", + ANS_LOGE("Invalid VisiblenessType:%{public}d. It should be in [0 , %{public}d).", visiblenessTypeValue, static_cast(NotificationConstant::VisiblenessType::ILLEGAL_TYPE)); return false; } visiblenessType_ = static_cast(visiblenessTypeValue); int32_t badgeStyleValue = parcel.ReadInt32(); if (badgeStyleValue < 0) { - ANS_LOGE("Invalid badge style value :%{public}d. It should be greater than 0.", badgeStyleValue); + ANS_LOGE("Invalid badgeStyle:%{public}d. It should be greater than 0.", badgeStyleValue); return false; } if (badgeStyleValue >= static_cast(NotificationRequest::BadgeStyle::ILLEGAL_TYPE)) { @@ -1653,7 +1653,7 @@ bool NotificationRequest::ReadFromParcel(Parcel &parcel) int32_t notificationContentTypeValue = parcel.ReadInt32(); if (notificationContentTypeValue <= static_cast(NotificationContent::Type::NONE) || notificationContentTypeValue >= static_cast(NotificationContent::Type::ILLEGAL_TYPE)) { - ANS_LOGE("Invalid notification content type value :%{public}d. It should be in (%{public}d , %{public}d)", + ANS_LOGE("Invalid notificationContent:%{public}d. It should be in (%{public}d , %{public}d)", notificationContentTypeValue, static_cast(NotificationContent::Type::NONE), static_cast(NotificationContent::Type::ILLEGAL_TYPE)); return false; diff --git a/frameworks/ans/src/notification_slot.cpp b/frameworks/ans/src/notification_slot.cpp index 61ce2be2d..59385e761 100644 --- a/frameworks/ans/src/notification_slot.cpp +++ b/frameworks/ans/src/notification_slot.cpp @@ -387,12 +387,12 @@ bool NotificationSlot::Marshalling(Parcel &parcel) const if (sound_.ToString().empty()) { if (!parcel.WriteInt32(VALUE_NULL)) { - ANS_LOGE("Failed to write int"); + ANS_LOGE("Failed to write VALUE_NULL"); return false; } } else { if (!parcel.WriteInt32(VALUE_OBJECT)) { - ANS_LOGE("Failed to write int"); + ANS_LOGE("Failed to write VALUE_OBJECT"); return false; } if (!parcel.WriteString((sound_.ToString()))) { diff --git a/frameworks/ans/src/notification_sorting.cpp b/frameworks/ans/src/notification_sorting.cpp index 6a392de8b..804e447eb 100644 --- a/frameworks/ans/src/notification_sorting.cpp +++ b/frameworks/ans/src/notification_sorting.cpp @@ -83,7 +83,7 @@ bool NotificationSorting::Marshalling(Parcel &parcel) const } if (!parcel.WriteInt32(visiblenessOverride_)) { - ANS_LOGE("Can't write importance"); + ANS_LOGE("Can't write visiblenessOverride"); return false; } diff --git a/frameworks/ans/src/notification_subscriber.cpp b/frameworks/ans/src/notification_subscriber.cpp index cd256b4fe..0ae73181b 100644 --- a/frameworks/ans/src/notification_subscriber.cpp +++ b/frameworks/ans/src/notification_subscriber.cpp @@ -85,7 +85,7 @@ bool NotificationSubscriber::ProcessSyncDecision( if (deviceType.size() <= 0 || deviceType.compare(NotificationConstant::CURRENT_DEVICE_TYPE) == 0) { return true; } - ANS_LOGI("Cannot find deviceFlags,notificationKey = %{public}s, deviceType: %{public}s.", + ANS_LOGE("Cannot find deviceFlags,notificationKey = %{public}s, deviceType: %{public}s.", request->GetKey().c_str(), deviceType.c_str()); return false; } diff --git a/frameworks/ans/src/push_callback_stub.cpp b/frameworks/ans/src/push_callback_stub.cpp index aefe12c23..7b317d7bf 100644 --- a/frameworks/ans/src/push_callback_stub.cpp +++ b/frameworks/ans/src/push_callback_stub.cpp @@ -156,12 +156,12 @@ void PushCallBackProxy::HandleEventControl( std::string eventControl, const std::shared_ptr &pushCallBackParam) { if (pushCallBackParam == nullptr) { - ANS_LOGI("pushCallBackParam is null"); + ANS_LOGE("pushCallBackParam is null"); return; } std::string event = pushCallBackParam->event; if (event.empty()) { - ANS_LOGI("event is null"); + ANS_LOGE("event is null"); return; } ANS_LOGI("eventControl:%{public}s,event:%{public}s", eventControl.c_str(), event.c_str()); @@ -174,7 +174,7 @@ void PushCallBackProxy::HandleEventControl( return; } if (jsonObject.find(event) == jsonObject.cend()) { - ANS_LOGI("This event has not eventControl"); + ANS_LOGE("This event has not eventControl"); return; } pushCallBackParam->eventControl = jsonObject.at(event).dump(); diff --git a/frameworks/cj/ffi/src/notification_manager_ffi.cpp b/frameworks/cj/ffi/src/notification_manager_ffi.cpp index 3975b7876..fec11362e 100644 --- a/frameworks/cj/ffi/src/notification_manager_ffi.cpp +++ b/frameworks/cj/ffi/src/notification_manager_ffi.cpp @@ -147,7 +147,7 @@ RetDataBool FfiOHOSNotificationManagerIsNotificationEnabled() RetDataBool ret = { .code = ERR_INVALID_INSTANCE_CODE, .data = 0 }; auto [status, enabledStatus] = NotificationManagerImpl::IsNotificationEnabled(); if (status != SUCCESS_CODE) { - LOGI("NOTIFICATION_TEST::FfiOHOSNotificationManagerIsNotificationEnabled error"); + LOGE("NOTIFICATION_TEST::FfiOHOSNotificationManagerIsNotificationEnabled error"); ret.code = status; ret.data = false; return ret; @@ -173,7 +173,7 @@ int32_t FfiOHOSNotificationManagerRequestEnableNotificationWithContext(int64_t i { auto context = FFIData::GetData(id); if (context == nullptr) { - LOGI("NOTIFICATION_TEST::FfiOHOSNotificationManagerRequestEnableNotificationWithContext error"); + LOGE("NOTIFICATION_TEST::FfiOHOSNotificationManagerRequestEnableNotificationWithContext error"); return ERROR_PARAM_INVALID; } auto code = NotificationManagerImpl::RequestEnableNotificationWithContext(context); @@ -185,7 +185,7 @@ RetDataBool FfiOHOSNotificationManagerIsDistributedEnabled() RetDataBool ret = { .code = ERR_INVALID_INSTANCE_CODE, .data = 0 }; auto [status, enabledStatus] = NotificationManagerImpl::IsDistributedEnabled(); if (status != SUCCESS_CODE) { - LOGI("NOTIFICATION_TEST::FfiOHOSNotificationManagerIsDistributedEnabled error"); + LOGE("NOTIFICATION_TEST::FfiOHOSNotificationManagerIsDistributedEnabled error"); ret.code = status; ret.data = false; return ret; diff --git a/frameworks/cj/ffi/src/notification_manager_impl.cpp b/frameworks/cj/ffi/src/notification_manager_impl.cpp index dc2b8c5f8..21bb0cdda 100644 --- a/frameworks/cj/ffi/src/notification_manager_impl.cpp +++ b/frameworks/cj/ffi/src/notification_manager_impl.cpp @@ -327,19 +327,19 @@ namespace CJSystemapi { bool allowed = false; int errorCode; if (params.hasBundleOption) { - LOGI("option.bundle : %{public}s option.uid : %{public}d", + LOGI("option.bundle:%{public}s option.uid:%{public}d", params.option.GetBundleName().c_str(), params.option.GetUid()); errorCode = NotificationHelper::IsAllowedNotify(params.option, allowed); } else if (params.hasUserId) { - LOGI("userId : %{public}d", params.userId); + LOGI("userId:%{public}d", params.userId); errorCode = NotificationHelper::IsAllowedNotify(params.userId, allowed); } else { errorCode = NotificationHelper::IsAllowedNotifySelf(allowed); } ret.code = ErrorToExternal(errorCode); ret.data = allowed; - LOGI("errorCode : %{public}d, allowed : %{public}d", + LOGI("errorCode:%{public}d, allowed:%{public}d", errorCode, allowed); return ret; } @@ -360,7 +360,7 @@ namespace CJSystemapi { return ErrorToExternal(ERR_ANS_DIALOG_IS_POPPING); } int code = NotificationHelper::RequestEnableNotification(deviceId, client, params.callerToken); - LOGI("done, code is %{public}d.", code) + LOGI("code:%{public}d", code) return ErrorToExternal(code); } @@ -377,7 +377,7 @@ namespace CJSystemapi { return ErrorToExternal(ERR_ANS_DIALOG_IS_POPPING); } int code = NotificationHelper::RequestEnableNotification(deviceId, client, params.callerToken); - LOGI("done, code is %{public}d.", code) + LOGI("code:%{public}d", code) return ErrorToExternal(code); } diff --git a/frameworks/cj/ffi/src/notification_utils.cpp b/frameworks/cj/ffi/src/notification_utils.cpp index 75e54329d..6a7532159 100644 --- a/frameworks/cj/ffi/src/notification_utils.cpp +++ b/frameworks/cj/ffi/src/notification_utils.cpp @@ -881,13 +881,13 @@ namespace Notification { // type: SlotType SlotType outType = SlotType::UNKNOWN_TYPE; if (!SlotTypeCToCJ(slot.GetType(), outType)) { - LOGE("SetNotificationSlot SlotTypeCToCJ failed."); + LOGE("UNKNOWN_TYPE SlotTypeCToCJ failed."); return false; } // level?: int32_t SlotLevel outLevel = SlotLevel::LEVEL_NONE; if (!SlotLevelCToCJ(slot.GetLevel(), outLevel)) { - LOGE("SetNotificationSlot SlotLevelCToCJ failed."); + LOGE("LEVEL_NONE SlotLevelCToCJ failed."); return false; } notificationSlot.notificationType = static_cast(outType); @@ -914,7 +914,7 @@ namespace Notification { free(notificationSlot.sound); notificationSlot.desc = nullptr; notificationSlot.sound = nullptr; - LOGE("SetNotificationSlot malloc vibrationValues.head failed."); + LOGE("malloc vibrationValues.head failed"); return false; } int i = 0; @@ -1075,7 +1075,7 @@ namespace Notification { } auto native = FFIData::Create(pix); if (native == nullptr) { - LOGE("Invalid object pixelMap"); + LOGE("Invalid object Create pixelMap"); freeNotificationBasicContent(normal); return false; } @@ -1142,7 +1142,7 @@ namespace Notification { } auto native = FFIData::Create(pix); if (native == nullptr) { - LOGE("Invalid object pixelMap"); + LOGE("Invalid object Create pixelMap"); freeNotificationLongTextContent(longText); return false; } @@ -1195,7 +1195,7 @@ namespace Notification { } auto native1 = FFIData::Create(pix); if (native1 == nullptr) { - LOGE("Invalid object pixelMap"); + LOGE("Invalid object Create pixelMap"); freeNotificationPictureContent(picture); return false; } @@ -1211,7 +1211,7 @@ namespace Notification { } auto native2 = FFIData::Create(pixx); if (native2 == nullptr) { - LOGE("Invalid object pixelMap"); + LOGE("Invalid object Create pixelMap"); freeNotificationPictureContent(picture); return false; } @@ -1288,7 +1288,7 @@ namespace Notification { } auto native2 = FFIData::Create(pix); if (native2 == nullptr) { - LOGE("Invalid object pixelMap"); + LOGE("Invalid object Create pixelMap"); freeNotificationMultiLineContent(multiLine); return false; } @@ -1463,7 +1463,7 @@ namespace Notification { } auto native2 = FFIData::Create(pix); if (native2 == nullptr) { - LOGE("Invalid object pixelMap"); + LOGE("Invalid object Create pixelMap"); return false; } systemLiveView->lockscreenPicture = native2->GetID(); diff --git a/frameworks/core/src/ans_image_util.cpp b/frameworks/core/src/ans_image_util.cpp index 601168f1c..f5c2458bb 100644 --- a/frameworks/core/src/ans_image_util.cpp +++ b/frameworks/core/src/ans_image_util.cpp @@ -42,12 +42,12 @@ std::string AnsImageUtil::PackImage(const std::shared_ptr &pixe std::set formats; auto ret = imagePacker.GetSupportedFormats(formats); if (ret) { - ANS_LOGE("Failed to GetSupportedFormats, ret : %{public}u", ret); + ANS_LOGE("Failed to GetSupportedFormats, ret:%{public}u", ret); return {}; } auto size = static_cast(pixelMap->GetByteCount()); - ANS_LOGD("size of pixelMap : %{public}u", size); + ANS_LOGD("size of pixelMap:%{public}u", size); if (size < DEFAULT_SIZE) { size = DEFAULT_SIZE; } @@ -61,7 +61,7 @@ std::string AnsImageUtil::PackImage(const std::shared_ptr &pixe imagePacker.AddImage(*pixelMap); int64_t packedSize {0}; imagePacker.FinalizePacking(packedSize); - ANS_LOGD("packed size : %{public}" PRId64, packedSize); + ANS_LOGD("packed size:%{public}" PRId64, packedSize); std::string pixelMapStr(reinterpret_cast(pbuf), static_cast(packedSize)); delete [] pbuf; @@ -106,7 +106,7 @@ bool AnsImageUtil::PackImage2File( const std::string &format) { if (!pixelMap || outFilePath.empty() || format.empty()) { - ANS_LOGW("invalid parameters"); + ANS_LOGE("invalid parameters"); return false; } @@ -127,14 +127,14 @@ bool AnsImageUtil::PackImage2File( imagePacker.AddImage(*pixelMap); int64_t packedSize {0}; imagePacker.FinalizePacking(packedSize); - ANS_LOGI("packed size : %{public}" PRId64, packedSize); + ANS_LOGI("packed size:%{public}" PRId64, packedSize); return true; } std::shared_ptr AnsImageUtil::CreatePixelMap(const std::string &inFilePath, const std::string &format) { if (inFilePath.empty() || format.empty()) { - ANS_LOGW("invalid parameters"); + ANS_LOGE("invalid parameters"); return {}; } @@ -150,7 +150,7 @@ std::shared_ptr AnsImageUtil::CreatePixelMap(const std::string std::set formats; auto ret = imageSource->GetSupportedFormats(formats); if (ret) { - ANS_LOGE("image packer get supported format failed, ret : %{public}u", ret); + ANS_LOGE("image packer get supported format failed, ret:%{public}u", ret); return {}; } @@ -167,7 +167,7 @@ std::shared_ptr AnsImageUtil::CreatePixelMap(const std::string bool AnsImageUtil::ImageScale(const std::shared_ptr &pixelMap, int32_t width, int32_t height) { if (!pixelMap || width == 0 || height == 0) { - ANS_LOGW("invalid parameters"); + ANS_LOGE("invalid parameters"); return false; } @@ -186,7 +186,7 @@ bool AnsImageUtil::ImageScale(const std::shared_ptr &pixelMap, std::shared_ptr AnsImageUtil::CreatePixelMapByString(const std::string &imagedata) { if (imagedata.empty()) { - ANS_LOGW("invalid parameters"); + ANS_LOGE("invalid parameters"); return {}; } diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index d48a2998f..f199dd41d 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -84,7 +84,7 @@ ErrCode AnsNotification::AddNotificationSlots(const std::vector proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); @@ -1478,7 +1478,7 @@ ErrCode AnsNotification::CheckImageSize(const NotificationRequest &request) auto bigIcon = request.GetBigIcon(); if (NotificationRequest::CheckImageOverSizeForPixelMap(bigIcon, MAX_ICON_SIZE)) { request.ResetBigIcon(); - ANS_LOGI("The size of big icon exceeds limit"); + ANS_LOGW("The size of big icon exceeds limit"); } return ERR_OK; diff --git a/frameworks/core/src/listener/ans_subscriber_listener.cpp b/frameworks/core/src/listener/ans_subscriber_listener.cpp index 5b4ed3536..6621e30a9 100644 --- a/frameworks/core/src/listener/ans_subscriber_listener.cpp +++ b/frameworks/core/src/listener/ans_subscriber_listener.cpp @@ -33,7 +33,7 @@ void SubscriberListener::OnConnected() HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnConnected(); @@ -44,7 +44,7 @@ void SubscriberListener::OnDisconnected() HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnDisconnected(); @@ -56,7 +56,7 @@ void SubscriberListener::OnConsumed( HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } @@ -86,7 +86,7 @@ void SubscriberListener::OnCanceled( HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } if (notificationMap == nullptr) { @@ -103,7 +103,7 @@ void SubscriberListener::OnBatchCanceled(const std::vector> & { auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } std::vector> notificationList; @@ -125,7 +125,7 @@ void SubscriberListener::OnCanceledList(const std::vector> &n HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } if (subscriber->HasOnBatchCancelCallback()) { @@ -141,7 +141,7 @@ void SubscriberListener::OnUpdated(const sptr ¬ificat { auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnUpdate(std::make_shared(*notificationMap)); @@ -151,7 +151,7 @@ void SubscriberListener::OnDoNotDisturbDateChange(const sptrOnDoNotDisturbDateChange(std::make_shared(*date)); @@ -163,7 +163,7 @@ void SubscriberListener::OnEnabledNotificationChanged( HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnEnabledNotificationChanged(std::make_shared(*callbackData)); @@ -174,7 +174,7 @@ void SubscriberListener::OnBadgeChanged(const sptr &bad HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnBadgeChanged(std::make_shared(*badgeData)); @@ -186,7 +186,7 @@ void SubscriberListener::OnBadgeEnabledChanged( HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnBadgeEnabledChanged(callbackData); @@ -195,10 +195,10 @@ void SubscriberListener::OnBadgeEnabledChanged( void SubscriberListener::OnApplicationInfoNeedChanged(const std::string& bundleName) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - ANS_LOGE("OnApplicationInfoNeedChanged SubscriberListener 1."); + ANS_LOGD("OnApplicationInfoNeedChanged SubscriberListener 1."); auto subscriber = subscriber_.lock(); if (subscriber == nullptr) { - ANS_LOGW("Subscriber is nullptr"); + ANS_LOGE("Subscriber is nullptr"); return; } subscriber->OnApplicationInfoNeedChanged(bundleName); diff --git a/frameworks/core/src/listener/ans_subscriber_proxy.cpp b/frameworks/core/src/listener/ans_subscriber_proxy.cpp index a4f53f45f..e1ba775b8 100644 --- a/frameworks/core/src/listener/ans_subscriber_proxy.cpp +++ b/frameworks/core/src/listener/ans_subscriber_proxy.cpp @@ -411,7 +411,7 @@ void AnsSubscriberProxy::OnApplicationInfoNeedChanged(const std::string& bundleN } if (!data.WriteString(bundleName)) { - ANS_LOGE("Write callback data failed."); + ANS_LOGE("Write bundleName failed."); return; } @@ -433,7 +433,7 @@ ErrCode AnsSubscriberProxy::OnOperationResponse(const sptr notification = data.ReadParcelable(); if (!notification) { - ANS_LOGW("[HandleOnCanceledMap] fail: notification ReadParcelable failed"); + ANS_LOGE("[HandleOnCanceledMap] fail: notification ReadParcelable failed"); return ERR_ANS_PARCELABLE_FAILED; } bool existMap = false; if (!data.ReadBool(existMap)) { - ANS_LOGW("[HandleOnCanceledMap] fail: read existMap failed"); + ANS_LOGE("[HandleOnCanceledMap] fail: read existMap failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -185,14 +185,14 @@ ErrCode AnsSubscriberStub::HandleOnCanceledMap(MessageParcel &data, MessageParce if (existMap) { notificationMap = data.ReadParcelable(); if (notificationMap == nullptr) { - ANS_LOGW("[HandleOnCanceledMap] fail: read NotificationSortingMap failed"); + ANS_LOGE("[HandleOnCanceledMap] fail: read NotificationSortingMap failed"); return ERR_ANS_PARCELABLE_FAILED; } } int32_t reason = 0; if (!data.ReadInt32(reason)) { - ANS_LOGW("[HandleOnCanceledMap] fail: read reason failed"); + ANS_LOGE("[HandleOnCanceledMap] fail: read reason failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -240,7 +240,7 @@ bool AnsSubscriberStub::ReadParcelableVector(std::vector> &parcelableInf { int32_t infoSize = 0; if (!data.ReadInt32(infoSize)) { - ANS_LOGE("read Parcelable size failed."); + ANS_LOGE("read infoSize failed"); return false; } @@ -262,7 +262,7 @@ ErrCode AnsSubscriberStub::HandleOnUpdated(MessageParcel &data, MessageParcel &r { sptr notificationMap = data.ReadParcelable(); if (!notificationMap) { - ANS_LOGW("[HandleOnUpdated] fail: notificationMap ReadParcelable failed"); + ANS_LOGE("[HandleOnUpdated] fail: notificationMap ReadParcelable failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -274,7 +274,7 @@ ErrCode AnsSubscriberStub::HandleOnDoNotDisturbDateChange(MessageParcel &data, M { sptr date = data.ReadParcelable(); if (!date) { - ANS_LOGW("[HandleOnDoNotDisturbDateChange] fail: date ReadParcelable failed"); + ANS_LOGE("[HandleOnDoNotDisturbDateChange] fail: date ReadParcelable failed"); return ERR_ANS_PARCELABLE_FAILED; } OnDoNotDisturbDateChange(date); @@ -285,7 +285,7 @@ ErrCode AnsSubscriberStub::HandleOnEnabledNotificationChanged(MessageParcel &dat { sptr callbackData = data.ReadParcelable(); if (!callbackData) { - ANS_LOGW("[HandleOnEnabledNotificationChanged] fail: callbackData ReadParcelable failed"); + ANS_LOGE("[HandleOnEnabledNotificationChanged] fail: callbackData ReadParcelable failed"); return ERR_ANS_PARCELABLE_FAILED; } OnEnabledNotificationChanged(callbackData); @@ -296,7 +296,7 @@ ErrCode AnsSubscriberStub::HandleOnBadgeChanged(MessageParcel &data, MessageParc { sptr callbackData = data.ReadParcelable(); if (!callbackData) { - ANS_LOGW("[HandleOnBadgeChanged] fail: callbackData ReadParcelable failed"); + ANS_LOGE("[HandleOnBadgeChanged] fail: callbackData ReadParcelable failed"); return ERR_ANS_PARCELABLE_FAILED; } OnBadgeChanged(callbackData); @@ -329,7 +329,7 @@ ErrCode AnsSubscriberStub::HandleOnResponse(MessageParcel &data, MessageParcel & { sptr operationInfo = data.ReadParcelable(); if (!operationInfo) { - ANS_LOGW("notification ReadParcelable failed"); + ANS_LOGE("notification ReadParcelable failed"); return ERR_ANS_PARCELABLE_FAILED; } ErrCode result = OnOperationResponse(operationInfo); diff --git a/frameworks/core/src/manager/ans_manager_death_recipient.cpp b/frameworks/core/src/manager/ans_manager_death_recipient.cpp index 9048f8a58..2eb9bc1d9 100644 --- a/frameworks/core/src/manager/ans_manager_death_recipient.cpp +++ b/frameworks/core/src/manager/ans_manager_death_recipient.cpp @@ -31,13 +31,13 @@ void AnsManagerDeathRecipient::SubscribeSAManager() auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); statusChangeListener_ = new (std::nothrow) AnsManagerDeathRecipient::SystemAbilityStatusChangeListener(); if (samgrProxy == nullptr || statusChangeListener_ == nullptr) { - ANS_LOGI("GetSystemAbilityManager failed or new SystemAbilityStatusChangeListener failed"); + ANS_LOGE("GetSystemAbilityManager failed or new SystemAbilityStatusChangeListener failed"); statusChangeListener_ = nullptr; return; } int32_t ret = samgrProxy->SubscribeSystemAbility(ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, statusChangeListener_); if (ret != ERR_OK) { - ANS_LOGI("SubscribeSystemAbility to sa manager failed"); + ANS_LOGE("SubscribeSystemAbility to sa manager failed"); statusChangeListener_ = nullptr; } } diff --git a/frameworks/core/src/manager/ans_manager_proxy.cpp b/frameworks/core/src/manager/ans_manager_proxy.cpp index 07dcfbf10..b316f16c2 100644 --- a/frameworks/core/src/manager/ans_manager_proxy.cpp +++ b/frameworks/core/src/manager/ans_manager_proxy.cpp @@ -279,7 +279,7 @@ ErrCode AnsManagerProxy::CancelAsBundle( return ERR_ANS_PARCELABLE_FAILED; } if (!data.WriteInt32(userId)) { - ANS_LOGE("[CancelAsBundle] fail: write notificationId failed"); + ANS_LOGE("[CancelAsBundle] fail: write userId failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -621,7 +621,7 @@ ErrCode AnsManagerProxy::TriggerLocalLiveView(const sptr } if (!reply.ReadUint64(num)) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: read enabled failed."); + ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: read num failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -305,7 +305,7 @@ ErrCode AnsManagerProxy::GetSlotByBundle( } if (!data.WriteInt32(slotType)) { - ANS_LOGE("[GetSlotByBundle] fail:: write slotId failed"); + ANS_LOGE("[GetSlotByBundle] fail:: write slotType failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -531,7 +531,7 @@ ErrCode AnsManagerProxy::GetSlotFlagsAsBundle(const sptr= CANCEL_MAX_PARA - 1 && paras.hasOption) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_number) { - ANS_LOGW("Wrong argument type. Number expected."); + ANS_LOGE("Wrong argument type. Number expected."); std::string msg = "Incorrect parameter types.The type of param must be number."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -105,7 +105,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= CANCEL_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM2], 1, ¶s.callback); @@ -123,7 +123,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < CANCEL_GROUP_MIN_PARA) { - ANS_LOGW("Wrong number of arguments"); + ANS_LOGE("Wrong number of arguments"); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -132,7 +132,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[0]: groupName: string NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_string && valuetype != napi_number && valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. String number boolean expected."); + ANS_LOGE("Wrong argument type. String number boolean expected."); std::string msg = "Incorrect parameter types.The type of param must be number or string or boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -156,7 +156,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= CANCEL_GROUP_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM1], 1, ¶s.callback); @@ -414,7 +414,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc > CANCEL_AS_BUNDLEOPTION_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_number) { - ANS_LOGW("Wrong argument type. Number expected."); + ANS_LOGE("Wrong argument type. Number expected."); std::string msg = "Incorrect parameter types.The type of param must be number."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -425,7 +425,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= CANCEL_AS_BUNDLE_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM3], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM3], 1, ¶s.callback); diff --git a/frameworks/js/napi/src/common.cpp b/frameworks/js/napi/src/common.cpp index 4cc0cbc80..caad63fa5 100644 --- a/frameworks/js/napi/src/common.cpp +++ b/frameworks/js/napi/src/common.cpp @@ -484,7 +484,7 @@ napi_value Common::GetNotificationUserInputByInputKey( ANS_LOGI("NotificationUserInput::inputKey = %{public}s", str); userInput = NotificationUserInput::Create(str); if (!userInput) { - ANS_LOGI("Failed to create NotificationUserInput by inputKey=%{public}s", str); + ANS_LOGE("Failed to create NotificationUserInput by inputKey=%{public}s", str); return nullptr; } @@ -1218,7 +1218,7 @@ __attribute__((no_sanitize("cfi"))) napi_value Common::CreateWantAgentByJS(const const std::shared_ptr &agent) { if (agent == nullptr) { - ANS_LOGI("agent is nullptr"); + ANS_LOGE("agent is nullptr"); return nullptr; } diff --git a/frameworks/js/napi/src/common_convert_content.cpp b/frameworks/js/napi/src/common_convert_content.cpp index de61278d5..fed18c519 100644 --- a/frameworks/js/napi/src/common_convert_content.cpp +++ b/frameworks/js/napi/src/common_convert_content.cpp @@ -65,7 +65,7 @@ napi_value Common::SetNotificationContentDetailed(const napi_env &env, const Con std::shared_ptr basicContent = content->GetNotificationContent(); if (basicContent == nullptr) { - ANS_LOGE("content is null"); + ANS_LOGE("basicContent is null"); return ret; } @@ -1574,7 +1574,7 @@ napi_value Common::SetLockScreenPicture( napi_value pictureValue = Media::PixelMapNapi::CreatePixelMap(env, picture); NAPI_CALL(env, napi_typeof(env, pictureValue, &valuetype)); if (valuetype == napi_undefined) { - ANS_LOGI("LockScreenPicture is undefined"); + ANS_LOGE("LockScreenPicture is undefined"); napi_set_named_property(env, result, "lockscreenPicture", NapiGetNull(env)); } else { napi_set_named_property(env, result, "lockscreenPicture", pictureValue); diff --git a/frameworks/js/napi/src/common_convert_liveview.cpp b/frameworks/js/napi/src/common_convert_liveview.cpp index dd6bb0205..cf591495c 100644 --- a/frameworks/js/napi/src/common_convert_liveview.cpp +++ b/frameworks/js/napi/src/common_convert_liveview.cpp @@ -117,7 +117,7 @@ napi_value Common::SetNotificationLocalLiveViewContent( bool flag = localLiveViewContent->isFlagExist( NotificationLocalLiveViewContent::LiveViewContentInner::INITIAL_TIME); if (!SetTime(env, localLiveViewContent->GetTime(), time, flag)) { - ANS_LOGE("SetMessageUser call failed"); + ANS_LOGE("SetTime call failed"); return NapiGetBoolean(env, false); } napi_set_named_property(env, result, "time", time); @@ -151,7 +151,7 @@ napi_value Common::SetCapsule(const napi_env &env, const NotificationCapsule &ca iconResult = Media::PixelMapNapi::CreatePixelMap(env, icon); NAPI_CALL(env, napi_typeof(env, iconResult, &valuetype)); if (valuetype == napi_undefined) { - ANS_LOGW("iconResult is undefined"); + ANS_LOGE("iconResult is undefined"); napi_set_named_property(env, result, "icon", NapiGetNull(env)); } else { napi_set_named_property(env, result, "icon", iconResult); @@ -734,7 +734,7 @@ napi_value Common::GetNotificationIconButton( // icon?: Resource auto resource = std::make_shared(); if (Common::GetResourceObject(env, resource, iconResource) == nullptr) { - ANS_LOGI("Invalid icon resource object or not resource."); + ANS_LOGE("Invalid icon resource object or not resource."); } else { button.SetIconResource(resource); } diff --git a/frameworks/js/napi/src/common_convert_request.cpp b/frameworks/js/napi/src/common_convert_request.cpp index 1b118c77d..bf3bbfdba 100644 --- a/frameworks/js/napi/src/common_convert_request.cpp +++ b/frameworks/js/napi/src/common_convert_request.cpp @@ -247,7 +247,7 @@ napi_value Common::SetNotificationRequestByPixelMap( smallIconResult = Media::PixelMapNapi::CreatePixelMap(env, littleIcon); NAPI_CALL(env, napi_typeof(env, smallIconResult, &valuetype)); if (valuetype == napi_undefined) { - ANS_LOGI("smallIconResult is undefined"); + ANS_LOGE("smallIconResult is undefined"); napi_set_named_property(env, result, "smallIcon", NapiGetNull(env)); } else { napi_set_named_property(env, result, "smallIcon", smallIconResult); @@ -262,7 +262,7 @@ napi_value Common::SetNotificationRequestByPixelMap( largeIconResult = Media::PixelMapNapi::CreatePixelMap(env, largeIcon); NAPI_CALL(env, napi_typeof(env, largeIconResult, &valuetype)); if (valuetype == napi_undefined) { - ANS_LOGI("largeIconResult is undefined"); + ANS_LOGE("largeIconResult is undefined"); napi_set_named_property(env, result, "largeIcon", NapiGetNull(env)); } else { napi_set_named_property(env, result, "largeIcon", largeIconResult); @@ -277,7 +277,7 @@ napi_value Common::SetNotificationRequestByPixelMap( overlayIconResult = Media::PixelMapNapi::CreatePixelMap(env, overlayIcon); NAPI_CALL(env, napi_typeof(env, overlayIconResult, &valuetype)); if (valuetype == napi_undefined) { - ANS_LOGI("overlayIconResult is undefined"); + ANS_LOGE("overlayIconResult is undefined"); napi_set_named_property(env, result, "overlayIcon", NapiGetNull(env)); } else { napi_set_named_property(env, result, "overlayIcon", overlayIconResult); @@ -407,7 +407,7 @@ napi_value Common::SetNotificationActionButton( // wantAgent: WantAgent std::shared_ptr agent = actionButton->GetWantAgent(); if (agent == nullptr) { - ANS_LOGI("wantAgent is null"); + ANS_LOGE("wantAgent is null"); napi_set_named_property(env, result, "wantAgent", NapiGetNull(env)); return NapiGetBoolean(env, false); } else { @@ -424,7 +424,7 @@ napi_value Common::SetNotificationActionButton( iconResult = Media::PixelMapNapi::CreatePixelMap(env, icon); NAPI_CALL(env, napi_typeof(env, iconResult, &valuetype)); if (valuetype == napi_undefined) { - ANS_LOGW("icon result is undefined"); + ANS_LOGE("icon result is undefined"); napi_set_named_property(env, result, "icon", NapiGetNull(env)); } else { napi_set_named_property(env, result, "icon", iconResult); @@ -1774,7 +1774,7 @@ napi_value Common::GetNotificationActionButtons( } napi_get_array_length(env, actionButtons, &length); if (length == 0) { - ANS_LOGI("The array is empty."); + ANS_LOGE("The array is empty."); return Common::NapiGetNull(env); } for (size_t i = 0; i < length; i++) { diff --git a/frameworks/js/napi/src/disable_notification.cpp b/frameworks/js/napi/src/disable_notification.cpp index c63d42e2f..fde2792ca 100644 --- a/frameworks/js/napi/src/disable_notification.cpp +++ b/frameworks/js/napi/src/disable_notification.cpp @@ -26,7 +26,7 @@ bool ParseDisabledParameters(const napi_env &env, const napi_value &value, bool napi_valuetype valuetype = napi_undefined; NAPI_CALL_BASE(env, napi_typeof(env, value, &valuetype), false); if (valuetype != napi_boolean) { - ANS_LOGW("wrong argument type. Bool expected"); + ANS_LOGE("wrong argument type. Bool expected"); std::string msg = "Incorrect parameter types.The type of disabled must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return false; diff --git a/frameworks/js/napi/src/display_badge.cpp b/frameworks/js/napi/src/display_badge.cpp index a9bd57375..7b74a609f 100644 --- a/frameworks/js/napi/src/display_badge.cpp +++ b/frameworks/js/napi/src/display_badge.cpp @@ -32,7 +32,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < ENABLE_BADGE_DISPLAYED_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -41,7 +41,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Wrong argument type. Object expected"); + ANS_LOGE("Wrong argument type. Object expected"); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -57,7 +57,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: enable NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -68,7 +68,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= ENABLE_BADGE_DISPLAYED_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM2], 1, ¶ms.callback); @@ -87,7 +87,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < IS_DISPLAY_BADGE_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -97,7 +97,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if ((valuetype != napi_function) && (valuetype != napi_object)) { - ANS_LOGW("Wrong argument type. Function or object expected, %{public}d", valuetype); + ANS_LOGE("Wrong argument type. Function or object expected, %{public}d", valuetype); std::string msg = "Incorrect parameter types.The type of param must be function or object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -119,7 +119,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= IS_DISPLAY_BADGE_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM1], 1, ¶ms.callback); diff --git a/frameworks/js/napi/src/distributed.cpp b/frameworks/js/napi/src/distributed.cpp index fd8669054..bec1594eb 100644 --- a/frameworks/js/napi/src/distributed.cpp +++ b/frameworks/js/napi/src/distributed.cpp @@ -39,7 +39,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < SET_STATUS_PARA_NUM) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -48,7 +48,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[0]: deviceType: string NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Argument type error. String expected."); + ANS_LOGE("Argument type error. String expected."); std::string msg = "Incorrect parameter deviceType. The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -67,7 +67,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: status: number NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_number) { - ANS_LOGW("Argument type error. number expected."); + ANS_LOGE("Argument type error. number expected."); std::string msg = "Incorrect parameter status. The type of param must be number."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; diff --git a/frameworks/js/napi/src/distributed_operation_callback.cpp b/frameworks/js/napi/src/distributed_operation_callback.cpp index 93dcb1832..aa7de7d2f 100644 --- a/frameworks/js/napi/src/distributed_operation_callback.cpp +++ b/frameworks/js/napi/src/distributed_operation_callback.cpp @@ -32,7 +32,7 @@ void DistributedOperationCallback::OnOperationCallback(const int32_t operationRe { OperationOnCallBack *operationOnCallBack = new (std::nothrow) OperationOnCallBack(); if (operationOnCallBack == nullptr) { - ANS_LOGW("new operationOnCallBack failed"); + ANS_LOGE("new operationOnCallBack failed"); return; } @@ -45,19 +45,19 @@ void DistributedOperationCallback::OnOperationCallback(const int32_t operationRe operationOnCallBack->deferred = asyncCallbackInfo_.deferred; bool bRet = UvQueue::Call(asyncCallbackInfo_.env, operationOnCallBack, UvWorkOnCallBack); if (!bRet) { - ANS_LOGW("DistributedOperationCallback::OnCallBack failed"); + ANS_LOGE("DistributedOperationCallback::OnCallBack failed"); } } void DistributedOperationCallback::UvWorkOnCallBack(uv_work_t *work, int32_t status) { if (work == nullptr) { - ANS_LOGW("UvWorkOnCallBack, work is null"); + ANS_LOGE("UvWorkOnCallBack, work is null"); return; } OperationOnCallBack *callBackPtr = static_cast(work->data); if (callBackPtr == nullptr) { - ANS_LOGW("UvWorkOnCallBack, callBackPtr is null"); + ANS_LOGE("UvWorkOnCallBack, callBackPtr is null"); if (work != nullptr) { delete work; work = nullptr; diff --git a/frameworks/js/napi/src/disturb_mode.cpp b/frameworks/js/napi/src/disturb_mode.cpp index 2274d4c29..fb27497ae 100644 --- a/frameworks/js/napi/src/disturb_mode.cpp +++ b/frameworks/js/napi/src/disturb_mode.cpp @@ -34,14 +34,14 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD // argv[0]: date:type NAPI_CALL(env, napi_has_named_property(env, argv, "type", &hasProperty)); if (!hasProperty) { - ANS_LOGW("Wrong argument type. Property type expected."); + ANS_LOGE("Wrong argument type. Property type expected."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } napi_get_named_property(env, argv, "type", &value); NAPI_CALL(env, napi_typeof(env, value, &valuetype)); if (valuetype != napi_number) { - ANS_LOGW("Wrong argument type. Number expected."); + ANS_LOGE("Wrong argument type. Number expected."); std::string msg = "Incorrect parameter types.The type of param must be number."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -59,7 +59,7 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD // argv[0]: date:begin NAPI_CALL(env, napi_has_named_property(env, argv, "begin", &hasProperty)); if (!hasProperty) { - ANS_LOGW("Wrong argument type. Property type expected."); + ANS_LOGE("Wrong argument type. Property type expected."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -79,7 +79,7 @@ napi_value GetDoNotDisturbDate(const napi_env &env, const napi_value &argv, SetD // argv[0]: date:end NAPI_CALL(env, napi_has_named_property(env, argv, "end", &hasProperty)); if (!hasProperty) { - ANS_LOGW("Wrong argument type. Property type expected."); + ANS_LOGE("Wrong argument type. Property type expected."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -190,7 +190,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < SET_DISTURB_MIN_PARA) { - ANS_LOGW("Wrong argument type. Property type expected."); + ANS_LOGE("Wrong argument type. Property type expected."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -199,7 +199,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Wrong argument type. Property type expected."); + ANS_LOGE("Wrong argument type. Property type expected."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -212,7 +212,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= SET_DISTURB_MAX_PARA - 1) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if ((valuetype != napi_number) && (valuetype != napi_function)) { - ANS_LOGW("Wrong argument type. Function or object expected. Excute promise."); + ANS_LOGE("Wrong argument type. Function or object expected. Excute promise."); return Common::NapiGetNull(env); } diff --git a/frameworks/js/napi/src/enable_notification.cpp b/frameworks/js/napi/src/enable_notification.cpp index 5f5d9bc95..d4fa19cd4 100644 --- a/frameworks/js/napi/src/enable_notification.cpp +++ b/frameworks/js/napi/src/enable_notification.cpp @@ -38,7 +38,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < ENABLE_NOTIFICATION_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -47,7 +47,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Parameter type error. Object expected."); + ANS_LOGE("Parameter type error. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -62,7 +62,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: enable NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -73,7 +73,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= ENABLE_NOTIFICATION_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM2], 1, ¶ms.callback); @@ -99,7 +99,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if ((valuetype != napi_object) && (valuetype != napi_number) && (valuetype != napi_function)) { - ANS_LOGW("Parameter type error. Function or object expected. Excute promise."); + ANS_LOGE("Parameter type error. Function or object expected. Excute promise."); return Common::NapiGetNull(env); } if (valuetype == napi_object) { @@ -121,7 +121,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= IS_NOTIFICATION_ENABLE_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM1], 1, ¶ms.callback); diff --git a/frameworks/js/napi/src/manager/napi_disable_notification.cpp b/frameworks/js/napi/src/manager/napi_disable_notification.cpp index eb80040ac..d6588d7bf 100644 --- a/frameworks/js/napi/src/manager/napi_disable_notification.cpp +++ b/frameworks/js/napi/src/manager/napi_disable_notification.cpp @@ -23,7 +23,7 @@ namespace NotificationNapi { napi_value NapiDisableNotificationFeature(napi_env env, napi_callback_info info) { #ifdef DISABLE_NOTIFICATION_FEATURE_ENABLE - ANS_LOGD("enter NapiDisableNotificationFeature"); + ANS_LOGD("enter"); NotificationDisable paras; if (!ParseDisableNotificationParameters(env, info, paras)) { Common::NapiThrow(env, ERROR_PARAM_INVALID); @@ -45,7 +45,7 @@ napi_value NapiDisableNotificationFeature(napi_env env, napi_callback_info info) // Asynchronous function call napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - ANS_LOGD("Napi disable notification Feature work excute."); + ANS_LOGD("NapiDisableNotificationFeature work excute"); AsyncCallbackInfoDisableNotification *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { @@ -54,15 +54,17 @@ napi_value NapiDisableNotificationFeature(napi_env env, napi_callback_info info) } }, [](napi_env env, napi_status status, void *data) { - ANS_LOGD("Napi disable notification Feature work complete."); + ANS_LOGD("NapiDisableNotificationFeature work complete"); AsyncCallbackInfoDisableNotification *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::CreateReturnValue(env, asynccallbackinfo->info, Common::NapiGetNull(env)); + ANS_LOGD("Delete NapiDisableNotificationFeature asyncWork"); napi_delete_async_work(env, asynccallbackinfo->asyncWork); delete asynccallbackinfo; asynccallbackinfo = nullptr; } + ANS_LOGD("NapiDisableNotificationFeature work complete end"); }, (void *)asynccallbackinfo, &asynccallbackinfo->asyncWork); diff --git a/frameworks/js/napi/src/manager/napi_distributed_enable.cpp b/frameworks/js/napi/src/manager/napi_distributed_enable.cpp index 3965a2dfd..782b15e69 100644 --- a/frameworks/js/napi/src/manager/napi_distributed_enable.cpp +++ b/frameworks/js/napi/src/manager/napi_distributed_enable.cpp @@ -38,7 +38,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < SET_DISTRIBUTED_ENABLE_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -47,7 +47,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Parameter type error. Object expected."); + ANS_LOGE("Parameter type error. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -62,7 +62,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: deviceType NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -81,7 +81,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[2]: enable NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -184,7 +184,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < SET_SMART_REMINDER_ENABLE_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -193,7 +193,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[0]: deviceType NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Wrong argument type. String expected."); + ANS_LOGE("Wrong argument type. String expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -212,7 +212,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: enable NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -344,7 +344,7 @@ napi_value ParseParameters(const napi_env &env, NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if ((setOperation && argc != SET_DISTRIBUTED_ENABLE_BY_SLOT_PARA) || (!setOperation && argc != GET_DISTRIBUTED_ENABLE_BY_SLOT_PARA)) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -353,7 +353,7 @@ napi_value ParseParameters(const napi_env &env, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_number) { - ANS_LOGW("Parameter type error. Object expected."); + ANS_LOGE("Parameter type error. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -371,7 +371,7 @@ napi_value ParseParameters(const napi_env &env, // argv[1]: deviceType NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -395,7 +395,7 @@ napi_value ParseParameters(const napi_env &env, if (setOperation) { NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. Bool expected."); + ANS_LOGE("Wrong argument type. Bool expected."); std::string msg = "Incorrect parameter types.The type of param must be boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; diff --git a/frameworks/js/napi/src/manager/napi_enable_notification.cpp b/frameworks/js/napi/src/manager/napi_enable_notification.cpp index 0ed78bcc4..c59f7278e 100644 --- a/frameworks/js/napi/src/manager/napi_enable_notification.cpp +++ b/frameworks/js/napi/src/manager/napi_enable_notification.cpp @@ -153,14 +153,14 @@ __attribute__((no_sanitize("cfi"))) napi_value NapiIsNotificationEnabled(napi_en asynccallbackinfo->info.errorCode = NotificationHelper::IsAllowedNotify( asynccallbackinfo->params.option, asynccallbackinfo->allowed); } else if (asynccallbackinfo->params.hasUserId) { - ANS_LOGI("userId : %{public}d", asynccallbackinfo->params.userId); + ANS_LOGI("userId:%{public}d", asynccallbackinfo->params.userId); asynccallbackinfo->info.errorCode = NotificationHelper::IsAllowedNotify( asynccallbackinfo->params.userId, asynccallbackinfo->allowed); } else { asynccallbackinfo->info.errorCode = NotificationHelper::IsAllowedNotifySelf( asynccallbackinfo->allowed); } - ANS_LOGI("asynccallbackinfo->info.errorCode : %{public}d, allowed : %{public}d", + ANS_LOGI("asynccallbackinfo->info.errorCode:%{public}d, allowed:%{public}d", asynccallbackinfo->info.errorCode, asynccallbackinfo->allowed); } }, @@ -213,7 +213,7 @@ napi_value NapiIsNotificationEnabledSelf(napi_env env, napi_callback_info info) asynccallbackinfo->info.errorCode = NotificationHelper::IsAllowedNotifySelf(asynccallbackinfo->allowed); } - ANS_LOGD("asynccallbackinfo->info.errorCode = %{public}d, allowed = %{public}d", + ANS_LOGD("asynccallbackinfo->info.errorCode:%{public}d, allowed:%{public}d", asynccallbackinfo->info.errorCode, asynccallbackinfo->allowed); } }, @@ -291,7 +291,7 @@ napi_value NapiRequestEnableNotification(napi_env env, napi_callback_info info) bool canPop = false; std::string bundleName {""}; ErrCode errCode = NotificationHelper::CanPopEnableNotificationDialog(client, canPop, bundleName); - ANS_LOGI("CanPopEnableNotificationDialog result , errCode = %{public}d , canPop = %{public}d", + ANS_LOGI("CanPopEnableNotificationDialog result, errCode:%{public}d, canPop:%{public}d", errCode, canPop); if (canPop == false) { asynccallbackinfo->info.errorCode = errCode; diff --git a/frameworks/js/napi/src/manager/napi_get_active.cpp b/frameworks/js/napi/src/manager/napi_get_active.cpp index 038451ee5..02ac507e6 100644 --- a/frameworks/js/napi/src/manager/napi_get_active.cpp +++ b/frameworks/js/napi/src/manager/napi_get_active.cpp @@ -299,7 +299,7 @@ napi_value ParseGetLiveViewFilter(const napi_env &env, const napi_value &obj, Li // bundle napi_value result = AppExecFwk::GetPropertyValueByPropertyName(env, obj, "bundle", napi_object); if (result == nullptr) { - ANS_LOGW("Failed to get bundle from params."); + ANS_LOGE("Failed to get bundle from params."); return nullptr; } auto retValue = Common::GetBundleOption(env, result, filter.bundle); @@ -311,7 +311,7 @@ napi_value ParseGetLiveViewFilter(const napi_env &env, const napi_value &obj, Li // notificationKey result = AppExecFwk::GetPropertyValueByPropertyName(env, obj, "notificationKey", napi_object); if (result == nullptr) { - ANS_LOGW("Failed to get notificationKeys from params."); + ANS_LOGE("Failed to get notificationKeys from params."); return nullptr; } retValue = Common::GetNotificationKey(env, result, filter.notificationKey); @@ -322,7 +322,7 @@ napi_value ParseGetLiveViewFilter(const napi_env &env, const napi_value &obj, Li // extraInfoKeys if (AppExecFwk::IsExistsByPropertyName(env, obj, "extraInfoKeys") == false) { - ANS_LOGI("No extraInfoKeys in filter"); + ANS_LOGW("No extraInfoKeys in filter"); return Common::NapiGetNull(env); } diff --git a/frameworks/js/napi/src/manager/napi_push_callback.cpp b/frameworks/js/napi/src/manager/napi_push_callback.cpp index 066c6796a..e93a6bbeb 100644 --- a/frameworks/js/napi/src/manager/napi_push_callback.cpp +++ b/frameworks/js/napi/src/manager/napi_push_callback.cpp @@ -283,7 +283,7 @@ int32_t JSPushCallBack::ConvertFunctionResult(napi_env env, napi_value funcResul return false; } - ANS_LOGI("code : %{public}d ,message : %{public}s", code, message.c_str()); + ANS_LOGI("code:%{public}d, message:%{public}s", code, message.c_str()); return code; } } // namespace Notification diff --git a/frameworks/js/napi/src/manager/napi_remove_group.cpp b/frameworks/js/napi/src/manager/napi_remove_group.cpp index cf504b265..7bac7aa36 100644 --- a/frameworks/js/napi/src/manager/napi_remove_group.cpp +++ b/frameworks/js/napi/src/manager/napi_remove_group.cpp @@ -35,7 +35,7 @@ napi_value ParseParameters( napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < REMOVE_GROUP_BY_BUNDLE_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -43,7 +43,7 @@ napi_value ParseParameters( // argv[0]: bundle NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Argument type error. Object expected."); + ANS_LOGE("Argument type error. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -58,7 +58,7 @@ napi_value ParseParameters( // argv[1]: groupName: string NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_string && valuetype != napi_number && valuetype != napi_boolean) { - ANS_LOGW("Wrong argument type. String number boolean expected."); + ANS_LOGE("Wrong argument type. String number boolean expected."); std::string msg = "Incorrect parameter types.The type of param must be string or number or boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -138,7 +138,7 @@ napi_value NapiRemoveGroupByBundle(napi_env env, napi_callback_info info) AsyncCallbackInfoRemoveGroupByBundle *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { - ANS_LOGI("option.bundle : %{public}s, option.uid : %{public}d, groupName : %{public}s", + ANS_LOGI("option.bundle:%{public}s, option.uid:%{public}d, groupName:%{public}s", asynccallbackinfo->params.option.GetBundleName().c_str(), asynccallbackinfo->params.option.GetUid(), asynccallbackinfo->params.groupName.c_str()); diff --git a/frameworks/js/napi/src/manager/napi_sync_config.cpp b/frameworks/js/napi/src/manager/napi_sync_config.cpp index c90484908..b023048fe 100644 --- a/frameworks/js/napi/src/manager/napi_sync_config.cpp +++ b/frameworks/js/napi/src/manager/napi_sync_config.cpp @@ -50,7 +50,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value thisVar = nullptr; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < SETADDITION_CONFIG_NUM) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -59,7 +59,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[0]: key: string NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Argument type error. String expected."); + ANS_LOGE("Argument type error. String expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -71,7 +71,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (std::strlen(keyStr) == 0 || (strcmp(keyStr, KEY_NAME) != 0 && strcmp(keyStr, RING_LIST_KEY_NAME) != 0 && strcmp(keyStr, CTRL_LIST_KEY_NAME) != 0)) { - ANS_LOGW("Argument type error. String expected."); + ANS_LOGE("Argument type error. String expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -80,7 +80,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: value: string NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Argument type error. String expected."); + ANS_LOGE("Argument type error. String expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; diff --git a/frameworks/js/napi/src/publish.cpp b/frameworks/js/napi/src/publish.cpp index 7ccf804d0..398713471 100644 --- a/frameworks/js/napi/src/publish.cpp +++ b/frameworks/js/napi/src/publish.cpp @@ -38,7 +38,7 @@ napi_value GetCallback(const napi_env &env, const napi_value &value, ParametersI napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, value, &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, value, 1, ¶ms.callback); @@ -54,7 +54,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value argv[PUBLISH_NOTIFICATION_MAX] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); if (argc < 1) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -62,7 +62,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Argument type error. Object expected."); + ANS_LOGE("Argument type error. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -77,7 +77,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, if (argc >= PUBLISH_NOTIFICATION_MAX - 1) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if ((valuetype != napi_number) && (valuetype != napi_function)) { - ANS_LOGW("Wrong argument type. Function or object expected. Execute promise"); + ANS_LOGE("Wrong argument type. Function or object expected. Execute promise"); return Common::NapiGetNull(env); } @@ -198,7 +198,7 @@ napi_value GetStringProperty( napi_get_named_property(env, content, property.data(), &value); NAPI_CALL(env, napi_typeof(env, value, &valuetype)); if (valuetype != napi_string) { - ANS_LOGW("Wrong argument type. String expected."); + ANS_LOGE("Wrong argument type. String expected."); std::string msg = "Incorrect parameter types.The type of param must be string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -222,7 +222,7 @@ napi_value GetObjectProperty( napi_get_named_property(env, content, property.data(), &result); NAPI_CALL(env, napi_typeof(env, result, &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Wrong argument type. Object expected."); + ANS_LOGE("Wrong argument type. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -238,7 +238,7 @@ napi_value ParseShowOptions(const napi_env &env, const napi_callback_info &info, napi_value argv[SHOW_NOTIFICATION_MAX] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); if (argc == 0) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); return nullptr; } @@ -246,7 +246,7 @@ napi_value ParseShowOptions(const napi_env &env, const napi_callback_info &info, napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Wrong argument type. Object expected."); + ANS_LOGE("Wrong argument type. Object expected."); return nullptr; } @@ -312,13 +312,13 @@ napi_value ShowNotification(napi_env env, napi_callback_info info) ParametersInfoPublish params; if (ParseShowOptions(env, info, params) == nullptr) { - ANS_LOGW("parse showOptions failed"); + ANS_LOGE("parse showOptions failed"); return Common::NapiGetUndefined(env); } auto asynccallbackinfo = new (std::nothrow) AsyncCallbackInfoPublish {.env = env, .asyncWork = nullptr}; if (!asynccallbackinfo) { - ANS_LOGW("failed to create asynccallbackinfo"); + ANS_LOGE("failed to create asynccallbackinfo"); return Common::JSParaError(env, params.callback); } @@ -382,7 +382,7 @@ napi_value ParsePublishAsBundleParameters( napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Wrong argument type. Object expected."); + ANS_LOGE("Wrong argument type. Object expected."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -408,7 +408,7 @@ napi_value ParsePublishAsBundleParameters( // argv[1] : bundleName / NotificationRequest NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_string && valuetype != napi_number && valuetype != napi_boolean && valuetype != napi_object) { - ANS_LOGW("Error argument type. String number boolean object expected."); + ANS_LOGE("Error argument type. String number boolean object expected."); std::string msg = "Incorrect parameter types.The type of param must be string or number or boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -438,7 +438,7 @@ napi_value ParsePublishAsBundleParameters( if (argc > PUBLISH_AS_BUNDLEOPTION_MAX) { NAPI_CALL(env, napi_typeof(env, argv[PARAM2], &valuetype)); if (valuetype != napi_number) { - ANS_LOGW("Wrong argument type. Number expected."); + ANS_LOGE("Wrong argument type. Number expected."); std::string msg = "Incorrect parameter types.The type of param must be number."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; diff --git a/frameworks/js/napi/src/reminder/publish.cpp b/frameworks/js/napi/src/reminder/publish.cpp index 3ce96921d..124ec328f 100644 --- a/frameworks/js/napi/src/reminder/publish.cpp +++ b/frameworks/js/napi/src/reminder/publish.cpp @@ -77,7 +77,7 @@ napi_value GetCallback(const napi_env &env, const napi_value &value, AsyncCallba napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, value, &valuetype)); if (valuetype != napi_function) { - ANSR_LOGW("Wrong argument type. Function expected."); + ANSR_LOGE("Wrong argument type. Function expected."); return nullptr; } napi_create_reference(env, value, 1, &asyncCallbackInfo.callback); @@ -97,7 +97,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, napi_value argv[PUBLISH_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc < 1) { - ANSR_LOGW("Wrong number of arguments"); + ANSR_LOGE("Wrong number of arguments"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -107,7 +107,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[1]: callback if (argc >= PUBLISH_PARAM_LEN) { if (GetCallback(env, argv[1], asyncCallbackInfo) == nullptr) { - ANSR_LOGW("[reminderAgent]GetCallbak returns nullptr"); + ANSR_LOGE("[reminderAgent]GetCallbak returns nullptr"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -117,7 +117,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, // argv[0] : reminderRequest if (ReminderCommon::GetReminderRequest(env, argv[0], params.reminder) == nullptr) { - ANSR_LOGW("[reminderAgent]CreateReminder returns nullptr"); + ANSR_LOGE("[reminderAgent]CreateReminder returns nullptr"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -134,7 +134,7 @@ napi_value ParseSlotParameters(const napi_env &env, const napi_callback_info &in napi_value argv[ADD_SLOT_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc < 1) { - ANSR_LOGW("Wrong number of arguments"); + ANSR_LOGE("Wrong number of arguments"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -144,7 +144,7 @@ napi_value ParseSlotParameters(const napi_env &env, const napi_callback_info &in // argv[1]: callback if (argc >= ADD_SLOT_PARAM_LEN) { if (GetCallback(env, argv[1], asyncCallbackInfo) == nullptr) { - ANSR_LOGW("GetCallbak returns nullptr"); + ANSR_LOGE("GetCallbak returns nullptr"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -159,7 +159,7 @@ napi_value ParseSlotParameters(const napi_env &env, const napi_callback_info &in int32_t propertyVal = 0; if (!ReminderCommon::GetInt32(env, argv[0], propertyKey, propertyVal, false) && !ReminderCommon::GetInt32(env, argv[0], propertyNewKey, propertyVal, false)) { - ANSR_LOGW("Failed to get valid slot type."); + ANSR_LOGE("Failed to get valid slot type."); params.errCode = ERR_REMINDER_INVALID_PARAM; if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); @@ -168,7 +168,7 @@ napi_value ParseSlotParameters(const napi_env &env, const napi_callback_info &in } if (!NotificationNapi::AnsEnumUtil::SlotTypeJSToC(NotificationNapi::SlotType(propertyVal), params.inType)) { - ANSR_LOGW("Failed to get valid slot type"); + ANSR_LOGE("Failed to get valid slot type"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -185,7 +185,7 @@ napi_value ParseCanCelParameter(const napi_env &env, const napi_callback_info &i napi_value argv[CANCEL_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc < 1) { - ANSR_LOGW("Wrong number of arguments"); + ANSR_LOGE("Wrong number of arguments"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -195,7 +195,7 @@ napi_value ParseCanCelParameter(const napi_env &env, const napi_callback_info &i // argv[1]: callback if (argc >= CANCEL_PARAM_LEN) { if (GetCallback(env, argv[1], asyncCallbackInfo) == nullptr) { - ANSR_LOGW("GetCallbak is nullptr"); + ANSR_LOGE("GetCallbak is nullptr"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -212,7 +212,7 @@ napi_value ParseCanCelParameter(const napi_env &env, const napi_callback_info &i return nullptr; } if (reminderId < 0) { - ANSR_LOGW("Param id of cancels Reminder is illegal."); + ANSR_LOGE("Param id of cancels Reminder is illegal."); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -234,7 +234,7 @@ napi_value ParseCanCelAllParameter(const napi_env &env, const napi_callback_info // argv[0]: callback if (argc >= CANCEL_ALL_PARAM_LEN) { if (GetCallback(env, argv[0], asyncCallbackInfo) == nullptr) { - ANSR_LOGW("getCallbak is nullptr"); + ANSR_LOGE("getCallbak is nullptr"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -254,7 +254,7 @@ napi_value ParseGetValidParameter(const napi_env &env, const napi_callback_info // argv[0]: callback if (argc >= GET_VALID_PARAM_LEN) { if (GetCallback(env, argv[0], asyncCallbackInfo) == nullptr) { - ANSR_LOGW("getCallbak is nullptr"); + ANSR_LOGE("getCallbak is nullptr"); if (isThrow) { ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); } @@ -1154,7 +1154,7 @@ napi_value ParseAddExcludeDateParameter(const napi_env &env, const napi_callback napi_value argv[ADD_EXCLUDE_DATE_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc < ADD_EXCLUDE_DATE_PARAM_LEN) { - ANSR_LOGW("Wrong number of arguments"); + ANSR_LOGE("Wrong number of arguments"); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } @@ -1162,12 +1162,12 @@ napi_value ParseAddExcludeDateParameter(const napi_env &env, const napi_callback // argv[0]: reminder id int32_t reminderId = -1; if (!ReminderCommon::GetInt32(env, argv[0], nullptr, reminderId, true)) { - ANSR_LOGW("Parse reminder id failed."); + ANSR_LOGE("Parse reminder id failed."); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } if (reminderId < 0) { - ANSR_LOGW("Param reminder id is illegal."); + ANSR_LOGE("Param reminder id is illegal."); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } @@ -1176,12 +1176,12 @@ napi_value ParseAddExcludeDateParameter(const napi_env &env, const napi_callback // argv[1]: exclude date double date = 0.0; if (!ReminderCommon::GetDate(env, argv[1], nullptr, date)) { - ANSR_LOGW("Parse exclude date failed."); + ANSR_LOGE("Parse exclude date failed."); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } if (date < 0.0) { - ANSR_LOGW("Param exclude date is illegal."); + ANSR_LOGE("Param exclude date is illegal."); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } @@ -1255,7 +1255,7 @@ napi_value ParseReminderIdParameter(const napi_env &env, const napi_callback_inf napi_value argv[DEL_EXCLUDE_DATE_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); if (argc < DEL_EXCLUDE_DATE_PARAM_LEN) { - ANSR_LOGW("Wrong number of arguments"); + ANSR_LOGE("Wrong number of arguments"); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } @@ -1263,12 +1263,12 @@ napi_value ParseReminderIdParameter(const napi_env &env, const napi_callback_inf // argv[0]: reminder id int32_t reminderId = -1; if (!ReminderCommon::GetInt32(env, argv[0], nullptr, reminderId, true)) { - ANSR_LOGW("Parse reminder id failed."); + ANSR_LOGE("Parse reminder id failed."); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } if (reminderId < 0) { - ANSR_LOGW("Param reminder id is illegal."); + ANSR_LOGE("Param reminder id is illegal."); ReminderCommon::HandleErrCode(env, ERR_REMINDER_INVALID_PARAM); return nullptr; } diff --git a/frameworks/js/napi/src/reminder/reminder_common.cpp b/frameworks/js/napi/src/reminder/reminder_common.cpp index ce7037672..682f623ee 100644 --- a/frameworks/js/napi/src/reminder/reminder_common.cpp +++ b/frameworks/js/napi/src/reminder/reminder_common.cpp @@ -36,7 +36,7 @@ napi_value ReminderCommon::GetReminderRequest( napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, value, &valuetype)); if (valuetype != napi_object) { - ANSR_LOGW("Wrong argument type. Object expected."); + ANSR_LOGE("Wrong argument type. Object expected."); return nullptr; } @@ -59,7 +59,7 @@ bool ReminderCommon::GenActionButtons( bool isArray = false; napi_is_array(env, actionButtons, &isArray); if (!isArray) { - ANSR_LOGW("Wrong argument type:%{public}s. array expected.", ACTION_BUTTON); + ANSR_LOGE("Wrong argument type:%{public}s. array expected.", ACTION_BUTTON); return false; } @@ -70,7 +70,7 @@ bool ReminderCommon::GenActionButtons( napi_get_element(env, actionButtons, i, &actionButton); NAPI_CALL_BASE(env, napi_typeof(env, actionButton, &valuetype), false); if (valuetype != napi_object) { - ANSR_LOGW("Wrong element type:%{public}s. object expected.", ACTION_BUTTON); + ANSR_LOGE("Wrong element type:%{public}s. object expected.", ACTION_BUTTON); return false; } @@ -82,12 +82,12 @@ bool ReminderCommon::GenActionButtons( ReminderRequest::ActionButtonType(buttonType) == ReminderRequest::ActionButtonType::SNOOZE || (ReminderRequest::ActionButtonType(buttonType) == ReminderRequest::ActionButtonType::CUSTOM && isSysApp))) { - ANSR_LOGW("Wrong argument type:%{public}s. buttonType not support.", ACTION_BUTTON); + ANSR_LOGE("Wrong argument type:%{public}s. buttonType not support.", ACTION_BUTTON); return false; } HandleActionButtonTitle(env, actionButton, reminder, str, buttonType); } else { - ANSR_LOGW("Parse action button error."); + ANSR_LOGE("Parse action button error."); return false; } } @@ -124,7 +124,7 @@ bool ReminderCommon::IsSelfSystemApp() { auto selfToken = IPCSkeleton::GetSelfTokenID(); if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) { - ANSR_LOGW("This application is not system-app, can not use system-api"); + ANSR_LOGE("This application is not system-app, can not use system-api"); return false; } return true; @@ -193,7 +193,7 @@ bool ReminderCommon::GetValueBucketObject(std::string &valueBucketString, const uint32_t arrlen = 0; napi_status status = napi_get_array_length(env, keys, &arrlen); if (status != napi_ok) { - ANSR_LOGW("get the valuesBucket length err"); + ANSR_LOGE("get the valuesBucket length err"); return false; } for (size_t i = 0; i < arrlen; ++i) { @@ -206,7 +206,7 @@ bool ReminderCommon::GetValueBucketObject(std::string &valueBucketString, const } std::string keyStr = GetStringFromJS(env, key); if (!ValidateString(keyStr)) { - ANSR_LOGW("The key contains separator"); + ANSR_LOGE("The key contains separator"); return false; } // value @@ -220,7 +220,7 @@ bool ReminderCommon::GetValueBucketObject(std::string &valueBucketString, const continue; } if (!ValidateString(valueObject)) { - ANSR_LOGW("The value contains separator"); + ANSR_LOGE("The value contains separator"); return false; } valueBucketString += keyStr + ReminderRequest::SEP_BUTTON_VALUE + type @@ -439,11 +439,11 @@ bool ReminderCommon::CreateReminder( CreateReminderCalendar(env, value, isSysApp, reminder); break; default: - ANSR_LOGW("Reminder type is not support. (type:%{public}d)", reminderType); + ANSR_LOGE("Reminder type is not support. (type:%{public}d)", reminderType); break; } if (reminder == nullptr) { - ANSR_LOGW("Instance of reminder error."); + ANSR_LOGE("Instance of reminder error."); return false; } return true; @@ -456,7 +456,7 @@ napi_value ReminderCommon::GenReminder( bool hasProperty = false; NAPI_CALL(env, napi_has_named_property(env, value, ReminderAgentNapi::REMINDER_TYPE, &hasProperty)); if (!hasProperty) { - ANSR_LOGW("Property %{public}s expected.", ReminderAgentNapi::REMINDER_TYPE); + ANSR_LOGE("Property %{public}s expected.", ReminderAgentNapi::REMINDER_TYPE); return nullptr; } @@ -584,7 +584,7 @@ bool ReminderCommon::GenReminderIntInner( if (GetInt32(env, value, ReminderAgentNapi::SLOT_TYPE, slotType, false)) { enum NotificationConstant::SlotType actureType = NotificationConstant::SlotType::OTHER; if (!NotificationNapi::AnsEnumUtil::SlotTypeJSToC(NotificationNapi::SlotType(slotType), actureType)) { - ANSR_LOGW("slot type not support."); + ANSR_LOGE("slot type not support."); return false; } reminder->SetSlotType(actureType); @@ -651,7 +651,7 @@ bool ReminderCommon::GetStringUtf8(const napi_env &env, const napi_value &value, napi_get_named_property(env, value, propertyName, &result); NAPI_CALL_BASE(env, napi_typeof(env, result, &valuetype), false); if (valuetype != napi_string) { - ANSR_LOGW("Wrong argument type:%{public}s. string expected.", propertyName); + ANSR_LOGE("Wrong argument type:%{public}s. string expected.", propertyName); return false; } NAPI_CALL_BASE(env, napi_get_value_string_utf8(env, result, propertyVal, size - 1, &strLen), false); @@ -667,13 +667,13 @@ bool ReminderCommon::GetBool(const napi_env &env, const napi_value &value, napi_valuetype valuetype = napi_undefined; NAPI_CALL_BASE(env, napi_has_named_property(env, value, propertyName, &hasProperty), false); if (!hasProperty) { - ANSR_LOGW("Does not have argument type:%{public}s.", propertyName); + ANSR_LOGE("Does not have argument type:%{public}s.", propertyName); return false; } napi_get_named_property(env, value, propertyName, &result); NAPI_CALL_BASE(env, napi_typeof(env, result, &valuetype), false); if (valuetype != napi_boolean) { - ANSR_LOGW("Wrong argument type:%{public}s. boolean expected.", propertyName); + ANSR_LOGE("Wrong argument type:%{public}s. boolean expected.", propertyName); return false; } napi_get_value_bool(env, result, &propertyVal); @@ -744,7 +744,7 @@ bool ReminderCommon::GetObject(const napi_env &env, const napi_value &value, napi_get_named_property(env, value, propertyName, &propertyVal); NAPI_CALL_BASE(env, napi_typeof(env, propertyVal, &valuetype), false); if (valuetype != napi_object) { - ANSR_LOGW("Wrong argument type:%{public}s. object expected.", propertyName); + ANSR_LOGE("Wrong argument type:%{public}s. object expected.", propertyName); return false; } return true; @@ -786,7 +786,7 @@ napi_value ReminderCommon::CreateReminderTimer( auto countDownTimeInSeconds = static_cast(propertyCountDownTime); if (propertyCountDownTime <= 0 || countDownTimeInSeconds >= (UINT64_MAX / ReminderRequest::MILLI_SECONDS)) { - ANSR_LOGW("Create countDown reminder fail: designated %{public}s is illegal.", + ANSR_LOGE("Create countDown reminder fail: designated %{public}s is illegal.", ReminderAgentNapi::TIMER_COUNT_DOWN_TIME); return nullptr; } @@ -813,13 +813,13 @@ napi_value ReminderCommon::CreateReminderAlarm( } if ((propertyHourVal < 0) || (propertyHourVal > maxHour)) { - ANSR_LOGW("Create alarm reminder fail: designated %{public}s must between [0, 23].", + ANSR_LOGE("Create alarm reminder fail: designated %{public}s must between [0, 23].", ReminderAgentNapi::ALARM_HOUR); return nullptr; } if ((propertyMinuteVal < 0) || (propertyMinuteVal > maxMinute)) { - ANSR_LOGW("Create alarm reminder fail: designated %{public}s must between [0, 59].", + ANSR_LOGE("Create alarm reminder fail: designated %{public}s must between [0, 59].", ReminderAgentNapi::ALARM_MINUTE); return nullptr; } @@ -841,12 +841,12 @@ napi_value ReminderCommon::CreateReminderCalendar( struct tm dateTime; napi_value dateTimeObj = nullptr; if (!GetObject(env, value, ReminderAgentNapi::CALENDAR_DATE_TIME, dateTimeObj)) { - ANSR_LOGW("Create calendar reminder fail: dateTime must be setted."); + ANSR_LOGE("Create calendar reminder fail: dateTime must be setted."); return nullptr; } if (!ParseLocalDateTime(env, dateTimeObj, dateTime)) { - ANSR_LOGW("Parce DateTime failed."); + ANSR_LOGE("Parce DateTime failed."); return nullptr; } @@ -880,7 +880,7 @@ napi_value ReminderCommon::CreateReminderCalendar( return nullptr; } if (!reminderCalendar->SetEndDateTime(ReminderRequest::GetDurationSinceEpochInMilli(endTime))) { - ANSR_LOGW("The end time must be greater than start time"); + ANSR_LOGE("The end time must be greater than start time"); return nullptr; } } @@ -897,30 +897,30 @@ bool ReminderCommon::CheckCalendarParams(const int32_t &year, const int32_t &mon const int32_t &hour, const int32_t &min) { if ((year < 0) || (year > UINT16_MAX)) { - ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [0, %{public}d]", + ANSR_LOGE("Create calendar reminder fail: designated %{public}s must between [0, %{public}d]", ReminderAgentNapi::CALENDAR_YEAR, UINT16_MAX); return false; } if ((month < 1) || (month > ReminderRequestCalendar::MAX_MONTHS_OF_YEAR)) { - ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [1, %{public}hhu]", + ANSR_LOGE("Create calendar reminder fail: designated %{public}s must between [1, %{public}hhu]", ReminderAgentNapi::CALENDAR_MONTH, ReminderRequestCalendar::MAX_MONTHS_OF_YEAR); return false; } uint8_t maxDaysOfMonth = ReminderRequestCalendar::GetDaysOfMonth(static_cast(year), month); if ((day < 1) || (day > maxDaysOfMonth)) { - ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [1, %{public}hhu]", + ANSR_LOGE("Create calendar reminder fail: designated %{public}s must between [1, %{public}hhu]", ReminderAgentNapi::CALENDAR_DAY, maxDaysOfMonth); return false; } uint8_t maxHour = 23; if (hour < 0 || hour > maxHour) { - ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [0, %{public}hhu]", + ANSR_LOGE("Create calendar reminder fail: designated %{public}s must between [0, %{public}hhu]", ReminderAgentNapi::CALENDAR_HOUR, maxHour); return false; } uint8_t maxMinute = 59; if (min < 0 || min > maxMinute) { - ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [0, %{public}hhu]", + ANSR_LOGE("Create calendar reminder fail: designated %{public}s must between [0, %{public}hhu]", ReminderAgentNapi::CALENDAR_MINUTE, maxMinute); return false; } @@ -992,13 +992,13 @@ napi_value ReminderCommon::ParseInt32Array(const napi_env &env, const napi_value bool isArray = false; napi_is_array(env, result, &isArray); if (!isArray) { - ANSR_LOGW("Property %{public}s is expected to be an array.", propertyName); + ANSR_LOGE("Property %{public}s is expected to be an array.", propertyName); return nullptr; } uint32_t length = 0; napi_get_array_length(env, result, &length); if (length > maxLen) { - ANSR_LOGW("The max length of array of %{public}s is %{public}hhu.", propertyName, maxLen); + ANSR_LOGE("The max length of array of %{public}s is %{public}hhu.", propertyName, maxLen); return nullptr; } napi_valuetype valuetype = napi_undefined; @@ -1008,12 +1008,12 @@ napi_value ReminderCommon::ParseInt32Array(const napi_env &env, const napi_value napi_get_element(env, result, i, &repeatDayVal); NAPI_CALL(env, napi_typeof(env, repeatDayVal, &valuetype)); if (valuetype != napi_number) { - ANSR_LOGW("%{public}s's element is expected to be number.", propertyName); + ANSR_LOGE("%{public}s's element is expected to be number.", propertyName); return nullptr; } napi_get_value_int32(env, repeatDayVal, &propertyDayVal); if (propertyDayVal < 1 || propertyDayVal > static_cast(maxLen)) { - ANSR_LOGW("%{public}s's element must between [1, %{public}d].", propertyName, maxLen); + ANSR_LOGE("%{public}s's element must between [1, %{public}d].", propertyName, maxLen); return nullptr; } propertyVal.push_back(static_cast(propertyDayVal)); diff --git a/frameworks/js/napi/src/remove.cpp b/frameworks/js/napi/src/remove.cpp index dccf0cee8..b6942edbf 100644 --- a/frameworks/js/napi/src/remove.cpp +++ b/frameworks/js/napi/src/remove.cpp @@ -35,13 +35,13 @@ bool ParseRemoveReason(const napi_env &env, const napi_value &value, RemoveParam napi_valuetype valueType = napi_undefined; NAPI_CALL_BASE(env, napi_typeof(env, value, &valueType), false); if (valueType != napi_number) { - ANS_LOGW("RemoveReason valueType unexpected."); + ANS_LOGE("RemoveReason valueType unexpected."); return false; } int32_t removeReason = 0; napi_get_value_int32(env, value, &removeReason); if (!Common::IsValidRemoveReason(removeReason)) { - ANS_LOGW("RemoveReason value unexpected."); + ANS_LOGE("RemoveReason value unexpected."); return false; } params.removeReason = removeReason; @@ -54,7 +54,7 @@ bool ParseCallbackFunc(const napi_env &env, const napi_value &value, napi_valuetype valueType = napi_undefined; NAPI_CALL_BASE(env, napi_typeof(env, value, &valueType), false); if (valueType != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return true; } napi_create_reference(env, value, 1, ¶ms.callback); @@ -71,7 +71,7 @@ bool ParseHashcodeTypeParams( std::vector hashcodes; auto retValue = Common::GetHashCodes(env, argv[PARAM0], hashcodes); if (retValue == nullptr) { - ANS_LOGW("GetHashCodes failed."); + ANS_LOGE("GetHashCodes failed."); return false; } params.hashcodes = hashcodes; @@ -105,7 +105,7 @@ bool ParseHashcodeTypeParams( bool ParseBundleOptionTypeParams(const napi_env &env, napi_value* argv, size_t argc, RemoveParams ¶ms) { if (argc < REMOVE_BY_BUNDLE_AND_KEY_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); return false; } BundleAndKeyInfo bundleInfo {}; @@ -137,7 +137,7 @@ bool ParseParameters(const napi_env &env, const napi_callback_info &info, Remove napi_value thisVar = nullptr; NAPI_CALL_BASE(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL), false); if (argc < REMOVE_MIN_PARA) { - ANS_LOGW("Wrong number of arguments."); + ANS_LOGE("Wrong number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return false; } @@ -147,7 +147,7 @@ bool ParseParameters(const napi_env &env, const napi_callback_info &info, Remove NAPI_CALL_BASE(env, napi_typeof(env, argv[PARAM0], &valueType), false); if ((valueType != napi_string) && (valueType != napi_object) && (valueType != napi_number) && (valueType != napi_boolean) && !isArray) { - ANS_LOGW("Wrong argument type. String or object expected."); + ANS_LOGE("Wrong argument type. String or object expected."); std::string msg = "Incorrect parameter types.The type of param must be object or string."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return false; @@ -175,14 +175,14 @@ napi_value ParseParametersByRemoveAll(const napi_env &env, const napi_callback_i napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if ((valuetype != napi_object) && (valuetype != napi_number) && (valuetype != napi_function)) { - ANS_LOGW("Wrong argument type. Function or object expected. Excute promise."); + ANS_LOGE("Wrong argument type. Function or object expected. Excute promise."); return Common::NapiGetNull(env); } if (valuetype == napi_object) { BundleAndKeyInfo bundleandKeyInfo {}; auto retValue = Common::GetBundleOption(env, argv[PARAM0], bundleandKeyInfo.option); if (retValue == nullptr) { - ANS_LOGW("GetBundleOption failed."); + ANS_LOGE("GetBundleOption failed."); Common::NapiThrow(env, ERROR_PARAM_INVALID, PARAMETER_VERIFICATION_FAILED); return nullptr; } @@ -198,7 +198,7 @@ napi_value ParseParametersByRemoveAll(const napi_env &env, const napi_callback_i if (argc >= REMOVE_ALL_MAX_PARA) { NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_function) { - ANS_LOGW("Callback is not function excute promise."); + ANS_LOGE("Callback is not function excute promise."); return Common::NapiGetNull(env); } napi_create_reference(env, argv[PARAM1], 1, ¶ms.callback); @@ -218,7 +218,7 @@ napi_value ParseParameters( napi_valuetype valuetype = napi_undefined; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL)); if (argc < REMOVE_GROUP_BY_BUNDLE_MIN_PARA) { - ANS_LOGW("Error number of arguments."); + ANS_LOGE("Error number of arguments."); Common::NapiThrow(env, ERROR_PARAM_INVALID, MANDATORY_PARAMETER_ARE_LEFT_UNSPECIFIED); return nullptr; } @@ -226,7 +226,7 @@ napi_value ParseParameters( // argv[0]: bundle NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valuetype)); if (valuetype != napi_object) { - ANS_LOGW("Valuetype is not object."); + ANS_LOGE("Valuetype is not object."); std::string msg = "Incorrect parameter types.The type of param must be object."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; @@ -241,7 +241,7 @@ napi_value ParseParameters( // argv[1]: groupName: string NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valuetype)); if (valuetype != napi_string && valuetype != napi_number && valuetype != napi_boolean) { - ANS_LOGW("Error argument type. String number boolean anticipate."); + ANS_LOGE("Error argument type. String number boolean anticipate."); std::string msg = "Incorrect parameter types.The type of param must be string or number or boolean."; Common::NapiThrow(env, ERROR_PARAM_INVALID, msg); return nullptr; diff --git a/frameworks/reminder/src/reminder_request_factory.cpp b/frameworks/reminder/src/reminder_request_factory.cpp index 9cf50fd57..b257db47c 100644 --- a/frameworks/reminder/src/reminder_request_factory.cpp +++ b/frameworks/reminder/src/reminder_request_factory.cpp @@ -46,12 +46,12 @@ ReminderRequest* ReminderRequestFactory::CreateReminderRequest(ReminderRequest:: break; } default: { - ANSR_LOGW("Create ReminderRequest fail."); + ANSR_LOGE("Create ReminderRequest fail."); return nullptr; } } if (reminderRequest == nullptr) { - ANSR_LOGW("CreateReminderRequest fail."); + ANSR_LOGE("CreateReminderRequest fail."); return nullptr; } reminderRequest->SetReminderType(reminderType); diff --git a/frameworks/reminder/src/reminder_request_timer.cpp b/frameworks/reminder/src/reminder_request_timer.cpp index fb581fde4..9358fc834 100644 --- a/frameworks/reminder/src/reminder_request_timer.cpp +++ b/frameworks/reminder/src/reminder_request_timer.cpp @@ -34,13 +34,13 @@ ReminderRequestTimer::ReminderRequestTimer(uint64_t countDownTimeInSeconds) ReminderRequest::GetDurationSinceEpochInMilli(now) + countDownTimeInSeconds_ * ReminderRequest::MILLI_SECONDS); sptr timer = MiscServices::TimeServiceClient::GetInstance(); if (timer == nullptr) { - ANSR_LOGW("Failed to get boot time due to TimeServiceClient is null."); + ANSR_LOGE("Failed to get boot time due to TimeServiceClient is null."); } else { int64_t bootTimeMs = timer->GetBootTimeMs(); if (bootTimeMs >= 0) { firstRealTimeInMilliSeconds_ = static_cast(bootTimeMs); } else { - ANSR_LOGW("Get boot time error."); + ANSR_LOGE("Get boot time error."); } } } @@ -106,12 +106,12 @@ void ReminderRequestTimer::UpdateTimeInfo(const std::string &description) whenToChangeSysTime_ = ReminderRequest::GetDurationSinceEpochInMilli(now); sptr timer = MiscServices::TimeServiceClient::GetInstance(); if (timer == nullptr) { - ANSR_LOGW("Failed to updateTime info due to TimeServiceClient is null."); + ANSR_LOGE("Failed to updateTime info due to TimeServiceClient is null."); return; } int64_t bootTime = timer->GetBootTimeMs(); if (bootTime < 0) { - ANSR_LOGW("BootTime is illegal"); + ANSR_LOGE("BootTime is illegal"); return; } SetTriggerTimeInMilli(whenToChangeSysTime_ + countDownTimeInSeconds_ * MILLI_SECONDS - diff --git a/frameworks/reminder/src/reminder_service_load_callback.cpp b/frameworks/reminder/src/reminder_service_load_callback.cpp index ffda91ae1..24bfb7283 100644 --- a/frameworks/reminder/src/reminder_service_load_callback.cpp +++ b/frameworks/reminder/src/reminder_service_load_callback.cpp @@ -33,7 +33,7 @@ void ReminderServiceCallback::OnLoadSystemAbilitySuccess( void ReminderServiceCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DelayedSingleton::GetInstance()->LoadSystemAbilityFail(); - ANS_LOGI("on load system ability failed!"); + ANS_LOGE("on load system ability failed!"); } } } \ No newline at end of file diff --git a/interfaces/ndk/src/notification.cpp b/interfaces/ndk/src/notification.cpp index 1b1fe73aa..22ad319de 100644 --- a/interfaces/ndk/src/notification.cpp +++ b/interfaces/ndk/src/notification.cpp @@ -27,7 +27,7 @@ bool OH_Notification_IsNotificationEnabled(void) bool isEnable = false; int32_t result = OHOS::Notification::NotificationHelper::IsAllowedNotifySelf(isEnable); if (result != OHOS::ERR_OK) { - ANS_LOGW("Get notification enable failed %{public}d", result); + ANS_LOGE("Get notification enable failed %{public}d", result); return false; } return isEnable; diff --git a/services/ans/src/advanced_notification_flow_control_service.cpp b/services/ans/src/advanced_notification_flow_control_service.cpp index 2c47d90bf..78ffa1be3 100644 --- a/services/ans/src/advanced_notification_flow_control_service.cpp +++ b/services/ans/src/advanced_notification_flow_control_service.cpp @@ -40,7 +40,7 @@ ErrCode FlowControlService::FlowControl(const std::shared_ptrrequest->IsUpdateOnly()) { - ANS_LOGW("Notification not exists when update"); + ANS_LOGE("Notification not exists when update"); return ERR_ANS_NOTIFICATION_NOT_EXISTS; } result = PublishFlowCtrl(record, callingUid); diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 048b18c74..ac86233fd 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -1343,7 +1343,7 @@ ErrCode AdvancedNotificationService::RemoveEnableNotificationDialog() ErrCode AdvancedNotificationService::RemoveEnableNotificationDialog(const sptr &bundleOption) { - ANS_LOGI("RemoveEnableNotificationDialog %{public}s, %{public}d", + ANS_LOGI("RemoveEnableNotificationDialog %{public}s, %{public}d", bundleOption->GetBundleName().c_str(), bundleOption->GetUid()); if (!CreateDialogManager()) { diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index c8d6900e9..48a818525 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -382,7 +382,7 @@ ErrCode AdvancedNotificationService::AssignToNotificationList(const std::shared_ ErrCode result = ERR_OK; if (!IsNotificationExists(record->notification->GetKey())) { if (record->request->IsUpdateOnly()) { - ANS_LOGW("Notification not exists when update"); + ANS_LOGE("Notification not exists when update"); return ERR_ANS_NOTIFICATION_NOT_EXISTS; } record->request->SetCreateTime(GetCurrentTime()); @@ -2034,27 +2034,27 @@ ErrCode AdvancedNotificationService::RegisterPushCallback( { bool isSubSystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubSystem && !AccessTokenHelper::IsSystemApp()) { - ANS_LOGW("Not system app or SA!"); + ANS_LOGE("Not system app or SA!"); return ERR_ANS_NON_SYSTEM_APP; } if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER)) { - ANS_LOGW("Not have OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER approval!"); + ANS_LOGE("Not have OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER approval!"); return ERR_ANS_PERMISSION_DENIED; } if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { - ANS_LOGW("Not have OHOS_PERMISSION_NOTIFICATION_CONTROLLER Permission!"); + ANS_LOGE("Not have OHOS_PERMISSION_NOTIFICATION_CONTROLLER Permission!"); return ERR_ANS_PERMISSION_DENIED; } if (pushCallback == nullptr) { - ANS_LOGW("pushCallback is null."); + ANS_LOGE("pushCallback is null."); return ERR_INVALID_VALUE; } if (notificationCheckRequest == nullptr) { - ANS_LOGW("notificationCheckRequest is null."); + ANS_LOGE("notificationCheckRequest is null."); return ERR_INVALID_VALUE; } @@ -2091,17 +2091,17 @@ ErrCode AdvancedNotificationService::RegisterPushCallback( ErrCode AdvancedNotificationService::UnregisterPushCallback() { if (!AccessTokenHelper::IsSystemApp()) { - ANS_LOGW("Not system app!"); + ANS_LOGE("Not system app!"); return ERR_ANS_NON_SYSTEM_APP; } if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER)) { - ANS_LOGW("Not have OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER Permission!"); + ANS_LOGE("Not have OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER Permission!"); return ERR_ANS_PERMISSION_DENIED; } if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { - ANS_LOGW("Not have OHOS_PERMISSION_NOTIFICATION_CONTROLLER Permission!"); + ANS_LOGE("Not have OHOS_PERMISSION_NOTIFICATION_CONTROLLER Permission!"); return ERR_ANS_PERMISSION_DENIED; } @@ -2140,7 +2140,7 @@ bool AdvancedNotificationService::IsNeedPushCheck(const sptrGetUid(), IPCSkeleton::GetCallingUid()); } else { if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { - ANS_LOGW("Get live view by filter failed because check permission is false."); + ANS_LOGE("Get live view by filter failed because check permission is false."); return ERR_ANS_PERMISSION_DENIED; } } @@ -337,7 +337,7 @@ void AdvancedNotificationService::SetAgentNotification(sptr auto bundleManager = BundleManagerHelper::GetInstance(); int32_t activeUserId = -1; if (OsAccountManagerHelper::GetInstance().GetCurrentActiveUserId(activeUserId) != ERR_OK) { - ANSR_LOGW("Failed to get active user id!"); + ANSR_LOGE("Failed to get active user id!"); return; } @@ -540,7 +540,7 @@ void AdvancedNotificationService::OnBundleRemoved(const sptrRemoveNotificationForBundle(bundleOption); if (result != ERR_OK) { - ANS_LOGW("NotificationPreferences::RemoveNotificationForBundle failed: %{public}d", result); + ANS_LOGE("NotificationPreferences::RemoveNotificationForBundle failed: %{public}d", result); } #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED DistributedPreferences::GetInstance()->DeleteDistributedBundleInfo(bundleOption); diff --git a/services/ans/src/ans_manager_stub.cpp b/services/ans/src/ans_manager_stub.cpp index a427643e2..08303d401 100644 --- a/services/ans/src/ans_manager_stub.cpp +++ b/services/ans/src/ans_manager_stub.cpp @@ -732,7 +732,7 @@ ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessagePar } if (!reply.WriteUint64(num)) { - ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write enabled failed, ErrCode=%{public}d", result); + ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write num failed, ErrCode=%{public}d", result); return ERR_ANS_PARCELABLE_FAILED; } return ERR_OK; @@ -748,7 +748,7 @@ ErrCode AnsManagerStub::HandleSetSlotFlagsAsBundle(MessageParcel &data, MessageP int32_t slotFlags = 0; if (!data.ReadInt32(slotFlags)) { - ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: read notification failed"); + ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: read slotFlags failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -777,7 +777,7 @@ ErrCode AnsManagerStub::HandleGetSlotFlagsAsBundle(MessageParcel &data, MessageP } if (!reply.WriteUint32(slotFlags)) { - ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: write enabled failed, ErrCode=%{public}d", result); + ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: write slotFlags failed, ErrCode=%{public}d", result); return ERR_ANS_PARCELABLE_FAILED; } @@ -937,7 +937,7 @@ ErrCode AnsManagerStub::HandleSetNotificationBadgeNum(MessageParcel &data, Messa { int32_t num = 0; if (!data.ReadInt32(num)) { - ANS_LOGE("[HandleSetNotificationBadgeNum] fail: read notification failed"); + ANS_LOGE("[HandleSetNotificationBadgeNum] fail: read num failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -2106,7 +2106,7 @@ ErrCode AnsManagerStub::HandleSetBadgeNumber(MessageParcel &data, MessageParcel ErrCode result = SetBadgeNumber(badgeNumber, appInstanceKey); if (!reply.WriteInt32(result)) { - ANSR_LOGE("Write badge number failed"); + ANSR_LOGE("Write result failed"); return ERR_ANS_PARCELABLE_FAILED; } return result; @@ -2255,7 +2255,7 @@ ErrCode AnsManagerStub::HandleSetDistributedEnabledByBundle(MessageParcel &data, std::string deviceType; if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceId failed."); + ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceType failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2326,7 +2326,7 @@ ErrCode AnsManagerStub::HandleIsDistributedEnabledByBundle(MessageParcel &data, std::string deviceType; if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: read deviceId failed."); + ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: read deviceType failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2371,7 +2371,7 @@ ErrCode AnsManagerStub::HandleSetSmartReminderEnabled(MessageParcel &data, Messa ANS_LOGD("enter"); std::string deviceType; if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetSmartReminderEnabled] fail: read deviceId failed."); + ANS_LOGE("[HandleSetSmartReminderEnabled] fail: read deviceType failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2416,7 +2416,7 @@ ErrCode AnsManagerStub::HandleIsSmartReminderEnabled(MessageParcel &data, Messag ANS_LOGD("enter"); std::string deviceType; if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleIsSmartReminderEnabled] fail: read deviceId failed."); + ANS_LOGE("[HandleIsSmartReminderEnabled] fail: read deviceType failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2441,7 +2441,7 @@ ErrCode AnsManagerStub::HandleSetDistributedEnabledBySlot(MessageParcel &data, M std::string deviceType; if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: read deviceId failed."); + ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: read deviceType failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2497,7 +2497,7 @@ ErrCode AnsManagerStub::HandleIsDistributedEnabledBySlot(MessageParcel &data, Me std::string deviceType; if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: read deviceId failed."); + ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: read deviceType failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2583,7 +2583,7 @@ ErrCode AnsManagerStub::HandleAllowUseReminder(MessageParcel &data, MessageParce ANS_LOGD("enter"); std::string bundleName; if (!data.ReadString(bundleName)) { - ANS_LOGE("fail: read deviceId failed."); + ANS_LOGE("fail: read bundleName failed."); return ERR_ANS_PARCELABLE_FAILED; } @@ -2595,7 +2595,7 @@ ErrCode AnsManagerStub::HandleAllowUseReminder(MessageParcel &data, MessageParce } if (!reply.WriteBool(isAllowUseReminder)) { - ANS_LOGE("fail: write enabled failed."); + ANS_LOGE("fail: write isAllowUseReminder failed."); return ERR_ANS_PARCELABLE_FAILED; } return ERR_OK; @@ -2628,7 +2628,7 @@ ErrCode AnsManagerStub::HandleSetDeviceStatus(MessageParcel &data, MessageParcel int32_t controlFlag = 0; if (!data.ReadInt32(controlFlag)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed"); + ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read controlFlag failed"); return ERR_ANS_PARCELABLE_FAILED; } @@ -2661,7 +2661,7 @@ ErrCode AnsManagerStub::HandleGetDeviceStatus(MessageParcel &data, MessageParcel return ERR_ANS_PARCELABLE_FAILED; } if (!reply.WriteInt32(status)) { - ANS_LOGE("[HandleGetDeviceStatus] fail: write slot failed."); + ANS_LOGE("[HandleGetDeviceStatus] fail: write status failed."); return ERR_ANS_PARCELABLE_FAILED; } return ERR_OK; @@ -2722,7 +2722,7 @@ ErrCode AnsManagerStub::HandleReplyDistributeOperation(MessageParcel &data, Mess int32_t resultCode = 0; if (!data.ReadInt32(resultCode)) { - ANS_LOGE("read hashCode failed."); + ANS_LOGE("read resultCode failed."); return ERR_ANS_PARCELABLE_FAILED; } diff --git a/services/ans/src/bundle_manager_helper.cpp b/services/ans/src/bundle_manager_helper.cpp index 2605e2ada..a5c34e305 100644 --- a/services/ans/src/bundle_manager_helper.cpp +++ b/services/ans/src/bundle_manager_helper.cpp @@ -93,7 +93,7 @@ bool BundleManagerHelper::CheckApiCompatibility(const std::string &bundleName, c int32_t callingUserId; AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, callingUserId); if (!GetBundleInfoByBundleName(bundleName, callingUserId, bundleInfo)) { - ANS_LOGW("Failed to GetBundleInfoByBundleName, bundlename = %{public}s", + ANS_LOGE("Failed to GetBundleInfoByBundleName, bundlename = %{public}s", bundleName.c_str()); return false; } diff --git a/services/ans/src/clone/notification_clone_manager.cpp b/services/ans/src/clone/notification_clone_manager.cpp index 51ac15dae..f085944b1 100644 --- a/services/ans/src/clone/notification_clone_manager.cpp +++ b/services/ans/src/clone/notification_clone_manager.cpp @@ -88,13 +88,13 @@ int32_t NotificationCloneManager::OnBackup(MessageParcel& data, MessageParcel& r FILE *fdfile = fopen(BACKUP_CONFIG_FILE_PATH, "r"); if (fdfile == nullptr) { - ANS_LOGW("Notification open file failed."); + ANS_LOGE("Notification open file failed."); return ANS_CLONE_ERROR; } auto fd = fileno(fdfile); if (reply.WriteFileDescriptor(fd) == false) { (void)fclose(fdfile); - ANS_LOGW("Notification write file descriptor failed!"); + ANS_LOGE("Notification write file descriptor failed!"); return ANS_CLONE_ERROR; } @@ -149,24 +149,24 @@ ErrCode NotificationCloneManager::LoadConfig(UniqueFd &fd, std::string& config) ANS_LOGI("Load notification config."); struct stat statBuf; if (fstat(fd.Get(), &statBuf) < 0) { - ANS_LOGW("LoadConfig fstat fd fail %{public}d.", fd.Get()); + ANS_LOGE("LoadConfig fstat fd fail %{public}d.", fd.Get()); return ANS_CLONE_ERROR; } int destFd = open(BACKUP_CONFIG_FILE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (destFd < 0) { - ANS_LOGW("LoadConfig open file fail."); + ANS_LOGE("LoadConfig open file fail."); return ANS_CLONE_ERROR; } fdsan_exchange_owner_tag(destFd, COMMON_FDSAN_TAG, NOTIFICATION_FDSAN_TAG); if (sendfile(destFd, fd.Get(), nullptr, statBuf.st_size) < 0) { - ANS_LOGW("LoadConfig fd sendfile(size: %{public}d) to destFd fail.", static_cast(statBuf.st_size)); + ANS_LOGE("LoadConfig fd sendfile(size: %{public}d) to destFd fail.", static_cast(statBuf.st_size)); fdsan_close_with_tag(destFd, NOTIFICATION_FDSAN_TAG); return ANS_CLONE_ERROR; } fdsan_close_with_tag(destFd, NOTIFICATION_FDSAN_TAG); std::ifstream fs(BACKUP_CONFIG_FILE_PATH); if (!fs.is_open()) { - ANS_LOGW("Loading config file%{public}s is_open() failed!", BACKUP_CONFIG_FILE_PATH); + ANS_LOGE("Loading config file%{public}s is_open() failed!", BACKUP_CONFIG_FILE_PATH); return ANS_CLONE_ERROR; } config.clear(); @@ -184,13 +184,13 @@ ErrCode NotificationCloneManager::SaveConfig(const std::string& config) RemoveBackUpFile(); FILE* fp = fopen(BACKUP_CONFIG_FILE_PATH, "w"); if (!fp) { - ANS_LOGW("Save config file: %{public}s, fopen() failed!", BACKUP_CONFIG_FILE_PATH); + ANS_LOGE("Save config file: %{public}s, fopen() failed!", BACKUP_CONFIG_FILE_PATH); return ANS_CLONE_ERROR; } int ret = static_cast(fwrite(config.c_str(), 1, config.length(), fp)); if (ret != (int)config.length()) { - ANS_LOGW("Save config file: %{public}s, fwrite %{public}d failed!", BACKUP_CONFIG_FILE_PATH, ret); + ANS_LOGE("Save config file: %{public}s, fwrite %{public}d failed!", BACKUP_CONFIG_FILE_PATH, ret); } (void)fflush(fp); (void)fsync(fileno(fp)); diff --git a/services/ans/src/common/notification_analytics_util.cpp b/services/ans/src/common/notification_analytics_util.cpp index e3a520ca4..7582479bb 100644 --- a/services/ans/src/common/notification_analytics_util.cpp +++ b/services/ans/src/common/notification_analytics_util.cpp @@ -461,7 +461,7 @@ void NotificationAnalyticsUtil::ReportModifyEvent(const HaMetaMessage& message) void NotificationAnalyticsUtil::ReportDeleteFailedEvent(const HaMetaMessage& message) { if (!ReportFlowControl(DELETE_ERROR_EVENT_CODE)) { - ANS_LOGI("Publish event failed, reason:%{public}s", message.Build().c_str()); + ANS_LOGE("Publish event failed, reason:%{public}s", message.Build().c_str()); return; } EventFwk::Want want; @@ -859,7 +859,7 @@ int64_t NotificationAnalyticsUtil::GetCurrentTime() void NotificationAnalyticsUtil::ReportOperationsDotEvent(const HaMetaMessage& message) { if (!ReportFlowControl(ANS_CUSTOMIZE_CODE)) { - ANS_LOGI("Publish event failed, reason:%{public}s", message.Build().c_str()); + ANS_LOGE("Publish event failed, reason:%{public}s", message.Build().c_str()); return; } EventFwk::Want want; @@ -876,7 +876,7 @@ void NotificationAnalyticsUtil::ReportOperationsDotEvent(const HaMetaMessage& me void NotificationAnalyticsUtil::ReportPublishFailedEvent(const HaMetaMessage& message) { if (!ReportFlowControl(PUBLISH_ERROR_EVENT_CODE)) { - ANS_LOGI("Publish event failed, reason:%{public}s", message.Build().c_str()); + ANS_LOGE("Publish event failed, reason:%{public}s", message.Build().c_str()); return; } EventFwk::Want want; @@ -954,7 +954,7 @@ std::string NotificationAnalyticsUtil::BuildAnsData(const HaMetaMessage& message void NotificationAnalyticsUtil::ReportSkipFailedEvent(const HaMetaMessage& message) { if (!ReportFlowControl(MODIFY_ERROR_EVENT_CODE)) { - ANS_LOGI("Publish event failed, reason:%{public}s", message.Build().c_str()); + ANS_LOGE("Publish event failed, reason:%{public}s", message.Build().c_str()); return; } EventFwk::Want want; diff --git a/services/ans/src/common/notification_config_parse.cpp b/services/ans/src/common/notification_config_parse.cpp index aef8410f5..e9adb280f 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -53,7 +53,7 @@ std::shared_ptr NotificationConfigParse::GetAppPrivil return nullptr; } if (!root.contains(APP_PRIVILEGES)) { - ANS_LOGW("not found jsonKey appPrivileges"); + ANS_LOGE("not found jsonKey appPrivileges"); return nullptr; } nlohmann::json affects = root[APP_PRIVILEGES]; @@ -208,7 +208,7 @@ void NotificationConfigParse::GetFlowCtrlConfigFromCCM(FlowControlThreshold &thr return; } if (!root.contains(CFG_KEY_NOTIFICATION_SERVICE)) { - ANS_LOGW("GetFlowCtrlConfigFromCCM not found jsonKey"); + ANS_LOGE("GetFlowCtrlConfigFromCCM not found jsonKey"); return; } nlohmann::json affects = root[CFG_KEY_NOTIFICATION_SERVICE]; @@ -399,7 +399,7 @@ void NotificationConfigParse::GetCollaborationFilter() bool NotificationConfigParse::IsInCollaborationFilter(const std::string& bundleName, int32_t uid) const { if (uidList_.empty() && bundleNameList_.empty()) { - ANS_LOGW("UidList and bundleNameList empty."); + ANS_LOGE("UidList and bundleNameList empty."); return false; } @@ -413,7 +413,7 @@ bool NotificationConfigParse::IsInCollaborationFilter(const std::string& bundleN return true; } - ANS_LOGI("Uid <%{public}d> and BundleName <%{public}s> not in CollaborationFilter.", uid, bundleName.c_str()); + ANS_LOGE("Uid <%{public}d> and BundleName <%{public}s> not in CollaborationFilter.", uid, bundleName.c_str()); return false; } @@ -427,7 +427,7 @@ uint32_t NotificationConfigParse::GetStartAbilityTimeout() return 0; } if (!root.contains(CFG_KEY_NOTIFICATION_SERVICE)) { - ANS_LOGW("GetStartAbilityTimeout not found jsonKey"); + ANS_LOGE("GetStartAbilityTimeout not found jsonKey"); return 0; } nlohmann::json affects = root[CFG_KEY_NOTIFICATION_SERVICE]; diff --git a/services/ans/src/disturb_manager/add_do_not_disturb_profiles.cpp b/services/ans/src/disturb_manager/add_do_not_disturb_profiles.cpp index b5034d17e..daf9d1054 100644 --- a/services/ans/src/disturb_manager/add_do_not_disturb_profiles.cpp +++ b/services/ans/src/disturb_manager/add_do_not_disturb_profiles.cpp @@ -52,7 +52,7 @@ ErrCode DisturbManager::AddDoNotDisturbProfilesSyncQueue( { int32_t userId = SUBSCRIBE_USER_INIT; if (OsAccountManagerHelper::GetInstance().GetCurrentActiveUserId(userId) != ERR_OK) { - ANS_LOGW("No active user found."); + ANS_LOGE("No active user found."); return ERR_ANS_GET_ACTIVE_USER_FAILED; } AdvancedNotificationService::GetInstance()->SubmitSyncTask( diff --git a/services/ans/src/disturb_manager/get_do_not_disturb_profile.cpp b/services/ans/src/disturb_manager/get_do_not_disturb_profile.cpp index 3acd1fbbd..365271f6a 100644 --- a/services/ans/src/disturb_manager/get_do_not_disturb_profile.cpp +++ b/services/ans/src/disturb_manager/get_do_not_disturb_profile.cpp @@ -38,7 +38,7 @@ ErrCode DisturbManager::HandleGetDoNotDisturbProfile(MessageParcel &data, Messag if (result == ERR_OK) { if (!reply.WriteParcelable(profile)) { - ANS_LOGE("HandleGetDoNotDisturbProfile write slot failed."); + ANS_LOGE("HandleGetDoNotDisturbProfile write profile failed."); return ERR_ANS_PARCELABLE_FAILED; } } @@ -49,7 +49,7 @@ ErrCode DisturbManager::GetDoNotDisturbProfileInner(int64_t id, sptrSubmitSyncTask( diff --git a/services/ans/src/disturb_manager/set_do_not_disturb_date.cpp b/services/ans/src/disturb_manager/set_do_not_disturb_date.cpp index a1b2f6317..52b42d0b4 100644 --- a/services/ans/src/disturb_manager/set_do_not_disturb_date.cpp +++ b/services/ans/src/disturb_manager/set_do_not_disturb_date.cpp @@ -74,7 +74,7 @@ ErrCode DisturbManager::SetDoNotDisturbDate(const sptr("ans_extension"); if (distributedQueue_ == nullptr) { - ANS_LOGW("ffrt create failed!"); + ANS_LOGE("ffrt create failed!"); return; } } @@ -234,7 +234,7 @@ void DistributedExtensionService::OnDeviceOnline(const DmDeviceInfo &deviceInfo) { std::string name = TransDeviceTypeToName(deviceInfo.deviceTypeId); if (deviceConfig_.supportPeerDevice.find(name) == deviceConfig_.supportPeerDevice.end()) { - ANS_LOGI("The current device type not support %{public}d.", deviceInfo.deviceTypeId); + ANS_LOGE("The current device type not support %{public}d.", deviceInfo.deviceTypeId); return; } if (distributedQueue_ == nullptr) { @@ -242,13 +242,13 @@ void DistributedExtensionService::OnDeviceOnline(const DmDeviceInfo &deviceInfo) } std::function onlineTask = std::bind([&, deviceInfo]() { if (InitDans() != 0) { - ANS_LOGW("OnDeviceOnline init dans failed."); + ANS_LOGE("OnDeviceOnline init dans failed."); return; }; ADD_DEVICE handler = (ADD_DEVICE)dansHandler_->GetProxyFunc("AddDevice"); if (handler == nullptr) { - ANS_LOGW("Dans handler is null ptr."); + ANS_LOGE("Dans handler is null ptr."); return; } std::lock_guard lock(mapLock_); @@ -331,16 +331,16 @@ void DistributedExtensionService::OnDeviceOffline(const DmDeviceInfo &deviceInfo std::function offlineTask = std::bind([&, deviceInfo]() { std::lock_guard lock(mapLock_); if (deviceMap_.count(deviceInfo.deviceId) == 0) { - ANS_LOGI("Not target device %{public}s", StringAnonymous(deviceInfo.deviceId).c_str()); + ANS_LOGE("Not target device %{public}s", StringAnonymous(deviceInfo.deviceId).c_str()); return; } if (!dansRunning_.load() || dansHandler_ == nullptr || !dansHandler_->IsValid()) { - ANS_LOGW("Dans state not normal %{public}d", dansRunning_.load()); + ANS_LOGE("Dans state not normal %{public}d", dansRunning_.load()); return; } RELEASE_DEVICE handler = (RELEASE_DEVICE)dansHandler_->GetProxyFunc("ReleaseDevice"); if (handler == nullptr) { - ANS_LOGW("Dans handler is null ptr."); + ANS_LOGE("Dans handler is null ptr."); return; } handler(deviceInfo.deviceId, deviceInfo.deviceTypeId); @@ -360,16 +360,16 @@ void DistributedExtensionService::OnDeviceChanged(const DmDeviceInfo &deviceInfo std::function changeTask = std::bind([&, deviceInfo]() { std::lock_guard lock(mapLock_); if (deviceMap_.count(deviceInfo.deviceId) == 0) { - ANS_LOGI("Not target device %{public}s", StringAnonymous(deviceInfo.deviceId).c_str()); + ANS_LOGE("Not target device %{public}s", StringAnonymous(deviceInfo.deviceId).c_str()); return; } if (!dansRunning_.load() || dansHandler_ == nullptr || !dansHandler_->IsValid()) { - ANS_LOGW("Dans state not normal %{public}d", dansRunning_.load()); + ANS_LOGE("Dans state not normal %{public}d", dansRunning_.load()); return; } REFRESH_DEVICE handler = (REFRESH_DEVICE)dansHandler_->GetProxyFunc("RefreshDevice"); if (handler == nullptr) { - ANS_LOGW("Dans handler is null ptr."); + ANS_LOGE("Dans handler is null ptr."); return; } handler(deviceInfo.deviceId, deviceInfo.deviceTypeId, deviceInfo.networkId); diff --git a/services/ans/src/notification_extension/notification_operation_service.cpp b/services/ans/src/notification_extension/notification_operation_service.cpp index 9535890d4..da309df44 100644 --- a/services/ans/src/notification_extension/notification_operation_service.cpp +++ b/services/ans/src/notification_extension/notification_operation_service.cpp @@ -41,7 +41,7 @@ DistributedOperationService::DistributedOperationService() { operationQueue_ = std::make_shared("ans_operation"); if (operationQueue_ == nullptr) { - ANS_LOGW("ffrt create failed!"); + ANS_LOGE("ffrt create failed!"); return; } ANS_LOGI("Operation service init successfully."); diff --git a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp index 575a4b66b..e0f23ab95 100644 --- a/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp +++ b/services/ans/src/notification_smart_reminder/smart_reminder_center.cpp @@ -50,19 +50,19 @@ void SmartReminderCenter::GetMultiDeviceReminder() multiJsonPoint.append("/"); multiJsonPoint.append(MULTI_DEVICE_REMINDER); if (!DelayedSingleton::GetInstance()->GetConfigJson(multiJsonPoint, root)) { - ANS_LOGW("Failed to get multiDeviceReminder CCM config file."); + ANS_LOGE("Failed to get multiDeviceReminder CCM config file."); return; } if (root.find(NotificationConfigParse::CFG_KEY_NOTIFICATION_SERVICE) == root.end()) { - ANS_LOGW("GetMultiDeviceReminder failed as can not find notificationService."); + ANS_LOGE("GetMultiDeviceReminder failed as can not find notificationService."); return; } nlohmann::json multiDeviceRemindJson = root[NotificationConfigParse::CFG_KEY_NOTIFICATION_SERVICE][MULTI_DEVICE_REMINDER]; if (multiDeviceRemindJson.is_null() || !multiDeviceRemindJson.is_array() || multiDeviceRemindJson.empty()) { - ANS_LOGW("GetMultiDeviceReminder failed as invalid multiDeviceReminder json."); + ANS_LOGE("GetMultiDeviceReminder failed as invalid multiDeviceReminder json."); return; } diff --git a/services/ans/src/reminder_swing_decision_center.cpp b/services/ans/src/reminder_swing_decision_center.cpp index 3749c8b71..ec2894ccd 100644 --- a/services/ans/src/reminder_swing_decision_center.cpp +++ b/services/ans/src/reminder_swing_decision_center.cpp @@ -37,7 +37,7 @@ ReminderSwingDecisionCenter &ReminderSwingDecisionCenter::GetInstance() ErrCode ReminderSwingDecisionCenter::RegisterSwingCallback(const sptr &swingCallback) { if (swingCallback == nullptr) { - ANS_LOGW("swingCallback is null."); + ANS_LOGE("swingCallback is null."); return ERR_INVALID_VALUE; } swingRecipient_ = new (nothrow) SwingCallbackRecipient(); diff --git a/services/ans/src/utils/notifictaion_load_utils.cpp b/services/ans/src/utils/notifictaion_load_utils.cpp index 83edd6ec6..908a12a61 100644 --- a/services/ans/src/utils/notifictaion_load_utils.cpp +++ b/services/ans/src/utils/notifictaion_load_utils.cpp @@ -43,7 +43,7 @@ NotificationLoadUtils::~NotificationLoadUtils() void* NotificationLoadUtils::GetProxyFunc(const std::string& func) { if (proxyHandle_ == nullptr) { - ANS_LOGW("Get func failed: %{public}s %{public}s", path_.c_str(), func.c_str()); + ANS_LOGE("Get func failed: %{public}s %{public}s", path_.c_str(), func.c_str()); return nullptr; } diff --git a/services/reminder/src/reminder_config_change_observer.cpp b/services/reminder/src/reminder_config_change_observer.cpp index e0efc126f..a19712fb0 100644 --- a/services/reminder/src/reminder_config_change_observer.cpp +++ b/services/reminder/src/reminder_config_change_observer.cpp @@ -26,7 +26,7 @@ void ReminderConfigChangeObserver::OnConfigurationUpdated(const AppExecFwk::Conf ANSR_LOGD("OnConfigurationUpdated."); auto reminderDataMgr = ReminderDataManager::GetInstance(); if (reminderDataMgr == nullptr) { - ANSR_LOGW("Reminder data manager is nullptr"); + ANSR_LOGE("Reminder data manager is nullptr"); return; } std::string newLanguageInfo = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); diff --git a/services/reminder/src/reminder_data_manager.cpp b/services/reminder/src/reminder_data_manager.cpp index 50d44a7c4..93569ba02 100644 --- a/services/reminder/src/reminder_data_manager.cpp +++ b/services/reminder/src/reminder_data_manager.cpp @@ -1175,12 +1175,12 @@ void ReminderDataManager::StartRecentReminder() std::lock_guard lock(ReminderDataManager::MUTEX); sptr reminder = GetRecentReminder(); if (reminder == nullptr) { - ANSR_LOGI("No reminder need to start"); + ANSR_LOGW("No reminder need to start"); SetActiveReminder(reminder); return; } if (activeReminderId_ == reminder->GetReminderId()) { - ANSR_LOGI("Recent reminder has already run, no need to start again."); + ANSR_LOGW("Recent reminder has already run, no need to start again."); return; } if (activeReminderId_ != -1) { diff --git a/services/reminder/src/reminder_data_manager_inner.cpp b/services/reminder/src/reminder_data_manager_inner.cpp index f71bfb87a..1e0eb507a 100644 --- a/services/reminder/src/reminder_data_manager_inner.cpp +++ b/services/reminder/src/reminder_data_manager_inner.cpp @@ -139,12 +139,12 @@ void ReminderDataManager::CloseCustomRingFileDesc(const int32_t reminderId, cons { std::lock_guard locker(resourceMutex_); if (soundResource_ == nullptr) { - ANSR_LOGW("ResourceManager is nullptr."); + ANSR_LOGE("ResourceManager is nullptr."); return; } auto result = soundResource_->CloseRawFileDescriptor(customRingUri); if (result != Global::Resource::SUCCESS) { - ANSR_LOGW("CloseRawFileDescriptor fail[%{public}d]", static_cast(result)); + ANSR_LOGE("CloseRawFileDescriptor fail[%{public}d]", static_cast(result)); } ANSR_LOGI("Stop custom sound, reminderId:[%{public}d].", reminderId); soundResource_ = nullptr; @@ -170,7 +170,7 @@ bool ReminderDataManager::CheckShowLimit(std::unordered_map& reminder) { if (totalCount > TOTAL_MAX_NUMBER_SHOW_AT_ONCE) { - ANSR_LOGW("The maximum number of displays that can be displayed at a time has been reached."); + ANSR_LOGE("The maximum number of displays that can be displayed at a time has been reached."); return false; } ++totalCount; @@ -181,7 +181,7 @@ bool ReminderDataManager::CheckShowLimit(std::unordered_mapsecond > ONE_HAP_MAX_NUMBER_SHOW_AT_ONCE) { - ANSR_LOGW("The maximum number of displays that can be displayed in a single app[%{public}s] has been reached", + ANSR_LOGE("The maximum number of displays that can be displayed in a single app[%{public}s] has been reached", reminder->GetBundleName().c_str()); return false; } @@ -230,19 +230,19 @@ void ReminderDataManager::AsyncStartExtensionAbility(const sptr { auto manager = ReminderDataManager::GetInstance(); if (manager == nullptr) { - ANSR_LOGW("ReminderDataManager is nullptr."); + ANSR_LOGE("ReminderDataManager is nullptr."); return; } if (!manager->IsSystemReady()) { - ANSR_LOGW("bundle service or ability service not ready."); + ANSR_LOGE("bundle service or ability service not ready."); return; } if (!reminder->IsSystemApp()) { - ANSR_LOGI("Start extension ability failed, is not system app"); + ANSR_LOGE("Start extension ability failed, is not system app"); return; } if (count > TOTAL_MAX_NUMBER_START_EXTENSION) { - ANSR_LOGW("The maximum number of start extension has been reached."); + ANSR_LOGE("The maximum number of start extension has been reached."); return; } ++count; -- Gitee From ff22fe7453cd5cec2f7f7f02cc8c377a7a5c8619 Mon Sep 17 00:00:00 2001 From: heguokai Date: Mon, 24 Mar 2025 08:28:17 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20fram?= =?UTF-8?q?eworks/cj/ffi/src/notification=5Futils.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/cj/ffi/src/notification_utils.cpp | 1631 ------------------ 1 file changed, 1631 deletions(-) delete mode 100644 frameworks/cj/ffi/src/notification_utils.cpp diff --git a/frameworks/cj/ffi/src/notification_utils.cpp b/frameworks/cj/ffi/src/notification_utils.cpp deleted file mode 100644 index db755f916..000000000 --- a/frameworks/cj/ffi/src/notification_utils.cpp +++ /dev/null @@ -1,1631 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "notification_utils.h" -#include "notification_manager_log.h" - -namespace OHOS { -namespace CJSystemapi { -namespace Notification { - using namespace OHOS::FFI; - using namespace OHOS::Notification; - - char *MallocCString(const std::string &origin) - { - if (origin.empty()) { - return nullptr; - } - auto len = origin.length() + 1; - char *res = static_cast(malloc(sizeof(char) * len)); - if (res == nullptr) { - return nullptr; - } - return std::char_traits::copy(res, origin.c_str(), len); - } - - bool GetNotificationSupportDisplayDevicesV2( - CDistributedOptionsV2* distributedOption, - NotificationRequest request) - { - int64_t length = distributedOption->supportDisplayDevices.size; - if (length == 0) { - LOGE("The array is empty."); - return false; - } - std::vector devices; - for (int64_t i = 0; i < length; i++) { - char str[STR_MAX_SIZE] = {0}; - auto displayDevice = distributedOption->supportDisplayDevices.head[i]; - if (strcpy_s(str, STR_MAX_SIZE, displayDevice) != EOK) { - return false; - } - devices.emplace_back(str); - LOGI("supportDisplayDevices = %{public}s", str); - } - request.SetDevicesSupportDisplay(devices); - return true; - } - - bool GetNotificationSupportOperateDevicesV2( - CDistributedOptionsV2* distributedOption, - NotificationRequest request) - { - int64_t length = distributedOption->supportOperateDevices.size; - if (length == 0) { - LOGE("The array is empty."); - return false; - } - std::vector devices; - for (int64_t i = 0; i < length; i++) { - char str[STR_MAX_SIZE] = {0}; - auto operateDevice = distributedOption->supportOperateDevices.head[i]; - if (strcpy_s(str, STR_MAX_SIZE, operateDevice) != EOK) { - return false; - } - devices.emplace_back(str); - LOGI("supportOperateDevices = %{public}s", str); - } - request.SetDevicesSupportOperate(devices); - return true; - } - - bool GetNotificationRequestDistributedOptionsV2( - CDistributedOptionsV2* distributedOption, - NotificationRequest request) - { - if (distributedOption != nullptr) { - // isDistributed?: boolean - request.SetDistributed(distributedOption->isDistributed); - - // supportDisplayDevices?: Array - if (!GetNotificationSupportDisplayDevicesV2(distributedOption, request)) { - return false; - } - - // supportOperateDevices?: Array - if (!GetNotificationSupportOperateDevicesV2(distributedOption, request)) { - return false; - } - } - return true; - } - - bool GetNotificationRequestByNumberV2(CNotificationRequestV2 cjRequest, NotificationRequest &request) - { - // id?: int32_t - int32_t id = cjRequest.id; - request.SetNotificationId(id); - - // deliveryTime?: int64_t - int64_t deliveryTime = cjRequest.deliveryTime; - request.SetDeliveryTime(deliveryTime); - - // autoDeletedTime?: int64_t - int64_t autoDeletedTime = cjRequest.autoDeletedTime; - request.SetAutoDeletedTime(autoDeletedTime); - - // color?: uint32_t - request.SetColor(cjRequest.color); - - // badgeIconStyle?: int32_t - int32_t badgeIconStyle = cjRequest.badgeIconStyle; - request.SetBadgeIconStyle(static_cast(badgeIconStyle)); - - // badgeNumber?: uint32_t - uint32_t badgeNumber = cjRequest.badgeNumber; - if (badgeNumber < 0) { - LOGE("Wrong badge number."); - return false; - } - request.SetBadgeNumber(badgeNumber); - - return true; - } - - bool GetNotificationRequestByStringV2(CNotificationRequestV2 cjRequest, NotificationRequest &request) - { - // label?: string - char label[STR_MAX_SIZE] = {0}; - if (strcpy_s(label, STR_MAX_SIZE, cjRequest.label) != EOK) { - return false; - } - request.SetLabel(std::string(label)); - - // groupName?: string - char groupName[STR_MAX_SIZE] = {0}; - if (strcpy_s(groupName, STR_MAX_SIZE, cjRequest.groupName) != EOK) { - return false; - } - request.SetGroupName(std::string(groupName)); - - // groupName?: string - char appMessageId[STR_MAX_SIZE] = {0}; - if (strcpy_s(appMessageId, STR_MAX_SIZE, cjRequest.appMessageId) != EOK) { - return false; - } - request.SetAppMessageId(std::string(appMessageId)); - - return true; - } - - bool GetNotificationRequestByBoolV2(CNotificationRequestV2 cjRequest, NotificationRequest &request) - { - // isOngoing?: boolean - bool isOngoing = cjRequest.isOngoing; - request.SetInProgress(isOngoing); - - // isUnremovable?: boolean - bool isUnremovable = cjRequest.isUnremovable; - request.SetUnremovable(isUnremovable); - - // tapDismissed?: boolean - bool tapDismissed = cjRequest.tapDismissed; - request.SetTapDismissed(tapDismissed); - - // colorEnabled?: boolean - bool colorEnabled = cjRequest.colorEnabled; - request.SetColorEnabled(colorEnabled); - - // isAlertOnce?: boolean - bool isAlertOnce = cjRequest.isAlertOnce; - request.SetAlertOneTime(isAlertOnce); - - // isStopwatch?: boole - bool isStopwatch = cjRequest.isStopwatch; - request.SetShowStopwatch(isStopwatch); - - // isCountDown?: boolean - bool isCountDown = cjRequest.isCountDown; - request.SetCountdownTimer(isCountDown); - - // showDeliveryTime?: boolean - bool showDeliveryTime = cjRequest.showDeliveryTime; - request.SetShowDeliveryTime(showDeliveryTime); - - return true; - } - - bool GetNotificationRequestByCustomV2(CNotificationRequestV2 cjRequest, NotificationRequest &request) - { - // content: NotificationContent - if (!GetNotificationContentV2(cjRequest.notificationContent, request)) { - return false; - } - // slotType?: notification.SlotTypeV2 - if (!GetNotificationSlotTypeV2(cjRequest.notificationSlotType, request)) { - return false; - } - // smallIcon?: image.PixelMap - if (!GetNotificationSmallIconV2(cjRequest.smallIcon, request)) { - return false; - } - // largeIcon?: image.PixelMap - if (!GetNotificationLargeIconV2(cjRequest.largeIcon, request)) { - return false; - } - // distributedOption?:DistributedOptions - if (!GetNotificationRequestDistributedOptionsV2(cjRequest.distributedOption, request)) { - return false; - } - - return true; - } - - bool GetNotificationBasicContentDetailedV2(CNotificationBasicContentV2* contentResult, - std::shared_ptr basicContent) - { - char str[SHORT_STR_SIZE] = {0}; - char long_str[LONG_STR_SIZE] = {0}; - // title: String - if (strcpy_s(str, SHORT_STR_SIZE, contentResult->title) != EOK) { - return false; - } - if (strlen(str) == 0) { - LOGE("Property title is empty"); - return false; - } - basicContent->SetTitle(std::string(str)); - // text: String - if (strcpy_s(long_str, LONG_STR_SIZE, contentResult->text) != EOK) { - return false; - } - if (strlen(long_str) == 0) { - LOGE("Property text is empty"); - return false; - } - basicContent->SetText(std::string(long_str)); - // additionalText: string - if (strcpy_s(long_str, LONG_STR_SIZE, contentResult->additionalText) != EOK) { - return false; - } - basicContent->SetAdditionalText(std::string(long_str)); - - // lockScreenPicture?: pixelMap - if (contentResult->lockscreenPicture != -1) { - auto pixelMap = FFIData::GetData(contentResult->lockscreenPicture); - if (pixelMap == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - basicContent->SetLockScreenPicture(pixelMap->GetRealPixelMap()); - } - return true; - } - - bool GetNotificationBasicContentV2(CNotificationBasicContentV2* contentResult, NotificationRequest &request) - { - std::shared_ptr normalContent = std::make_shared(); - if (normalContent == nullptr) { - LOGE("normalContent is null"); - return false; - } - - if (!GetNotificationBasicContentDetailedV2(contentResult, normalContent)) { - return false; - } - request.SetContent(std::make_shared(normalContent)); - return true; - } - - bool GetNotificationLongTextContentDetailedV2( - CNotificationLongTextContentV2* contentResult, - std::shared_ptr &longContent) - { - char str[SHORT_STR_SIZE] = {0}; - char long_str[LONG_STR_SIZE] = {0}; - - std::shared_ptr tempContent = std::make_shared(); - tempContent->title = contentResult->title; - tempContent->text = contentResult->text; - tempContent->additionalText = contentResult->additionalText; - tempContent->lockscreenPicture = contentResult->lockscreenPicture; - if (!GetNotificationBasicContentDetailedV2(tempContent.get(), longContent)) { - return false; - } - - // longText: String - if (strcpy_s(long_str, LONG_STR_SIZE, contentResult->longText) != EOK) { - return false; - } - if (strlen(long_str) == 0) { - LOGE("Property longText is empty"); - return false; - } - longContent->SetLongText(std::string(long_str)); - - // briefText: String - if (strcpy_s(str, SHORT_STR_SIZE, contentResult->briefText) != EOK) { - return false; - } - if (strlen(str) == 0) { - LOGE("Property briefText is empty"); - return false; - } - longContent->SetBriefText(std::string(str)); - - // expandedTitle: String - if (strcpy_s(str, SHORT_STR_SIZE, contentResult->expandedTitle) != EOK) { - return false; - } - if (strlen(str) == 0) { - LOGE("Property expandedTitle is empty"); - return false; - } - longContent->SetExpandedTitle(std::string(str)); - - return true; - } - - bool GetNotificationLongTextContentV2( - CNotificationLongTextContentV2* contentResult, - NotificationRequest &request) - { - std::shared_ptr longContent = - std::make_shared(); - if (longContent == nullptr) { - LOGE("longContent is null"); - return false; - } - if (!GetNotificationLongTextContentDetailedV2(contentResult, longContent)) { - return false; - } - - request.SetContent(std::make_shared(longContent)); - return true; - } - - bool GetNotificationPictureContentDetailedV2( - CNotificationPictureContentV2* contentResult, - std::shared_ptr &pictureContent) - { - char str[SHORT_STR_SIZE] = {0}; - char long_str[LONG_STR_SIZE] = {0}; - - std::shared_ptr tempContent = std::make_shared(); - tempContent->title = contentResult->title; - tempContent->text = contentResult->text; - tempContent->additionalText = contentResult->additionalText; - tempContent->lockscreenPicture = contentResult->lockscreenPicture; - if (!GetNotificationBasicContentDetailedV2(tempContent.get(), pictureContent)) { - return false; - } - - // briefText: String - if (strcpy_s(str, SHORT_STR_SIZE, contentResult->briefText) != EOK) { - return false; - } - if (std::strlen(str) == 0) { - LOGE("Property briefText is empty"); - return false; - } - pictureContent->SetBriefText(std::string(str)); - - // expandedTitle: String - if (strcpy_s(long_str, LONG_STR_SIZE, contentResult->expandedTitle) != EOK) { - return false; - } - if (std::strlen(long_str) == 0) { - LOGE("Property expandedTitle is empty"); - return false; - } - pictureContent->SetExpandedTitle(std::string(long_str)); - - // picture: image.PixelMap - auto pixelMap = FFIData::GetData(contentResult->picture); - if (pixelMap == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - pictureContent->SetBigPicture(pixelMap->GetRealPixelMap()); - - return true; - } - - bool GetNotificationPictureContentV2( - CNotificationPictureContentV2* contentResult, - NotificationRequest &request) - { - std::shared_ptr pictureContent = - std::make_shared(); - if (pictureContent == nullptr) { - LOGE("pictureContent is null"); - return false; - } - - if (!GetNotificationPictureContentDetailedV2(contentResult, pictureContent)) { - return false; - } - - request.SetContent(std::make_shared(pictureContent)); - return true; - } - - bool GetNotificationMultiLineContentLinesV2( - CNotificationMultiLineContentV2* result, - std::shared_ptr &multiLineContent) - { - char str[SHORT_STR_SIZE] = {0}; - int64_t length = result->lines.size; - if (length == 0) { - LOGE("The array is empty."); - return false; - } - for (int64_t i = 0; i < length; i++) { - if (strcpy_s(str, SHORT_STR_SIZE, result->lines.head[i]) != EOK) { - return false; - } - multiLineContent->AddSingleLine(std::string(str)); - } - return true; - } - - bool GetNotificationMultiLineContentV2( - CNotificationMultiLineContentV2* contentResult, - NotificationRequest &request) - { - char str[SHORT_STR_SIZE] = {0}; - - std::shared_ptr multiLineContent = - std::make_shared(); - if (multiLineContent == nullptr) { - LOGE("multiLineContent is null"); - return false; - } - - std::shared_ptr tempContent = std::make_shared(); - tempContent->title = contentResult->title; - tempContent->text = contentResult->text; - tempContent->additionalText = contentResult->additionalText; - tempContent->lockscreenPicture = contentResult->lockscreenPicture; - if (!GetNotificationBasicContentDetailedV2(tempContent.get(), multiLineContent)) { - return false; - } - - // briefText: String - if (strcpy_s(str, SHORT_STR_SIZE, contentResult->briefText) != EOK) { - return false; - } - if (std::strlen(str) == 0) { - LOGE("Property briefText is empty"); - return false; - } - multiLineContent->SetBriefText(std::string(str)); - - // longTitle: String - if (strcpy_s(str, LONG_STR_SIZE, contentResult->longTitle) != EOK) { - return false; - } - if (std::strlen(str) == 0) { - LOGE("Property longTitle is empty"); - return false; - } - multiLineContent->SetExpandedTitle(std::string(str)); - - // lines: Array - if (!GetNotificationMultiLineContentLinesV2(contentResult, multiLineContent)) { - return false; - } - - request.SetContent(std::make_shared(multiLineContent)); - return true; - } - - bool GetNotificationLocalLiveViewCapsuleV2(CNotificationSystemLiveViewContentV2* contentResult, - std::shared_ptr &content) - { - char str[STR_MAX_SIZE] = {0}; - NotificationCapsule capsule; - if (strcpy_s(str, STR_MAX_SIZE, contentResult->capsule.title) != EOK) { - LOGE("copy capsule.title failed"); - return false; - } - capsule.SetTitle(std::string(str)); - - if (strcpy_s(str, STR_MAX_SIZE, contentResult->capsule.backgroundColor) != EOK) { - LOGE("copy capsule.backgroundColor failed"); - return false; - } - capsule.SetBackgroundColor(std::string(str)); - - if (contentResult->capsule.icon != -1) { - auto pixelMap = FFIData::GetData(contentResult->capsule.icon); - if (pixelMap == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - capsule.SetIcon(pixelMap->GetRealPixelMap()); - } - - content->SetCapsule(capsule); - content->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::CAPSULE); - return true; - } - - bool GetNotificationLocalLiveViewButtonV2(CNotificationSystemLiveViewContentV2* contentResult, - std::shared_ptr &content) - { - char str[STR_MAX_SIZE] = {0}; - NotificationLocalLiveViewButton button; - int64_t length = contentResult->button.names.size; - for (int64_t i = 0; i < length; i++) { - if (strcpy_s(str, STR_MAX_SIZE, contentResult->button.names.head[i]) != EOK) { - LOGE("copy button.names failed"); - return false; - } - button.addSingleButtonName(std::string(str)); - } - - length = contentResult->button.icons.size; - for (int64_t i = 0; i < length; i++) { - int64_t id = contentResult->button.icons.head[i]; - auto pixelMap = FFIData::GetData(id); - if (pixelMap == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - auto pix = pixelMap->GetRealPixelMap(); - if (pix != nullptr && static_cast(pix->GetByteCount()) <= MAX_ICON_SIZE) { - button.addSingleButtonIcon(pix); - } else { - LOGE("Invalid pixelMap object or pixelMap is over size."); - return false; - } - } - content->SetButton(button); - content->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::BUTTON); - return true; - } - - bool GetNotificationLocalLiveViewProgressV2(CNotificationSystemLiveViewContentV2* contentResult, - std::shared_ptr &content) - { - NotificationProgress progress; - if (contentResult->progress.maxValue < 0 || contentResult->progress.currentValue < 0) { - LOGE("Wrong argument value. Number expected."); - return false; - } - progress.SetMaxValue(contentResult->progress.maxValue); - progress.SetCurrentValue(contentResult->progress.currentValue); - progress.SetIsPercentage(contentResult->progress.isPercentage); - - content->SetProgress(progress); - content->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::PROGRESS); - return true; - } - - bool GetNotificationLocalLiveViewTimeV2(CNotificationSystemLiveViewContentV2* contentResult, - std::shared_ptr &content) - { - NotificationTime time; - if (contentResult->time.initialTime < 0) { - return false; - } - time.SetInitialTime(contentResult->time.initialTime); - content->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::INITIAL_TIME); - time.SetIsCountDown(contentResult->time.isCountDown); - time.SetIsPaused(contentResult->time.isPaused); - time.SetIsInTitle(contentResult->time.isInTitle); - - content->SetTime(time); - content->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::TIME); - - return true; - } - - bool GetNotificationLocalLiveViewContentDetailedV2(CNotificationSystemLiveViewContentV2* contentResult, - std::shared_ptr &content) - { - // title, text - std::shared_ptr tempContent = std::make_shared(); - tempContent->title = contentResult->title; - tempContent->text = contentResult->text; - tempContent->additionalText = contentResult->additionalText; - tempContent->lockscreenPicture = contentResult->lockscreenPicture; - if (!GetNotificationBasicContentDetailedV2(tempContent.get(), content)) { - LOGE("Basic content get fail."); - return false; - } - - // typeCode - content->SetType(contentResult->typeCode); - - // capsule? - if (!GetNotificationLocalLiveViewCapsuleV2(contentResult, content)) { - LOGE("GetNotificationLocalLiveViewCapsuleV2 fail."); - return false; - } - - // button? - if (!GetNotificationLocalLiveViewButtonV2(contentResult, content)) { - LOGE("GetNotificationLocalLiveViewButtonV2 fail."); - return false; - } - - // progress? - if (!GetNotificationLocalLiveViewProgressV2(contentResult, content)) { - LOGE("GetNotificationLocalLiveViewProgressV2 fail."); - return false; - } - - // time? - if (!GetNotificationLocalLiveViewTimeV2(contentResult, content)) { - LOGE("GetNotificationLocalLiveViewTimeV2 fail."); - return false; - } - - return true; - } - - bool GetNotificationLocalLiveViewContentV2(CNotificationSystemLiveViewContentV2* contentResult, - NotificationRequest &request) - { - std::shared_ptr localLiveViewContent = - std::make_shared(); - if (localLiveViewContent == nullptr) { - LOGE("localLiveViewContent is null"); - return false; - } - - if (!GetNotificationLocalLiveViewContentDetailedV2(contentResult, localLiveViewContent)) { - return false; - } - - request.SetContent(std::make_shared(localLiveViewContent)); - - // set isOnGoing of live view true - request.SetInProgress(true); - return true; - } - - bool SlotTypeCJToCV2(const SlotTypeV2 &inType, NotificationConstant::SlotType &outType) - { - switch (inType) { - case SlotTypeV2::SOCIAL_COMMUNICATION: - outType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION; - break; - case SlotTypeV2::SERVICE_INFORMATION: - outType = NotificationConstant::SlotType::SERVICE_REMINDER; - break; - case SlotTypeV2::CONTENT_INFORMATION: - outType = NotificationConstant::SlotType::CONTENT_INFORMATION; - break; - case SlotTypeV2::LIVE_VIEW: - outType = NotificationConstant::SlotType::LIVE_VIEW; - break; - case SlotTypeV2::CUSTOMER_SERVICE: - outType = NotificationConstant::SlotType::CUSTOMER_SERVICE; - break; - case SlotTypeV2::UNKNOWN_TYPE: - case SlotTypeV2::OTHER_TYPES: - outType = NotificationConstant::SlotType::OTHER; - break; - default: - LOGE("SlotType %{public}d is an invalid value", inType); - return false; - } - return true; - } - - bool SlotTypeCToCJV2(const NotificationConstant::SlotType &inType, SlotTypeV2 &outType) - { - switch (inType) { - case NotificationConstant::SlotType::CUSTOM: - outType = SlotTypeV2::UNKNOWN_TYPE; - break; - case NotificationConstant::SlotType::SOCIAL_COMMUNICATION: - outType = SlotTypeV2::SOCIAL_COMMUNICATION; - break; - case NotificationConstant::SlotType::SERVICE_REMINDER: - outType = SlotTypeV2::SERVICE_INFORMATION; - break; - case NotificationConstant::SlotType::CONTENT_INFORMATION: - outType = SlotTypeV2::CONTENT_INFORMATION; - break; - case NotificationConstant::SlotType::LIVE_VIEW: - outType = SlotTypeV2::LIVE_VIEW; - break; - case NotificationConstant::SlotType::CUSTOMER_SERVICE: - outType = SlotTypeV2::CUSTOMER_SERVICE; - break; - case NotificationConstant::SlotType::OTHER: - outType = SlotTypeV2::OTHER_TYPES; - break; - default: - LOGE("SlotType %{public}d is an invalid value", inType); - return false; - } - return true; - } - - bool SlotLevelCToCJV2(const NotificationSlot::NotificationLevel &inLevel, SlotLevel &outLevel) - { - switch (inLevel) { - case NotificationSlot::NotificationLevel::LEVEL_NONE: - case NotificationSlot::NotificationLevel::LEVEL_UNDEFINED: - outLevel = SlotLevel::LEVEL_NONE; - break; - case NotificationSlot::NotificationLevel::LEVEL_MIN: - outLevel = SlotLevel::LEVEL_MIN; - break; - case NotificationSlot::NotificationLevel::LEVEL_LOW: - outLevel = SlotLevel::LEVEL_LOW; - break; - case NotificationSlot::NotificationLevel::LEVEL_DEFAULT: - outLevel = SlotLevel::LEVEL_DEFAULT; - break; - case NotificationSlot::NotificationLevel::LEVEL_HIGH: - outLevel = SlotLevel::LEVEL_HIGH; - break; - default: - LOGE("SlotLevel %{public}d is an invalid value", inLevel); - return false; - } - return true; - } - - bool ContentTypeCJToCV2(const ContentTypeV2 &inType, NotificationContent::Type &outType) - { - switch (inType) { - case ContentTypeV2::NOTIFICATION_CONTENT_BASIC_TEXT: - outType = NotificationContent::Type::BASIC_TEXT; - break; - case ContentTypeV2::NOTIFICATION_CONTENT_LONG_TEXT: - outType = NotificationContent::Type::LONG_TEXT; - break; - case ContentTypeV2::NOTIFICATION_CONTENT_MULTILINE: - outType = NotificationContent::Type::MULTILINE; - break; - case ContentTypeV2::NOTIFICATION_CONTENT_PICTURE: - outType = NotificationContent::Type::PICTURE; - break; - case ContentTypeV2::NOTIFICATION_CONTENT_CONVERSATION: - outType = NotificationContent::Type::CONVERSATION; - break; - case ContentTypeV2::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW: - outType = NotificationContent::Type::LOCAL_LIVE_VIEW; - break; - case ContentTypeV2::NOTIFICATION_CONTENT_LIVE_VIEW: - outType = NotificationContent::Type::LIVE_VIEW; - break; - default: - LOGE("ContentType %{public}d is an invalid value", inType); - return false; - } - return true; - } - - bool ContentTypeCToCJV2(const NotificationContent::Type &inType, ContentTypeV2 &outType) - { - switch (inType) { - case NotificationContent::Type::BASIC_TEXT: - outType = ContentTypeV2::NOTIFICATION_CONTENT_BASIC_TEXT; - break; - case NotificationContent::Type::LONG_TEXT: - outType = ContentTypeV2::NOTIFICATION_CONTENT_LONG_TEXT; - break; - case NotificationContent::Type::MULTILINE: - outType = ContentTypeV2::NOTIFICATION_CONTENT_MULTILINE; - break; - case NotificationContent::Type::PICTURE: - outType = ContentTypeV2::NOTIFICATION_CONTENT_PICTURE; - break; - case NotificationContent::Type::CONVERSATION: - outType = ContentTypeV2::NOTIFICATION_CONTENT_CONVERSATION; - break; - case NotificationContent::Type::LOCAL_LIVE_VIEW: - outType = ContentTypeV2::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW; - break; - case NotificationContent::Type::LIVE_VIEW: - outType = ContentTypeV2::NOTIFICATION_CONTENT_LIVE_VIEW; - break; - default: - LOGE("ContentType %{public}d is an invalid value", inType); - return false; - } - return true; - } - - bool GetNotificationSlotTypeV2(int32_t slotType, NotificationRequest &request) - { - NotificationConstant::SlotType outType = NotificationConstant::SlotType::OTHER; - if (!SlotTypeCJToCV2(SlotTypeV2(slotType), outType)) { - return false; - } - request.SetSlotType(outType); - return true; - } - - bool GetNotificationSmallIconV2(int64_t smallIcon, NotificationRequest &request) - { - if (smallIcon != -1) { - auto pixelMap = FFIData::GetData(smallIcon); - if (pixelMap == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - request.SetLittleIcon(pixelMap->GetRealPixelMap()); - } - return true; - } - - bool GetNotificationLargeIconV2(int64_t largeIcon, NotificationRequest &request) - { - if (largeIcon != -1) { - auto pixelMap = FFI::FFIData::GetData(largeIcon); - if (pixelMap == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - request.SetBigIcon(pixelMap->GetRealPixelMap()); - } - return true; - } - - bool GetNotificationContentV2(CNotificationContentV2 &content, NotificationRequest &request) - { - NotificationContent::Type outType = NotificationContent::Type::NONE; - if (!ContentTypeCJToCV2(ContentTypeV2(content.notificationContentType), outType)) { - return false; - } - switch (outType) { - case NotificationContent::Type::BASIC_TEXT: - if (content.normal == nullptr || !GetNotificationBasicContentV2(content.normal, request)) { - return false; - } - break; - case NotificationContent::Type::LONG_TEXT: - if (content.longText == nullptr || !GetNotificationLongTextContentV2(content.longText, request)) { - return false; - } - break; - case NotificationContent::Type::PICTURE: - if (content.picture == nullptr || !GetNotificationPictureContentV2(content.picture, request)) { - return false; - } - break; - case NotificationContent::Type::CONVERSATION: - break; - case NotificationContent::Type::MULTILINE: - if (content.multiLine == nullptr || !GetNotificationMultiLineContentV2(content.multiLine, request)) { - return false; - } - break; - case NotificationContent::Type::LOCAL_LIVE_VIEW: - if (content.systemLiveView == nullptr || - !GetNotificationLocalLiveViewContentV2(content.systemLiveView, request)) { - return false; - } - break; - case NotificationContent::Type::LIVE_VIEW: - break; - default: - return false; - } - return true; - } - - bool SetNotificationSlotV2(const NotificationSlot &slot, CNotificationSlotV2 ¬ificationSlot) - { - // type: SlotType - SlotType outType = SlotType::UNKNOWN_TYPE; - if (!SlotTypeCToCJ(slot.GetType(), outType)) { - LOGE("UNKNOWN_TYPE SlotTypeCToCJ failed."); - return false; - } - // level?: int32_t - SlotLevel outLevel = SlotLevel::LEVEL_NONE; - if (!SlotLevelCToCJ(slot.GetLevel(), outLevel)) { - LOGE("LEVEL_NONE SlotLevelCToCJ failed."); - return false; - } - notificationSlot.notificationType = static_cast(outType); - notificationSlot.level = static_cast(outLevel); - - notificationSlot.desc = MallocCString(slot.GetDescription()); // desc?: string - notificationSlot.badgeFlag = slot.IsShowBadge(); // badgeFlag?: bool - notificationSlot.bypassDnd = slot.IsEnableBypassDnd(); // bypassDnd?: bool - // lockscreenVisibility?: int32_t - notificationSlot.lockscreenVisibility = static_cast(slot.GetLockScreenVisibleness()); - notificationSlot.vibrationEnabled = slot.CanVibrate(); // vibrationEnabled?: bool - notificationSlot.sound = MallocCString(slot.GetSound().ToString()); // sound?: string - notificationSlot.lightEnabled = slot.CanEnableLight(); // lightEnabled?: bool - notificationSlot.lightColor = slot.GetLedLightColor(); // lightColor?: int32_t - - // vibrationValues?: Array - auto vec = slot.GetVibrationStyle(); - CArrI64 vibrationValues = { .head = NULL, .size = 0 }; - vibrationValues.size = static_cast(vec.size()); - if (vibrationValues.size > 0) { - int64_t* head = static_cast(malloc(sizeof(int64_t) * vec.size())); - if (head == nullptr) { - free(notificationSlot.desc); - free(notificationSlot.sound); - notificationSlot.desc = nullptr; - notificationSlot.sound = nullptr; - LOGE("malloc vibrationValues.head failed"); - return false; - } - int i = 0; - for (auto value : vec) { - head[i++] = static_cast(value); - } - vibrationValues.head = head; - } - notificationSlot.vibrationValues = vibrationValues; - notificationSlot.enabled = slot.GetEnable(); // enabled?: boolean - return true; - } - - void SetNotificationRequestByStringV2( - const NotificationRequest *request, - CNotificationRequestV2 ¬ificationRequest) - { - // label?: string - notificationRequest.label = MallocCString(request->GetLabel()); - - // groupName?: string - notificationRequest.groupName = MallocCString(request->GetGroupName()); - - // readonly creatorBundleName?: string - notificationRequest.creatorBundleName = MallocCString(request->GetCreatorBundleName()); - } - - bool SetNotificationRequestByNumberV2( - const NotificationRequest *request, - CNotificationRequestV2 ¬ificationRequest) - { - // id?: int32_t - notificationRequest.id = request->GetNotificationId(); - - // slotType?: SlotTypeV2 - SlotTypeV2 outType = SlotTypeV2::UNKNOWN_TYPE; - if (!SlotTypeCToCJV2(request->GetSlotType(), outType)) { - return false; - } - notificationRequest.notificationSlotType = static_cast(outType); - - // deliveryTime?: int32_t - notificationRequest.deliveryTime = request->GetDeliveryTime(); - - // autoDeletedTime?: int32_t - notificationRequest.autoDeletedTime = request->GetAutoDeletedTime(); - - // color ?: int32_t - notificationRequest.color = request->GetColor(); - - // badgeIconStyle ?: int32_t - notificationRequest.badgeIconStyle = static_cast(request->GetBadgeIconStyle()); - - // readonly creatorUid?: int32_t - notificationRequest.creatorUid = request->GetCreatorUid(); - - // readonly creatorPid?: int32_t - notificationRequest.creatorPid = request->GetCreatorPid(); - - // badgeNumber?: uint32_t - notificationRequest.badgeNumber = request->GetBadgeNumber(); - - return true; - } - - void SetNotificationRequestByBoolV2( - const NotificationRequest *request, - CNotificationRequestV2 ¬ificationRequest) - { - // isOngoing?: boolean - notificationRequest.isOngoing = request->IsInProgress(); - - // isUnremovable?: boolean - notificationRequest.isUnremovable = request->IsUnremovable(); - - // tapDismissed?: boolean - notificationRequest.tapDismissed = request->IsTapDismissed(); - - // colorEnabled?: boolean - notificationRequest.colorEnabled = request->IsColorEnabled(); - - // isAlertOnce?: boolean - notificationRequest.isAlertOnce = request->IsAlertOneTime(); - - // isStopwatch?: boolean - notificationRequest.isStopwatch = request->IsShowStopwatch(); - - // isCountDown?: boolean - notificationRequest.isCountDown = request->IsCountdownTimer(); - - // isFloatingIcon?: boolean - notificationRequest.isFloatingIcon = request->IsFloatingIcon(); - - // showDeliveryTime?: boolean - notificationRequest.showDeliveryTime = request->IsShowDeliveryTime(); - } - - void SetNotificationRequestByPixelMapV2( - const NotificationRequest *request, - CNotificationRequestV2 ¬ificationRequest) - { - // smallIcon?: image.PixelMap - std::shared_ptr littleIcon = request->GetLittleIcon(); - notificationRequest.smallIcon = -1; - if (littleIcon) { - auto native = FFIData::Create(littleIcon); - if (native != nullptr) { - notificationRequest.smallIcon = native->GetID(); - } - } - - // largeIcon?: image.PixelMap - notificationRequest.largeIcon = -1; - std::shared_ptr largeIcon = request->GetBigIcon(); - if (largeIcon) { - auto native = FFIData::Create(largeIcon); - if (native != nullptr) { - notificationRequest.largeIcon = native->GetID(); - } - } - } - - static void freeNotificationBasicContent(CNotificationBasicContentV2* normal) - { - free(normal->title); - free(normal->text); - free(normal->additionalText); - normal->title = nullptr; - normal->text = nullptr; - normal->additionalText = nullptr; - } - - bool SetNotificationBasicContentV2( - const NotificationBasicContent *basicContent, - CNotificationBasicContentV2* normal) - { - if (basicContent == nullptr || normal == nullptr) { - return false; - } - - // title: string - normal->title = MallocCString(basicContent->GetTitle()); - - // text: string - normal->text = MallocCString(basicContent->GetText()); - - // additionalText?: string - normal->additionalText = MallocCString(basicContent->GetAdditionalText()); - - // lockScreenPicture?: pixelMap - normal->lockscreenPicture = -1; - if (basicContent->GetLockScreenPicture()) { - std::shared_ptr pix = basicContent->GetLockScreenPicture(); - if (pix == nullptr) { - LOGE("Invalid object pixelMap"); - freeNotificationBasicContent(normal); - return false; - } - auto native = FFIData::Create(pix); - if (native == nullptr) { - LOGE("Invalid object Create pixelMap"); - freeNotificationBasicContent(normal); - return false; - } - normal->lockscreenPicture = native->GetID(); - } - return true; - } - - static void freeNotificationLongTextContent(CNotificationLongTextContentV2* longText) - { - free(longText->title); - free(longText->text); - free(longText->additionalText); - free(longText->longText); - free(longText->briefText); - free(longText->expandedTitle); - longText->title = nullptr; - longText->text = nullptr; - longText->additionalText = nullptr; - longText->longText = nullptr; - longText->briefText = nullptr; - longText->expandedTitle = nullptr; - } - - bool SetNotificationLongTextContentV2( - NotificationBasicContent *basicContent, - CNotificationLongTextContentV2* longText) - { - if (basicContent == nullptr) { - LOGE("basicContent is null."); - return false; - } - if (longText == nullptr) { - LOGE("malloc CNotificationLongTextContent failed, longText is null."); - return false; - } - - OHOS::Notification::NotificationLongTextContent *longTextContent = - static_cast(basicContent); - if (longTextContent == nullptr) { - LOGE("longTextContent is null"); - return false; - } - // title: string - longText->title = MallocCString(longTextContent->GetTitle()); - // text: string - longText->text = MallocCString(longTextContent->GetText()); - // additionalText?: string - longText->additionalText = MallocCString(longTextContent->GetAdditionalText()); - // longText: string - longText->longText = MallocCString(longTextContent->GetLongText()); - // briefText: string - longText->briefText = MallocCString(longTextContent->GetBriefText()); - // expandedTitle: string - longText->expandedTitle = MallocCString(longTextContent->GetExpandedTitle()); - // lockScreenPicture?: pixelMap - longText->lockscreenPicture = -1; - if (longTextContent->GetLockScreenPicture()) { - std::shared_ptr pix = longTextContent->GetLockScreenPicture(); - if (pix == nullptr) { - LOGE("Invalid object pixelMap"); - freeNotificationLongTextContent(longText); - return false; - } - auto native = FFIData::Create(pix); - if (native == nullptr) { - LOGE("Invalid object Create pixelMap"); - freeNotificationLongTextContent(longText); - return false; - } - longText->lockscreenPicture = native->GetID(); - } - return true; - } - - static void freeNotificationPictureContent(CNotificationPictureContentV2* picture) - { - free(picture->title); - free(picture->text); - free(picture->additionalText); - free(picture->briefText); - free(picture->expandedTitle); - picture->title = nullptr; - picture->text = nullptr; - picture->additionalText = nullptr; - picture->briefText = nullptr; - picture->expandedTitle = nullptr; - } - - bool SetNotificationPictureContentV2(NotificationBasicContent *basicContent, - CNotificationPictureContentV2* picture) - { - if (basicContent == nullptr) { - LOGE("basicContent is null"); - return false; - } - OHOS::Notification::NotificationPictureContent *pictureContent = - static_cast(basicContent); - if (pictureContent == nullptr) { - LOGE("pictureContent is null"); - return false; - } - // title、text: string - picture->title = MallocCString(pictureContent->GetTitle()); - picture->text = MallocCString(pictureContent->GetText()); - // additionalText?: string - picture->additionalText = MallocCString(pictureContent->GetAdditionalText()); - // briefText、expandedTitle: string - picture->briefText = MallocCString(pictureContent->GetBriefText()); - picture->expandedTitle = MallocCString(pictureContent->GetExpandedTitle()); - // picture: image.PixelMap - std::shared_ptr pix = pictureContent->GetBigPicture(); - if (pix == nullptr) { - LOGE("Invalid object pixelMap"); - freeNotificationPictureContent(picture); - return false; - } - auto native1 = FFIData::Create(pix); - if (native1 == nullptr) { - LOGE("Invalid object Create pixelMap"); - freeNotificationPictureContent(picture); - return false; - } - picture->picture = native1->GetID(); - // lockScreenPicture?: pixelMap - picture->lockscreenPicture = -1; - if (pictureContent->GetLockScreenPicture()) { - std::shared_ptr pixx = pictureContent->GetLockScreenPicture(); - if (pixx == nullptr) { - LOGE("Invalid object pixelMap"); - freeNotificationPictureContent(picture); - return false; - } - auto native2 = FFIData::Create(pixx); - if (native2 == nullptr) { - LOGE("Invalid object Create pixelMap"); - freeNotificationPictureContent(picture); - return false; - } - picture->lockscreenPicture = native2->GetID(); - } - return true; - } - - static void freeNotificationMultiLineContent(CNotificationMultiLineContentV2* multiLine) - { - free(multiLine->title); - free(multiLine->text); - free(multiLine->additionalText); - free(multiLine->briefText); - free(multiLine->longTitle); - if (multiLine->lines.head != nullptr) { - for (int64_t i = 0; i < multiLine->lines.size; i++) { - free(multiLine->lines.head[i]); - } - free(multiLine->lines.head); - multiLine->lines.head = nullptr; - } - multiLine->title = nullptr; - multiLine->text = nullptr; - multiLine->additionalText = nullptr; - multiLine->briefText = nullptr; - multiLine->longTitle = nullptr; - } - - bool SetNotificationMultiLineContentV2( - NotificationBasicContent *basicContent, - CNotificationMultiLineContentV2* multiLine) - { - if (basicContent == nullptr) { - LOGE("basicContent is null"); - return false; - } - OHOS::Notification::NotificationMultiLineContent *multiLineContent = - static_cast(basicContent); - if (multiLineContent == nullptr) { - LOGE("multiLineContent is null"); - return false; - } - // title、text、additionalText?: string - multiLine->title = MallocCString(multiLineContent->GetTitle()); - multiLine->text = MallocCString(multiLineContent->GetText()); - multiLine->additionalText = MallocCString(multiLineContent->GetAdditionalText()); - // briefText、longTitle: string - multiLine->briefText = MallocCString(multiLineContent->GetBriefText()); - multiLine->longTitle = MallocCString(multiLineContent->GetExpandedTitle()); - // lines: Array - auto vecs = multiLineContent->GetAllLines(); - CArrString lines = { .head = nullptr, .size = 0 }; - lines.head = static_cast(malloc(sizeof(char *) * vecs.size())); - lines.size = static_cast(vecs.size()); - if (lines.head == nullptr) { - LOGE("multiLineContent lines malloc failed"); - freeNotificationMultiLineContent(multiLine); - return false; - } - int i = 0 ; - for (auto vec : vecs) { - lines.head[i++] = MallocCString(vec); - } - multiLine->lines = lines; - // lockScreenPicture?: pixelMap - multiLine->lockscreenPicture = -1; - if (multiLineContent->GetLockScreenPicture()) { - std::shared_ptr pix = multiLineContent->GetLockScreenPicture(); - if (pix == nullptr) { - LOGE("Invalid object pixelMap"); - freeNotificationMultiLineContent(multiLine); - return false; - } - auto native2 = FFIData::Create(pix); - if (native2 == nullptr) { - LOGE("Invalid object Create pixelMap"); - freeNotificationMultiLineContent(multiLine); - return false; - } - multiLine->lockscreenPicture = native2->GetID(); - } - return true; - } - - bool SetCapsuleV2(const NotificationCapsule &capsule, CNotificationCapsuleV2 &cCapsule) - { - // title: string - cCapsule.title = MallocCString(capsule.GetTitle()); - // backgroundColor: string - cCapsule.backgroundColor = MallocCString(capsule.GetBackgroundColor()); - // icon?: image.PixelMap - std::shared_ptr icon = capsule.GetIcon(); - if (icon) { - auto native = FFIData::Create(icon); - if (native == nullptr) { - free(cCapsule.title); - free(cCapsule.backgroundColor); - cCapsule.title = nullptr; - cCapsule.backgroundColor = nullptr; - LOGE("Invalid object pixelMap of icon"); - return false; - } - cCapsule.icon = native->GetID(); - } - return true; - } - - bool SetButtonV2(const NotificationLocalLiveViewButton &button, CNotificationButtonV2 &cButton) - { - // buttonNames: Array - auto vecs = button.GetAllButtonNames(); - CArrString names = { .head = nullptr, .size = 0 }; - if (vecs.size() > 0) { - names.head = static_cast(malloc(sizeof(char *) * vecs.size())); - names.size = static_cast(vecs.size()); - if (names.head == nullptr) { - LOGE("NotificationButton names malloc failed"); - return false; - } - int i = 0; - for (auto vec : vecs) { - names.head[i++] = MallocCString(vec); - } - } - cButton.names = names; - - // buttonIcons: Array - int iconCount = 0; - std::vector> iconsVec = button.GetAllButtonIcons(); - CArrI64 icons = { .head = nullptr, .size = 0 }; - if (iconsVec.size()) { - icons.head = static_cast(malloc(sizeof(int64_t) * iconsVec.size())); - if (icons.head == nullptr) { - LOGE("NotificationButton icons malloc failed"); - return false; - } - for (auto vec : iconsVec) { - if (!vec) { - continue; - } - // buttonIcon - auto native = FFIData::Create(vec); - if (native == nullptr) { - LOGE("Invalid object pixelMap of buttonIcons."); - return false; // memory free at cj - } - icons.head[iconCount++] = native->GetID(); - } - } - icons.size = static_cast(iconsVec.size()); - cButton.icons = icons; - return true; - } - - bool SetNotificationLocalLiveViewContentDetailedV2(NotificationLocalLiveViewContent *localLiveViewContent, - CNotificationSystemLiveViewContentV2* systemLiveView) - { - // capsule: NotificationCapsule - CNotificationCapsuleV2 capsule = { - .title = nullptr, - .icon = -1, - .backgroundColor = nullptr - }; - if (localLiveViewContent->isFlagExist(NotificationLocalLiveViewContent::LiveViewContentInner::CAPSULE)) { - if (!SetCapsuleV2(localLiveViewContent->GetCapsule(), capsule)) { - LOGE("SetCapsuleV2 call failed"); - return false; - } - } - systemLiveView->capsule = capsule; - - // button: NotificationLocalLiveViewButton - CNotificationButtonV2 cButton = { - .names = { .head = nullptr, .size = 0 }, - .icons = { .head = nullptr, .size = 0 } - }; - if (localLiveViewContent->isFlagExist(NotificationLocalLiveViewContent::LiveViewContentInner::BUTTON)) { - if (!SetButtonV2(localLiveViewContent->GetButton(), cButton)) { - LOGE("SetButtonV2 call failed"); - return false; - } - } - systemLiveView->button = cButton; - - // progress: NotificationProgress - CNotificationProgressV2 cProgress; - if (localLiveViewContent->isFlagExist(NotificationLocalLiveViewContent::LiveViewContentInner::PROGRESS)) { - NotificationProgress progress = localLiveViewContent->GetProgress(); - cProgress.maxValue = progress.GetMaxValue(); - cProgress.currentValue = progress.GetCurrentValue(); - cProgress.isPercentage = progress.GetIsPercentage(); - } - systemLiveView->progress = cProgress; - - // time: NotificationTime - CNotificationTimeV2 cTime; - if (localLiveViewContent->isFlagExist(NotificationLocalLiveViewContent::LiveViewContentInner::TIME)) { - NotificationTime time = localLiveViewContent->GetTime(); - bool flag = localLiveViewContent->isFlagExist( - NotificationLocalLiveViewContent::LiveViewContentInner::INITIAL_TIME); - cTime.initialTime = flag ? time.GetInitialTime() : 0; - cTime.isCountDown = time.GetIsCountDown(); - cTime.isPaused = time.GetIsPaused(); - cTime.isInTitle = time.GetIsInTitle(); - } - systemLiveView->time = cTime; - - return true; - } - - bool SetNotificationLocalLiveViewContentV2(NotificationBasicContent *basicContent, - CNotificationSystemLiveViewContentV2* systemLiveView) - { - if (basicContent == nullptr) { - LOGE("basicContent is null."); - return false; - } - if (systemLiveView == nullptr) { - LOGE("malloc CNotificationSystemLiveViewContent failed, systemLiveView is null"); - return false; - } - OHOS::Notification::NotificationLocalLiveViewContent *localLiveViewContent = - static_cast(basicContent); - if (localLiveViewContent == nullptr) { - LOGE("localLiveViewContent is null"); - return false; - } - - // title, text, additionalText? - systemLiveView->title = MallocCString(localLiveViewContent->GetTitle()); - systemLiveView->text = MallocCString(localLiveViewContent->GetText()); - systemLiveView->additionalText = MallocCString(localLiveViewContent->GetAdditionalText()); - // typeCode: int32_t - systemLiveView->typeCode = localLiveViewContent->GetType(); - - if (!SetNotificationLocalLiveViewContentDetailedV2(localLiveViewContent, systemLiveView)) { - LOGE("SetNotificationLocalLiveViewContentDetail call failed"); - return false; - } - - // lockScreenPicture?: pixelMap - systemLiveView->lockscreenPicture = -1; - if (localLiveViewContent->GetLockScreenPicture()) { - std::shared_ptr pix = localLiveViewContent->GetLockScreenPicture(); - if (pix == nullptr) { - LOGE("Invalid object pixelMap"); - return false; - } - auto native2 = FFIData::Create(pix); - if (native2 == nullptr) { - LOGE("Invalid object Create pixelMap"); - return false; - } - systemLiveView->lockscreenPicture = native2->GetID(); - } - return true; - } - - bool SetNotificationContentDetailedV2(const ContentTypeV2 &type, - const std::shared_ptr &content, CNotificationContentV2 ¬ificationContent) - { - bool ret = false; - std::shared_ptr basicContent = content->GetNotificationContent(); - if (basicContent == nullptr) { - LOGE("content is null"); - return ret; - } - switch (type) { - // normal?: NotificationBasicContent - case ContentTypeV2::NOTIFICATION_CONTENT_BASIC_TEXT: - notificationContent.normal = - static_cast(malloc(sizeof(CNotificationBasicContentV2))); - ret = SetNotificationBasicContentV2(basicContent.get(), notificationContent.normal); - break; - // longText?: NotificationLongTextContent - case ContentTypeV2::NOTIFICATION_CONTENT_LONG_TEXT: - notificationContent.longText = - static_cast(malloc(sizeof(CNotificationLongTextContentV2))); - ret = SetNotificationLongTextContentV2(basicContent.get(), notificationContent.longText); - break; - // picture?: NotificationPictureContent - case ContentTypeV2::NOTIFICATION_CONTENT_PICTURE: - notificationContent.picture = - static_cast(malloc(sizeof(CNotificationPictureContentV2))); - if (notificationContent.picture == nullptr) { - LOGE("SetNotificationContentDetailedV2 malloc CNotificationPictureContent failed."); - return false; - } - ret = SetNotificationPictureContentV2(basicContent.get(), notificationContent.picture); - break; - // multiLine?: NotificationMultiLineContent - case ContentTypeV2::NOTIFICATION_CONTENT_MULTILINE: - notificationContent.multiLine = - static_cast(malloc(sizeof(CNotificationMultiLineContentV2))); - if (notificationContent.multiLine == nullptr) { - LOGE("SetNotificationContentDetailedV2 malloc CNotificationMultiLineContent failed."); - return false; - } - ret = SetNotificationMultiLineContentV2(basicContent.get(), notificationContent.multiLine); - break; - // systemLiveView?: NotificationLocalLiveViewContent - case ContentTypeV2::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW: - notificationContent.systemLiveView = static_cast( - malloc(sizeof(CNotificationSystemLiveViewContentV2))); - ret = SetNotificationLocalLiveViewContentV2(basicContent.get(), notificationContent.systemLiveView); - break; - // liveView?: NotificationLiveViewContent - case ContentTypeV2::NOTIFICATION_CONTENT_LIVE_VIEW: - LOGE("ContentType::NOTIFICATION_CONTENT_LIVE_VIEW is not support"); - break; - default: - LOGE("ContentType is does not exist"); - return ret; - } - return ret; - } - - bool SetNotificationContentV2( - const std::shared_ptr &content, - CNotificationContentV2 ¬ificationContent) - { - // contentType: ContentTypeV2 - NotificationContent::Type type = content->GetContentType(); - ContentTypeV2 outType = ContentTypeV2::NOTIFICATION_CONTENT_BASIC_TEXT; - if (!ContentTypeCToCJV2(type, outType)) { - return false; - } - notificationContent.notificationContentType = static_cast(outType); - if (!SetNotificationContentDetailedV2(outType, content, notificationContent)) { - LOGE("SetNotificationContentDetailedV2 failed"); - return false; - } - return true; - } - - bool SetNotificationFlagsV2( - const std::shared_ptr &flags, - CNotificationFlagsV2 ¬ificationFlags) - { - if (flags == nullptr) { - LOGE("flags is null"); - return false; - } - notificationFlags.soundEnabled = static_cast(flags->IsSoundEnabled()); - notificationFlags.vibrationEnabled = static_cast(flags->IsVibrationEnabled()); - return true; - } - - bool SetNotificationRequestByCustomV2( - const NotificationRequest *request, - CNotificationRequestV2 ¬ificationRequest) - { - // content: NotificationContent - std::shared_ptr content = request->GetContent(); - if (!content) { - LOGE("content is nullptr"); - return false; - } - if (!SetNotificationContentV2(content, notificationRequest.notificationContent)) { - LOGE("SetNotificationContentV2 call failed"); - return false; - } - - // readonly notificationFlags?: NotificationFlags - std::shared_ptr flags = request->GetFlags(); - if (flags) { - if (!SetNotificationFlagsV2(flags, notificationRequest.notificationFlags)) { - LOGE("SetNotificationFlagsV2 call failed"); - return false; - } - } - return true; - } - - static void InitNotificationRequest(CNotificationRequestV2 ¬ificationRequest) - { - notificationRequest.notificationContent = { - .notificationContentType = 0, - .normal = nullptr, - .longText = nullptr, - .multiLine = nullptr, - .picture = nullptr - }; - notificationRequest.label = nullptr; - notificationRequest.creatorBundleName = nullptr; - notificationRequest.groupName = nullptr; - notificationRequest.distributedOption = nullptr; - notificationRequest.hashCode = nullptr; - notificationRequest.appMessageId = nullptr; - } - - bool SetNotificationRequestV2( - const NotificationRequest *request, - CNotificationRequestV2 ¬ificationRequest) - { - if (request == nullptr) { - LOGE("request is nullptr"); - return false; - } - InitNotificationRequest(notificationRequest); - SetNotificationRequestByStringV2(request, notificationRequest); - SetNotificationRequestByBoolV2(request, notificationRequest); - SetNotificationRequestByPixelMapV2(request, notificationRequest); - if (!SetNotificationRequestByNumberV2(request, notificationRequest)) { - LOGE("SetNotificationRequestByNumberV2 failed"); - return false; - } - if (!SetNotificationRequestByCustomV2(request, notificationRequest)) { - LOGE("SetNotificationRequestByCustomV2 failed"); - return false; - } - return true; - } -} -} -} \ No newline at end of file -- Gitee From cb3dacbd87f2706f14aacd58dd67dc86ed9a718c Mon Sep 17 00:00:00 2001 From: heguokai Date: Mon, 24 Mar 2025 08:29:47 +0000 Subject: [PATCH 3/3] update frameworks/ans/src/notification_request.cpp. Signed-off-by: heguokai --- frameworks/ans/src/notification_request.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/ans/src/notification_request.cpp b/frameworks/ans/src/notification_request.cpp index e76f44e56..c1f298089 100644 --- a/frameworks/ans/src/notification_request.cpp +++ b/frameworks/ans/src/notification_request.cpp @@ -236,7 +236,7 @@ void NotificationRequest::SetIsAgentNotification(bool isAgent) void NotificationRequest::AddMessageUser(const std::shared_ptr &messageUser) { if (!messageUser) { - ANS_LOG("messageUser can not be null"); + ANS_LOGE("messageUser can not be null"); return; } -- Gitee