From f6c373d648b808376427451a027f4a997a316c5c Mon Sep 17 00:00:00 2001 From: dongqingran Date: Tue, 24 Dec 2024 22:39:05 +0800 Subject: [PATCH] refactor_slot_fix_none_systemapp Signed-off-by: dongqingran --- services/ans/include/slot_manager/slot_manager.h | 3 +-- services/ans/src/slot_manager/AddSlots.cpp | 14 +++++++------- .../src/slot_manager/setNotificationEnableSlot.cpp | 13 ++++++------- services/ans/src/slot_manager/slot_manager.cpp | 5 ++++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/services/ans/include/slot_manager/slot_manager.h b/services/ans/include/slot_manager/slot_manager.h index bd82903bc..9a245d9bf 100644 --- a/services/ans/include/slot_manager/slot_manager.h +++ b/services/ans/include/slot_manager/slot_manager.h @@ -43,13 +43,12 @@ public: int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply); private: ErrCode AddSlots(MessageParcel &data, MessageParcel &reply); - ErrCode AddSlotsSyncQue(const std::vector> &slots, sptr bundleOption); + ErrCode AddSlotsSyncQue(const std::vector> &slots); ErrCode AddSlotsInner(const std::vector> &slots, sptr bundleOption); ErrCode SetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply); ErrCode SetEnabledForBundleSlotSyncQue( const sptr &bundleOption, - const sptr &bundle, const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl); ErrCode SetEnabledForBundleSlotInner( const sptr &bundleOption, diff --git a/services/ans/src/slot_manager/AddSlots.cpp b/services/ans/src/slot_manager/AddSlots.cpp index 340ffc901..3ea5b6f52 100644 --- a/services/ans/src/slot_manager/AddSlots.cpp +++ b/services/ans/src/slot_manager/AddSlots.cpp @@ -48,12 +48,7 @@ ErrCode SlotManager::AddSlots(MessageParcel &data, MessageParcel &reply) return ERR_ANS_PARCELABLE_FAILED; } - sptr bundleOption = AdvancedNotificationService::GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = AddSlotsSyncQue(slots, bundleOption); + ErrCode result = AddSlotsSyncQue(slots); if (!reply.WriteInt32(result)) { ANS_LOGE("[HandleAddSlots] fail: write result failed, ErrCode=%{public}d", result); @@ -62,8 +57,13 @@ ErrCode SlotManager::AddSlots(MessageParcel &data, MessageParcel &reply) return ERR_OK; } -ErrCode SlotManager::AddSlotsSyncQue(const std::vector> &slots, sptr bundleOption) +ErrCode SlotManager::AddSlotsSyncQue(const std::vector> &slots) { + sptr bundleOption = AdvancedNotificationService::GenerateBundleOption(); + if (bundleOption == nullptr) { + return ERR_ANS_INVALID_BUNDLE; + } + auto excuteQueue = AdvancedNotificationService::GetInstance()->GetNotificationSvrQueue(); if (excuteQueue == nullptr) { ANS_LOGE("Serial queue is invalid."); diff --git a/services/ans/src/slot_manager/setNotificationEnableSlot.cpp b/services/ans/src/slot_manager/setNotificationEnableSlot.cpp index bf24c3870..1632f3cb8 100644 --- a/services/ans/src/slot_manager/setNotificationEnableSlot.cpp +++ b/services/ans/src/slot_manager/setNotificationEnableSlot.cpp @@ -70,11 +70,6 @@ ErrCode SlotManager::SetEnabledForBundleSlot(MessageParcel &data, MessageParcel return ERR_ANS_PARCELABLE_FAILED; } - sptr bundle = AdvancedNotificationService::GenerateValidBundleOption(bundleOption); - if (bundle == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - ANS_LOGD("slotType: %{public}d, enabled: %{public}d, isForceControl: %{public}d", slotType, enabled, isForceControl); HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_5, EventBranchId::BRANCH_4); @@ -82,7 +77,7 @@ ErrCode SlotManager::SetEnabledForBundleSlot(MessageParcel &data, MessageParcel " slotType: " + std::to_string(static_cast(slotType)) + " enabled: " +std::to_string(enabled) + "isForceControl" + std::to_string(isForceControl)); - ErrCode result = SetEnabledForBundleSlotSyncQue(bundleOption, bundle, slotType, enabled, isForceControl); + ErrCode result = SetEnabledForBundleSlotSyncQue(bundleOption, slotType, enabled, isForceControl); if (!reply.WriteInt32(result)) { ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result); @@ -99,9 +94,13 @@ ErrCode SlotManager::SetEnabledForBundleSlot(MessageParcel &data, MessageParcel ErrCode SlotManager::SetEnabledForBundleSlotSyncQue( const sptr &bundleOption, - const sptr &bundle, const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) { + sptr bundle = AdvancedNotificationService::GenerateValidBundleOption(bundleOption); + if (bundle == nullptr) { + return ERR_ANS_INVALID_BUNDLE; + } + auto excuteQueue = AdvancedNotificationService::GetInstance()->GetNotificationSvrQueue(); if (excuteQueue == nullptr) { ANS_LOGE("Serial queue is invalid."); diff --git a/services/ans/src/slot_manager/slot_manager.cpp b/services/ans/src/slot_manager/slot_manager.cpp index c6abd0174..8c025b163 100644 --- a/services/ans/src/slot_manager/slot_manager.cpp +++ b/services/ans/src/slot_manager/slot_manager.cpp @@ -45,7 +45,10 @@ int32_t SlotManager::OnRemoteRequest(uint32_t code, MessageParcel &data, Message { ErrCode result = CheckInterfacePermission(code); if (result != ERR_OK) { - return result; + if (!reply.WriteInt32(result)) { + return ERR_ANS_PARCELABLE_FAILED; + } + return ERR_OK; } switch (code) { -- Gitee