diff --git a/frameworks/ets/ani/BUILD.gn b/frameworks/ets/ani/BUILD.gn index 46336e3a10f08cac02050894918af79048deadd1..48d259ac669b920d6031f4be00f27c50fa83d57c 100644 --- a/frameworks/ets/ani/BUILD.gn +++ b/frameworks/ets/ani/BUILD.gn @@ -83,10 +83,38 @@ ohos_shared_library("notification_manager_ani") { defines = [] + if (distributed_notification_service_disable_control) { + defines += [ "DISABLE_NOTIFICATION_FEATURE_ENABLE" ] + } + + if (distributed_notification_service_feature_badge_manager) { + defines += [ "ANS_FEATURE_BADGE_MANAGER" ] + } + if (distributed_notification_service_feature_local_liveview) { defines += [ "ANS_FEATURE_LIVEVIEW_LOCAL_LIVEVIEW" ] } + if (distributed_notification_service_feature_distributed_db) { + defines += [ "ANS_FEATURE_DISTRIBUTED_DB" ] + } + + if (distributed_notification_service_feature_disturb_manager) { + defines += [ "ANS_FEATURE_DISTURB_MANAGER" ] + } + + if (distributed_notification_service_feature_slot_manager) { + defines += [ "ANS_FEATURE_SLOT_MANAGER" ] + } + + if (distributed_notification_service_feature_additional_config) { + defines += [ "ANS_FEATURE_ADDITIONAL_CONFIG" ] + } + + if (distributed_notification_service_feature_open_notification_settings) { + defines += [ "ANS_FEATURE_OPEN_NOTIFICATION_SETTINGS" ] + } + external_deps = [ "c_utils:utils", "hilog:libhilog", diff --git a/frameworks/ets/ani/src/manager/ani_display_badge.cpp b/frameworks/ets/ani/src/manager/ani_display_badge.cpp index f744d8852b89fc621d70f6121abe119437c97598..8d0c9a799fb373c10a62f8b8fcc3389aaf7c60a1 100644 --- a/frameworks/ets/ani/src/manager/ani_display_badge.cpp +++ b/frameworks/ets/ani/src/manager/ani_display_badge.cpp @@ -28,6 +28,7 @@ namespace NotificationManagerSts { void AniDisplayBadge(ani_env *env, ani_object obj, ani_boolean enable) { ANS_LOGD("DisplayBadgeAni call"); +#ifdef ANS_FEATURE_BADGE_MANAGER int returncode = 0; BundleOption option; if (NotificationSts::UnwrapBundleOption(env, obj, option)) { @@ -45,14 +46,18 @@ void AniDisplayBadge(ani_env *env, ani_object obj, ani_boolean enable) OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("DisplayBadgeAni end"); } ani_boolean AniIsBadgeDisplayed(ani_env *env, ani_object obj) { ANS_LOGD("sts IsBadgeDisplayed call"); - int returncode = 0; bool isDisplayed = false; +#ifdef ANS_FEATURE_BADGE_MANAGER + int returncode = 0; if (obj == nullptr) { returncode = Notification::NotificationHelper::GetShowBadgeEnabled(isDisplayed); } else { @@ -66,13 +71,15 @@ ani_boolean AniIsBadgeDisplayed(ani_env *env, ani_object obj) return NotificationSts::BoolToAniBoolean(false); } } - if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts IsBadgeDisplayed error, errorCode: %{public}d", externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("sts IsBadgeDisplayed end, isDisplayed: %{public}d", isDisplayed); return NotificationSts::BoolToAniBoolean(isDisplayed); } @@ -80,18 +87,23 @@ ani_boolean AniIsBadgeDisplayed(ani_env *env, ani_object obj) void AniSetBadgeNumber(ani_env *env, ani_double badgeNumber) { ANS_LOGD("sts AniSetBadgeNumber call, BadgeNumber: %{public}lf", badgeNumber); +#ifdef ANS_FEATURE_BADGE_MANAGER int returncode = Notification::NotificationHelper::SetBadgeNumber(static_cast(badgeNumber)); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts AniSetBadgeNumber error, errorCode: %{public}d", externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("sts AniSetBadgeNumber end"); } void AniSetBadgeNumberByBundle(ani_env *env, ani_object obj, ani_double badgeNumber) { ANS_LOGD("AniSetBadgeNumberByBundle call, badgeNumber: %{public}lf", badgeNumber); +#ifdef ANS_FEATURE_BADGE_MANAGER int returncode = ERR_OK; BundleOption option; if (NotificationSts::UnwrapBundleOption(env, obj, option)) { @@ -108,6 +120,9 @@ void AniSetBadgeNumberByBundle(ani_env *env, ani_object obj, ani_double badgeNum ANS_LOGE("sts AniSetBadgeNumberByBundle error, errorCode: %{public}d", externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSetBadgeNumberByBundle end"); } } diff --git a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp index bd63b2444613e834328a7b818474ba072353842f..1c24a651894390ed7e0dfcb7598894408413fa55 100755 --- a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp @@ -40,6 +40,7 @@ ani_boolean AniIsDistributedEnabled(ani_env* env) { ANS_LOGD("AniIsDistributedEnabled call"); bool enabled = false; +#ifdef ANS_FEATURE_DISTRIBUTED_DB int returncode = Notification::NotificationHelper::IsDistributedEnabled(enabled); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); @@ -47,6 +48,9 @@ ani_boolean AniIsDistributedEnabled(ani_env* env) OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return NotificationSts::BoolToAniBoolean(false); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniIsDistributedEnabled end"); return NotificationSts::BoolToAniBoolean(enabled); } @@ -54,18 +58,21 @@ ani_boolean AniIsDistributedEnabled(ani_env* env) ani_boolean AniIsDistributedEnabledByBundle(ani_env* env, ani_object obj) { ANS_LOGD("AniIsDistributedEnabledByBundle call"); + bool enabled = false; +#ifdef ANS_FEATURE_DISTRIBUTED_DB Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { NotificationSts::ThrowStsErroWithMsg(env, "AniIsDistributedEnabledByBundle : erro arguments."); - return NotificationSts::BoolToAniBoolean(false); } - bool enabled = false; int returncode = Notification::NotificationHelper::IsDistributedEnableByBundle(option, enabled); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniIsDistributedEnabledByBundle -> error, errorCode: %{public}d", externalCode); NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniIsDistributedEnabledByBundle end"); return NotificationSts::BoolToAniBoolean(enabled); } @@ -73,6 +80,8 @@ ani_boolean AniIsDistributedEnabledByBundle(ani_env* env, ani_object obj) ani_boolean AniIsDistributedEnabledByBundleType(ani_env* env, ani_object obj, ani_string deviceType) { ANS_LOGD("AniIsDistributedEnabledByBundleType call"); + bool enabled = false; +#ifdef ANS_FEATURE_DISTRIBUTED_DB Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { NotificationSts::ThrowStsErroWithMsg(env, "AniIsDistributedEnabledByBundleType : erro arguments."); @@ -85,13 +94,15 @@ ani_boolean AniIsDistributedEnabledByBundleType(ani_env* env, ani_object obj, an } ANS_LOGD("Cancel by deviceType:%{public}s", deviceTypeStr.c_str()); - bool enabled = false; int returncode = Notification::NotificationHelper::IsDistributedEnabledByBundle(option, deviceTypeStr, enabled); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniIsDistributedEnabledByBundle -> error, errorCode: %{public}d", externalCode); NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniIsDistributedEnabledByBundle end"); return NotificationSts::BoolToAniBoolean(enabled); } @@ -99,6 +110,7 @@ ani_boolean AniIsDistributedEnabledByBundleType(ani_env* env, ani_object obj, an void AniSetDistributedEnableByBundle(ani_env *env, ani_object obj, ani_boolean enable) { ANS_LOGD("setDistributedEnableByBundle call"); +#ifdef ANS_FEATURE_DISTRIBUTED_DB int returncode = ERR_OK; Notification::NotificationBundleOption option; bool bFlag = NotificationSts::UnwrapBundleOption(env, obj, option); @@ -117,6 +129,9 @@ void AniSetDistributedEnableByBundle(ani_env *env, ani_object obj, ani_boolean e OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("sts setDistributedEnableByBundle end"); } @@ -124,6 +139,7 @@ void AniSetDistributedEnableByBundleAndType(ani_env *env, ani_object obj, ani_string deviceType, ani_boolean enable) { ANS_LOGD("sts setDistributedEnabledByBundle call"); +#ifdef ANS_FEATURE_DISTRIBUTED_DB std::string deviceTypeStr; if (NotificationSts::GetStringByAniString(env, deviceType, deviceTypeStr) != ANI_OK) { std::string msg = "Parameter verification failed"; @@ -149,6 +165,9 @@ void AniSetDistributedEnableByBundleAndType(ani_env *env, OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("sts setDistributedEnabledByBundle end"); } @@ -177,6 +196,7 @@ ani_boolean AniIsSmartReminderEnabled(ani_env *env, ani_string deviceType) { ANS_LOGD("isSmartReminderEnabled call"); bool allowed = false; +#ifdef ANS_FEATURE_DISTRIBUTED_DB std::string deviceTypeStr; if (env == nullptr || deviceType == nullptr) { ANS_LOGE("Invalid env or deviceType is null"); @@ -194,6 +214,9 @@ ani_boolean AniIsSmartReminderEnabled(ani_env *env, ani_string deviceType) ANS_LOGE("isSmartReminderEnabled -> error, errorCode: %{public}d", externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("isSmartReminderEnabled end"); return NotificationSts::BoolToAniBoolean(allowed); } @@ -202,6 +225,7 @@ ani_boolean AniIsSmartReminderEnabled(ani_env *env, ani_string deviceType) void AniSetSmartReminderEnable(ani_env *env, ani_string deviceType, ani_boolean enable) { ANS_LOGD("setSmartReminderEnabled call"); +#ifdef ANS_FEATURE_DISTRIBUTED_DB std::string deviceTypeStr; if (env == nullptr || deviceType == nullptr) { ANS_LOGE("Invalid env or deviceType is null"); @@ -221,6 +245,9 @@ void AniSetSmartReminderEnable(ani_env *env, ani_string deviceType, ani_boolean ANS_LOGE("setSmartReminderEnabled -> error, errorCode: %{public}d", externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("setSmartReminderEnabled end"); } 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 fffa6a1e67c058ff4ecfd5891c6e2bb0ae25be59..ea36941d07dd3bb790ae5a69d68f015618780840 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 @@ -27,6 +27,7 @@ namespace NotificationManagerSts { void AniSetDoNotDisturbDate(ani_env *env, ani_object date) { ANS_LOGD("AniSetDoNotDisturbDate enter"); +#ifdef ANS_FEATURE_DISTURB_MANAGER Notification::NotificationDoNotDisturbDate doNotDisturbDate; if (!NotificationSts::UnWarpNotificationDoNotDisturbDate(env, date, doNotDisturbDate)) { ANS_LOGE("AniSetDoNotDisturbDate UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); @@ -41,12 +42,16 @@ void AniSetDoNotDisturbDate(ani_env *env, ani_object date) returncode, externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSetDoNotDisturbDate end"); } void AniSetDoNotDisturbDateWithId(ani_env *env, ani_object date, ani_double userId) { ANS_LOGD("AniSetDoNotDisturbDateWithId enter"); +#ifdef ANS_FEATURE_DISTURB_MANAGER Notification::NotificationDoNotDisturbDate doNotDisturbDate; if (!NotificationSts::UnWarpNotificationDoNotDisturbDate(env, date, doNotDisturbDate)) { ANS_LOGE("AniSetDoNotDisturbDateWithId UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); @@ -61,15 +66,18 @@ void AniSetDoNotDisturbDateWithId(ani_env *env, ani_object date, ani_double user returncode, externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSetDoNotDisturbDateWithId end"); } ani_object AniGetDoNotDisturbDate(ani_env *env) { + ANS_LOGD("AniGetDoNotDisturbDate enter"); ani_object data = nullptr; +#ifdef ANS_FEATURE_DISTURB_MANAGER Notification::NotificationDoNotDisturbDate doNotDisturbDate; - - ANS_LOGD("AniGetDoNotDisturbDate enter"); int returncode = Notification::NotificationHelper::GetDoNotDisturbDate(doNotDisturbDate); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); @@ -83,15 +91,19 @@ ani_object AniGetDoNotDisturbDate(ani_env *env) ANS_LOGE("WarpNotificationDoNotDisturbDate faild"); NotificationSts::ThrowStsErroWithMsg(env, "AniGetDoNotDisturbDate ERROR_INTERNAL_ERROR"); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniGetDoNotDisturbDate end"); return data; } ani_object AniGetDoNotDisturbDateWithId(ani_env *env, ani_double userId) { + ANS_LOGD("AniGetDoNotDisturbDateWithId enter"); ani_object data = nullptr; +#ifdef ANS_FEATURE_DISTURB_MANAGER Notification::NotificationDoNotDisturbDate doNotDisturbDate; - ANS_LOGD("AniGetDoNotDisturbDateWithId enter"); const int32_t id = static_cast(userId); int returncode = Notification::NotificationHelper::GetDoNotDisturbDate(id, doNotDisturbDate); if (returncode != ERR_OK) { @@ -106,6 +118,9 @@ ani_object AniGetDoNotDisturbDateWithId(ani_env *env, ani_double userId) ANS_LOGE("AniGetDoNotDisturbDateWithId WarpNotificationDoNotDisturbDate faild"); NotificationSts::ThrowStsErroWithMsg(env, "AniGetDoNotDisturbDate ERROR_INTERNAL_ERROR"); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniGetDoNotDisturbDateWithId end"); return data; } @@ -114,6 +129,7 @@ ani_boolean AniIsSupportDoNotDisturbMode(ani_env *env) { bool supportDoNotDisturbMode = false; ANS_LOGD("AniIsSupportDoNotDisturbMode enter"); +#ifdef ANS_FEATURE_DISTURB_MANAGER int returncode = Notification::NotificationHelper::DoesSupportDoNotDisturbMode(supportDoNotDisturbMode); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); @@ -122,6 +138,9 @@ ani_boolean AniIsSupportDoNotDisturbMode(ani_env *env) OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return ANI_FALSE; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniIsSupportDoNotDisturbMode end"); return NotificationSts::BoolToAniBoolean(supportDoNotDisturbMode); } diff --git a/frameworks/ets/ani/src/manager/ani_get_active.cpp b/frameworks/ets/ani/src/manager/ani_get_active.cpp index 0f248c2fc7fb437ea5633bb6d553a1eb640fcb43..daf025b0f655f08c25b0c1a330ec2356654d37b7 100644 --- a/frameworks/ets/ani/src/manager/ani_get_active.cpp +++ b/frameworks/ets/ani/src/manager/ani_get_active.cpp @@ -32,7 +32,7 @@ ani_double AniGetActiveNotificationCount(ani_env *env) if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); - ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); + ANS_LOGE("GetActiveNotificationCount error, errorCode: %{public}d", externalCode); return 0; } return retNum; 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 9885a5dfb07f512f78615dd82fd9fe77aaf0d4d2..8337960c35bcda95894e4c1bb6fe3bffb84e983f 100644 --- a/frameworks/ets/ani/src/manager/ani_local_live_view.cpp +++ b/frameworks/ets/ani/src/manager/ani_local_live_view.cpp @@ -27,6 +27,7 @@ void AniTriggerSystemLiveView( ani_env *env, ani_object bundleOptionObj, ani_double notificationId, ani_object buttonOptionsObj) { ANS_LOGD("AniTriggerSystemLiveView call"); +#ifdef ANS_FEATURE_LIVEVIEW_LOCAL_LIVEVIEW BundleOption bundleOption; if (!NotificationSts::UnwrapBundleOption(env, bundleOptionObj, bundleOption)) { OHOS::NotificationSts::ThrowError(env, OHOS::Notification::ERROR_INTERNAL_ERROR, @@ -48,12 +49,16 @@ void AniTriggerSystemLiveView( OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniTriggerSystemLiveView error, errorCode: %{public}d", externalCode); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniTriggerSystemLiveView end"); } void AniSubscribeSystemLiveView(ani_env *env, ani_object subscriberObj) { ANS_LOGD("AniSubscribeSystemLiveView call"); +#ifdef ANS_FEATURE_LIVEVIEW_LOCAL_LIVEVIEW NotificationSts::StsNotificationLocalLiveViewSubscriber *localLiveViewSubscriber = new (std::nothrow)NotificationSts::StsNotificationLocalLiveViewSubscriber(); localLiveViewSubscriber->SetStsNotificationLocalLiveViewSubscriber(env, subscriberObj); @@ -64,6 +69,9 @@ void AniSubscribeSystemLiveView(ani_env *env, ani_object subscriberObj) OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSubscribeSystemLiveView error, errorCode: %{public}d", externalCode); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSubscribeSystemLiveView end"); } } // namespace NotificationManagerSts diff --git a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp index 5314a4ecd01125bcf984ba892383abe789fe32b2..61a7a31157bb1416048d7402b6b2051ae425db5b 100644 --- a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp @@ -59,7 +59,7 @@ ani_boolean AniIsNotificationEnabledWithBundleOption(ani_env *env, ani_object bu if (NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { returncode = Notification::NotificationHelper::IsAllowedNotify(option, allowed); } else { - NotificationSts::ThrowStsErroWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowStsErroWithMsg(env, "sts IsNotificationEnabled ERROR_INTERNAL_ERROR"); return ANI_FALSE; } @@ -78,7 +78,7 @@ void AniSetNotificationEnable(ani_env *env, ani_object bundleOption, ani_boolean ANS_LOGD("AniSetNotificationEnable call"); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { - NotificationSts::ThrowStsErroWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowStsErroWithMsg(env, "sts SetNotificationEnable ERROR_INTERNAL_ERROR"); return ; } std::string deviceId {""}; @@ -145,6 +145,7 @@ ani_boolean AniGetSyncNotificationEnabledWithoutApp(ani_env* env, ani_double use void AniSetSyncNotificationEnabledWithoutApp(ani_env* env, ani_double userId, ani_boolean enabled) { ANS_LOGD("AniSetSyncNotificationEnabledWithoutApp call,enable : %{public}d", enabled); +#ifdef ANS_FEATURE_DISTRIBUTED_DB int returncode = Notification::NotificationHelper::SetSyncNotificationEnabledWithoutApp( static_cast(userId), NotificationSts::AniBooleanToBool(enabled)); if (returncode != ERR_OK) { @@ -153,6 +154,9 @@ void AniSetSyncNotificationEnabledWithoutApp(ani_env* env, ani_double userId, an OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSetSyncNotificationEnabledWithoutApp end"); } diff --git a/frameworks/ets/ani/src/manager/ani_open_settings.cpp b/frameworks/ets/ani/src/manager/ani_open_settings.cpp index 54b432b694b8b332fd4892424255b4b28c148a63..7a2ec6ae98b01ada660e1ba6fe8dea50adbd32a1 100644 --- a/frameworks/ets/ani/src/manager/ani_open_settings.cpp +++ b/frameworks/ets/ani/src/manager/ani_open_settings.cpp @@ -168,6 +168,7 @@ void StsAsyncCompleteCallbackOpenSettings(ani_env *env, std::shared_ptr info = std::make_shared(); if (!GetOpenSettingsInfo(env, content, info)) { ANS_LOGE("sts AniOpenNotificationSettings GetOpenSettingsInfo fail"); @@ -204,8 +205,10 @@ ani_object AniOpenNotificationSettings(ani_env *env, ani_object content) isExist.store(false); return nullptr; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("sts AniOpenNotificationSettings end"); - return aniPromise; } diff --git a/frameworks/ets/ani/src/manager/ani_slot.cpp b/frameworks/ets/ani/src/manager/ani_slot.cpp index 01444be38bd8dccd4ed1da94a896742d11e8b81c..3f04d0c7202e3c159f4a3bfe1401d920bc3599ba 100644 --- a/frameworks/ets/ani/src/manager/ani_slot.cpp +++ b/frameworks/ets/ani/src/manager/ani_slot.cpp @@ -33,6 +33,8 @@ constexpr int32_t RETURN_EXCEPTION_VALUE = -1; ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption) { ANS_LOGD("sts GetSlotsByBundle enter"); + ani_object outAniObj; +#ifdef ANS_FEATURE_SLOT_MANAGER int returncode = ERR_OK; std::vector> slots; BundleOption option; @@ -42,18 +44,19 @@ ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption) NotificationSts::ThrowStsErroWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); return nullptr; } - if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("sts GetSlotsByBundle error, errorCode: %{public}d", externalCode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; } - ani_object outAniObj; if (!NotificationSts::WrapNotificationSlotArray(env, slots, outAniObj)) { NotificationSts::ThrowStsErroWithMsg(env, "GetSlotsByBundle:failed to WrapNotificationSlotArray"); return nullptr; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif return outAniObj; } @@ -201,10 +204,11 @@ void AniRemoveAllSlots(ani_env *env) void AniSetSlotByBundle(ani_env *env, ani_object bundleOptionObj, ani_object slotObj) { ANS_LOGD("AniSetSlotByBundle enter"); +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOptionObj, option)) { ANS_LOGE("UnwrapBundleOption failed"); - NotificationSts::ThrowStsErroWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowStsErroWithMsg(env, "AniSetSlotByBundle ERROR_INTERNAL_ERROR"); return; } @@ -231,19 +235,23 @@ void AniSetSlotByBundle(ani_env *env, ani_object bundleOptionObj, ani_object slo OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSetSlotByBundle leave"); } ani_double AniGetSlotNumByBundle(ani_env *env, ani_object bundleOption) { ANS_LOGD("AniGetSlotNumByBundle enter"); + uint64_t num = 0; +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { ANS_LOGE("UnwrapBundleOption failed"); NotificationSts::ThrowStsErroWithMsg(env, "AniGetSlotNumByBundle ERROR_INTERNAL_ERROR"); return RETURN_EXCEPTION_VALUE; } - uint64_t num = 0; int returncode = Notification::NotificationHelper::GetNotificationSlotNumAsBundle(option, num); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); @@ -251,6 +259,9 @@ ani_double AniGetSlotNumByBundle(ani_env *env, ani_object bundleOption) OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return RETURN_EXCEPTION_VALUE; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ani_double retNum = static_cast(num); ANS_LOGD("AniGetSlotNumByBundle leave"); return retNum; @@ -258,6 +269,7 @@ ani_double AniGetSlotNumByBundle(ani_env *env, ani_object bundleOption) void AniSetNotificationEnableSlot(ani_env *env, ani_object bundleOption, ani_enum_item type, ani_boolean enable) { ANS_LOGD("AniSetNotificationEnableSlot enter "); +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { NotificationSts::ThrowStsErroWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); @@ -278,6 +290,9 @@ void AniSetNotificationEnableSlot(ani_env *env, ani_object bundleOption, ani_enu NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif ANS_LOGD("AniSetNotificationEnableSlot end"); } @@ -285,6 +300,7 @@ void AniSetNotificationEnableSlotWithForce(ani_env *env, ani_object bundleOption, ani_enum_item type, ani_boolean enable, ani_boolean isForceControl) { ANS_LOGD("AniSetNotificationEnableSlotWithForce enter "); +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!(NotificationSts::SlotTypeEtsToC(env, type, slotType)) @@ -296,14 +312,20 @@ void AniSetNotificationEnableSlotWithForce(ani_env *env, NotificationSts::AniBooleanToBool(enable), NotificationSts::AniBooleanToBool(isForceControl)); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); - ANS_LOGE("AniSetNotificationEnableSlotSync error, errorCode: %{public}d", externalCode); + ANS_LOGE("AniSetNotificationEnableSlotWithForce error, errorCode: %{public}d", externalCode); NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif + ANS_LOGD("AniSetNotificationEnableSlotWithForce end"); } ani_boolean AniIsNotificationSlotEnabled(ani_env *env, ani_object bundleOption, ani_enum_item type) { ANS_LOGD("IsNotificationSlotEnabled enter"); + bool isEnable = false; +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option) @@ -312,37 +334,44 @@ ani_boolean AniIsNotificationSlotEnabled(ani_env *env, ani_object bundleOption, return ANI_FALSE; } - bool isEnable = false; int returncode = Notification::NotificationHelper::GetEnabledForBundleSlot(option, slotType, isEnable); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("IsNotificationSlotEnabled -> error, errorCode: %{public}d", externalCode); NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif return isEnable ? ANI_TRUE : ANI_FALSE; } ani_int AniGetSlotFlagsByBundle(ani_env *env, ani_object obj) { ANS_LOGD("sts getSlotFlagsByBundle call"); + uint32_t slotFlags = 0; +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { NotificationSts::ThrowStsErroWithMsg(env, "AniGetSlotFlagsByBundle : erro arguments."); return ANI_FALSE; } - uint32_t slotFlags = 0; int returncode = Notification::NotificationHelper::GetNotificationSlotFlagsAsBundle(option, slotFlags); if (returncode != ERR_OK) { int externalCode = NotificationSts::GetExternalCode(returncode); ANS_LOGE("AniGetSlotFlagsByBundle -> error, errorCode: %{public}d", externalCode); NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif return slotFlags; } void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj, ani_double slotFlags) { ANS_LOGD("sts setSlotFlagsByBundle call"); +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { NotificationSts::ThrowStsErroWithMsg(env, "AniSetSlotFlagsByBundle : erro arguments."); @@ -355,11 +384,16 @@ void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj, ani_double slotFlags) ANS_LOGE("AniSetSlotFlagsByBundle -> error, errorCode: %{public}d", externalCode); NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif } ani_object AniGetSlotByBundle(ani_env *env, ani_object bundleOption, ani_enum_item type) { ANS_LOGD("AniGetSlotByBundle enter"); + ani_object infoObj; +#ifdef ANS_FEATURE_SLOT_MANAGER Notification::NotificationBundleOption option; Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option) @@ -375,11 +409,13 @@ ani_object AniGetSlotByBundle(ani_env *env, ani_object bundleOption, ani_enum_it NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return nullptr; } - ani_object infoObj; if (!NotificationSts::WrapNotificationSlot(env, slot, infoObj) || infoObj == nullptr) { NotificationSts::ThrowStsErroWithMsg(env, "WrapNotificationSlot Failed"); return nullptr; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif return infoObj; } } diff --git a/frameworks/ets/ani/src/manager/ani_sync_config.cpp b/frameworks/ets/ani/src/manager/ani_sync_config.cpp index 877b9e5113aecfb1b8f368b19b9bba0cbd547471..3c2cad7d11c780f515b645f6f7bca75dbc603ef6 100644 --- a/frameworks/ets/ani/src/manager/ani_sync_config.cpp +++ b/frameworks/ets/ani/src/manager/ani_sync_config.cpp @@ -29,6 +29,7 @@ const double RESULT_FAILED = 1.0; ani_double AniSetAdditionalConfig(ani_env *env, ani_string key, ani_string value) { ANS_LOGD("sts setAdditionalConfig call"); +#ifdef ANS_FEATURE_ADDITIONAL_CONFIG if (env == nullptr || key == nullptr) { ANS_LOGE("Invalid env or key is null"); return RESULT_FAILED; @@ -54,6 +55,9 @@ ani_double AniSetAdditionalConfig(ani_env *env, ani_string key, ani_string value NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); return RESULT_FAILED; } +#else + OHOS::NotificationSts::ThrowStsErrorWithCode(env, OHOS::Notification::ERROR_SYSTEM_CAP_ERROR); +#endif return RESULT_OK; } } // namespace NotificationManagerSts