From 3e9b1514bbc4e0f4af321e5c3ef18625a85891b7 Mon Sep 17 00:00:00 2001 From: heguokai Date: Wed, 25 Jun 2025 17:32:32 +0800 Subject: [PATCH 1/4] fix for erro && capsule param Signed-off-by: heguokai --- frameworks/ets/ani/include/sts_common.h | 2 + .../ani/include/sts_notification_content.h | 2 +- frameworks/ets/ani/src/manager/ani_cance.cpp | 32 ++-- .../ets/ani/src/manager/ani_display_badge.cpp | 16 +- .../src/manager/ani_distributed_enable.cpp | 44 ++--- .../src/manager/ani_do_not_disturb_date.cpp | 20 +-- .../manager/ani_do_not_disturb_profile.cpp | 12 +- .../ets/ani/src/manager/ani_get_active.cpp | 16 +- .../ani/src/manager/ani_local_live_view.cpp | 8 +- .../src/manager/ani_notification_enable.cpp | 36 ++-- .../ets/ani/src/manager/ani_publish.cpp | 16 +- .../ets/ani/src/manager/ani_remove_group.cpp | 4 +- frameworks/ets/ani/src/manager/ani_slot.cpp | 60 +++---- .../ani/src/manager/ani_support_template.cpp | 8 +- .../ets/ani/src/manager/ani_sync_config.cpp | 4 +- frameworks/ets/ani/src/sts_common.cpp | 16 ++ .../ets/ani/src/sts_notification_content.cpp | 166 ++++++++++++------ frameworks/ets/ani/src/sts_subscribe.cpp | 5 +- .../ets/ets/@ohos.notificationManager.ets | 24 +-- 19 files changed, 278 insertions(+), 213 deletions(-) diff --git a/frameworks/ets/ani/include/sts_common.h b/frameworks/ets/ani/include/sts_common.h index 35f9d908f..8fc00d4e5 100644 --- a/frameworks/ets/ani/include/sts_common.h +++ b/frameworks/ets/ani/include/sts_common.h @@ -56,6 +56,8 @@ ani_status GetPropertyStringArray(ani_env *env, ani_object param, const char *na ani_status GetPropertyNumberArray(ani_env *env, ani_object param, const char *name, ani_boolean &isUndefined, std::vector &res); +void GetPropertyRefValue(ani_env *env, ani_object obj, const char *name, ani_boolean &isUndefined, ani_ref &outRef); + bool SetFieldString(ani_env *env, ani_class cls, ani_object &object, const std::string fieldName, const std::string value); bool SetOptionalFieldBoolean(ani_env *env, ani_class cls, ani_object &object, diff --git a/frameworks/ets/ani/include/sts_notification_content.h b/frameworks/ets/ani/include/sts_notification_content.h index cd6051dbc..ba4656b72 100644 --- a/frameworks/ets/ani/include/sts_notification_content.h +++ b/frameworks/ets/ani/include/sts_notification_content.h @@ -75,7 +75,7 @@ void UnWarpNotificationLocalLiveViewButton(ani_env *env, ani_object obj, bool WarpNotificationLocalLiveViewButton(ani_env *env, const NotificationLocalLiveViewButton &button, ani_object &buttonObject); -void UnWarpNotificationCapsule(ani_env *env, ani_object obj, NotificationCapsule &capsule); +bool UnWarpNotificationCapsule(ani_env *env, ani_object obj, NotificationCapsule &capsule); bool WarpNotificationCapsule(ani_env *env, const NotificationCapsule &capsule, ani_object &capsuleObject); ani_status UnWarpNotificationBasicContent(ani_env *env, ani_object obj, diff --git a/frameworks/ets/ani/src/manager/ani_cance.cpp b/frameworks/ets/ani/src/manager/ani_cance.cpp index bc48b59e9..f2ff17699 100644 --- a/frameworks/ets/ani/src/manager/ani_cance.cpp +++ b/frameworks/ets/ani/src/manager/ani_cance.cpp @@ -26,8 +26,8 @@ void AniCancelAll(ani_env* env) { ANS_LOGD("AniCancelAll notifications call"); int returncode = Notification::NotificationHelper::CancelAllNotifications(); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniCancelAll -> error, errorCode: %{public}d", externalCode); } @@ -38,8 +38,8 @@ void AniCancelWithId(ani_env* env, ani_double id) { ANS_LOGD("AniCancelWithId call,id : %{public}lf", id); int returncode = Notification::NotificationHelper::CancelNotification(static_cast(id)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniCancelWithId -> error, errorCode: %{public}d", externalCode); } @@ -57,8 +57,8 @@ void AniCancelWithIdLabel(ani_env* env, ani_double id, ani_string label) std::string labelStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); ANS_LOGD("Cancel by label id:%{public}lf label:%{public}s", id, labelStr.c_str()); int returncode = Notification::NotificationHelper::CancelNotification(labelStr, static_cast(id)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniCancelWithIdLabel -> error, errorCode: %{public}d", externalCode); } @@ -77,8 +77,8 @@ void AniCancelWithBundle(ani_env* env, ani_object bundleObj, ani_double id) ANS_LOGD("Cancel by bundle:%{public}s id:%{public}lf", option.GetBundleName().c_str(), id); int returncode = Notification::NotificationHelper::CancelAsBundle(option, static_cast(id)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniCancelWithBundle -> error, errorCode: %{public}d", externalCode); } @@ -106,8 +106,8 @@ void AniCancelWithIdOptinalLabel(ani_env* env, ani_double id, ani_string label) ANS_LOGD("sts AniCancelWithIdOptinalLabel id:%{public}lf label:%{public}s", id, labelStr.c_str()); ret = Notification::NotificationHelper::CancelNotification(labelStr, id); } - int externalCode = NotificationSts::GetExternalCode(ret); - if (externalCode != ERR_OK) { + if (ret != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(ret); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("sts AniCancelWithIdOptinalLabel error, errorCode: %{public}d", externalCode); return; @@ -131,8 +131,8 @@ void AniCancelAsBundle(ani_env *env, ani_double id, ani_string representativeBun convertedId, UserId, bundleStr.c_str()); int returncode = Notification::NotificationHelper::CancelAsBundle(convertedId, bundleStr, UserId); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniCancelAsBundle: CancelAsBundle retern erro. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); @@ -156,8 +156,8 @@ void AniCancelAsBundleWithBundleOption(ani_env *env, ani_object representativeBu option.GetBundleName().c_str(), option.GetUid(), idTest); int returncode = Notification::NotificationHelper::CancelAsBundle(option, idTest); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("CancelAsBundle retern error. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); @@ -178,8 +178,8 @@ void AniCancelGroup(ani_env *env, ani_string groupName) std::string groupNameStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); ANS_LOGD("AniCancelGroup groupNameStr: %{public}s", groupNameStr.c_str()); int returncode = Notification::NotificationHelper::CancelGroup(groupNameStr); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniCancelGroup: CancelAsBundle retern erro. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); diff --git a/frameworks/ets/ani/src/manager/ani_display_badge.cpp b/frameworks/ets/ani/src/manager/ani_display_badge.cpp index d1a4d6532..8bda85b5b 100644 --- a/frameworks/ets/ani/src/manager/ani_display_badge.cpp +++ b/frameworks/ets/ani/src/manager/ani_display_badge.cpp @@ -39,8 +39,8 @@ void AniDisplayBadge(ani_env *env, ani_object obj, ani_boolean enable) ANS_LOGE("sts DisplayBadge ERROR_INTERNAL_ERROR"); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("sts DisplayBadge error, errorCode: %{public}d", externalCode); return; @@ -67,8 +67,8 @@ ani_boolean AniIsBadgeDisplayed(ani_env *env, ani_object obj) } } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("sts IsBadgeDisplayed error, errorCode: %{public}d", externalCode); return NotificationSts::BoolToAniBoolean(false); @@ -82,8 +82,8 @@ void AniSetBadgeNumber(ani_env *env, ani_double badgeNumber) { ANS_LOGD("sts AniSetBadgeNumber call, BadgeNumber: %{public}lf", badgeNumber); int returncode = Notification::NotificationHelper::SetBadgeNumber(static_cast(badgeNumber)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts AniSetBadgeNumber error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -104,8 +104,8 @@ void AniSetBadgeNumberByBundle(ani_env *env, ani_object obj, ani_double badgeNum NotificationSts::FindAnsErrMsg(OHOS::Notification::ERROR_INTERNAL_ERROR)); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts AniSetBadgeNumberByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } diff --git a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp index 4d8ce628a..bb9618abe 100755 --- a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp @@ -27,8 +27,8 @@ void AniSetDistributedEnable(ani_env* env, ani_boolean enabled) { ANS_LOGD("AniSetDistributedEnable call,enable : %{public}d", enabled); int returncode = Notification::NotificationHelper::EnableDistributed(NotificationSts::AniBooleanToBool(enabled)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSetDistributedEnable -> error, errorCode: %{public}d", externalCode); return; @@ -41,8 +41,8 @@ ani_boolean AniIsDistributedEnabled(ani_env* env) ANS_LOGD("AniIsDistributedEnabled call"); bool enabled = false; int returncode = Notification::NotificationHelper::IsDistributedEnabled(enabled); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsDistributedEnabled -> error, errorCode: %{public}d", externalCode); return NotificationSts::BoolToAniBoolean(false); @@ -61,8 +61,8 @@ ani_boolean AniIsDistributedEnabledByBundle(ani_env* env, ani_object obj) } bool enabled = false; int returncode = Notification::NotificationHelper::IsDistributedEnableByBundle(option, enabled); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsDistributedEnabledByBundle -> error, errorCode: %{public}d", externalCode); } @@ -87,8 +87,8 @@ ani_boolean AniIsDistributedEnabledByBundleType(ani_env* env, ani_object obj, an bool enabled = false; int returncode = Notification::NotificationHelper::IsDistributedEnabledByBundle(option, deviceTypeStr, enabled); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsDistributedEnabledByBundle -> error, errorCode: %{public}d", externalCode); } @@ -111,8 +111,8 @@ void AniSetDistributedEnableByBundle(ani_env *env, ani_object obj, ani_boolean e NotificationSts::FindAnsErrMsg(OHOS::Notification::ERROR_INTERNAL_ERROR)); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts setDistributedEnableByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -143,8 +143,8 @@ void AniSetDistributedEnableByBundleAndType(ani_env *env, NotificationSts::FindAnsErrMsg(OHOS::Notification::ERROR_INTERNAL_ERROR)); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts setDistributedEnabledByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -164,8 +164,8 @@ void AniSetTargetDeviceStatus(ani_env* env, ani_string deviceType, ani_double st } ANS_LOGD("sts setTargetDeviceStatus id:%{public}lf deviceType:%{public}s", status, deviceTypeStr.c_str()); int32_t ret = Notification::NotificationHelper::SetTargetDeviceStatus(deviceTypeStr, status, DISTURB_DEFAULT_FLAG); - int externalCode = NotificationSts::GetExternalCode(ret); - if (externalCode != ERR_OK) { + if (ret != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(ret); ANS_LOGE("sts setTargetDeviceStatus error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -189,8 +189,8 @@ ani_boolean AniIsSmartReminderEnabled(ani_env *env, ani_string deviceType) return ANI_FALSE; } int returncode = Notification::NotificationHelper::IsSmartReminderEnabled(deviceTypeStr, allowed); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("isSmartReminderEnabled -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -216,8 +216,8 @@ void AniSetSmartReminderEnable(ani_env *env, ani_string deviceType, ani_boolean } int returncode = Notification::NotificationHelper::SetSmartReminderEnabled(deviceTypeStr, NotificationSts::AniBooleanToBool(enable)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("setSmartReminderEnabled -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -249,8 +249,8 @@ void AniSetDistributedEnableBySlot(ani_env *env, ani_enum_item slot, ani_string returncode = Notification::NotificationHelper::SetDistributedEnabledBySlot(slotType, deviceTypeStr, NotificationSts::AniBooleanToBool(enable)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("setDistributedEnabledBySlot error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -280,8 +280,8 @@ ani_boolean AniIsDistributedEnabledBySlot(ani_env *env, ani_enum_item slot, ani_ } bool isEnable = false; int returncode = Notification::NotificationHelper::IsDistributedEnabledBySlot(slotType, deviceTypeStr, isEnable); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("isDistributedEnabledBySlot -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } diff --git a/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp b/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp index 226e42790..4b742fcfb 100644 --- a/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp +++ b/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp @@ -35,8 +35,8 @@ void AniSetDoNotDisturbDate(ani_env *env, ani_object date) } int returncode = Notification::NotificationHelper::SetDoNotDisturbDate(doNotDisturbDate); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("SetDoNotDisturbDate error. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); @@ -56,8 +56,8 @@ void AniSetDoNotDisturbDateWithId(ani_env *env, ani_object date, ani_double user const int32_t id = static_cast(userId); int returncode = Notification::NotificationHelper::SetDoNotDisturbDate(id, doNotDisturbDate); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("SetDoNotDisturbDate erro. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); @@ -73,8 +73,8 @@ ani_object AniGetDoNotDisturbDate(ani_env *env) ANS_LOGD("AniGetDoNotDisturbDate enter"); int returncode = Notification::NotificationHelper::GetDoNotDisturbDate(doNotDisturbDate); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("GetDoNotDisturbDate retern erro. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); @@ -100,8 +100,8 @@ ani_object AniGetDoNotDisturbDateWithId(ani_env *env, ani_double userId) const int32_t id = static_cast(userId); int returncode = Notification::NotificationHelper::GetDoNotDisturbDate(id, doNotDisturbDate); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("GetDoNotDisturbDate erro. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); @@ -122,8 +122,8 @@ ani_boolean AniIsSupportDoNotDisturbMode(ani_env *env) bool supportDoNotDisturbMode = false; ANS_LOGD("AniIsSupportDoNotDisturbMode enter"); int returncode = Notification::NotificationHelper::DoesSupportDoNotDisturbMode(supportDoNotDisturbMode); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("DoesSupportDoNotDisturbMode error. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); diff --git a/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp b/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp index 6d32f3bf5..faf2fd4e6 100644 --- a/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp +++ b/frameworks/ets/ani/src/manager/ani_do_not_disturb_profile.cpp @@ -36,8 +36,8 @@ void AniAddDoNotDisturbProfile(ani_env *env, ani_object obj) ANS_LOGE("AniAddDoNotDisturbProfile failed : ERROR_INTERNAL_ERROR"); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniAddDoNotDisturbProfile error, errorCode: %{public}d", externalCode); } @@ -57,8 +57,8 @@ void AniRemoveDoNotDisturbProfile(ani_env *env, ani_object obj) ANS_LOGE("AniRemoveDoNotDisturbProfile failed : ERROR_INTERNAL_ERROR"); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniRemoveDoNotDisturbProfile error, errorCode: %{public}d", externalCode); } @@ -81,8 +81,8 @@ ani_object AniGetDoNotDisturbProfile(ani_env *env, ani_double id) int32_t idTest = static_cast(id); ANS_LOGD("AniGetDoNotDisturbProfile: idTest: %{public}d", idTest); int returncode = Notification::NotificationHelper::GetDoNotDisturbProfile(idTest, doNotDisturbProfile); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetDoNotDisturbDateWithId error, errorCode: %{public}d, returncode: %{public}d", externalCode, returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); diff --git a/frameworks/ets/ani/src/manager/ani_get_active.cpp b/frameworks/ets/ani/src/manager/ani_get_active.cpp index b22e68405..aaf611ddc 100644 --- a/frameworks/ets/ani/src/manager/ani_get_active.cpp +++ b/frameworks/ets/ani/src/manager/ani_get_active.cpp @@ -29,8 +29,8 @@ ani_double AniGetActiveNotificationCount(ani_env *env) int returncode = OHOS::Notification::NotificationHelper::GetActiveNotificationNums(num); ANS_LOGD("sts GetActiveNotificationCount end, num: %{public}llu", num); ani_double retNum = static_cast(num); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); return 0; @@ -43,8 +43,8 @@ ani_object AniGetAllActiveNotifications(ani_env *env) ANS_LOGD("sts AniGetAllActiveNotifications call"); std::vector> notifications; int returncode = OHOS::Notification::NotificationHelper::GetAllActiveNotifications(notifications); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniGetAllActiveNotifications error, errorCode: %{public}d", externalCode); return nullptr; @@ -69,8 +69,8 @@ ani_object AniGetActiveNotifications(ani_env *env) ANS_LOGD("sts AniGetActiveNotifications call"); std::vector> requests; int returncode = OHOS::Notification::NotificationHelper::GetActiveNotifications(requests); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniGetActiveNotifications error, errorCode: %{public}d", externalCode); return nullptr; @@ -100,8 +100,8 @@ ani_object AniGetActiveNotificationByFilter(ani_env *env, ani_object obj) } sptr notificationRequest = nullptr; int returncode = Notification::NotificationHelper::GetActiveNotificationByFilter(filter, notificationRequest); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetActiveNotificationByFilter -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; diff --git a/frameworks/ets/ani/src/manager/ani_local_live_view.cpp b/frameworks/ets/ani/src/manager/ani_local_live_view.cpp index 5d7179c5f..5bf5afe85 100644 --- a/frameworks/ets/ani/src/manager/ani_local_live_view.cpp +++ b/frameworks/ets/ani/src/manager/ani_local_live_view.cpp @@ -43,8 +43,8 @@ void AniTriggerSystemLiveView( } int returncode = OHOS::Notification::NotificationHelper::TriggerLocalLiveView(bundleOption, static_cast(notificationId), buttonOption); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniTriggerSystemLiveView error, errorCode: %{public}d", externalCode); } @@ -59,8 +59,8 @@ void AniSubscribeSystemLiveView(ani_env *env, ani_object subscriberObj) localLiveViewSubscriber->SetStsNotificationLocalLiveViewSubscriber(env, subscriberObj); int returncode = OHOS::Notification::NotificationHelper::SubscribeLocalLiveViewNotification(*localLiveViewSubscriber, false); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSubscribeSystemLiveView error, errorCode: %{public}d", externalCode); } diff --git a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp index aae5494da..07c974693 100644 --- a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp @@ -27,8 +27,8 @@ ani_boolean AniIsNotificationEnabled(ani_env *env) ANS_LOGD("AniIsNotificationEnabled call"); bool allowed = false; int returncode = Notification::NotificationHelper::IsAllowedNotifySelf(allowed); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsNotificationEnabled -> error, errorCode: %{public}d", externalCode); } @@ -41,8 +41,8 @@ ani_boolean AniIsNotificationEnabledWithId(ani_env *env, ani_double userId) ANS_LOGD("AniIsNotificationEnabledWithId call"); bool allowed = false; int returncode = Notification::NotificationHelper::IsAllowedNotify(userId, allowed); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsNotificationEnabledWithId -> error, errorCode: %{public}d", externalCode); } @@ -63,8 +63,8 @@ ani_boolean AniIsNotificationEnabledWithBundleOption(ani_env *env, ani_object bu return ANI_FALSE; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsNotificationEnabledWithBundleOption -> error, errorCode: %{public}d", externalCode); return ANI_FALSE; @@ -84,8 +84,8 @@ void AniSetNotificationEnable(ani_env *env, ani_object bundleOption, ani_boolean std::string deviceId {""}; int returncode = Notification::NotificationHelper::SetNotificationsEnabledForSpecifiedBundle(option, deviceId, NotificationSts::AniBooleanToBool(enable)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSetNotificationEnable -> error, errorCode: %{public}d", externalCode); } @@ -97,8 +97,8 @@ ani_object AniGetAllNotificationEnabledBundles(ani_env *env) ANS_LOGD("AniGetAllNotificationEnabledBundles call"); std::vector bundleOptions = {}; int returncode = Notification::NotificationHelper::GetAllNotificationEnabledBundles(bundleOptions); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetAllNotificationEnabledBundles -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; @@ -117,8 +117,8 @@ ani_boolean AniIsNotificationEnabledSync(ani_env *env) ANS_LOGD("AniIsNotificationEnabledSync call"); bool allowed = false; int returncode = Notification::NotificationHelper::IsAllowedNotifySelf(allowed); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniIsNotificationEnabledSync -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); @@ -132,8 +132,8 @@ ani_boolean AniGetSyncNotificationEnabledWithoutApp(ani_env* env, ani_double use bool enabled = false; int returncode = Notification::NotificationHelper::GetSyncNotificationEnabledWithoutApp( static_cast(userId), enabled); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetSyncNotificationEnabledWithoutApp -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); @@ -147,8 +147,8 @@ void AniSetSyncNotificationEnabledWithoutApp(ani_env* env, ani_double userId, an ANS_LOGD("AniSetSyncNotificationEnabledWithoutApp call,enable : %{public}d", enabled); int returncode = Notification::NotificationHelper::SetSyncNotificationEnabledWithoutApp( static_cast(userId), NotificationSts::AniBooleanToBool(enabled)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetSyncNotificationEnabledWithoutApp -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -172,8 +172,8 @@ void AniDisableNotificationFeature(ani_env *env, ani_boolean disabled, ani_objec int returncode = ERR_OK; returncode = Notification::NotificationHelper::DisableNotificationFeature(param); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniDisableNotificationFeature error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } diff --git a/frameworks/ets/ani/src/manager/ani_publish.cpp b/frameworks/ets/ani/src/manager/ani_publish.cpp index 674d6b945..64f6676fa 100644 --- a/frameworks/ets/ani/src/manager/ani_publish.cpp +++ b/frameworks/ets/ani/src/manager/ani_publish.cpp @@ -36,8 +36,8 @@ void AniPublish(ani_env *env, ani_object obj) return; } int returncode = NotificationHelper::PublishNotification(*notificationRequest); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } ANS_LOGD("AniPublish end"); @@ -54,8 +54,8 @@ void AniPublishWithId(ani_env *env, ani_object obj, ani_double userId) } notificationRequest->SetOwnerUserId(static_cast(userId)); int returncode = NotificationHelper::PublishNotification(*notificationRequest); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniPublishWithId error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -80,8 +80,8 @@ void AniPublishAsBundle(ani_env *env, ani_object request, ani_string representat notificationRequest->SetOwnerUserId(static_cast(userId)); notificationRequest->SetOwnerBundleName(bundleStr); int returncode = NotificationHelper::PublishNotification(*notificationRequest); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniPublishAsBundle: PublishNotificationerror, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -111,8 +111,8 @@ void AniPublishAsBundleWithBundleOption(ani_env *env, ani_object representativeB notificationRequest->SetIsAgentNotification(true); int returncode = NotificationHelper::PublishNotification(*notificationRequest); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniPublishAsBundleWithBundleOption error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } diff --git a/frameworks/ets/ani/src/manager/ani_remove_group.cpp b/frameworks/ets/ani/src/manager/ani_remove_group.cpp index 33d90ca76..7c3b3f3b8 100644 --- a/frameworks/ets/ani/src/manager/ani_remove_group.cpp +++ b/frameworks/ets/ani/src/manager/ani_remove_group.cpp @@ -42,8 +42,8 @@ void AniRemoveGroupByBundle(ani_env *env, ani_object bundleOption, ani_string gr } std::string groupNameStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); int returncode = OHOS::Notification::NotificationHelper::RemoveGroupByBundle(option, groupNameStr); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniRemoveGroupByBundle -> error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } diff --git a/frameworks/ets/ani/src/manager/ani_slot.cpp b/frameworks/ets/ani/src/manager/ani_slot.cpp index d0d49fc53..8e5ea1c8b 100644 --- a/frameworks/ets/ani/src/manager/ani_slot.cpp +++ b/frameworks/ets/ani/src/manager/ani_slot.cpp @@ -43,8 +43,8 @@ ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption) return nullptr; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts GetSlotsByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; @@ -68,8 +68,8 @@ void AniAddSlots(ani_env *env, ani_object notificationSlotArrayObj) return; } int returncode = Notification::NotificationHelper::AddNotificationSlots(slots); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniAddSlots -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -88,8 +88,8 @@ void AniAddSlotByNotificationSlot(ani_env *env, ani_object notificationSlotObj) NotificationSts::ThrowStsErroWithMsg(env, "sts AddSlot ERROR_INTERNAL_ERROR"); return; } - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts AddSlot error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -106,8 +106,8 @@ void AniAddSlotBySlotType(ani_env *env, ani_enum_item enumObj) return; } int returncode = Notification::NotificationHelper::AddSlotByType(slotType); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniAddSlotBySlotType -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -126,8 +126,8 @@ ani_object AniGetSlot(ani_env *env, ani_enum_item enumObj) } sptr slot = nullptr; int returncode = Notification::NotificationHelper::GetNotificationSlot(slotType, slot); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetSlot -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -151,8 +151,8 @@ ani_object AniGetSlots(ani_env *env) ANS_LOGD("AniGetSlots enter"); std::vector> slots; int returncode = Notification::NotificationHelper::GetNotificationSlots(slots); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetSlots -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; @@ -177,8 +177,8 @@ void AniRemoveSlot(ani_env *env, ani_enum_item enumObj) return; } int returncode = Notification::NotificationHelper::RemoveNotificationSlot(slotType); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniRemoveSlot -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -190,8 +190,8 @@ void AniRemoveAllSlots(ani_env *env) { ANS_LOGD("AniRemoveAllSlots enter"); int returncode = Notification::NotificationHelper::RemoveAllSlots(); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniRemoveAllSlots -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -226,8 +226,8 @@ void AniSetSlotByBundle(ani_env *env, ani_object bundleOptionObj, ani_object slo slotsVct.emplace_back(slotPtr); int returncode = Notification::NotificationHelper::UpdateNotificationSlots(option, slotsVct); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts SetSlotByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -246,8 +246,8 @@ ani_double AniGetSlotNumByBundle(ani_env *env, ani_object bundleOption) } uint64_t num = 0; int returncode = Notification::NotificationHelper::GetNotificationSlotNumAsBundle(option, num); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts GetSlotNumByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return RETURN_EXCEPTION_VALUE; @@ -274,8 +274,8 @@ void AniSetNotificationEnableSlot(ani_env *env, ani_object bundleOption, ani_enu returncode = Notification::NotificationHelper::SetEnabledForBundleSlot(option, slotType, NotificationSts::AniBooleanToBool(enable), isForceControl); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetNotificationEnableSlot error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; @@ -299,8 +299,8 @@ void AniSetNotificationEnableSlotWithForce(ani_env *env, returncode = Notification::NotificationHelper::SetEnabledForBundleSlot(option, slotType, NotificationSts::AniBooleanToBool(enable), NotificationSts::AniBooleanToBool(isForceControl)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -319,8 +319,8 @@ ani_boolean AniIsNotificationSlotEnabled(ani_env *env, ani_object bundleOption, bool isEnable = false; int returncode = Notification::NotificationHelper::GetEnabledForBundleSlot(option, slotType, isEnable); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("IsNotificationSlotEnabled -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -337,8 +337,8 @@ ani_int AniGetSlotFlagsByBundle(ani_env *env, ani_object obj) } uint32_t slotFlags = 0; int returncode = Notification::NotificationHelper::GetNotificationSlotFlagsAsBundle(option, slotFlags); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetSlotFlagsByBundle -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } @@ -355,8 +355,8 @@ void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj, ani_double slotFlags) } int returncode = Notification::NotificationHelper::SetNotificationSlotFlagsAsBundle(option, static_cast(slotFlags)); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetSlotFlagsByBundle -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } diff --git a/frameworks/ets/ani/src/manager/ani_support_template.cpp b/frameworks/ets/ani/src/manager/ani_support_template.cpp index b79ef22eb..1f447606d 100755 --- a/frameworks/ets/ani/src/manager/ani_support_template.cpp +++ b/frameworks/ets/ani/src/manager/ani_support_template.cpp @@ -35,8 +35,8 @@ ani_boolean AniIsSupportTemplate(ani_env* env, ani_string templateName) ANS_LOGD("AniIsSupportTemplate by templateName:%{public}s", templateNameStr.c_str()); bool support = false; int returncode = Notification::NotificationHelper::IsSupportTemplate(templateNameStr, support); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsSupportTemplate -> error, errorCode: %{public}d", externalCode); return NotificationSts::BoolToAniBoolean(false); @@ -53,8 +53,8 @@ ani_object AniGetDeviceRemindType(ani_env *env) Notification::NotificationConstant::RemindType::DEVICE_IDLE_REMIND; int returncode = Notification::NotificationHelper::GetDeviceRemindType(remindType); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniGetDeviceRemindType error, errorCode: %{public}d", externalCode); return nullptr; diff --git a/frameworks/ets/ani/src/manager/ani_sync_config.cpp b/frameworks/ets/ani/src/manager/ani_sync_config.cpp index edf00e43c..c034a218d 100644 --- a/frameworks/ets/ani/src/manager/ani_sync_config.cpp +++ b/frameworks/ets/ani/src/manager/ani_sync_config.cpp @@ -48,8 +48,8 @@ ani_double AniSetAdditionalConfig(ani_env *env, ani_string key, ani_string value return RESULT_FAILED; } int returncode = Notification::NotificationHelper::SetAdditionConfig(keyStr, valueStr); - int externalCode = NotificationSts::GetExternalCode(returncode); - if (externalCode != ERR_OK) { + if (returncode != ERR_OK) { + int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("setAdditionalConfig -> error, errorCode: %{public}d", externalCode); AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return RESULT_FAILED; diff --git a/frameworks/ets/ani/src/sts_common.cpp b/frameworks/ets/ani/src/sts_common.cpp index 54e5d0e47..e578e0aa5 100644 --- a/frameworks/ets/ani/src/sts_common.cpp +++ b/frameworks/ets/ani/src/sts_common.cpp @@ -61,6 +61,7 @@ ani_status GetStringByAniString(ani_env *env, ani_string str, std::string &res) ANS_LOGE("GetStringByAniString fail, has nullptr"); return ANI_INVALID_ARGS; } + res = ""; ani_size sz {}; ani_status status = ANI_ERROR; if ((status = env->String_GetUTF8Size(str, &sz)) != ANI_OK) { @@ -194,6 +195,21 @@ ani_status GetPropertyDouble(ani_env *env, ani_object obj, const char *name, return status; } +void GetPropertyRefValue(ani_env *env, ani_object obj, const char *name, ani_boolean &isUndefined, ani_ref &outRef) { + if (env == nullptr || obj == nullptr || name == nullptr) { + return; + } + outRef = nullptr; + isUndefined = ANI_TRUE; + if (env->Object_GetPropertyByName_Ref(obj, name, &outRef) != ANI_OK) { + return; + } + if (outRef == nullptr) { + return; + } + env->Reference_IsUndefined(outRef, &isUndefined); +} + ani_status GetPropertyRef(ani_env *env, ani_object obj, const char *name, ani_boolean &isUndefined, ani_ref &outRef) { ANS_LOGD("GetPropertyRef call"); diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index 8e3b5764a..611bc238f 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -442,71 +442,121 @@ bool WarpNotificationLocalLiveViewButton( return true; } -void UnWarpNotificationCapsuleByOther(ani_env *env, ani_object obj, NotificationCapsule &capsule) -{ - ANS_LOGD("UnWarpNotificationCapsuleByOther call"); - if (env == nullptr || obj == nullptr) { - ANS_LOGE("UnWarpNotificationCapsuleByOther failed, has nullptr"); - return; +bool getCapsuleByIcon(ani_env *env, ani_object obj, std::shared_ptr &pixelMap) { + ani_boolean isUndefined = ANI_TRUE; + pixelMap = nullptr; + ani_ref tempRef = nullptr; + GetPropertyRefValue(env, obj, "icon", isUndefined, tempRef); + if (tempRef != nullptr) { + if (isUndefined == ANI_TRUE) { + ANS_LOGE("icon of Capsule is undefined"); + return false; + } + std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(tempRef)); } + return true; +} + +bool getCapsuleByButtons(ani_env *env, ani_object obj, std::vector &iconButtons) { ani_boolean isUndefined = ANI_TRUE; - ani_ref iconRef = {}; - if (GetPropertyRef(env, obj, "icon", isUndefined, iconRef) != ANI_OK - || isUndefined == ANI_TRUE || iconRef == nullptr) { - ANS_LOGD("UnWarpNotificationCapsule: get icon ref failed"); - } else { - std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(iconRef)); - if (pixelMap != nullptr) { - capsule.SetIcon(pixelMap); - } else { - ANS_LOGD("UnWarpNotificationCapsule: get icon failed"); + iconButtons = {}; + ani_ref tempRef = nullptr; + GetPropertyRefValue(env, obj, "capsuleButtons", isUndefined, tempRef); + if (tempRef != nullptr) { + if (isUndefined == ANI_TRUE) { + ANS_LOGE("capsuleButtons of Capsule is undefined"); + return false; + } + if (GetIconButtonArray(env, obj, "capsuleButtons", iconButtons) != ANI_OK || iconButtons.empty()) { + ANS_LOGE("get capsuleButtons failed"); + return false; } } - std::vector iconButtons = {}; - if (GetIconButtonArray(env, obj, "capsuleButtons", iconButtons) == ANI_OK && !(iconButtons.empty())) { - capsule.SetCapsuleButton(iconButtons); - } else { - ANS_LOGD("UnWarpNotificationCapsule: get capsuleButtons failed"); + return true; +} + +bool getCapsuleByString(ani_env *env, ani_object obj, const char *name, std::string &out) { + ani_boolean isUndefined = ANI_TRUE; + out = ""; + ani_ref tempRef = nullptr; + GetPropertyRefValue(env, obj, name, isUndefined, tempRef); + if (tempRef != nullptr) { + if (isUndefined == ANI_TRUE) { + ANS_LOGE("%{public}s of Capsule is undefined", name); + return false; + } + if (GetStringByAniString(env, reinterpret_cast(tempRef), out) != ANI_OK) { + ANS_LOGE("get string of %{public}s failed", name); + return false; + } + } + return true; +} + +bool getCapsuleByDouble(ani_env *env, ani_object obj, const char *name, double &out) { + ani_boolean isUndefined = ANI_TRUE; + out = ERR_OK; + ani_ref tempRef = nullptr; + GetPropertyRefValue(env, obj, name, isUndefined, tempRef); + if (tempRef != nullptr) { + if (isUndefined == ANI_TRUE) { + ANS_LOGE("%{public}s of Capsule is undefined", name); + return false; + } + if ((env->Object_CallMethodByName_Double(static_cast(tempRef), + "unboxed", ":D", &out)) != ANI_OK) { + ANS_LOGE("get double of %{public}s failed", name); + return false; + } } + return true; } -void UnWarpNotificationCapsule(ani_env *env, ani_object obj, NotificationCapsule &capsule) +bool UnWarpNotificationCapsule(ani_env *env, ani_object obj, NotificationCapsule &capsule) { ANS_LOGD("UnWarpNotificationCapsule call"); if (env == nullptr || obj == nullptr) { ANS_LOGE("UnWarpNotificationCapsule failed, has nullptr"); - return; + return false; } - ani_boolean isUndefined = ANI_TRUE; - std::string title = ""; - if (GetPropertyString(env, obj, "title", isUndefined, title) == ANI_OK && isUndefined == ANI_FALSE) { - capsule.SetTitle(GetResizeStr(title, STR_MAX_SIZE)); - } else { - ANS_LOGE("UnWarpNotificationCapsule: get title failed"); + std::string tempStr = ""; + if (!getCapsuleByString(env, obj, "title", tempStr)) { + ANS_LOGE("get title failed"); + return false; } - std::string backgroundColor = ""; - isUndefined = ANI_TRUE; - if (GetPropertyString(env, obj, "backgroundColor", isUndefined, backgroundColor) == ANI_OK - && isUndefined == ANI_FALSE) { - capsule.SetBackgroundColor(GetResizeStr(backgroundColor, STR_MAX_SIZE)); - } else { - ANS_LOGE("UnWarpNotificationCapsule: get backgroundColor failed"); + capsule.SetTitle(GetResizeStr(tempStr, STR_MAX_SIZE)); + + if (!getCapsuleByString(env, obj, "backgroundColor", tempStr)) { + ANS_LOGE("get backgroundColor failed"); + return false; } - std::string content = ""; - isUndefined = ANI_TRUE; - if (GetPropertyString(env, obj, "content", isUndefined, content) == ANI_OK && isUndefined == ANI_FALSE) { - capsule.SetContent(GetResizeStr(content, STR_MAX_SIZE)); - } else { - ANS_LOGE("UnWarpNotificationCapsule: get content failed"); + capsule.SetBackgroundColor(GetResizeStr(tempStr, STR_MAX_SIZE)); + + if (!getCapsuleByString(env, obj, "content", tempStr)) { + ANS_LOGE("get content failed"); + return false; } + capsule.SetContent(GetResizeStr(tempStr, STR_MAX_SIZE)); + ani_double time = 0.0; - if (GetPropertyDouble(env, obj, "time", isUndefined, time) == ANI_OK && isUndefined == ANI_FALSE) { - capsule.SetTime(static_cast(time)); - } else { - ANS_LOGE("UnWarpNotificationCapsule: get time failed"); + if (!getCapsuleByDouble(env, obj, "time", time)) { + ANS_LOGE("get content failed"); + return false; + } + capsule.SetTime(static_cast(time)); + std::shared_ptr pixelMap = nullptr; + if (!getCapsuleByIcon(env, obj, pixelMap) || pixelMap == nullptr) { + ANS_LOGE("get icon failed"); + return false; } - UnWarpNotificationCapsuleByOther(env, obj, capsule); - ANS_LOGD("UnWarpNotificationCapsule end"); + capsule.SetIcon(pixelMap); + std::vector iconButtons = {}; + if (!getCapsuleByButtons(env, obj, iconButtons)) { + ANS_LOGE("get icon failed"); + return false; + } + capsule.SetCapsuleButton(iconButtons); + return true; } ani_object WarpNotificationIconButton(ani_env *env, const NotificationIconButton &button) @@ -977,23 +1027,24 @@ ani_status UnWarpNotificationLiveViewContent(ani_env *env, ani_object obj, return status; } -void GetLocalLiveViewContentByOne(ani_env *env, ani_object obj, +bool GetLocalLiveViewContentByOne(ani_env *env, ani_object obj, std::shared_ptr &localLiveViewContent) { ANS_LOGD("GetLocalLiveViewContentByOne call"); if (env == nullptr || obj == nullptr || localLiveViewContent == nullptr) { ANS_LOGE("GetLocalLiveViewContentByOne failed, has nullptr"); - return; + return false; } ani_boolean isUndefined = ANI_TRUE; ani_ref capsuleRef = {}; if (GetPropertyRef(env, obj, "capsule", isUndefined, capsuleRef) == ANI_OK && isUndefined == ANI_FALSE && capsuleRef != nullptr) { NotificationCapsule capsule; - UnWarpNotificationCapsule(env, static_cast(capsuleRef), capsule); + if (!UnWarpNotificationCapsule(env, static_cast(capsuleRef), capsule)) { + return false; + } localLiveViewContent->SetCapsule(capsule); - } else { - ANS_LOGD("GetLocalLiveViewContentByOne: get capsule failed"); + localLiveViewContent->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::CAPSULE); } ani_ref buttonRef = {}; if (GetPropertyRef(env, obj, "button", isUndefined, buttonRef) == ANI_OK @@ -1001,16 +1052,19 @@ void GetLocalLiveViewContentByOne(ani_env *env, ani_object obj, NotificationLocalLiveViewButton button; UnWarpNotificationLocalLiveViewButton(env, static_cast(buttonRef), button); localLiveViewContent->SetButton(button); + localLiveViewContent->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::BUTTON); } else { ANS_LOGD("GetLocalLiveViewContentByOne: get button failed"); } std::vector buttons = {}; if (GetIconButtonArray(env, obj, "cardButtons", buttons) == ANI_OK) { localLiveViewContent->SetCardButton(buttons); + localLiveViewContent->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::CARD_BUTTON); } else { ANS_LOGD("GetLocalLiveViewContentByOne: get cardButtons failed"); } ANS_LOGD("GetLocalLiveViewContentByOne end"); + return true; } void GetLocalLiveViewContentByTwo(ani_env *env, ani_object obj, @@ -1028,6 +1082,7 @@ void GetLocalLiveViewContentByTwo(ani_env *env, ani_object obj, NotificationTime notificationTime; UnWarpNotificationTime(env, static_cast(timeRef), notificationTime); localLiveViewContent->SetTime(notificationTime); + localLiveViewContent->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::TIME); } else { ANS_LOGD("GetLocalLiveViewContentByTwo: get time failed"); } @@ -1037,6 +1092,7 @@ void GetLocalLiveViewContentByTwo(ani_env *env, ani_object obj, NotificationProgress notificationProgress; UnWarpNotificationProgress(env, static_cast(progressRef), notificationProgress); localLiveViewContent->SetProgress(notificationProgress); + localLiveViewContent->addFlag(NotificationLocalLiveViewContent::LiveViewContentInner::PROGRESS); } else { ANS_LOGD("GetLocalLiveViewContentByTwo: get progress failed"); } @@ -1076,7 +1132,9 @@ ani_status UnWarpNotificationLocalLiveViewContent(ani_env *env, ani_object obj, return ANI_INVALID_ARGS; } localLiveViewContent->SetType(static_cast(typeCode)); - GetLocalLiveViewContentByOne(env, obj, localLiveViewContent); + if (!GetLocalLiveViewContentByOne(env, obj, localLiveViewContent)) { + return ANI_INVALID_ARGS; + } GetLocalLiveViewContentByTwo(env, obj, localLiveViewContent); ANS_LOGD("UnWarpNotificationLocalLiveViewContent end"); return status; diff --git a/frameworks/ets/ani/src/sts_subscribe.cpp b/frameworks/ets/ani/src/sts_subscribe.cpp index 5d6797b4a..8ed278ad2 100644 --- a/frameworks/ets/ani/src/sts_subscribe.cpp +++ b/frameworks/ets/ani/src/sts_subscribe.cpp @@ -62,11 +62,10 @@ void StsDistributedOperationCallback::OnStsOperationCallback(ani_env *env, const return; } ani_status status = ANI_OK; - int32_t externalErrorCode = GetExternalCode(operationResult); - externalErrorCode = (externalErrorCode == ERR_OK) ? operationResult : externalErrorCode; + int32_t externalErrorCode = (operationResult == ERR_OK) ? operationResult : GetExternalCode(operationResult); ANS_LOGD("operationResult %{public}d, externalCode %{public}d", operationResult, externalErrorCode); - if (externalErrorCode == 0) { + if (externalErrorCode == ERR_OK) { ANS_LOGD("OnStsOperationCallback Resolve"); ani_object ret = OHOS::AppExecFwk::createInt(env, externalErrorCode); if (ANI_OK != (status = env->PromiseResolver_Resolve(resolver_, static_cast(ret)))) { diff --git a/frameworks/ets/ets/@ohos.notificationManager.ets b/frameworks/ets/ets/@ohos.notificationManager.ets index d7606acea..5c846a6c2 100644 --- a/frameworks/ets/ets/@ohos.notificationManager.ets +++ b/frameworks/ets/ets/@ohos.notificationManager.ets @@ -427,23 +427,13 @@ export default namespace notificationManager { if (systemLiveView?.lockscreenPicture != undefined && !(systemLiveView?.lockscreenPicture instanceof image.PixelMap)) { return false; } - if (systemLiveView?.capsule !== undefined && systemLiveView?.capsule === null) { - return false - } - if (systemLiveView?.capsule?.title !== undefined && systemLiveView?.capsule?.title?.trim() === '') { - return false; - } - if (systemLiveView?.capsule?.icon != undefined && !(systemLiveView?.capsule?.icon instanceof image.PixelMap)) { - return false; - } - if (systemLiveView?.capsule?.backgroundColor != undefined && systemLiveView?.capsule?.backgroundColor?.trim() === '') { - return false; - } - if (systemLiveView?.capsule?.content != undefined && systemLiveView?.capsule?.content?.trim() === '') { - return false; - } - if (systemLiveView?.capsule?.capsuleButtons != undefined && systemLiveView?.capsule?.capsuleButtons?.length === 0) { - return false; + if (systemLiveView?.capsule !== undefined) { + if (systemLiveView?.capsule?.icon != undefined && !(systemLiveView?.capsule?.icon instanceof image.PixelMap)) { + return false; + } + if (systemLiveView?.capsule?.capsuleButtons != undefined && systemLiveView?.capsule?.capsuleButtons?.length === 0) { + return false; + } } if (systemLiveView?.button !== undefined && systemLiveView?.button === null) { return false; -- Gitee From b2da925bbc7ed5bf72ceb8308ccf6c67b6337f68 Mon Sep 17 00:00:00 2001 From: heguokai Date: Wed, 25 Jun 2025 18:01:53 +0800 Subject: [PATCH 2/4] modify Signed-off-by: heguokai --- frameworks/ets/ani/src/manager/ani_support_template.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/ets/ani/src/manager/ani_support_template.cpp b/frameworks/ets/ani/src/manager/ani_support_template.cpp index 1f447606d..ed2e17ff8 100755 --- a/frameworks/ets/ani/src/manager/ani_support_template.cpp +++ b/frameworks/ets/ani/src/manager/ani_support_template.cpp @@ -41,7 +41,7 @@ ani_boolean AniIsSupportTemplate(ani_env* env, ani_string templateName) ANS_LOGE("AniIsSupportTemplate -> error, errorCode: %{public}d", externalCode); return NotificationSts::BoolToAniBoolean(false); } - ANS_LOGD("AniIsSupportTemplate end, support: %{public}d, returncode: %{public}d", support, externalCode); + ANS_LOGD("AniIsSupportTemplate end, support: %{public}d, returncode: %{public}d", support, returncode); return NotificationSts::BoolToAniBoolean(support); } @@ -64,7 +64,7 @@ ani_object AniGetDeviceRemindType(ani_env *env) NotificationSts::ThrowStsErroWithMsg(env, "AniGetDeviceRemindType:failed to WrapNotificationSlotArray"); return nullptr; } - ANS_LOGD("AniGetDeviceRemindType end, ret: %{public}d", externalCode); + ANS_LOGD("AniGetDeviceRemindType end, ret: %{public}d", returncode); return remindTypeItem; } } -- Gitee From eb9bd3ed90aabf247f8d38f8e2e16f7e03bb2733 Mon Sep 17 00:00:00 2001 From: heguokai Date: Wed, 25 Jun 2025 18:17:37 +0800 Subject: [PATCH 3/4] modify Signed-off-by: heguokai --- .../ets/ani/src/manager/ani_distributed_enable.cpp | 1 - .../ets/ani/src/manager/ani_do_not_disturb_date.cpp | 2 +- frameworks/ets/ani/src/manager/ani_slot.cpp | 6 +----- .../ets/ani/src/manager/ani_support_template.cpp | 2 -- frameworks/ets/ani/src/sts_notification_content.cpp | 12 ++++++++---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp index bb9618abe..ae75acdfe 100755 --- a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp @@ -248,7 +248,6 @@ void AniSetDistributedEnableBySlot(ani_env *env, ani_enum_item slot, ani_string int returncode = ERR_OK; returncode = Notification::NotificationHelper::SetDistributedEnabledBySlot(slotType, deviceTypeStr, NotificationSts::AniBooleanToBool(enable)); - if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("setDistributedEnabledBySlot error, errorCode: %{public}d", externalCode); diff --git a/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp b/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp index 4b742fcfb..07eefac05 100644 --- a/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp +++ b/frameworks/ets/ani/src/manager/ani_do_not_disturb_date.cpp @@ -122,7 +122,7 @@ ani_boolean AniIsSupportDoNotDisturbMode(ani_env *env) bool supportDoNotDisturbMode = false; ANS_LOGD("AniIsSupportDoNotDisturbMode enter"); int returncode = Notification::NotificationHelper::DoesSupportDoNotDisturbMode(supportDoNotDisturbMode); - if (returncode != ERR_OK) { + if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("DoesSupportDoNotDisturbMode error. returncode: %{public}d, externalCode: %{public}d", returncode, externalCode); diff --git a/frameworks/ets/ani/src/manager/ani_slot.cpp b/frameworks/ets/ani/src/manager/ani_slot.cpp index 8e5ea1c8b..4270fc96d 100644 --- a/frameworks/ets/ani/src/manager/ani_slot.cpp +++ b/frameworks/ets/ani/src/manager/ani_slot.cpp @@ -273,7 +273,6 @@ void AniSetNotificationEnableSlot(ani_env *env, ani_object bundleOption, ani_enu bool isForceControl = false; returncode = Notification::NotificationHelper::SetEnabledForBundleSlot(option, slotType, NotificationSts::AniBooleanToBool(enable), isForceControl); - if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetNotificationEnableSlot error, errorCode: %{public}d", externalCode); @@ -294,11 +293,8 @@ void AniSetNotificationEnableSlotWithForce(ani_env *env, NotificationSts::ThrowStsErroWithMsg(env, "SetNotificationEnableSlotWithForce ERROR_INTERNAL_ERROR"); return; } - int returncode = 0; - - returncode = Notification::NotificationHelper::SetEnabledForBundleSlot(option, slotType, + int returncode = Notification::NotificationHelper::SetEnabledForBundleSlot(option, slotType, NotificationSts::AniBooleanToBool(enable), NotificationSts::AniBooleanToBool(isForceControl)); - if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); diff --git a/frameworks/ets/ani/src/manager/ani_support_template.cpp b/frameworks/ets/ani/src/manager/ani_support_template.cpp index ed2e17ff8..5fc721eb2 100755 --- a/frameworks/ets/ani/src/manager/ani_support_template.cpp +++ b/frameworks/ets/ani/src/manager/ani_support_template.cpp @@ -48,11 +48,9 @@ ani_boolean AniIsSupportTemplate(ani_env* env, ani_string templateName) ani_object AniGetDeviceRemindType(ani_env *env) { ANS_LOGD("AniGetDeviceRemindType enter"); - Notification::NotificationConstant::RemindType remindType = Notification::NotificationConstant::RemindType::DEVICE_IDLE_REMIND; int returncode = Notification::NotificationHelper::GetDeviceRemindType(remindType); - if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index 611bc238f..75118f8c2 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -442,7 +442,8 @@ bool WarpNotificationLocalLiveViewButton( return true; } -bool getCapsuleByIcon(ani_env *env, ani_object obj, std::shared_ptr &pixelMap) { +bool getCapsuleByIcon(ani_env *env, ani_object obj, std::shared_ptr &pixelMap) +{ ani_boolean isUndefined = ANI_TRUE; pixelMap = nullptr; ani_ref tempRef = nullptr; @@ -457,7 +458,8 @@ bool getCapsuleByIcon(ani_env *env, ani_object obj, std::shared_ptr &p return true; } -bool getCapsuleByButtons(ani_env *env, ani_object obj, std::vector &iconButtons) { +bool getCapsuleByButtons(ani_env *env, ani_object obj, std::vector &iconButtons) +{ ani_boolean isUndefined = ANI_TRUE; iconButtons = {}; ani_ref tempRef = nullptr; @@ -475,7 +477,8 @@ bool getCapsuleByButtons(ani_env *env, ani_object obj, std::vector Date: Wed, 25 Jun 2025 18:56:16 +0800 Subject: [PATCH 4/4] modify Signed-off-by: heguokai --- frameworks/ets/ani/src/manager/ani_cance.cpp | 4 ++-- .../ets/ani/src/manager/ani_display_badge.cpp | 11 +++++------ .../ani/src/manager/ani_distributed_enable.cpp | 18 +++++++++--------- .../src/manager/ani_notification_enable.cpp | 6 +++--- frameworks/ets/ani/src/manager/ani_slot.cpp | 1 - .../ani/src/manager/ani_support_template.cpp | 4 ++-- frameworks/ets/ani/src/sts_common.cpp | 3 ++- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/frameworks/ets/ani/src/manager/ani_cance.cpp b/frameworks/ets/ani/src/manager/ani_cance.cpp index f2ff17699..a57c5dcb4 100644 --- a/frameworks/ets/ani/src/manager/ani_cance.cpp +++ b/frameworks/ets/ani/src/manager/ani_cance.cpp @@ -108,11 +108,11 @@ void AniCancelWithIdOptinalLabel(ani_env* env, ani_double id, ani_string label) } if (ret != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(ret); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("sts AniCancelWithIdOptinalLabel error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } - ANS_LOGD("sts AniCancelWithIdOptinalLabel end, externalCode: %{public}d", externalCode); + ANS_LOGD("sts AniCancelWithIdOptinalLabel end"); } void AniCancelAsBundle(ani_env *env, ani_double id, ani_string representativeBundle, ani_double userId) diff --git a/frameworks/ets/ani/src/manager/ani_display_badge.cpp b/frameworks/ets/ani/src/manager/ani_display_badge.cpp index 8bda85b5b..08b5f5aaf 100644 --- a/frameworks/ets/ani/src/manager/ani_display_badge.cpp +++ b/frameworks/ets/ani/src/manager/ani_display_badge.cpp @@ -41,11 +41,11 @@ void AniDisplayBadge(ani_env *env, ani_object obj, ani_boolean enable) } if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("sts DisplayBadge error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } - ANS_LOGD("DisplayBadgeAni end, ret: %{public}d", externalCode); + ANS_LOGD("DisplayBadgeAni end"); } ani_boolean AniIsBadgeDisplayed(ani_env *env, ani_object obj) @@ -69,12 +69,11 @@ ani_boolean AniIsBadgeDisplayed(ani_env *env, ani_object obj) if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("sts IsBadgeDisplayed error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); } - ANS_LOGD("sts IsBadgeDisplayed end, isDisplayed: %{public}d, returncode: %{public}d", isDisplayed, - externalCode); + ANS_LOGD("sts IsBadgeDisplayed end, isDisplayed: %{public}d", isDisplayed); return NotificationSts::BoolToAniBoolean(isDisplayed); } @@ -109,7 +108,7 @@ void AniSetBadgeNumberByBundle(ani_env *env, ani_object obj, ani_double badgeNum ANS_LOGE("sts AniSetBadgeNumberByBundle error, errorCode: %{public}d", externalCode); OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } - ANS_LOGD("AniSetBadgeNumberByBundle end, ret: %{public}d", externalCode); + ANS_LOGD("AniSetBadgeNumberByBundle end"); } } } \ No newline at end of file diff --git a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp index ae75acdfe..77f6d9616 100755 --- a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp @@ -43,11 +43,11 @@ ani_boolean AniIsDistributedEnabled(ani_env* env) int returncode = Notification::NotificationHelper::IsDistributedEnabled(enabled); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsDistributedEnabled -> error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); } - ANS_LOGD("AniIsDistributedEnabled end, enabled: %{public}d, returncode: %{public}d", enabled, externalCode); + ANS_LOGD("AniIsDistributedEnabled end"); return NotificationSts::BoolToAniBoolean(enabled); } @@ -63,10 +63,10 @@ ani_boolean AniIsDistributedEnabledByBundle(ani_env* env, ani_object obj) int returncode = Notification::NotificationHelper::IsDistributedEnableByBundle(option, enabled); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsDistributedEnabledByBundle -> error, errorCode: %{public}d", externalCode); + AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } - ANS_LOGD("AniIsDistributedEnabledByBundle end, enabled: %{public}d, returncode: %{public}d", enabled, externalCode); + ANS_LOGD("AniIsDistributedEnabledByBundle end"); return NotificationSts::BoolToAniBoolean(enabled); } @@ -89,10 +89,10 @@ ani_boolean AniIsDistributedEnabledByBundleType(ani_env* env, ani_object obj, an int returncode = Notification::NotificationHelper::IsDistributedEnabledByBundle(option, deviceTypeStr, enabled); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsDistributedEnabledByBundle -> error, errorCode: %{public}d", externalCode); + AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } - ANS_LOGD("AniIsDistributedEnabledByBundle end, enabled: %{public}d, returncode: %{public}d", enabled, externalCode); + ANS_LOGD("AniIsDistributedEnabledByBundle end"); return NotificationSts::BoolToAniBoolean(enabled); } @@ -117,7 +117,7 @@ void AniSetDistributedEnableByBundle(ani_env *env, ani_object obj, ani_boolean e OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } - ANS_LOGD("sts setDistributedEnableByBundle end, ret: %{public}d", externalCode); + ANS_LOGD("sts setDistributedEnableByBundle end"); } void AniSetDistributedEnableByBundleAndType(ani_env *env, @@ -149,7 +149,7 @@ void AniSetDistributedEnableByBundleAndType(ani_env *env, OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } - ANS_LOGD("sts setDistributedEnabledByBundle end, ret: %{public}d", externalCode); + ANS_LOGD("sts setDistributedEnabledByBundle end"); } void AniSetTargetDeviceStatus(ani_env* env, ani_string deviceType, ani_double status) @@ -170,7 +170,7 @@ void AniSetTargetDeviceStatus(ani_env* env, ani_string deviceType, ani_double st OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } - ANS_LOGD("sts setTargetDeviceStatus end, externalCode: %{public}d", externalCode); + ANS_LOGD("sts setTargetDeviceStatus end"); } ani_boolean AniIsSmartReminderEnabled(ani_env *env, ani_string deviceType) diff --git a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp index 07c974693..778634bda 100644 --- a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp @@ -65,8 +65,8 @@ ani_boolean AniIsNotificationEnabledWithBundleOption(ani_env *env, ani_object bu if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsNotificationEnabledWithBundleOption -> error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return ANI_FALSE; } ANS_LOGD("AniIsNotificationEnabledWithBundleOption end"); @@ -86,8 +86,8 @@ void AniSetNotificationEnable(ani_env *env, ani_object bundleOption, ani_boolean NotificationSts::AniBooleanToBool(enable)); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSetNotificationEnable -> error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } ANS_LOGD("AniSetNotificationEnable end"); } @@ -138,7 +138,7 @@ ani_boolean AniGetSyncNotificationEnabledWithoutApp(ani_env* env, ani_double use OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); } - ANS_LOGD("End success, enabled: %{public}d, returncode: %{public}d", enabled, externalCode); + ANS_LOGD("End success, enabled: %{public}d, returncode: %{public}d", enabled, returncode); return NotificationSts::BoolToAniBoolean(enabled); } diff --git a/frameworks/ets/ani/src/manager/ani_slot.cpp b/frameworks/ets/ani/src/manager/ani_slot.cpp index 4270fc96d..1c7bf7d98 100644 --- a/frameworks/ets/ani/src/manager/ani_slot.cpp +++ b/frameworks/ets/ani/src/manager/ani_slot.cpp @@ -54,7 +54,6 @@ ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption) NotificationSts::ThrowStsErroWithMsg(env, "GetSlotsByBundle:failed to WrapNotificationSlotArray"); return nullptr; } - ANS_LOGD("sts GetSlotsByBundle end, ret: %{public}d", externalCode); return outAniObj; } diff --git a/frameworks/ets/ani/src/manager/ani_support_template.cpp b/frameworks/ets/ani/src/manager/ani_support_template.cpp index 5fc721eb2..4487b0e47 100755 --- a/frameworks/ets/ani/src/manager/ani_support_template.cpp +++ b/frameworks/ets/ani/src/manager/ani_support_template.cpp @@ -37,8 +37,8 @@ ani_boolean AniIsSupportTemplate(ani_env* env, ani_string templateName) int returncode = Notification::NotificationHelper::IsSupportTemplate(templateNameStr, support); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniIsSupportTemplate -> error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); } ANS_LOGD("AniIsSupportTemplate end, support: %{public}d, returncode: %{public}d", support, returncode); @@ -53,8 +53,8 @@ ani_object AniGetDeviceRemindType(ani_env *env) int returncode = Notification::NotificationHelper::GetDeviceRemindType(remindType); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniGetDeviceRemindType error, errorCode: %{public}d", externalCode); + OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; } ani_enum_item remindTypeItem {}; diff --git a/frameworks/ets/ani/src/sts_common.cpp b/frameworks/ets/ani/src/sts_common.cpp index e578e0aa5..e58fc37ac 100644 --- a/frameworks/ets/ani/src/sts_common.cpp +++ b/frameworks/ets/ani/src/sts_common.cpp @@ -195,7 +195,8 @@ ani_status GetPropertyDouble(ani_env *env, ani_object obj, const char *name, return status; } -void GetPropertyRefValue(ani_env *env, ani_object obj, const char *name, ani_boolean &isUndefined, ani_ref &outRef) { +void GetPropertyRefValue(ani_env *env, ani_object obj, const char *name, ani_boolean &isUndefined, ani_ref &outRef) +{ if (env == nullptr || obj == nullptr || name == nullptr) { return; } -- Gitee