diff --git a/services/ans/include/slot_manager/slot_manager.h b/services/ans/include/slot_manager/slot_manager.h index bd82903bc3ca5d01f9f1e62babbdd02551536749..9a245d9bfdfda6f268eda97079c3503d13c6f1ad 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 340ffc90161c7bf086c83d4d09fd21292c69c9d1..3ea5b6f522a32eb2ddd924106097f032d8cf5097 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 bf24c387068797ef3647c4708d1489871241e535..1632f3cb843a03f7c8e81208b270df7877d1a189 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 c6abd0174049dc38368975a6d25d21dc1691a920..8c025b163f3e73b8f54ee0b77dd2e90190c9c3f6 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) {