• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_ANS_SERVICES_ANS_INCLUDE_SLOT_MANAGER_H
17 #define BASE_NOTIFICATION_ANS_SERVICES_ANS_INCLUDE_SLOT_MANAGER_H
18 
19 #include <functional>
20 #include <map>
21 
22 #include "ans_manager_interface.h"
23 #include "ans_subscriber_local_live_view_interface.h"
24 #include "base_manager.h"
25 #include "distributed_notification_service_ipc_interface_code.h"
26 #include "iremote_stub.h"
27 #include "singleton.h"
28 
29 namespace OHOS {
30 namespace Notification {
31 class SlotManager final : protected BaseManager {
32 public:
33     DECLARE_DELAYED_SINGLETON(SlotManager);
34 public:
35     static const uint32_t DEFAULT_SLOT_FLAGS = 59; // 0b111011
36     /**
37      * @brief Handle remote request.
38      *
39      * @param data Indicates the input parcel.
40      * @param reply Indicates the output parcel.
41      * @param option Indicates the message option.
42      * @return Returns ERR_OK on success, others on failure.
43      */
44     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
45 private:
46     ErrCode AddSlots(MessageParcel &data, MessageParcel &reply);
47     ErrCode AddSlotsSyncQue(const std::vector<sptr<NotificationSlot>> &slots);
48     ErrCode AddSlotsInner(
49         const std::vector<sptr<NotificationSlot>> &slots, sptr<NotificationBundleOption> bundleOption);
50 
51     ErrCode SetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply);
52     ErrCode SetEnabledForBundleSlotSyncQue(
53         const sptr<NotificationBundleOption> &bundleOption,
54         const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl);
55     ErrCode SetEnabledForBundleSlotInner(
56         const sptr<NotificationBundleOption> &bundleOption,
57         const sptr<NotificationBundleOption> &bundle,
58         const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl);
59 private:
60     int32_t CheckInterfacePermission(uint32_t code);
61     void GenerateSlotReminderMode(const sptr<NotificationSlot> &slot, const sptr<NotificationBundleOption> &bundle,
62         bool isSpecifiedSlot = false, uint32_t defaultSlotFlags = DEFAULT_SLOT_FLAGS);
63     void SendEnableNotificationSlotHiSysEvent(
64         const sptr<NotificationBundleOption> &bundleOption, const NotificationConstant::SlotType &slotType,
65         bool enabled, ErrCode errCode);
66     ErrCode AddSlotThenPublishEvent(
67         const sptr<NotificationSlot> &slot,
68         const sptr<NotificationBundleOption> &bundle,
69         bool enabled, bool isForceControl);
70 };
71 }  // namespace Notification
72 }  // namespace OHOS
73 
74 #endif  // BASE_NOTIFICATION_ANS_SERVICES_ANS_INCLUDE_SLOT_MANAGER_H
75