1 /* 2 * Copyright (c) 2021-2023 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_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CONFIG_FILE_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CONFIG_FILE_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 #include <singleton.h> 23 24 #ifdef CONFIG_POLICY_ENABLE 25 #include "config_policy_utils.h" 26 #endif 27 #include "nlohmann/json.hpp" 28 #include "notification_bundle_option.h" 29 #include "notification_constant.h" 30 #include "notification_flags.h" 31 #include "advanced_notification_flow_control_service.h" 32 33 namespace OHOS { 34 namespace Notification { 35 class NotificationConfigParse : public DelayedSingleton<NotificationConfigParse> { 36 public: 37 NotificationConfigParse(); 38 ~NotificationConfigParse() = default; 39 40 bool GetConfigJson(const std::string &keyCheck, nlohmann::json &configJson) const; 41 bool GetCurrentSlotReminder( 42 std::map<NotificationConstant::SlotType, std::shared_ptr<NotificationFlags>> ¤tSlotReminder) const; 43 uint32_t GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType) const; 44 uint32_t GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType, 45 const sptr<NotificationBundleOption> &bundleOption) const; 46 void GetFlowCtrlConfigFromCCM(FlowControlThreshold &threshold); 47 48 private: 49 std::map<NotificationConstant::SlotType, uint32_t> defaultCurrentSlotReminder_; 50 std::vector<nlohmann::json> notificationConfigJsons_; 51 52 public: 53 constexpr static const char* CFG_KEY_NOTIFICATION_SERVICE = "notificationService"; 54 constexpr static const char* CFG_KEY_SLOT_TYPE_REMINDER = "slotTypeReminder"; 55 constexpr static const char* CFG_KEY_NAME = "name"; 56 constexpr static const char* CFG_KEY_REMINDER_FLAGS = "reminderFlags"; 57 constexpr static const char* APP_PRIVILEGES = "appPrivileges"; 58 constexpr static const char* CFG_KEY_MAX_CREATE_NUM_PERSECOND = "MaxCreateNumPerSecond"; 59 constexpr static const char* CFG_KEY_MAX_UPDATE_NUM_PERSECOND = "MaxUpdateNumPerSecond"; 60 constexpr static const char* CFG_KEY_MAX_CREATE_NUM_PERSECOND_PERAPP = "MaxCreateNumPerSecondPerApp"; 61 constexpr static const char* CFG_KEY_MAX_UPDATE_NUM_PERSECOND_PERAPP = "MaxUpdateNumPerSecondPerApp"; 62 #ifdef CONFIG_POLICY_ENABLE 63 constexpr static const char* NOTIFICAITON_CONFIG_FILE = "etc/notification/notification_config.json"; 64 # else 65 constexpr static const char* NOTIFICAITON_CONFIG_FILE = "system/etc/notification/notification_config.json"; 66 #endif 67 }; 68 } // namespace Notification 69 } // namespace OHOS 70 71 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_CONFIG_FILE_H 72