diff --git a/frameworks/ans/core/src/ans_manager_stub.cpp b/frameworks/ans/core/src/ans_manager_stub.cpp index 98f514cca3f4676815caca08d6011668c683b79b..3dabf996416cb43d5ccebc7841eb406a0b7b3e87 100644 --- a/frameworks/ans/core/src/ans_manager_stub.cpp +++ b/frameworks/ans/core/src/ans_manager_stub.cpp @@ -450,7 +450,7 @@ ErrCode AnsManagerStub::HandleGetSlotByType(MessageParcel &data, MessageParcel & { NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - sptr slot; + sptr slot = nullptr; ErrCode result = GetSlotByType(slotType, slot); if (!reply.WriteInt32(result)) { ANS_LOGW("[HandleGetSlotByType] fail: write result failed, ErrCode=%{public}d", result); diff --git a/frameworks/ans/core/src/ans_notification.cpp b/frameworks/ans/core/src/ans_notification.cpp index 02f3ff0d3c28e1b70585239504d67a7ffb4134ae..c57bd3076074c74c538074b07ccfc0e53da83d31 100644 --- a/frameworks/ans/core/src/ans_notification.cpp +++ b/frameworks/ans/core/src/ans_notification.cpp @@ -825,7 +825,7 @@ ErrCode AnsNotification::GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNot return ERR_ANS_SERVICE_NOT_CONNECTED; } - sptr dndDate; + sptr dndDate = nullptr; auto ret = ansManagerProxy_->GetDoNotDisturbDate(dndDate); if (ret != ERR_OK) { ANS_LOGE("Get DoNotDisturbDate failed."); @@ -985,7 +985,7 @@ ErrCode AnsNotification::PublishReminder(ReminderRequest &reminder) ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - sptr tarReminder; + sptr tarReminder = nullptr; switch (reminder.GetReminderType()) { case (ReminderRequest::ReminderType::TIMER): { ANSR_LOGI("Publish timer"); @@ -1320,7 +1320,7 @@ ErrCode AnsNotification::GetDoNotDisturbDate(const int32_t &userId, Notification return ERR_ANS_SERVICE_NOT_CONNECTED; } - sptr dndDate; + sptr dndDate = nullptr; auto ret = ansManagerProxy_->GetDoNotDisturbDate(dndDate); if (ret != ERR_OK) { ANS_LOGE("Get DoNotDisturbDate failed."); diff --git a/interfaces/kits/napi/ans/src/ans_template.cpp b/interfaces/kits/napi/ans/src/ans_template.cpp index a1816c4df9524e639738d1b90f7e097ee6e8221b..ebce81e33f4c92902602ec880aa8e5ebbce9d387 100644 --- a/interfaces/kits/napi/ans/src/ans_template.cpp +++ b/interfaces/kits/napi/ans/src/ans_template.cpp @@ -87,7 +87,7 @@ napi_value IsSupportTemplate(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("IsSupportTemplate napi_create_async_work start"); - AsyncCallbackInfoTemplate *asyncCallbackinfo = (AsyncCallbackInfoTemplate *)data; + AsyncCallbackInfoTemplate *asyncCallbackinfo = static_cast(data); if (asyncCallbackinfo) { asyncCallbackinfo->info.errorCode = NotificationHelper::IsSupportTemplate( @@ -96,7 +96,7 @@ napi_value IsSupportTemplate(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("IsSupportTemplate napi_create_async_work end"); - AsyncCallbackInfoTemplate *asyncCallbackinfo = (AsyncCallbackInfoTemplate *)data; + AsyncCallbackInfoTemplate *asyncCallbackinfo = static_cast(data); if (asyncCallbackinfo) { napi_value result = nullptr; napi_get_boolean(env, asyncCallbackinfo->params.support, &result); diff --git a/interfaces/kits/napi/ans/src/cancel.cpp b/interfaces/kits/napi/ans/src/cancel.cpp index 691113cf29d90a48a210564527fcaa7d507e1f5e..7524026d78938a8cb459b091bac74c662daef14e 100644 --- a/interfaces/kits/napi/ans/src/cancel.cpp +++ b/interfaces/kits/napi/ans/src/cancel.cpp @@ -143,7 +143,7 @@ napi_value Cancel(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("Cancel napi_create_async_work start"); - AsyncCallbackInfoCancel *asynccallbackinfo = (AsyncCallbackInfoCancel *)data; + AsyncCallbackInfoCancel *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { asynccallbackinfo->info.errorCode = @@ -152,7 +152,7 @@ napi_value Cancel(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("Cancel napi_create_async_work end"); - AsyncCallbackInfoCancel *asynccallbackinfo = (AsyncCallbackInfoCancel *)data; + AsyncCallbackInfoCancel *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -200,14 +200,14 @@ napi_value CancelAll(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("CancelAll napi_create_async_work start"); - AsyncCallbackInfoCancel *asynccallbackinfo = (AsyncCallbackInfoCancel *)data; + AsyncCallbackInfoCancel *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { asynccallbackinfo->info.errorCode = NotificationHelper::CancelAllNotifications(); } }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("CancelAll napi_create_async_work end"); - AsyncCallbackInfoCancel *asynccallbackinfo = (AsyncCallbackInfoCancel *)data; + AsyncCallbackInfoCancel *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -255,7 +255,7 @@ napi_value CancelGroup(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("CancelGroup napi_create_async_work start"); - AsyncCallbackInfoCancelGroup *asynccallbackinfo = (AsyncCallbackInfoCancelGroup *)data; + AsyncCallbackInfoCancelGroup *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { ANS_LOGI("asynccallbackinfo->params.groupName = %{public}s", asynccallbackinfo->params.groupName.c_str()); @@ -265,7 +265,7 @@ napi_value CancelGroup(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("CancelGroup napi_create_async_work end"); - AsyncCallbackInfoCancelGroup *asynccallbackinfo = (AsyncCallbackInfoCancelGroup *)data; + AsyncCallbackInfoCancelGroup *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { diff --git a/interfaces/kits/napi/ans/src/common.cpp b/interfaces/kits/napi/ans/src/common.cpp index 3590331e913567285aea7d7e11e7442a225cbcc7..7fd09dde49644e14d97ee67d740c47f4a17a2fe4 100644 --- a/interfaces/kits/napi/ans/src/common.cpp +++ b/interfaces/kits/napi/ans/src/common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -354,7 +354,7 @@ napi_value Common::SetNotificationRequestByNumber( napi_set_named_property(env, result, "color", value); // badgeIconStyle ?: number - int badgeIconStyle = (int)request->GetBadgeIconStyle(); + int badgeIconStyle = static_cast(request->GetBadgeIconStyle()); napi_create_int32(env, badgeIconStyle, &value); napi_set_named_property(env, result, "badgeIconStyle", value); @@ -4022,7 +4022,7 @@ napi_value Common::CreateWantAgentByJS(const napi_env &env, wantAgent, (void *)agent.get(), [](napi_env env, void *data, void *hint) { - AbilityRuntime::WantAgent::WantAgent *objectInfo = (AbilityRuntime::WantAgent::WantAgent *)data; + AbilityRuntime::WantAgent::WantAgent *objectInfo = static_cast(data); ANS_LOGI("CreateWantAgentByJS this = %{public}p", objectInfo); if (objectInfo) { diff --git a/interfaces/kits/napi/ans/src/display_badge.cpp b/interfaces/kits/napi/ans/src/display_badge.cpp index 392f02df3c45367b9bda268eabc64ec0b28aeb3c..d1a365469df9359277e81e0f1b44f5bb8f4b2d92 100644 --- a/interfaces/kits/napi/ans/src/display_badge.cpp +++ b/interfaces/kits/napi/ans/src/display_badge.cpp @@ -169,7 +169,7 @@ napi_value DisplayBadge(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("DisplayBadge napi_create_async_work start"); - AsyncCallbackInfoEnableBadge *asynccallbackinfo = (AsyncCallbackInfoEnableBadge *)data; + AsyncCallbackInfoEnableBadge *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { ANS_LOGI("option.bundle = %{public}s option.uid = %{public}d enable = %{public}d", asynccallbackinfo->params.option.GetBundleName().c_str(), @@ -182,7 +182,7 @@ napi_value DisplayBadge(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("DisplayBadge napi_create_async_work end"); - AsyncCallbackInfoEnableBadge *asynccallbackinfo = (AsyncCallbackInfoEnableBadge *)data; + AsyncCallbackInfoEnableBadge *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -212,7 +212,7 @@ void AsyncCompleteCallbackIsBadgeDisplayed(napi_env env, napi_status status, voi ANS_LOGE("Invalid async callback data"); return; } - AsyncCallbackInfoIsDisplayBadge *asynccallbackinfo = (AsyncCallbackInfoIsDisplayBadge *)data; + AsyncCallbackInfoIsDisplayBadge *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { napi_value result = nullptr; napi_get_boolean(env, asynccallbackinfo->enabled, &result); @@ -252,7 +252,7 @@ napi_value IsBadgeDisplayed(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("IsBadgeDisplayed napi_create_async_work start"); - AsyncCallbackInfoIsDisplayBadge *asynccallbackinfo = (AsyncCallbackInfoIsDisplayBadge *)data; + AsyncCallbackInfoIsDisplayBadge *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { if (asynccallbackinfo->params.hasBundleOption) { ANS_LOGI("option.bundle = %{public}s option.uid = %{public}d", diff --git a/interfaces/kits/napi/ans/src/distributed.cpp b/interfaces/kits/napi/ans/src/distributed.cpp index 06eb1ab31dccb309b927623ff217b33335cb9e5a..3edfaee4ca2878145fcd068f72236faa6f55bc2a 100644 --- a/interfaces/kits/napi/ans/src/distributed.cpp +++ b/interfaces/kits/napi/ans/src/distributed.cpp @@ -177,7 +177,7 @@ void AsyncCompleteCallbackIsDistributedEnabled(napi_env env, napi_status status, return; } ANS_LOGI("IsDistributedEnabled napi_create_async_work end"); - AsyncCallbackInfoIsEnabled *asynccallbackinfo = (AsyncCallbackInfoIsEnabled *)data; + AsyncCallbackInfoIsEnabled *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { napi_value result = nullptr; if (asynccallbackinfo->info.errorCode != ERR_OK) { @@ -221,7 +221,7 @@ napi_value IsDistributedEnabled(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("IsDistributedEnabled napi_create_async_work start"); - AsyncCallbackInfoIsEnabled *asynccallbackinfo = (AsyncCallbackInfoIsEnabled *)data; + AsyncCallbackInfoIsEnabled *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { asynccallbackinfo->info.errorCode = @@ -268,7 +268,7 @@ napi_value EnableDistributed(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("EnableDistributed napi_create_async_work start"); - AsyncCallbackInfoEnabled *asynccallbackinfo = (AsyncCallbackInfoEnabled *)data; + AsyncCallbackInfoEnabled *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { asynccallbackinfo->info.errorCode = @@ -277,7 +277,7 @@ napi_value EnableDistributed(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("EnableDistributed napi_create_async_work end"); - AsyncCallbackInfoEnabled *asynccallbackinfo = (AsyncCallbackInfoEnabled *)data; + AsyncCallbackInfoEnabled *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -326,14 +326,14 @@ napi_value EnableDistributedByBundle(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("EnableDistributedByBundle napi_create_async_work start"); - AsyncCallbackInfoEnabledByBundle *asynccallbackinfo = (AsyncCallbackInfoEnabledByBundle *)data; + AsyncCallbackInfoEnabledByBundle *asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::EnableDistributedByBundle( asynccallbackinfo->params.option, asynccallbackinfo->params.enable); }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("EnableDistributedByBundle napi_create_async_work end"); - AsyncCallbackInfoEnabledByBundle *asynccallbackinfo = (AsyncCallbackInfoEnabledByBundle *)data; + AsyncCallbackInfoEnabledByBundle *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { diff --git a/interfaces/kits/napi/ans/src/disturb_mode.cpp b/interfaces/kits/napi/ans/src/disturb_mode.cpp index 1f6d0bf664be940c7532144ea2f3351fdd8f6081..1b5d26335bf03c384cdf3f2719a1c72e0fda50e7 100644 --- a/interfaces/kits/napi/ans/src/disturb_mode.cpp +++ b/interfaces/kits/napi/ans/src/disturb_mode.cpp @@ -197,7 +197,7 @@ napi_value SetDoNotDisturbDate(napi_env env, napi_callback_info info) napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { ANS_LOGI("SetDoNotDisturbDate napi_create_async_work start"); - AsyncCallbackInfoSetDoNotDisturb *asynccallbackinfo = (AsyncCallbackInfoSetDoNotDisturb *)data; + AsyncCallbackInfoSetDoNotDisturb *asynccallbackinfo = static_cast(data); if (asynccallbackinfo->params.hasUserId) { asynccallbackinfo->info.errorCode = NotificationHelper::SetDoNotDisturbDate( asynccallbackinfo->params.userId, asynccallbackinfo->params.date); @@ -212,7 +212,7 @@ napi_value SetDoNotDisturbDate(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("SetDoNotDisturbDate napi_create_async_work end"); - AsyncCallbackInfoSetDoNotDisturb *asynccallbackinfo = (AsyncCallbackInfoSetDoNotDisturb *)data; + AsyncCallbackInfoSetDoNotDisturb *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -323,7 +323,7 @@ napi_value GetDoNotDisturbDate(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("GetDoNotDisturbDate napi_create_async_work start"); - AsyncCallbackInfoGetDoNotDisturb *asynccallbackinfo = (AsyncCallbackInfoGetDoNotDisturb *)data; + AsyncCallbackInfoGetDoNotDisturb *asynccallbackinfo = static_cast(data); if (asynccallbackinfo->params.hasUserId) { asynccallbackinfo->info.errorCode = NotificationHelper::GetDoNotDisturbDate( asynccallbackinfo->params.userId, asynccallbackinfo->date); @@ -375,7 +375,7 @@ napi_value SupportDoNotDisturbMode(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("SupportDoNotDisturbMode napi_create_async_work start"); - AsyncCallbackInfoSupportDoNotDisturb *asynccallbackinfo = (AsyncCallbackInfoSupportDoNotDisturb *)data; + AsyncCallbackInfoSupportDoNotDisturb *asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::DoesSupportDoNotDisturbMode(asynccallbackinfo->isSupported); ANS_LOGI("SupportDoNotDisturbMode errorCode=%{public}d isSupported=%{public}d", @@ -383,7 +383,7 @@ napi_value SupportDoNotDisturbMode(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("SupportDoNotDisturbMode napi_create_async_work end"); - AsyncCallbackInfoSupportDoNotDisturb *asynccallbackinfo = (AsyncCallbackInfoSupportDoNotDisturb *)data; + AsyncCallbackInfoSupportDoNotDisturb *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { napi_value result = nullptr; napi_get_boolean(env, asynccallbackinfo->isSupported, &result); diff --git a/interfaces/kits/napi/ans/src/enable_notification.cpp b/interfaces/kits/napi/ans/src/enable_notification.cpp index ee5f3299000e22439a3963d51a10b02a21765ef5..f16100bcbbee8bd0044dba04d7589d59a069b986 100644 --- a/interfaces/kits/napi/ans/src/enable_notification.cpp +++ b/interfaces/kits/napi/ans/src/enable_notification.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -151,7 +151,7 @@ void AsyncCompleteCallbackEnableNotification(napi_env env, napi_status status, v ANS_LOGE("Invalid async callback data"); return; } - AsyncCallbackInfoEnable *asynccallbackinfo = (AsyncCallbackInfoEnable *)data; + AsyncCallbackInfoEnable *asynccallbackinfo = static_cast(data); Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); @@ -191,7 +191,7 @@ napi_value EnableNotification(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("EnableNotification napi_create_async_work start"); - AsyncCallbackInfoEnable *asynccallbackinfo = (AsyncCallbackInfoEnable *)data; + AsyncCallbackInfoEnable *asynccallbackinfo = static_cast(data); std::string deviceId {""}; asynccallbackinfo->info.errorCode = NotificationHelper::SetNotificationsEnabledForSpecifiedBundle( asynccallbackinfo->params.option, deviceId, asynccallbackinfo->params.enable); @@ -217,7 +217,7 @@ void AsyncCompleteCallbackIsNotificationEnabled(napi_env env, napi_status status ANS_LOGE("Invalid async callback data"); return; } - AsyncCallbackInfoIsEnable *asynccallbackinfo = (AsyncCallbackInfoIsEnable *)data; + AsyncCallbackInfoIsEnable *asynccallbackinfo = static_cast(data); napi_value result = nullptr; napi_get_boolean(env, asynccallbackinfo->allowed, &result); @@ -259,7 +259,7 @@ napi_value IsNotificationEnabled(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("IsNotificationEnabled napi_create_async_work start"); - AsyncCallbackInfoIsEnable *asynccallbackinfo = (AsyncCallbackInfoIsEnable *)data; + AsyncCallbackInfoIsEnable *asynccallbackinfo = static_cast(data); if (asynccallbackinfo->params.hasBundleOption) { ANS_LOGI("option.bundle = %{public}s option.uid = %{public}d", @@ -315,7 +315,7 @@ napi_value IsNotificationEnabledSelf(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("IsNotificationEnabledSelf napi_create_async_work start"); - AsyncCallbackInfoIsEnable *asynccallbackinfo = (AsyncCallbackInfoIsEnable *)data; + AsyncCallbackInfoIsEnable *asynccallbackinfo = static_cast(data); if (asynccallbackinfo->params.hasBundleOption) { ANS_LOGE("Not allowed to query another application"); @@ -364,7 +364,7 @@ napi_value RequestEnableNotification(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("RequestEnableNotification napi_create_async_work start"); - AsyncCallbackInfoIsEnable *asynccallbackinfo = (AsyncCallbackInfoIsEnable *)data; + AsyncCallbackInfoIsEnable *asynccallbackinfo = static_cast(data); std::string deviceId {""}; asynccallbackinfo->info.errorCode = NotificationHelper::RequestEnableNotification(deviceId); diff --git a/interfaces/kits/napi/ans/src/get_active.cpp b/interfaces/kits/napi/ans/src/get_active.cpp index f924d7f8fab40f1f46069a824d92fb8a447a2b96..69e9776ff6dc9c5ad7ef33ff706eed944a564ecf 100644 --- a/interfaces/kits/napi/ans/src/get_active.cpp +++ b/interfaces/kits/napi/ans/src/get_active.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +35,7 @@ void AsyncCompleteCallbackGetAllActiveNotifications(napi_env env, napi_status st return; } - auto asynccallbackinfo = (AsyncCallbackInfoActive *)data; + auto asynccallbackinfo = static_cast(data); napi_value result = nullptr; if (asynccallbackinfo->info.errorCode != ERR_OK) { result = Common::NapiGetNull(env); @@ -104,7 +104,7 @@ napi_value GetAllActiveNotifications(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("GetAllActiveNotifications napi_create_async_work start"); - auto asynccallbackinfo = (AsyncCallbackInfoActive *)data; + auto asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::GetAllActiveNotifications(asynccallbackinfo->notifications); @@ -131,7 +131,7 @@ void AsyncCompleteCallbackGetActiveNotifications(napi_env env, napi_status statu return; } - auto asynccallbackinfo = (AsyncCallbackInfoActive *)data; + auto asynccallbackinfo = static_cast(data); napi_value result = nullptr; if (asynccallbackinfo->info.errorCode != ERR_OK) { result = Common::NapiGetNull(env); @@ -199,7 +199,7 @@ napi_value GetActiveNotifications(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("GetActiveNotifications napi_create_async_work start"); - auto asynccallbackinfo = (AsyncCallbackInfoActive *)data; + auto asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::GetActiveNotifications(asynccallbackinfo->requests); @@ -226,7 +226,7 @@ void AsyncCompleteCallbackGetActiveNotificationCount(napi_env env, napi_status s return; } - auto asynccallbackinfo = (AsyncCallbackInfoActive *)data; + auto asynccallbackinfo = static_cast(data); napi_value result = nullptr; if (asynccallbackinfo->info.errorCode != ERR_OK) { result = Common::NapiGetNull(env); @@ -273,7 +273,7 @@ napi_value GetActiveNotificationCount(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("GetActiveNotificationCount napi_create_async_work start"); - auto asynccallbackinfo = (AsyncCallbackInfoActive *)data; + auto asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::GetActiveNotificationNums(asynccallbackinfo->num); ANS_LOGI("GetActiveNotificationCount count = %{public}d", asynccallbackinfo->num); diff --git a/interfaces/kits/napi/ans/src/publish.cpp b/interfaces/kits/napi/ans/src/publish.cpp index 2c4b9609586b84e596b647a939d3841b8011797e..2cd55c3184c5518361aec1472e93c4ef70966d36 100644 --- a/interfaces/kits/napi/ans/src/publish.cpp +++ b/interfaces/kits/napi/ans/src/publish.cpp @@ -125,7 +125,7 @@ napi_value Publish(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("Publish napi_create_async_work start"); - AsyncCallbackInfoPublish *asynccallbackinfo = (AsyncCallbackInfoPublish *)data; + AsyncCallbackInfoPublish *asynccallbackinfo = static_cast(data); ANS_LOGI("Publish napi_create_async_work start notificationId = %{public}d, contentType = " "%{public}d", asynccallbackinfo->request.GetNotificationId(), @@ -136,7 +136,7 @@ napi_value Publish(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("Publish napi_create_async_work complete start"); - AsyncCallbackInfoPublish *asynccallbackinfo = (AsyncCallbackInfoPublish *)data; + AsyncCallbackInfoPublish *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { diff --git a/interfaces/kits/napi/ans/src/reminder/publish.cpp b/interfaces/kits/napi/ans/src/reminder/publish.cpp index e49b9678637c17c34b1e29553bb41bf7f3b8f0ea..a64e2bab14d005cfc23e1e52edf872239e876073 100644 --- a/interfaces/kits/napi/ans/src/reminder/publish.cpp +++ b/interfaces/kits/napi/ans/src/reminder/publish.cpp @@ -545,14 +545,14 @@ napi_value GetValidReminders(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANSR_LOGI("GetValid reminders napi_create_async_work start"); - AsyncCallbackInfo *asynccallbackinfo = (AsyncCallbackInfo *)data; + AsyncCallbackInfo *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { asynccallbackinfo->info.errorCode = ReminderHelper::GetValidReminders( asynccallbackinfo->validReminders); } }, [](napi_env env, napi_status status, void *data) { - AsyncCallbackInfo *asynccallbackinfo = (AsyncCallbackInfo *)data; + AsyncCallbackInfo *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { if (asynccallbackinfo->info.errorCode != ERR_OK) { @@ -611,7 +611,7 @@ napi_value PublishReminder(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANSR_LOGI("Publish napi_create_async_work start"); - AsyncCallbackInfo *asynccallbackinfo = (AsyncCallbackInfo *)data; + AsyncCallbackInfo *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { asynccallbackinfo->info.errorCode = ReminderHelper::PublishReminder(*(asynccallbackinfo->reminder)); ANSR_LOGD("Return reminderId=%{public}d", asynccallbackinfo->reminder->GetReminderId()); @@ -619,7 +619,7 @@ napi_value PublishReminder(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANSR_LOGI("Publish napi_create_async_work complete start"); - AsyncCallbackInfo *asynccallbackinfo = (AsyncCallbackInfo *)data; + AsyncCallbackInfo *asynccallbackinfo = static_cast(data); // reminderId if (asynccallbackinfo) { diff --git a/interfaces/kits/napi/ans/src/remove.cpp b/interfaces/kits/napi/ans/src/remove.cpp index 3206b87325843ffeaed0aa4937ba5b4226e4fcc8..7b9b4fb1a9648e33ce1e5bbb32bd03bc339c7d45 100644 --- a/interfaces/kits/napi/ans/src/remove.cpp +++ b/interfaces/kits/napi/ans/src/remove.cpp @@ -259,7 +259,7 @@ napi_value Remove(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("Remove napi_create_async_work start"); - AsyncCallbackInfoRemove *asynccallbackinfo = (AsyncCallbackInfoRemove *)data; + AsyncCallbackInfoRemove *asynccallbackinfo = static_cast(data); if (asynccallbackinfo->params.hashcode.has_value()) { asynccallbackinfo->info.errorCode = @@ -273,7 +273,7 @@ napi_value Remove(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("Remove napi_create_async_work end"); - AsyncCallbackInfoRemove *asynccallbackinfo = (AsyncCallbackInfoRemove *)data; + AsyncCallbackInfoRemove *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -321,7 +321,7 @@ napi_value RemoveAll(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("RemoveAll napi_create_async_work start"); - AsyncCallbackInfoRemove *asynccallbackinfo = (AsyncCallbackInfoRemove *)data; + AsyncCallbackInfoRemove *asynccallbackinfo = static_cast(data); if (asynccallbackinfo->params.bundleAndKeyInfo.has_value()) { auto &infos = asynccallbackinfo->params.bundleAndKeyInfo.value(); @@ -336,7 +336,7 @@ napi_value RemoveAll(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("RemoveAll napi_create_async_work end"); - AsyncCallbackInfoRemove *asynccallbackinfo = (AsyncCallbackInfoRemove *)data; + AsyncCallbackInfoRemove *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -366,7 +366,7 @@ void AsyncCompleteCallbackRemoveGroupByBundle(napi_env env, napi_status status, ANS_LOGE("Invalid async callback data"); return; } - AsyncCallbackInfoRemoveGroupByBundle *asynccallbackinfo = (AsyncCallbackInfoRemoveGroupByBundle *)data; + AsyncCallbackInfoRemoveGroupByBundle *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -403,7 +403,7 @@ napi_value RemoveGroupByBundle(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("RemoveGroupByBundle napi_create_async_work start"); - AsyncCallbackInfoRemoveGroupByBundle *asynccallbackinfo = (AsyncCallbackInfoRemoveGroupByBundle *)data; + AsyncCallbackInfoRemoveGroupByBundle *asynccallbackinfo = static_cast(data); ANS_LOGI("option.bundle = %{public}s, option.uid = %{public}d, groupName = %{public}s", asynccallbackinfo->params.option.GetBundleName().c_str(), asynccallbackinfo->params.option.GetUid(), diff --git a/interfaces/kits/napi/ans/src/slot.cpp b/interfaces/kits/napi/ans/src/slot.cpp index ca4ac4f20299d8e6fc863a0383d3cce7a8bbc8a1..b8f6b242e2d760d3e7b319989602d8b2eefbed1f 100644 --- a/interfaces/kits/napi/ans/src/slot.cpp +++ b/interfaces/kits/napi/ans/src/slot.cpp @@ -404,7 +404,7 @@ napi_value AddSlot(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("AddSlot napi_create_async_work start"); - auto asynccallbackinfo = (AsyncCallbackInfoAddSlot *)data; + auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo->isAddSlotByType) { asynccallbackinfo->info.errorCode = NotificationHelper::AddSlotByType(asynccallbackinfo->inType); } else { @@ -413,7 +413,7 @@ napi_value AddSlot(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("AddSlot napi_create_async_work end"); - auto asynccallbackinfo = (AsyncCallbackInfoAddSlot *)data; + auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -466,7 +466,7 @@ napi_value AddSlots(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("AddSlots napi_create_async_work end"); - auto asynccallbackinfo = (AsyncCallbackInfoAddSlots *)data; + auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -514,14 +514,14 @@ napi_value SetSlotByBundle(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("SetSlotByBundle napi_create_async_work start"); - auto asynccallbackinfo = (AsyncCallbackInfoSetSlotByBundle *)data; + auto asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::UpdateNotificationSlots( asynccallbackinfo->params.option, asynccallbackinfo->params.slots); }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("SetSlotByBundle napi_create_async_work end"); - auto asynccallbackinfo = (AsyncCallbackInfoSetSlotByBundle *)data; + auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { @@ -554,7 +554,7 @@ void AsyncCompleteCallbackGetSlot(napi_env env, napi_status status, void *data) return; } - auto asynccallbackinfo = (AsyncCallbackInfoGetSlot *)data; + auto asynccallbackinfo = static_cast(data); if (!asynccallbackinfo) { ANS_LOGE("asynccallbackinfo is nullptr"); return; @@ -605,7 +605,7 @@ napi_value GetSlot(napi_env env, napi_callback_info info) resourceName, [](napi_env env, void *data) { ANS_LOGI("GetSlot napi_create_async_work start"); - auto asynccallbackinfo = (AsyncCallbackInfoGetSlot *)data; + auto asynccallbackinfo = static_cast(data); asynccallbackinfo->info.errorCode = NotificationHelper::GetNotificationSlot(asynccallbackinfo->outType, asynccallbackinfo->slot); @@ -655,7 +655,7 @@ napi_value GetSlotNumByBundle(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("GetSlotNumByBundle napi_create_async_work end"); - auto asynccallbackinfo = (AsyncCallbackInfoGetSlotNumByBundle *)data; + auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { napi_value result = nullptr; napi_create_int32(env, asynccallbackinfo->num, &result); diff --git a/interfaces/kits/napi/ans/src/unsubscribe.cpp b/interfaces/kits/napi/ans/src/unsubscribe.cpp index 0d46462d7d1327d1018f64244219a40b9679fd98..0ba592149706e507b5cb76e40ac5a162f87e05a0 100644 --- a/interfaces/kits/napi/ans/src/unsubscribe.cpp +++ b/interfaces/kits/napi/ans/src/unsubscribe.cpp @@ -105,7 +105,7 @@ napi_value Unsubscribe(napi_env env, napi_callback_info info) }, [](napi_env env, napi_status status, void *data) { ANS_LOGI("Unsubscribe napi_create_async_work end"); - AsyncCallbackInfoUnsubscribe *asynccallbackinfo = (AsyncCallbackInfoUnsubscribe *)data; + AsyncCallbackInfoUnsubscribe *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); if (asynccallbackinfo->info.callback != nullptr) { diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 1858504086865fb1b10172d3b626e413f897abbf..5da610cf0cdca10df48936d82fdd94f910dd83fe 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -173,19 +173,19 @@ inline ErrCode CheckPictureSize(const sptr &request) std::static_pointer_cast(content->GetNotificationContent()); if (pictureContent != nullptr) { auto picture = pictureContent->GetBigPicture(); - if (picture != nullptr && (uint32_t)picture->GetByteCount() > MAX_PICTURE_SIZE) { + if (picture != nullptr && static_cast(picture->GetByteCount()) > MAX_PICTURE_SIZE) { result = ERR_ANS_PICTURE_OVER_SIZE; } } } auto littleIcon = request->GetLittleIcon(); - if (littleIcon != nullptr && (uint32_t)littleIcon->GetByteCount() > MAX_ICON_SIZE) { + if (littleIcon != nullptr && static_cast(littleIcon->GetByteCount()) > MAX_ICON_SIZE) { result = ERR_ANS_ICON_OVER_SIZE; } auto bigIcon = request->GetBigIcon(); - if (bigIcon != nullptr && (uint32_t)bigIcon->GetByteCount() > MAX_ICON_SIZE) { + if (bigIcon != nullptr && static_cast(bigIcon->GetByteCount()) > MAX_ICON_SIZE) { result = ERR_ANS_ICON_OVER_SIZE; } diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index 6b275d9cd090d338a6e483c4290ce5d4339119ad..6f693fc3a628fb1e732233fafefe10a2f1787054 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -333,9 +333,9 @@ void NotificationSubscriberManager::NotifyCanceledInner( auto BundleNames = notification->GetBundleName(); auto iter = std::find(record->bundleList_.begin(), record->bundleList_.end(), BundleNames); if (!record->subscribedAll == (iter != record->bundleList_.end()) && - (record->userId == sendUserId || - record->userId == SUBSCRIBE_USER_ALL || - record->userId == recvUserId || + ((record->userId == sendUserId) || + (record->userId == SUBSCRIBE_USER_ALL) || + (record->userId == recvUserId) || IsSystemUser(record->userId) || // Delete this, When the systemui subscribe carry the user ID. IsSystemUser(sendUserId))) { record->subscriber->OnCanceled(notification, notificationMap, deleteReason); diff --git a/services/ans/src/reminder_data_manager.cpp b/services/ans/src/reminder_data_manager.cpp index 538c554a5e4fa8c89e46557c871cb75ef9b4d69a..36571960d82b42537086a69025bb4f39ef31cc60 100644 --- a/services/ans/src/reminder_data_manager.cpp +++ b/services/ans/src/reminder_data_manager.cpp @@ -673,7 +673,7 @@ void ReminderDataManager::StopAlertingReminder(const sptr &remi ANSR_LOGE("StopAlertingReminder illegal."); return; } - if (alertingReminderId_ == -1 || reminder->GetReminderId() != alertingReminderId_) { + if ((alertingReminderId_ == -1) || (reminder->GetReminderId() != alertingReminderId_)) { ANSR_LOGE("StopAlertingReminder is illegal."); return; } @@ -991,7 +991,7 @@ void ReminderDataManager::StopSoundAndVibration(const sptr &rem ANSR_LOGE("Stop sound and vibration failed as reminder is null."); return; } - if (alertingReminderId_ == -1 || (reminder->GetReminderId() != alertingReminderId_)) { + if ((alertingReminderId_ == -1) || (reminder->GetReminderId() != alertingReminderId_)) { ANSR_LOGE("Stop sound and vibration failed as alertingReminder is illegal, alertingReminderId_=" \ "%{public}d, tarReminderId=%{public}d", alertingReminderId_, reminder->GetReminderId()); return;