diff --git a/frameworks/ans/core/src/ans_manager_proxy.cpp b/frameworks/ans/core/src/ans_manager_proxy.cpp index ae493cd9da4650a7e9b8d16dc5557db6d359d2ce..b7ac0f7d019a35e00b50d959efe43faedba3d69a 100644 --- a/frameworks/ans/core/src/ans_manager_proxy.cpp +++ b/frameworks/ans/core/src/ans_manager_proxy.cpp @@ -354,10 +354,12 @@ ErrCode AnsManagerProxy::GetSlotByType(const NotificationConstant::SlotType &slo return ERR_ANS_PARCELABLE_FAILED; } - slot = reply.ReadParcelable(); - if (slot == nullptr) { - ANS_LOGW("[GetSlotByType] fail: read slot failed"); - return ERR_ANS_PARCELABLE_FAILED; + if (result == ERR_OK) { + slot = reply.ReadParcelable(); + if (slot == nullptr) { + ANS_LOGW("[GetSlotByType] fail: read slot failed"); + return ERR_ANS_PARCELABLE_FAILED; + } } return result; @@ -418,10 +420,12 @@ ErrCode AnsManagerProxy::GetSlotGroup(const std::string &groupId, sptr(); - if (group == nullptr) { - ANS_LOGW("[GetSlotGroup] fail: read group failed"); - return ERR_ANS_PARCELABLE_FAILED; + if (result == ERR_OK) { + group = reply.ReadParcelable(); + if (group == nullptr) { + ANS_LOGW("[GetSlotGroup] fail: read group failed"); + return ERR_ANS_PARCELABLE_FAILED; + } } return result; diff --git a/interfaces/kits/napi/ans/src/unsubscribe.cpp b/interfaces/kits/napi/ans/src/unsubscribe.cpp index f50a80441ec54dab0709180b47b0998aee78a388..a8b188eeb6b89721c214b3d63a916ee5b17339e3 100644 --- a/interfaces/kits/napi/ans/src/unsubscribe.cpp +++ b/interfaces/kits/napi/ans/src/unsubscribe.cpp @@ -16,6 +16,8 @@ #include "unsubscribe.h" #include "subscribe.h" +#include "ans_inner_errors.h" + namespace OHOS { namespace NotificationNapi { const int UNSUBSCRIBE_MAX_PARA = 2; @@ -48,8 +50,9 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, SubscriberInstancesInfo subscriberInstancesInfo; if (!HasNotificationSubscriber(env, argv[0], subscriberInstancesInfo)) { - return nullptr; + ANS_LOGW("Subscriber not found"); } + paras.objectInfo = subscriberInstancesInfo.subscriber; ANS_LOGI("ObjectInfo = %{public}p start", paras.objectInfo); @@ -91,6 +94,12 @@ napi_value Unsubscribe(napi_env env, napi_callback_info info) ANS_LOGI("Unsubscribe napi_create_async_work start"); AsyncCallbackInfoUnsubscribe *asynccallbackinfo = (AsyncCallbackInfoUnsubscribe *)data; + if (asynccallbackinfo->objectInfo == nullptr) { + ANS_LOGE("invalid object info"); + asynccallbackinfo->info.errorCode = ERR_ANS_INVALID_PARAM; + return; + } + asynccallbackinfo->info.errorCode = NotificationHelper::UnSubscribeNotification(*(asynccallbackinfo->objectInfo)); }, diff --git a/sa_profile/3203.xml b/sa_profile/3203.xml index 7f45c1fc08c584b6ff62c2b12119baacbd64c0e1..ccaa7c4fbe92e073c425e04ecd56b914ac888b9a 100755 --- a/sa_profile/3203.xml +++ b/sa_profile/3203.xml @@ -17,6 +17,8 @@ 3203 /system/lib/libans.z.so + 3299 + 5000 true false 1 diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 875112f77e009f61afabe4f21fd5427ad87944db..d67e8c03193704caa31cbd63f33b0f079f710ba1 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1403,10 +1403,10 @@ void AdvancedNotificationService::OnBundleRemoved(const sptrPostTask(std::bind([&]() { + handler_->PostTask(std::bind([bundleOption]() { ErrCode result = NotificationPreferences::GetInstance().RemoveNotificationForBundle(bundleOption); if (result != ERR_OK) { - ANS_LOGE("NotificationPreferences::RemoveNotificationForBundle failed: %{public}d", result); + ANS_LOGW("NotificationPreferences::RemoveNotificationForBundle failed: %{public}d", result); } })); }