diff --git a/frameworks/ets/ani/include/manager/ani_slot.h b/frameworks/ets/ani/include/manager/ani_slot.h index 127dcfff83c82d5a064151f8679fd3875dad751c..044d5a877020672a7c216bd0f332379010bc95c3 100644 --- a/frameworks/ets/ani/include/manager/ani_slot.h +++ b/frameworks/ets/ani/include/manager/ani_slot.h @@ -20,7 +20,7 @@ namespace OHOS { namespace NotificationManagerSts { ani_int AniGetSlotFlagsByBundle(ani_env *env, ani_object obj); -void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj); +void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj, ani_double slotFlags); ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption); ani_boolean AniIsNotificationSlotEnabled(ani_env *env, ani_object bundleOption, ani_enum_item type); diff --git a/frameworks/ets/ani/src/manager/ani_get_active.cpp b/frameworks/ets/ani/src/manager/ani_get_active.cpp index 8ae3e89573aa79a0cac9ea21ff506b32d3059048..74e1ccd83dbfdfe7890bc9aae3ce631471b10ab3 100644 --- a/frameworks/ets/ani/src/manager/ani_get_active.cpp +++ b/frameworks/ets/ani/src/manager/ani_get_active.cpp @@ -19,6 +19,7 @@ #include "ans_log_wrapper.h" #include "sts_throw_erro.h" #include "sts_request.h" +#include "sts_common.h" namespace OHOS { namespace NotificationManagerSts { @@ -46,14 +47,19 @@ ani_object AniGetAllActiveNotifications(ani_env *env) int externalCode = CJSystemapi::Notification::ErrorToExternal(returncode); if (externalCode != 0) { OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); - ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); + ANS_LOGE("AniGetAllActiveNotifications error, errorCode: %{public}d", externalCode); return nullptr; } - ani_object arrayRequestObj = NotificationSts::GetAniNotificationRequestArrayByNotifocations(env, notifications); + ani_object arrayRequestObj; + if (notifications.size() == 0) { + arrayRequestObj = NotificationSts::newArrayClass(env, 0); + } else { + arrayRequestObj = NotificationSts::GetAniNotificationRequestArrayByNotifocations(env, notifications); + } if (arrayRequestObj == nullptr) { OHOS::AbilityRuntime::ThrowStsError(env, OHOS::Notification::ERROR_INTERNAL_ERROR, NotificationSts::FindAnsErrMsg(OHOS::Notification::ERROR_INTERNAL_ERROR)); - ANS_LOGE("AniTriggerSystemLiveView buttonOption ERROR_INTERNAL_ERROR"); + ANS_LOGE("AniGetAllActiveNotifications ERROR_INTERNAL_ERROR"); } ANS_LOGD("sts AniGetAllActiveNotifications end"); return arrayRequestObj; @@ -61,22 +67,27 @@ ani_object AniGetAllActiveNotifications(ani_env *env) ani_object AniGetActiveNotifications(ani_env *env) { - ANS_LOGD("sts AniGetAllActiveNotifications call"); + ANS_LOGD("sts AniGetActiveNotifications call"); std::vector> requests; int returncode = OHOS::Notification::NotificationHelper::GetActiveNotifications(requests); int externalCode = CJSystemapi::Notification::ErrorToExternal(returncode); if (externalCode != 0) { OHOS::AbilityRuntime::ThrowStsError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); - ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); + ANS_LOGE("AniGetActiveNotifications error, errorCode: %{public}d", externalCode); return nullptr; } - ani_object arrayRequestObj = NotificationSts::GetAniNotificationRequestArray(env, requests); + ani_object arrayRequestObj; + if (requests.size() == 0) { + arrayRequestObj = NotificationSts::newArrayClass(env, 0); + } else { + arrayRequestObj = NotificationSts::GetAniNotificationRequestArray(env, requests); + } if (arrayRequestObj == nullptr) { OHOS::AbilityRuntime::ThrowStsError(env, OHOS::Notification::ERROR_INTERNAL_ERROR, NotificationSts::FindAnsErrMsg(OHOS::Notification::ERROR_INTERNAL_ERROR)); - ANS_LOGE("AniTriggerSystemLiveView buttonOption ERROR_INTERNAL_ERROR"); + ANS_LOGE("AniGetActiveNotifications ERROR_INTERNAL_ERROR"); } - ANS_LOGD("sts AniGetAllActiveNotifications end"); + ANS_LOGD("sts AniGetActiveNotifications end"); return arrayRequestObj; } } // namespace NotificationManagerSts diff --git a/frameworks/ets/ani/src/manager/ani_slot.cpp b/frameworks/ets/ani/src/manager/ani_slot.cpp index d9ce7326be78910a72f7f5f03fb19bdee3609d8f..86224ee2b86aa0b91b11372090831d61a39822b4 100644 --- a/frameworks/ets/ani/src/manager/ani_slot.cpp +++ b/frameworks/ets/ani/src/manager/ani_slot.cpp @@ -145,7 +145,7 @@ ani_int AniGetSlotFlagsByBundle(ani_env *env, ani_object obj) return slotFlags; } -void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj) +void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj, ani_double slotFlags) { ANS_LOGD("sts setSlotFlagsByBundle call"); Notification::NotificationBundleOption option; @@ -153,8 +153,8 @@ void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj) NotificationSts::ThrowStsErroWithMsg(env, "AniSetSlotFlagsByBundle : erro arguments."); return; } - uint32_t slotFlags = 0; - int returncode = Notification::NotificationHelper::SetNotificationSlotFlagsAsBundle(option, slotFlags); + int returncode = + Notification::NotificationHelper::SetNotificationSlotFlagsAsBundle(option, static_cast(slotFlags)); int externalCode = CJSystemapi::Notification::ErrorToExternal(returncode); if (externalCode != 0) { ANS_LOGE("AniSetSlotFlagsByBundle -> error, errorCode: %{public}d", externalCode); diff --git a/frameworks/ets/ani/src/sts_bundle_option.cpp b/frameworks/ets/ani/src/sts_bundle_option.cpp index 4da10d20264a11c39e79afaaeb4a9302e66ff2bb..938b388b38d91323e3dcccb9020ae91628b93e18 100644 --- a/frameworks/ets/ani/src/sts_bundle_option.cpp +++ b/frameworks/ets/ani/src/sts_bundle_option.cpp @@ -63,7 +63,7 @@ bool UnwrapArrayBundleOption(ani_env *env, for (int32_t i = 0; i < static_cast(length); i++) { ani_ref optionRef; status = env->Object_CallMethodByName_Ref(static_cast(arrayObj), - "$_get", "I:Lnotification/NotificationCommonDef/BundleOption;", &optionRef, i); + "$_get", "I:Lstd/core/Object;", &optionRef, i); if (status != ANI_OK) { ANS_LOGE("UnwrapArrayBundleOption: get bundleOptionRef failed, status = %{public}d", status); return false; diff --git a/frameworks/ets/ani/src/sts_disturb_mode.cpp b/frameworks/ets/ani/src/sts_disturb_mode.cpp index 345d3631930823a6d4c758031fa755e037f17b06..a24e389b81a86b1d135b60866bf0b88ac69a3007 100644 --- a/frameworks/ets/ani/src/sts_disturb_mode.cpp +++ b/frameworks/ets/ani/src/sts_disturb_mode.cpp @@ -30,16 +30,16 @@ bool UnwrapDoNotDisturbProfile(ani_env *env, ani_object param, } ani_boolean isUndefined = ANI_TRUE; ani_double idAni = 0.0; - if (ANI_OK != GetPropertyDouble(env, param, "id", isUndefined, idAni) || isUndefined == ANI_TRUE) { + if (ANI_OK != env->Object_GetPropertyByName_Double(param, "id", &idAni)) { ANS_LOGE("UnwrapDoNotDisturbProfile: get id failed"); return false; } + profile->SetProfileId(static_cast(idAni)); std::string nameStr = ""; if (ANI_OK != GetPropertyString(env, param, "name", isUndefined, nameStr) || isUndefined == ANI_TRUE) { ANS_LOGE("UnwrapDoNotDisturbProfile: get name failed"); return false; } - profile->SetProfileId(static_cast(idAni)); profile->SetProfileName(nameStr); ani_ref trustlistRef; if (ANI_OK != GetPropertyRef(env, param, "trustlist", isUndefined, trustlistRef) || isUndefined == ANI_TRUE) { @@ -70,15 +70,15 @@ bool UnwrapArrayDoNotDisturbProfile(ani_env *env, ani_object arrayObj, ANS_LOGD("UnwrapArrayDoNotDisturbProfile: status = %{public}d", status); return false; } - sptr profile; for (int i = 0; i < static_cast(length); i++) { ani_ref optionRef; status = env->Object_CallMethodByName_Ref(arrayObj, "$_get", - "I:L@ohos/notificationManager/notificationManager/DoNotDisturbProfile;", &optionRef, (ani_int)i); + "I:Lstd/core/Object;", &optionRef, (ani_int)i); if (status != ANI_OK) { ANS_LOGE("UnwrapArrayDoNotDisturbProfile: status : %{public}d, index: %{public}d", status, i); return false; } + sptr profile = new (std::nothrow)NotificationDoNotDisturbProfile(); if (!UnwrapDoNotDisturbProfile(env, static_cast(optionRef), profile)) { ANS_LOGE("Get profile failed, index: %{public}d", i); return false; diff --git a/frameworks/ets/ani/src/sts_notification_content.cpp b/frameworks/ets/ani/src/sts_notification_content.cpp index 96fc4cbc68a6e1add89ef859c0d6ba74629e9b84..b3aa635f9f0594c9b5abd4d43187bba6c0389a64 100644 --- a/frameworks/ets/ani/src/sts_notification_content.cpp +++ b/frameworks/ets/ani/src/sts_notification_content.cpp @@ -1254,11 +1254,6 @@ bool SetNotificationMultiLineContent( if (allLinesObject == nullptr || !SetPropertyByRef(env, contentObj, "lines", allLinesObject)) { ANS_LOGD("SetNotificationMultiLineContent: set lines failed"); } - ani_object lineWantAgentsObject = GetAniWantAgentArray(env, content->GetLineWantAgents()); - if (lineWantAgentsObject == nullptr - || !SetPropertyByRef(env, contentObj, "lineWantAgents", lineWantAgentsObject)) { - ANS_LOGD("SetNotificationMultiLineContent: set lineWantAgents failed"); - } return SetPropertyByRef(env, ncObj, "multiLine", contentObj); } diff --git a/frameworks/ets/ani/src/sts_subscriber.cpp b/frameworks/ets/ani/src/sts_subscriber.cpp index fc0142b743e4ab1bc8b24ec6ba6ddffe227f012d..19c966c1548e0bbbf8a47d1130841e07ca7ca1b6 100644 --- a/frameworks/ets/ani/src/sts_subscriber.cpp +++ b/frameworks/ets/ani/src/sts_subscriber.cpp @@ -191,7 +191,7 @@ bool WarpSubscribeCallbackDataArray( } if (ANI_OK != (status = env->Object_CallMethodByName_Void( outObj, "$_set", "ILstd/core/Object;:V", i, obj))) { - ANS_LOGE("set object faild. index %{public}d status %{public}d", i, status); + ANS_LOGE("set object faild. status %{public}d", status); return false; } } diff --git a/frameworks/ets/ets/notification/notificationFlags.ets b/frameworks/ets/ets/notification/notificationFlags.ets index e090d8d72765acbe0aaeb68fa26cf0ccf8af151d..7c98b19f50bca91d04f264823e7c50fa61837c5c 100644 --- a/frameworks/ets/ets/notification/notificationFlags.ets +++ b/frameworks/ets/ets/notification/notificationFlags.ets @@ -35,7 +35,7 @@ class NotificationFlagsInner implements NotificationFlags { public soundEnabled?: NotificationFlagStatus | undefined; - public vibrationEnabled?: NotificationFlagStatus| undefined; + public vibrationEnabled?: NotificationFlagStatus | undefined; public reminderFlags?: number | undefined; } \ No newline at end of file