1 /* 2 * Copyright (C) 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 NET_STATS_NOTIFICATION_H 17 #define NET_STATS_NOTIFICATION_H 18 19 #include <mutex> 20 #include <string> 21 22 #include "image_source.h" 23 #include "pixel_map.h" 24 #include "notification_helper.h" 25 #include "number_format.h" 26 27 static const int32_t COMM_NETSYS_NATIVE_SYS_ABILITY_ID = 1158; 28 29 typedef void (*NetMgrStatsLimitNtfCallback)(int notificationId); 30 31 enum NetMgrStatsLimitNotificationId : int { 32 NETMGR_STATS_LIMIT_DAY = 115800, 33 NETMGR_STATS_LIMIT_MONTH = 115801, 34 NETMGR_STATS_ALERT_MONTH = 115802, 35 }; 36 namespace OHOS { 37 namespace NetManagerStandard { 38 class NetMgrNetStatsLimitNotification { 39 40 public: 41 static NetMgrNetStatsLimitNotification &GetInstance(void); 42 43 void PublishNetStatsLimitNotification(int notificationId, bool isDaulCard); 44 void RegNotificationCallback(NetMgrStatsLimitNtfCallback callback); 45 46 private: 47 NetMgrNetStatsLimitNotification(); 48 ~NetMgrNetStatsLimitNotification(); 49 NetMgrNetStatsLimitNotification(const NetMgrNetStatsLimitNotification&) = delete; 50 NetMgrNetStatsLimitNotification &operator=(const NetMgrNetStatsLimitNotification&) = delete; 51 52 void GetPixelMap(); 53 void UpdateResourceMap(); 54 void ParseJSONFile(const std::string& filePath, std::map<std::string, std::string>& container); 55 std::unique_ptr<OHOS::Global::I18n::NumberFormat> GetNumberFormatter(); 56 57 std::string GetDayNotificationText(); 58 std::string GetMonthNotificationText(); 59 std::string GetMonthAlertText(); 60 std::string GetNotificationTile(std::string ¬ificationType); 61 void SetMonthWarningActionButton(Notification::NotificationRequest &request); 62 void SetDayWarningActionButton(Notification::NotificationRequest &request); 63 void SetNotificationWant(int notificationId, Notification::NotificationRequest &request); 64 bool SetTitleAndText(int notificationId, 65 std::shared_ptr<Notification::NotificationNormalContent> content, bool isDaulCard); 66 std::string GetTrafficNum(double traffic); 67 68 std::shared_ptr<Media::PixelMap> netmgrStatsLimitIconPixelMap_ {}; 69 std::map<std::string, std::string> resourceMap; 70 std::map<std::string, std::string> languageMap; 71 std::string localeBaseName; 72 std::mutex mutex_; 73 const int NETMGR_TRAFFIC_NTF_CONTROL_FLAG = 0; 74 }; 75 } // namespace NetManagerStandard 76 } // namespace OHOS 77 #endif // NETMGR_LIMIT_NOTIFICATION_H 78