From 4252dfdf10b5073deba1e684087e35d8f142c8e8 Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Sun, 10 Aug 2025 20:14:10 +0800 Subject: [PATCH 1/2] fixed for pixMap Signed-off-by: heguokai <275503077@qq.com> --- frameworks/ets/ani/BUILD.gn | 4 +-- frameworks/ets/ani/include/sts_common.h | 6 ++--- .../ets/ani/include/sts_convert_other.h | 4 +-- frameworks/ets/ani/src/sts_common.cpp | 13 +++++----- frameworks/ets/ani/src/sts_convert_other.cpp | 25 +++++-------------- frameworks/ets/ani/src/sts_request.cpp | 18 ++++++++++++- .../ets/ets/@ohos.notificationManager.ets | 3 +++ .../ets/notification/notificationRequest.ets | 2 ++ .../notification/notificationSubscriber.ets | 1 + 9 files changed, 42 insertions(+), 34 deletions(-) diff --git a/frameworks/ets/ani/BUILD.gn b/frameworks/ets/ani/BUILD.gn index ec2da9c05..ad182c55a 100644 --- a/frameworks/ets/ani/BUILD.gn +++ b/frameworks/ets/ani/BUILD.gn @@ -129,7 +129,7 @@ if (distributed_notification_service_disable_control) { "ability_runtime:runtime", "napi:ace_napi", "image_framework:image_native", - "image_framework:image_ani", + "image_framework:image_taihe", "resource_management:global_resmgr", "ability_runtime:ani_base_context", "ability_runtime:ability_context_native", @@ -214,7 +214,7 @@ ohos_shared_library("notification_subscribe_ani") { "ability_runtime:ani_common", "ability_runtime:ani_wantagent_common", "image_framework:image_native", - "image_framework:image_ani", + "image_framework:image_taihe", "resource_management:global_resmgr", ] diff --git a/frameworks/ets/ani/include/sts_common.h b/frameworks/ets/ani/include/sts_common.h index d242a27b4..aa6600ef6 100644 --- a/frameworks/ets/ani/include/sts_common.h +++ b/frameworks/ets/ani/include/sts_common.h @@ -41,7 +41,7 @@ bool GetDateByObject(ani_env *env, ani_object timeObj, int64_t &time); ani_status GetAniStringByString(ani_env* env, const std::string str, ani_string &aniStr); ani_status GetStringByAniString(ani_env *env, ani_string str, std::string &res); bool GetStringArrayByAniObj(ani_env *env, const ani_object ani_obj, std::vector &stdVString); -ani_object GetAniStringArrayByVectorString(ani_env *env, std::vector &strs); +ani_object GetAniStringArrayByVectorString(ani_env *env, std::vector strs); ani_object newArrayClass(ani_env *env, int length); ani_object newRecordClass(ani_env *env); ani_object ConvertArrayDoubleToAniObj(ani_env *env, const std::vector values); @@ -73,8 +73,8 @@ bool SetOptionalFieldBoolean(ani_env *env, ani_class cls, ani_object &object, const std::string fieldName, bool value); bool SetOptionalFieldDouble(ani_env *env, ani_class cls, ani_object &object, const std::string fieldName, double value); -bool SetOptionalFieldArrayLong(ani_env *env, ani_class cls, ani_object &object, const std::string &fieldName, - const std::vector &values); +bool SetOptionalFieldArrayLong(ani_env *env, ani_class cls, ani_object &object, const std::string fieldName, + const std::vector values); // property bool SetPropertyOptionalByBoolean(ani_env *env, ani_object &object, const char *name, bool value); diff --git a/frameworks/ets/ani/include/sts_convert_other.h b/frameworks/ets/ani/include/sts_convert_other.h index 2c32dcb83..aec482f65 100644 --- a/frameworks/ets/ani/include/sts_convert_other.h +++ b/frameworks/ets/ani/include/sts_convert_other.h @@ -43,11 +43,11 @@ 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_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); diff --git a/frameworks/ets/ani/src/sts_common.cpp b/frameworks/ets/ani/src/sts_common.cpp index 60ba64a03..949ff7b42 100644 --- a/frameworks/ets/ani/src/sts_common.cpp +++ b/frameworks/ets/ani/src/sts_common.cpp @@ -192,7 +192,7 @@ ani_status GetPropertyDouble(ani_env *env, ani_object obj, const char *name, ANS_LOGE("Object_CallMethodByName_Boolean failed, status : %{public}d", status); return status; } - ANS_LOGD("Object_CallMethodByName_Double sucess, status: %{public}f", outvalue); + ANS_LOGD("Object_CallMethodByName_Double sucess"); return status; } @@ -216,7 +216,7 @@ ani_status GetPropertyInt(ani_env *env, ani_object obj, const char *name, ANS_LOGE("Object_CallMethodByName_Int failed, status : %{public}d", status); return status; } - ANS_LOGD("Object_CallMethodByName_Int sucess, status: %{public}d", outvalue); + ANS_LOGD("Object_CallMethodByName_Int sucess"); return status; } @@ -240,7 +240,7 @@ ani_status GetPropertyLong(ani_env *env, ani_object obj, const char *name, ANS_LOGE("Object_CallMethodByName_Boolean failed, status : %{public}d", status); return status; } - ANS_LOGD("Object_CallMethodByName_Long sucess, status: %{public}lld", outvalue); + ANS_LOGD("Object_CallMethodByName_Long sucess"); return status; } @@ -320,7 +320,6 @@ ani_status GetPropertyStringArray(ani_env *env, ani_object param, const char *na return status; } res.push_back(str); - ANS_LOGD("GetStdString index: %{public}d %{public}s", i, str.c_str()); } return status; } @@ -401,7 +400,7 @@ ani_status GetPropertyLongArray(ani_env *env, ani_object param, const char *name return status; } -ani_object GetAniStringArrayByVectorString(ani_env *env, std::vector &strs) +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"); @@ -672,8 +671,8 @@ ani_object ConvertArrayLongToAniObj(ani_env *env, const std::vector &values) +bool SetOptionalFieldArrayLong(ani_env *env, ani_class cls, ani_object &object, const std::string fieldName, + const std::vector values) { if (env == nullptr || cls == nullptr || object == nullptr || fieldName.empty()) { ANS_LOGE("SetOptionalFieldArrayLong fail, has nullptr or fieldName is empty"); diff --git a/frameworks/ets/ani/src/sts_convert_other.cpp b/frameworks/ets/ani/src/sts_convert_other.cpp index 4d537c83a..c05cdaf0a 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,7 +84,7 @@ 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) @@ -94,20 +94,7 @@ std::shared_ptr GetPixelMapFromEnvSp(ani_env* env, ani_object obj) ANS_LOGE("GetPixelMapFromEnvSp 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) @@ -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) { @@ -386,7 +373,7 @@ ani_object GetAniArrayPixelMap(ani_env *env, const std::vectorSetAdditionalData(extras); } +void GetNotificationExtendInfo(ani_env *env, ani_object obj, std::shared_ptr &request) +{ + ani_boolean isUndefined = ANI_TRUE; + ani_ref extendInfoRef = {}; + if (ANI_OK != GetPropertyRef(env, obj, "extendInfo", isUndefined, extendInfoRef) + || isUndefined == ANI_TRUE || extendInfoRef == nullptr) { + ANS_LOGE("GetNotificationExtendInfo: get ref failed"); + return; + } + WantParams wantParams = {}; + UnwrapWantParams(env, extendInfoRef, wantParams); + std::shared_ptr extras = std::make_shared(wantParams); + request->SetExtendInfo(extras); +} + void GetNotificationRemovalWantAgent(ani_env *env, ani_object obj, std::shared_ptr &request) { @@ -724,6 +739,7 @@ ani_status GetNotificationRequestByCustom(ani_env *env, ani_object obj, GetNotificationSlotType(env, obj, notificationRequest); GetNotificationWantAgent(env, obj, notificationRequest); GetNotificationExtraInfo(env, obj, notificationRequest); + GetNotificationExtendInfo(env, obj, notificationRequest); GetNotificationRemovalWantAgent(env, obj, notificationRequest); GetNotificationActionButtons(env, obj, notificationRequest); GetNotificationSmallIcon(env, obj, notificationRequest); diff --git a/frameworks/ets/ets/@ohos.notificationManager.ets b/frameworks/ets/ets/@ohos.notificationManager.ets index 3bd9e4e93..bf860abf8 100644 --- a/frameworks/ets/ets/@ohos.notificationManager.ets +++ b/frameworks/ets/ets/@ohos.notificationManager.ets @@ -571,6 +571,9 @@ export default namespace notificationManager { if (request?.wantAgent !== undefined && request.wantAgent == null) { return errorParamInvalid; } + if(request?.extraInfo !== undefined && request?.extraInfo == null) { + return errorParamInvalid; + } if(request?.extendInfo !== undefined && request?.extendInfo == null) { return errorParamInvalid; } diff --git a/frameworks/ets/ets/notification/notificationRequest.ets b/frameworks/ets/ets/notification/notificationRequest.ets index 7ef87e113..2cfb62aad 100644 --- a/frameworks/ets/ets/notification/notificationRequest.ets +++ b/frameworks/ets/ets/notification/notificationRequest.ets @@ -89,6 +89,7 @@ export interface NotificationRequest { tapDismissed?: boolean; autoDeletedTime?: long; wantAgent?: WantAgent; + extraInfo?: Record; extendInfo?: Record; color?: long; colorEnabled?: boolean; @@ -140,6 +141,7 @@ class NotificationRequestInner implements NotificationRequest { public tapDismissed?: boolean | undefined; public autoDeletedTime?: long | undefined; public wantAgent?: WantAgent | undefined; + public extraInfo?: Record | undefined; public extendInfo?: Record | undefined; public color?: long | undefined; public colorEnabled?: boolean | undefined; diff --git a/frameworks/ets/ets/notification/notificationSubscriber.ets b/frameworks/ets/ets/notification/notificationSubscriber.ets index 1b9371a0d..af2b5def2 100644 --- a/frameworks/ets/ets/notification/notificationSubscriber.ets +++ b/frameworks/ets/ets/notification/notificationSubscriber.ets @@ -97,6 +97,7 @@ class SubscribeCallbackDataInner implements SubscribeCallbackData { tapDismissed: undefined, autoDeletedTime: undefined, wantAgent: undefined, + extraInfo: undefined, extendInfo: undefined, color: undefined, colorEnabled: undefined, -- Gitee From aa9a2fe99520c2afad700877401c1d71871472dc Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Sun, 10 Aug 2025 20:26:51 +0800 Subject: [PATCH 2/2] add Signed-off-by: heguokai <275503077@qq.com> --- frameworks/ets/ani/src/sts_common.cpp | 4 +-- frameworks/ets/ani/src/sts_request.cpp | 2 -- frameworks/ets/ani/src/sts_subscribe.cpp | 12 ++++---- .../ets/notification/notificationSorting.ets | 30 +++++++++---------- .../notification/notificationSubscriber.ets | 1 - 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/frameworks/ets/ani/src/sts_common.cpp b/frameworks/ets/ani/src/sts_common.cpp index 949ff7b42..d770dcbe0 100644 --- a/frameworks/ets/ani/src/sts_common.cpp +++ b/frameworks/ets/ani/src/sts_common.cpp @@ -402,8 +402,8 @@ ani_status GetPropertyLongArray(ani_env *env, ani_object param, const char *name 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_request.cpp b/frameworks/ets/ani/src/sts_request.cpp index e93cff6dc..5ff491a84 100644 --- a/frameworks/ets/ani/src/sts_request.cpp +++ b/frameworks/ets/ani/src/sts_request.cpp @@ -883,8 +883,6 @@ bool SetNotificationRequestByNumber(ani_env* env, ani_class cls, const OHOS::Not SetPropertyOptionalByInt(env, object, "creatorPid", request->GetCreatorPid()); // badgeNumber?: long SetPropertyOptionalByLong(env, object, "badgeNumber", request->GetBadgeNumber()); - // readonly creatorInstanceKey?: int - SetPropertyOptionalByInt(env, object, "creatorInstanceKey", request->GetCreatorInstanceKey()); return true; } diff --git a/frameworks/ets/ani/src/sts_subscribe.cpp b/frameworks/ets/ani/src/sts_subscribe.cpp index 945226c6b..27cfc4a19 100644 --- a/frameworks/ets/ani/src/sts_subscribe.cpp +++ b/frameworks/ets/ani/src/sts_subscribe.cpp @@ -632,15 +632,15 @@ bool SubscriberInstanceManager::UnSubscribe(ani_env *env, ani_object subscriber) ANS_LOGD("enter"); if (IsUndefine(env, subscriber)) { ANS_LOGD("Subscriber is undefine"); - std::string msg = OHOS::NotificationSts::FindAnsErrMsg(ERR_ANS_INVALID_PARAM); - OHOS::NotificationSts::ThrowError(env, ERR_ANS_INVALID_PARAM, msg); + std::string msg = OHOS::NotificationSts::FindAnsErrMsg(ERROR_PARAM_INVALID); + OHOS::NotificationSts::ThrowError(env, ERROR_PARAM_INVALID, msg); return false; } std::shared_ptr stsSubscriber = nullptr; if (!HasNotificationSubscriber(env, subscriber, stsSubscriber)) { ANS_LOGD("Subscriber not found"); - std::string msg = OHOS::NotificationSts::FindAnsErrMsg(ERR_ANS_INVALID_PARAM); - OHOS::NotificationSts::ThrowError(env, ERR_ANS_INVALID_PARAM, msg); + std::string msg = OHOS::NotificationSts::FindAnsErrMsg(ERROR_PARAM_INVALID); + OHOS::NotificationSts::ThrowError(env, ERROR_PARAM_INVALID, msg); return false; } bool ret = AddDeletingSubscriber(stsSubscriber); @@ -656,8 +656,8 @@ bool SubscriberInstanceManager::UnSubscribe(ani_env *env, ani_object subscriber) DelDeletingSubscriber(stsSubscriber); } } else { - std::string msg = OHOS::NotificationSts::FindAnsErrMsg(ERR_ANS_SUBSCRIBER_IS_DELETING); - OHOS::NotificationSts::ThrowError(env, ERR_ANS_SUBSCRIBER_IS_DELETING, msg); + std::string msg = OHOS::NotificationSts::FindAnsErrMsg(ERROR_INTERNAL_ERROR); + OHOS::NotificationSts::ThrowError(env, ERROR_INTERNAL_ERROR, "Subscriber is deleting"); return false; } return true; diff --git a/frameworks/ets/ets/notification/notificationSorting.ets b/frameworks/ets/ets/notification/notificationSorting.ets index 063e2b36f..9b8c51d9f 100644 --- a/frameworks/ets/ets/notification/notificationSorting.ets +++ b/frameworks/ets/ets/notification/notificationSorting.ets @@ -23,21 +23,21 @@ export interface NotificationSorting { class NotificationSortingInner implements NotificationSorting { public readonly slot: NotificationSlot = { - notificationType: undefined, - //level?: notification.SlotLevel; - desc: undefined, - badgeFlag: undefined, - bypassDnd: undefined, - lockscreenVisibility: undefined, - vibrationEnabled: undefined, - sound: undefined, - lightEnabled: undefined, - lightColor: undefined, - vibrationValues: undefined, - enabled: undefined, - reminderMode: undefined, - authorizedStatus: undefined - }; + notificationType: undefined, + notificationLevel: undefined, + desc: undefined, + badgeFlag: undefined, + bypassDnd: undefined, + lockscreenVisibility: undefined, + vibrationEnabled: undefined, + sound: undefined, + lightEnabled: undefined, + lightColor: undefined, + vibrationValues: undefined, + enabled: undefined, + reminderMode: undefined, + authorizedStatus: undefined + }; public readonly hashCode: string = ''; public readonly ranking: long = -1; } \ No newline at end of file diff --git a/frameworks/ets/ets/notification/notificationSubscriber.ets b/frameworks/ets/ets/notification/notificationSubscriber.ets index af2b5def2..9f7751783 100644 --- a/frameworks/ets/ets/notification/notificationSubscriber.ets +++ b/frameworks/ets/ets/notification/notificationSubscriber.ets @@ -117,7 +117,6 @@ class SubscribeCallbackDataInner implements SubscribeCallbackData { creatorUid: undefined, creatorPid: undefined, creatorUserId: undefined, - // creatorInstanceKey: undefined, sound: undefined, classification: undefined, hashCode: undefined, -- Gitee