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