From 3ced31f79b11656ca29bd26c0f1218a5d008afb2 Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Mon, 11 Aug 2025 04:01:14 +0800 Subject: [PATCH] 1.pixMap use taihe 2.ThrowErroWithMsg change to ThrowErrorWithMsg Signed-off-by: heguokai <275503077@qq.com> --- frameworks/ets/ani/BUILD.gn | 4 +- .../ets/ani/include/sts_convert_other.h | 12 ++-- frameworks/ets/ani/include/sts_throw_erro.h | 2 +- frameworks/ets/ani/src/manager/ani_cance.cpp | 10 ++-- .../src/manager/ani_distributed_enable.cpp | 6 +- .../src/manager/ani_do_not_disturb_date.cpp | 6 +- .../ets/ani/src/manager/ani_get_active.cpp | 4 +- .../src/manager/ani_notification_enable.cpp | 6 +- .../ets/ani/src/manager/ani_open_settings.cpp | 8 +-- .../ets/ani/src/manager/ani_publish.cpp | 12 ++-- .../ets/ani/src/manager/ani_remove_group.cpp | 4 +- frameworks/ets/ani/src/manager/ani_slot.cpp | 42 +++++++------- .../ani/src/manager/ani_support_template.cpp | 4 +- frameworks/ets/ani/src/sts_common.cpp | 8 +-- frameworks/ets/ani/src/sts_convert_other.cpp | 57 +++++++------------ .../ets/ani/src/sts_notification_content.cpp | 8 +-- frameworks/ets/ani/src/sts_request.cpp | 6 +- 17 files changed, 93 insertions(+), 106 deletions(-) diff --git a/frameworks/ets/ani/BUILD.gn b/frameworks/ets/ani/BUILD.gn index 5b8874971..a322f9fc9 100644 --- a/frameworks/ets/ani/BUILD.gn +++ b/frameworks/ets/ani/BUILD.gn @@ -103,7 +103,7 @@ ohos_shared_library("notification_manager_ani") { "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", - "image_framework:image_ani", + "image_framework:image_taihe", "image_framework:image_native", "ipc:ipc_core", "napi:ace_napi", @@ -179,7 +179,7 @@ ohos_shared_library("notification_subscribe_ani") { "c_utils:utils", "hilog:libhilog", "image_framework:image", - "image_framework:image_ani", + "image_framework:image_taihe", "image_framework:image_native", "ipc:ipc_core", "napi:ace_napi", diff --git a/frameworks/ets/ani/include/sts_convert_other.h b/frameworks/ets/ani/include/sts_convert_other.h index 2c32dcb83..39e909f83 100644 --- a/frameworks/ets/ani/include/sts_convert_other.h +++ b/frameworks/ets/ani/include/sts_convert_other.h @@ -32,7 +32,7 @@ ani_object WarpWantAgent(ani_env *env, std::shared_ptr wantAgent); ani_object GetAniWantAgentArray(ani_env *env, std::vector> wantAgents); ani_object CreateAniPixelMap(ani_env* env, std::shared_ptr pixelMap); -std::shared_ptr GetPixelMapFromEnvSp(ani_env* env, ani_object obj); +std::shared_ptr GetPixelMapFromAni(ani_env* env, ani_object obj); // ani_object to vector ani_status GetPixelMapArrayByRef(ani_env *env, ani_ref param, std::vector> &pixelMaps); // ani_object to vector @@ -43,16 +43,16 @@ bool GetAniPictrueInfo(ani_env *env, std::map>> pictureMap); + std::map>> &pictureMap); // vector to AniArray -ani_object GetAniArrayPixelMap(ani_env *env, const std::vector> &pixelMaps); +ani_object GetAniArrayPixelMap(ani_env *env, const std::vector> pixelMaps); -ani_status UnwrapResource(ani_env *env, ani_object obj, ResourceManager::Resource resource); +ani_status UnwrapResource(ani_env *env, ani_object obj, ResourceManager::Resource &resource); ani_status GetResourceArray(ani_env *env, ani_object param, const char *name, std::vector &res); -ani_object GetAniResource(ani_env *env, const std::shared_ptr &resource); +ani_object GetAniResource(ani_env *env, const std::shared_ptr resource); ani_object GetAniArrayResource(ani_env *env, - const std::vector> &resources); + const std::vector> resources); } // namespace NotificationSts } // OHOS #endif \ No newline at end of file diff --git a/frameworks/ets/ani/include/sts_throw_erro.h b/frameworks/ets/ani/include/sts_throw_erro.h index 93f07c6f5..17eb2b3a4 100644 --- a/frameworks/ets/ani/include/sts_throw_erro.h +++ b/frameworks/ets/ani/include/sts_throw_erro.h @@ -107,7 +107,7 @@ void ThrowError(ani_env *env, int32_t errCode, const std::string &errorMsg); ani_object CreateError(ani_env *env, int32_t code, const std::string &msg); -inline void ThrowErroWithMsg(ani_env *env, std::string logMsg) +inline void ThrowErrorWithMsg(ani_env *env, std::string logMsg) { ThrowError(env, OHOS::Notification::ERROR_INTERNAL_ERROR, FindAnsErrMsg(OHOS::Notification::ERROR_INTERNAL_ERROR)); diff --git a/frameworks/ets/ani/src/manager/ani_cance.cpp b/frameworks/ets/ani/src/manager/ani_cance.cpp index 070aab8c1..21b5bc039 100644 --- a/frameworks/ets/ani/src/manager/ani_cance.cpp +++ b/frameworks/ets/ani/src/manager/ani_cance.cpp @@ -51,7 +51,7 @@ void AniCancelWithIdLabel(ani_env* env, ani_double id, ani_string label) ANS_LOGD("AniCancelWithIdLabel call"); std::string tempStr; if (ANI_OK != NotificationSts::GetStringByAniString(env, label, tempStr)) { - NotificationSts::ThrowErroWithMsg(env, "Label parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "Label parse failed!"); return; } std::string labelStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); @@ -70,7 +70,7 @@ void AniCancelWithBundle(ani_env* env, ani_object bundleObj, ani_double id) ANS_LOGD("AniCancelWithBundle call"); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleObj, option)) { - NotificationSts::ThrowErroWithMsg(env, "BundleOption parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "BundleOption parse failed!"); return; } @@ -124,7 +124,7 @@ void AniCancelAsBundle(ani_env *env, ani_double id, ani_string representativeBun if (ANI_OK != NotificationSts::GetStringByAniString(env, representativeBundle, bundleStr)) { ANS_LOGE("AniCancelAsBundle:: representativeBundle parse failed!"); - NotificationSts::ThrowErroWithMsg(env, "representativeBundle parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "representativeBundle parse failed!"); return; } ANS_LOGD("AniCancelAsBundle, convertedId: %{public}d, UserId: %{public}d, bundleStr: %{public}s", @@ -148,7 +148,7 @@ void AniCancelAsBundleWithBundleOption(ani_env *env, ani_object representativeBu BundleOption option; if (NotificationSts::UnwrapBundleOption(env, representativeBundle, option) != true) { ANS_LOGE("AniPublishAsBundleWithBundleOption BundleOption parse failed!"); - NotificationSts::ThrowErroWithMsg(env, "AniPublishAsBundleWithBundleOption BundleOption parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "AniPublishAsBundleWithBundleOption BundleOption parse failed!"); return; } @@ -172,7 +172,7 @@ void AniCancelGroup(ani_env *env, ani_string groupName) std::string tempStr; if (ANI_OK != NotificationSts::GetStringByAniString(env, groupName, tempStr)) { - NotificationSts::ThrowErroWithMsg(env, "AniCancelGroup: groupName parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "AniCancelGroup: groupName parse failed!"); return; } std::string groupNameStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); diff --git a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp index e67a6a2bd..d31676f6f 100755 --- a/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp +++ b/frameworks/ets/ani/src/manager/ani_distributed_enable.cpp @@ -56,7 +56,7 @@ ani_boolean AniIsDistributedEnabledByBundle(ani_env* env, ani_object obj) ANS_LOGD("AniIsDistributedEnabledByBundle call"); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { - NotificationSts::ThrowErroWithMsg(env, "AniIsDistributedEnabledByBundle : erro arguments."); + NotificationSts::ThrowErrorWithMsg(env, "AniIsDistributedEnabledByBundle : erro arguments."); return NotificationSts::BoolToAniBoolean(false); } bool enabled = false; @@ -75,12 +75,12 @@ ani_boolean AniIsDistributedEnabledByBundleType(ani_env* env, ani_object obj, an ANS_LOGD("AniIsDistributedEnabledByBundleType call"); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { - NotificationSts::ThrowErroWithMsg(env, "AniIsDistributedEnabledByBundleType : erro arguments."); + NotificationSts::ThrowErrorWithMsg(env, "AniIsDistributedEnabledByBundleType : erro arguments."); return NotificationSts::BoolToAniBoolean(false); } std::string deviceTypeStr; if (NotificationSts::GetStringByAniString(env, deviceType, deviceTypeStr) != ANI_OK) { - NotificationSts::ThrowErroWithMsg(env, "deviceType parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "deviceType parse failed!"); return NotificationSts::BoolToAniBoolean(false); } ANS_LOGD("Cancel by deviceType:%{public}s", deviceTypeStr.c_str()); 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 3a206805f..16eb238ef 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 @@ -30,7 +30,7 @@ void AniSetDoNotDisturbDate(ani_env *env, ani_object date) Notification::NotificationDoNotDisturbDate doNotDisturbDate; if (!NotificationSts::UnWarpNotificationDoNotDisturbDate(env, date, doNotDisturbDate)) { ANS_LOGE("AniSetDoNotDisturbDate UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); - NotificationSts::ThrowErroWithMsg(env, "UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); return; } @@ -50,7 +50,7 @@ void AniSetDoNotDisturbDateWithId(ani_env *env, ani_object date, ani_double user Notification::NotificationDoNotDisturbDate doNotDisturbDate; if (!NotificationSts::UnWarpNotificationDoNotDisturbDate(env, date, doNotDisturbDate)) { ANS_LOGE("AniSetDoNotDisturbDateWithId UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); - NotificationSts::ThrowErroWithMsg(env, "UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "UnWarpNotificationDoNotDisturbDate ERROR_INTERNAL_ERROR"); return; } @@ -84,7 +84,7 @@ ani_object AniGetDoNotDisturbDate(ani_env *env) auto datePtr = std::make_shared(doNotDisturbDate); if (!NotificationSts::WarpNotificationDoNotDisturbDate(env, datePtr, data)) { ANS_LOGE("WarpNotificationDoNotDisturbDate faild"); - NotificationSts::ThrowErroWithMsg(env, "AniGetDoNotDisturbDate ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniGetDoNotDisturbDate ERROR_INTERNAL_ERROR"); } ANS_LOGD("AniGetDoNotDisturbDate end"); diff --git a/frameworks/ets/ani/src/manager/ani_get_active.cpp b/frameworks/ets/ani/src/manager/ani_get_active.cpp index 9388309f5..8a9a37364 100644 --- a/frameworks/ets/ani/src/manager/ani_get_active.cpp +++ b/frameworks/ets/ani/src/manager/ani_get_active.cpp @@ -95,7 +95,7 @@ ani_object AniGetActiveNotificationByFilter(ani_env *env, ani_object obj) ANS_LOGD("AniGetActiveNotificationByFilter call"); Notification::LiveViewFilter filter; if (!OHOS::NotificationSts::UnWarpNotificationFilter(env, obj, filter)) { - NotificationSts::ThrowErroWithMsg(env, "sts UnWarpNotificationFilter ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts UnWarpNotificationFilter ERROR_INTERNAL_ERROR"); return nullptr; } sptr notificationRequest = nullptr; @@ -111,7 +111,7 @@ ani_object AniGetActiveNotificationByFilter(ani_env *env, ani_object obj) ani_class requestCls; if (!NotificationSts::WarpNotificationRequest(env, notificationRequest.GetRefPtr(), requestCls, requestObj) || requestObj == nullptr) { - NotificationSts::ThrowErroWithMsg(env, "sts UnWarpNotificationFilter ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts UnWarpNotificationFilter ERROR_INTERNAL_ERROR"); ANS_LOGE("AniGetActiveNotificationByFilter WarpNotificationRequest faild"); return nullptr; } diff --git a/frameworks/ets/ani/src/manager/ani_notification_enable.cpp b/frameworks/ets/ani/src/manager/ani_notification_enable.cpp index b65f03114..934e4f58a 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::ThrowErroWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts GetSlotsByBundle 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::ThrowErroWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); return ; } std::string deviceId {""}; @@ -106,7 +106,7 @@ ani_object AniGetAllNotificationEnabledBundles(ani_env *env) ani_object arrayBundles = NotificationSts::GetAniArrayBundleOption(env, bundleOptions); if (arrayBundles == nullptr) { ANS_LOGE("GetAniArrayBundleOption filed,arrayBundles is nullptr"); - NotificationSts::ThrowErroWithMsg(env, "GetAniArrayBundleOption ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "GetAniArrayBundleOption ERROR_INTERNAL_ERROR"); return nullptr; } return arrayBundles; diff --git a/frameworks/ets/ani/src/manager/ani_open_settings.cpp b/frameworks/ets/ani/src/manager/ani_open_settings.cpp index cbd832458..1e881abd8 100644 --- a/frameworks/ets/ani/src/manager/ani_open_settings.cpp +++ b/frameworks/ets/ani/src/manager/ani_open_settings.cpp @@ -147,12 +147,12 @@ void StsAsyncCompleteCallbackOpenSettings(ani_env *env, std::shared_ptrPromiseResolver_Resolve(info->resolver, static_cast(ret)))) { ANS_LOGD("PromiseResolver_Resolve faild. status %{public}d", status); - NotificationSts::ThrowErroWithMsg(env, ""); + NotificationSts::ThrowErrorWithMsg(env, ""); } } else { std::string errMsg = OHOS::NotificationSts::FindAnsErrMsg(errorCode); @@ -161,7 +161,7 @@ void StsAsyncCompleteCallbackOpenSettings(ani_env *env, std::shared_ptr(OHOS::AbilityRuntime::EtsErrorUtil::CreateError(env, errorCode, errMsg)); if (ANI_OK != (status = env->PromiseResolver_Reject(info->resolver, rejection))) { ANS_LOGD("PromiseResolver_Resolve faild. status %{public}d", status); - NotificationSts::ThrowErroWithMsg(env, ""); + NotificationSts::ThrowErrorWithMsg(env, ""); } } } @@ -176,7 +176,7 @@ ani_object AniOpenNotificationSettings(ani_env *env, ani_object content) } if (info->context == nullptr) { ANS_LOGE("sts AniOpenNotificationSettings context is null"); - NotificationSts::ThrowErroWithMsg(env, ""); + NotificationSts::ThrowErrorWithMsg(env, ""); return nullptr; } std::string bundleName {""}; diff --git a/frameworks/ets/ani/src/manager/ani_publish.cpp b/frameworks/ets/ani/src/manager/ani_publish.cpp index 73c177d4c..285dd2f9f 100644 --- a/frameworks/ets/ani/src/manager/ani_publish.cpp +++ b/frameworks/ets/ani/src/manager/ani_publish.cpp @@ -32,7 +32,7 @@ void AniPublish(ani_env *env, ani_object obj) std::shared_ptr notificationRequest = std::make_shared(); if (NotificationSts::UnWarpNotificationRequest(env, obj, notificationRequest) != ANI_OK) { ANS_LOGE("UnWarpNotificationRequest failed"); - NotificationSts::ThrowErroWithMsg(env, "AniPublish ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniPublish ERROR_INTERNAL_ERROR"); return; } int returncode = NotificationHelper::PublishNotification(*notificationRequest); @@ -49,7 +49,7 @@ void AniPublishWithId(ani_env *env, ani_object obj, ani_double userId) //NotificationRequest request; std::shared_ptr notificationRequest = std::make_shared(); if (NotificationSts::UnWarpNotificationRequest(env, obj, notificationRequest) != ANI_OK) { - NotificationSts::ThrowErroWithMsg(env, "AniPublishWithId ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniPublishWithId ERROR_INTERNAL_ERROR"); return; } notificationRequest->SetOwnerUserId(static_cast(userId)); @@ -67,14 +67,14 @@ void AniPublishAsBundle(ani_env *env, ani_object request, ani_string representat ANS_LOGD("AniPublishAsBundle enter"); std::string bundleStr; if (ANI_OK != NotificationSts::GetStringByAniString(env, representativeBundle, bundleStr)) { - NotificationSts::ThrowErroWithMsg(env, "AniPublishAsBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniPublishAsBundle ERROR_INTERNAL_ERROR"); return; } std::shared_ptr notificationRequest = std::make_shared(); if (NotificationSts::UnWarpNotificationRequest(env, request, notificationRequest) != ANI_OK) { ANS_LOGE("AniPublishAsBundle failed"); - NotificationSts::ThrowErroWithMsg(env, "AniPublishAsBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniPublishAsBundle ERROR_INTERNAL_ERROR"); return; } notificationRequest->SetOwnerUserId(static_cast(userId)); @@ -94,13 +94,13 @@ void AniPublishAsBundleWithBundleOption(ani_env *env, ani_object representativeB ANS_LOGE("AniPublishAsBundleWithBundleOption enter"); std::shared_ptr notificationRequest = std::make_shared(); if (NotificationSts::UnWarpNotificationRequest(env, request, notificationRequest) != ANI_OK) { - NotificationSts::ThrowErroWithMsg(env, "AniPublishAsBundleWithBundleOption ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniPublishAsBundleWithBundleOption ERROR_INTERNAL_ERROR"); return; } BundleOption option; if (NotificationSts::UnwrapBundleOption(env, representativeBundle, option) != true) { - NotificationSts::ThrowErroWithMsg(env, "UnwrapBundleOption ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "UnwrapBundleOption ERROR_INTERNAL_ERROR"); return; } diff --git a/frameworks/ets/ani/src/manager/ani_remove_group.cpp b/frameworks/ets/ani/src/manager/ani_remove_group.cpp index 6c6e30d12..70e6199a8 100644 --- a/frameworks/ets/ani/src/manager/ani_remove_group.cpp +++ b/frameworks/ets/ani/src/manager/ani_remove_group.cpp @@ -30,13 +30,13 @@ void AniRemoveGroupByBundle(ani_env *env, ani_object bundleOption, ani_string gr ANS_LOGD("AniRemoveGroupByBundle call"); OHOS::Notification::NotificationBundleOption option; if (!OHOS::NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { - NotificationSts::ThrowErroWithMsg(env, "sts AniRemoveGroupByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts AniRemoveGroupByBundle ERROR_INTERNAL_ERROR"); return ; } std::string tempStr = ""; ani_status status = NotificationSts::GetStringByAniString(env, groupName, tempStr); if (status != ANI_OK) { - NotificationSts::ThrowErroWithMsg(env, "sts AniRemoveGroupByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts AniRemoveGroupByBundle ERROR_INTERNAL_ERROR"); return ; } std::string groupNameStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); diff --git a/frameworks/ets/ani/src/manager/ani_slot.cpp b/frameworks/ets/ani/src/manager/ani_slot.cpp index 16ab9d635..a5b0a1b89 100644 --- a/frameworks/ets/ani/src/manager/ani_slot.cpp +++ b/frameworks/ets/ani/src/manager/ani_slot.cpp @@ -38,7 +38,7 @@ ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption) if (NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { returncode = Notification::NotificationHelper::GetNotificationSlotsForBundle(option, slots); } else { - NotificationSts::ThrowErroWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts GetSlotsByBundle ERROR_INTERNAL_ERROR"); return nullptr; } @@ -50,7 +50,7 @@ ani_object AniGetSlotsByBundle(ani_env *env, ani_object bundleOption) } ani_object outAniObj; if (!NotificationSts::WrapNotificationSlotArray(env, slots, outAniObj)) { - NotificationSts::ThrowErroWithMsg(env, "GetSlotsByBundle:failed to WrapNotificationSlotArray"); + NotificationSts::ThrowErrorWithMsg(env, "GetSlotsByBundle:failed to WrapNotificationSlotArray"); return nullptr; } return outAniObj; @@ -62,7 +62,7 @@ void AniAddSlots(ani_env *env, ani_object notificationSlotArrayObj) std::vector slots; if (!NotificationSts::UnwrapNotificationSlotArrayByAniObj(env, notificationSlotArrayObj, slots)) { ANS_LOGE("UnwrapNotificationSlotArrayByAniObj failed"); - NotificationSts::ThrowErroWithMsg(env, "sts AddSlots ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts AddSlots ERROR_INTERNAL_ERROR"); return; } int returncode = Notification::NotificationHelper::AddNotificationSlots(slots); @@ -83,7 +83,7 @@ void AniAddSlotByNotificationSlot(ani_env *env, ani_object notificationSlotObj) if (NotificationSts::UnwrapNotificationSlot(env, notificationSlotObj, slot)) { returncode = Notification::NotificationHelper::AddNotificationSlot(slot); } else { - NotificationSts::ThrowErroWithMsg(env, "sts AddSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts AddSlot ERROR_INTERNAL_ERROR"); return; } if (returncode != ERR_OK) { @@ -100,7 +100,7 @@ void AniAddSlotBySlotType(ani_env *env, ani_enum_item enumObj) ANS_LOGD("AniAddSlotBySlotType enter"); Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::SlotTypeEtsToC(env, enumObj, slotType)) { - NotificationSts::ThrowErroWithMsg(env, "AddSlotByType ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AddSlotByType ERROR_INTERNAL_ERROR"); return; } int returncode = Notification::NotificationHelper::AddSlotByType(slotType); @@ -119,7 +119,7 @@ ani_object AniGetSlot(ani_env *env, ani_enum_item enumObj) Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::SlotTypeEtsToC(env, enumObj, slotType)) { ANS_LOGE("SlotTypeEtsToC failed"); - NotificationSts::ThrowErroWithMsg(env, "sts GetSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts GetSlot ERROR_INTERNAL_ERROR"); return nullptr; } sptr slot = nullptr; @@ -137,7 +137,7 @@ ani_object AniGetSlot(ani_env *env, ani_enum_item enumObj) ani_object slotObj; if (!NotificationSts::WrapNotificationSlot(env, slot, slotObj)) { ANS_LOGE("WrapNotificationSlot faild"); - NotificationSts::ThrowErroWithMsg(env, "sts GetSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts GetSlot ERROR_INTERNAL_ERROR"); return nullptr; } ANS_LOGD("AniGetSlot leave"); @@ -158,7 +158,7 @@ ani_object AniGetSlots(ani_env *env) ani_object outAniObj; if (!NotificationSts::WrapNotificationSlotArray(env, slots, outAniObj)) { ANS_LOGE("WrapNotificationSlotArray faild"); - NotificationSts::ThrowErroWithMsg(env, "AniGetSlots:failed to WrapNotificationSlotArray"); + NotificationSts::ThrowErrorWithMsg(env, "AniGetSlots:failed to WrapNotificationSlotArray"); return nullptr; } ANS_LOGD("AniGetSlots leave"); @@ -171,7 +171,7 @@ void AniRemoveSlot(ani_env *env, ani_enum_item enumObj) Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::SlotTypeEtsToC(env, enumObj, slotType)) { ANS_LOGE("SlotTypeEtsToC failed"); - NotificationSts::ThrowErroWithMsg(env, "sts GetSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts GetSlot ERROR_INTERNAL_ERROR"); return; } int returncode = Notification::NotificationHelper::RemoveNotificationSlot(slotType); @@ -203,14 +203,14 @@ void AniSetSlotByBundle(ani_env *env, ani_object bundleOptionObj, ani_object slo Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOptionObj, option)) { ANS_LOGE("UnwrapBundleOption failed"); - NotificationSts::ThrowErroWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); return; } Notification::NotificationSlot slot; if (!NotificationSts::UnwrapNotificationSlot(env, slotObj, slot)) { ANS_LOGE("UnwrapNotificationSlot failed"); - NotificationSts::ThrowErroWithMsg(env, "sts SetSlotByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts SetSlotByBundle ERROR_INTERNAL_ERROR"); return; } @@ -218,7 +218,7 @@ void AniSetSlotByBundle(ani_env *env, ani_object bundleOptionObj, ani_object slo sptr slotPtr = new (std::nothrow) Notification::NotificationSlot(slot); if (slotPtr == nullptr) { ANS_LOGE("Failed to create NotificationSlot ptr"); - NotificationSts::ThrowErroWithMsg(env, "sts AniSetSlotByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "sts AniSetSlotByBundle ERROR_INTERNAL_ERROR"); return; } slotsVct.emplace_back(slotPtr); @@ -239,7 +239,7 @@ ani_double AniGetSlotNumByBundle(ani_env *env, ani_object bundleOption) Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { ANS_LOGE("UnwrapBundleOption failed"); - NotificationSts::ThrowErroWithMsg(env, "AniGetSlotNumByBundle ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniGetSlotNumByBundle ERROR_INTERNAL_ERROR"); return RETURN_EXCEPTION_VALUE; } uint64_t num = 0; @@ -259,12 +259,12 @@ void AniSetNotificationEnableSlot(ani_env *env, ani_object bundleOption, ani_enu ANS_LOGD("AniSetNotificationEnableSlot enter "); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option)) { - NotificationSts::ThrowErroWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); return; } Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::SlotTypeEtsToC(env, type, slotType)) { - NotificationSts::ThrowErroWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "AniSetNotificationEnableSlot ERROR_INTERNAL_ERROR"); return; } int returncode = 0; @@ -288,7 +288,7 @@ void AniSetNotificationEnableSlotWithForce(ani_env *env, Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!(NotificationSts::SlotTypeEtsToC(env, type, slotType)) || !(NotificationSts::UnwrapBundleOption(env, bundleOption, option))) { - NotificationSts::ThrowErroWithMsg(env, "SetNotificationEnableSlotWithForce ERROR_INTERNAL_ERROR"); + NotificationSts::ThrowErrorWithMsg(env, "SetNotificationEnableSlotWithForce ERROR_INTERNAL_ERROR"); return; } int returncode = Notification::NotificationHelper::SetEnabledForBundleSlot(option, slotType, @@ -307,7 +307,7 @@ ani_boolean AniIsNotificationSlotEnabled(ani_env *env, ani_object bundleOption, Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option) || !NotificationSts::SlotTypeEtsToC(env, type, slotType)) { - NotificationSts::ThrowErroWithMsg(env, "IsNotificationSlotEnabled : erro arguments."); + NotificationSts::ThrowErrorWithMsg(env, "IsNotificationSlotEnabled : erro arguments."); return ANI_FALSE; } @@ -326,7 +326,7 @@ ani_int AniGetSlotFlagsByBundle(ani_env *env, ani_object obj) ANS_LOGD("sts getSlotFlagsByBundle call"); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { - NotificationSts::ThrowErroWithMsg(env, "AniGetSlotFlagsByBundle : erro arguments."); + NotificationSts::ThrowErrorWithMsg(env, "AniGetSlotFlagsByBundle : erro arguments."); return ANI_FALSE; } uint32_t slotFlags = 0; @@ -344,7 +344,7 @@ void AniSetSlotFlagsByBundle(ani_env *env, ani_object obj, ani_double slotFlags) ANS_LOGD("sts setSlotFlagsByBundle call"); Notification::NotificationBundleOption option; if (!NotificationSts::UnwrapBundleOption(env, obj, option)) { - NotificationSts::ThrowErroWithMsg(env, "AniSetSlotFlagsByBundle : erro arguments."); + NotificationSts::ThrowErrorWithMsg(env, "AniSetSlotFlagsByBundle : erro arguments."); return; } int returncode = @@ -363,7 +363,7 @@ ani_object AniGetSlotByBundle(ani_env *env, ani_object bundleOption, ani_enum_it Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType::OTHER; if (!NotificationSts::UnwrapBundleOption(env, bundleOption, option) || !NotificationSts::SlotTypeEtsToC(env, type, slotType)) { - NotificationSts::ThrowErroWithMsg(env, "GetSlotByBundle : erro arguments."); + NotificationSts::ThrowErrorWithMsg(env, "GetSlotByBundle : erro arguments."); return nullptr; } sptr slot = nullptr; @@ -376,7 +376,7 @@ ani_object AniGetSlotByBundle(ani_env *env, ani_object bundleOption, ani_enum_it } ani_object infoObj; if (!NotificationSts::WrapNotificationSlot(env, slot, infoObj) || infoObj == nullptr) { - NotificationSts::ThrowErroWithMsg(env, "WrapNotificationSlot Failed"); + NotificationSts::ThrowErrorWithMsg(env, "WrapNotificationSlot Failed"); return nullptr; } return infoObj; diff --git a/frameworks/ets/ani/src/manager/ani_support_template.cpp b/frameworks/ets/ani/src/manager/ani_support_template.cpp index 495cb7311..7d57f8fad 100755 --- a/frameworks/ets/ani/src/manager/ani_support_template.cpp +++ b/frameworks/ets/ani/src/manager/ani_support_template.cpp @@ -28,7 +28,7 @@ ani_boolean AniIsSupportTemplate(ani_env* env, ani_string templateName) ANS_LOGD("AniIsSupportTemplate call"); std::string tempStr; if (NotificationSts::GetStringByAniString(env, templateName, tempStr) != ANI_OK) { - NotificationSts::ThrowErroWithMsg(env, "templateName parse failed!"); + NotificationSts::ThrowErrorWithMsg(env, "templateName parse failed!"); return NotificationSts::BoolToAniBoolean(false); } std::string templateNameStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE); @@ -59,7 +59,7 @@ ani_object AniGetDeviceRemindType(ani_env *env) } ani_enum_item remindTypeItem {}; if (!NotificationSts::DeviceRemindTypeCToEts(env, remindType, remindTypeItem)) { - NotificationSts::ThrowErroWithMsg(env, "AniGetDeviceRemindType:failed to WrapNotificationSlotArray"); + NotificationSts::ThrowErrorWithMsg(env, "AniGetDeviceRemindType:failed to WrapNotificationSlotArray"); return nullptr; } ANS_LOGD("AniGetDeviceRemindType end, ret: %{public}d", returncode); diff --git a/frameworks/ets/ani/src/sts_common.cpp b/frameworks/ets/ani/src/sts_common.cpp index ce5254aa3..07368ab5a 100644 --- a/frameworks/ets/ani/src/sts_common.cpp +++ b/frameworks/ets/ani/src/sts_common.cpp @@ -188,10 +188,10 @@ ani_status GetPropertyDouble(ani_env *env, ani_object obj, const char *name, } if ((status = env->Object_CallMethodByName_Double(static_cast(refObj), "unboxed", ":D", &outvalue)) != ANI_OK) { - ANS_LOGE("Object_CallMethodByName_Boolean failed, status : %{public}d", status); + ANS_LOGE("Object_CallMethodByName_Double failed, status : %{public}d", status); return status; } - ANS_LOGD("Object_CallMethodByName_Double sucess, status: %{public}f", outvalue); + ANS_LOGD("GetPropertyDouble end."); return status; } @@ -316,8 +316,8 @@ ani_status GetPropertyNumberArray(ani_env *env, ani_object param, const char *na ani_object GetAniStringArrayByVectorString(ani_env *env, std::vector &strs) { - if (env == nullptr || strs.empty()) { - ANS_LOGE("GetAniStringArrayByVectorString fail, env is nullptr or strs is empty"); + if (env == nullptr) { + ANS_LOGE("GetAniStringArrayByVectorString fail, env is nullptr"); return nullptr; } int length = strs.size(); diff --git a/frameworks/ets/ani/src/sts_convert_other.cpp b/frameworks/ets/ani/src/sts_convert_other.cpp index f85af200b..29c205265 100644 --- a/frameworks/ets/ani/src/sts_convert_other.cpp +++ b/frameworks/ets/ani/src/sts_convert_other.cpp @@ -15,7 +15,7 @@ #include "sts_convert_other.h" #include "sts_common.h" -#include "pixel_map_ani.h" +#include "pixel_map_taihe_ani.h" namespace OHOS { namespace NotificationSts { @@ -43,7 +43,7 @@ std::shared_ptr UnwrapWantAgent(ani_env *env, ani_object agent) return wantAgentSp; } -ani_status UnwrapResource(ani_env *env, ani_object obj, ResourceManager::Resource resource) +ani_status UnwrapResource(ani_env *env, ani_object obj, ResourceManager::Resource &resource) { ANS_LOGD("UnwrapResource called"); if (env == nullptr || obj == nullptr) { @@ -84,30 +84,17 @@ ani_object CreateAniPixelMap(ani_env* env, std::shared_ptr pixelMap) ANS_LOGE("CreateAniPixelMap failed, has nullPtr"); return nullptr; } - return PixelMapAni::CreatePixelMap(env, pixelMap); + return PixelMapTaiheAni::CreateEtsPixelMap(env, pixelMap); } -std::shared_ptr GetPixelMapFromEnvSp(ani_env* env, ani_object obj) +std::shared_ptr GetPixelMapFromAni(ani_env* env, ani_object obj) { - ANS_LOGD("GetPixelMapFromEnvSp call"); + ANS_LOGD("GetPixelMapFromAni call"); if (env == nullptr || obj == nullptr) { - ANS_LOGE("GetPixelMapFromEnvSp failed, has nullPtr"); + ANS_LOGE("GetPixelMapFromAni failed, has nullPtr"); return nullptr; } - ani_status ret; - ani_long nativeObj {}; - if ((ret = env->Object_GetFieldByName_Long(obj, "nativeObj", &nativeObj)) != ANI_OK) { - ANS_LOGI("GetPixelMapFromEnvSp Object_GetField_Long fetch failed"); - return nullptr; - } - PixelMap* pixelmap = reinterpret_cast(nativeObj); - if (pixelmap == nullptr) { - ANS_LOGI("GetPixelMapFromEnvSp pixelmap nullptr"); - return nullptr; - } - std::shared_ptr pixelmapSp = std::make_shared(*pixelmap); - deletePoint(pixelmap); - return pixelmapSp; + return PixelMapTaiheAni::GetNativePixelMap(env, obj); } ani_status GetPixelMapArrayByRef(ani_env *env, ani_ref param, std::vector> &pixelMaps) @@ -134,9 +121,9 @@ ani_status GetPixelMapArrayByRef(ani_env *env, ani_ref param, std::vector pixelMap = GetPixelMapFromEnvSp(env, static_cast(pixelMapRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(pixelMapRef)); if (pixelMap == nullptr) { - ANS_LOGE("GetPixelMapArrayByRef: GetPixelMapFromEnvSp failed."); + ANS_LOGE("GetPixelMapArrayByRef: GetPixelMapFromAni failed."); pixelMaps.clear(); return ANI_INVALID_ARGS; } @@ -299,7 +286,7 @@ ani_status GetPixelMapByRef( } ani_status GetMapOfPictureInfo(ani_env *env, ani_object obj, - std::map>> pictureMap) + std::map>> &pictureMap) { ANS_LOGD("GetMapOfPictureInfo call"); if (env == nullptr || obj == nullptr) { @@ -338,7 +325,7 @@ ani_status GetMapOfPictureInfo(ani_env *env, ani_object obj, return status; } -ani_object GetAniResource(ani_env *env, const std::shared_ptr &resource) +ani_object GetAniResource(ani_env *env, const std::shared_ptr resource) { ANS_LOGD("GetAniResource call"); if (env == nullptr || resource == nullptr) { @@ -371,11 +358,11 @@ ani_object GetAniResource(ani_env *env, const std::shared_ptr> &pixelMaps) +ani_object GetAniArrayPixelMap(ani_env *env, const std::vector> pixelMaps) { ANS_LOGD("GetAniArrayPixelMap call"); - if (env == nullptr || pixelMaps.empty()) { - ANS_LOGE("GetAniArrayPixelMap failed, env is nullPtr or pixelMaps is empty"); + if (env == nullptr) { + ANS_LOGE("GetAniArrayPixelMap failed, env is nullPtr"); return nullptr; } ani_size length = pixelMaps.size(); @@ -385,8 +372,8 @@ ani_object GetAniArrayPixelMap(ani_env *env, const std::vector> &resources) + const std::vector> resources) { ANS_LOGD("GetAniArrayResource call"); - if (env == nullptr || resources.empty()) { - ANS_LOGE("GetAniArrayResource failed, env is nullPtr or resources is empty"); + if (env == nullptr) { + ANS_LOGE("GetAniArrayResource failed, env is nullPtr"); return nullptr; } ani_size length = resources.size(); @@ -418,7 +405,7 @@ ani_object GetAniArrayResource(ani_env *env, return nullptr; } ani_size i = 0; - for (auto &resource : resources) { + for (auto resource : resources) { ani_object resourceObject = GetAniResource(env, resource); if (resourceObject == nullptr) { ANS_LOGE("GetAniArrayResource : resourceObject is nullPtr"); @@ -440,8 +427,8 @@ bool GetAniPictrueInfo(ani_env *env, std::map(iconRef), resource)) { iconButton.SetIconResource(std::make_shared(resource)); } else { - std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(iconRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(iconRef)); if (pixelMap == nullptr) { ANS_LOGE("UnWarpNotificationIconButton: get iconResource failed"); return ANI_INVALID_ARGS; @@ -453,7 +453,7 @@ bool getCapsuleByIcon(ani_env *env, ani_object obj, std::shared_ptr &p ANS_LOGE("icon of Capsule is undefined"); return false; } - std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(tempRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(tempRef)); } return true; } @@ -726,7 +726,7 @@ ani_status UnWarpNotificationBasicContent(ani_env *env, ani_object obj, || lockscreenPictureRef == nullptr) { ANS_LOGD("UnWarpNotificationBasicContent: get lockscreenPicture failed"); } else { - std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(lockscreenPictureRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(lockscreenPictureRef)); if (pixelMap != nullptr) { basicContent->SetLockScreenPicture(pixelMap); } else { @@ -873,7 +873,7 @@ ani_status UnWarpNotificationPictureContent(ani_env *env, ani_object obj, ANS_LOGE("UnWarpNotificationPictureContent: get briefText failed"); return ANI_INVALID_ARGS; } - std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(pictureRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(pictureRef)); if (pixelMap == nullptr) { ANS_LOGE("UnWarpNotificationPictureContent: get briefText by pixelMap failed"); return ANI_INVALID_ARGS; diff --git a/frameworks/ets/ani/src/sts_request.cpp b/frameworks/ets/ani/src/sts_request.cpp index b8cbf7e57..538479672 100644 --- a/frameworks/ets/ani/src/sts_request.cpp +++ b/frameworks/ets/ani/src/sts_request.cpp @@ -606,7 +606,7 @@ void GetNotificationSmallIcon(ani_env *env, ani_object obj, std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(smallIconRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(smallIconRef)); if (pixelMap != nullptr) { request->SetLittleIcon(pixelMap); } @@ -621,7 +621,7 @@ void GetNotificationLargeIcon(ani_env *env, ani_object obj, std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(largeIconRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(largeIconRef)); if (pixelMap != nullptr) { request->SetBigIcon(pixelMap); } @@ -636,7 +636,7 @@ void GetNotificationOverlayIcon(ani_env *env, ani_object obj, std::shared_ptr pixelMap = GetPixelMapFromEnvSp(env, static_cast(overlayIconRef)); + std::shared_ptr pixelMap = GetPixelMapFromAni(env, static_cast(overlayIconRef)); if (pixelMap != nullptr) { request->SetOverlayIcon(pixelMap); } -- Gitee