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 BATTERY_NOTIFICATION_MANAGER_H 17 #define BATTERY_NOTIFICATION_MANAGER_H 18 19 #define API __attribute__((visibility("default"))) 20 21 #include <memory> 22 #include <string> 23 #include <unordered_map> 24 #include <mutex> 25 #include "battery_config.h" 26 #include "notification_center.h" 27 #include "notification_decorator.h" 28 29 namespace OHOS { 30 namespace PowerMgr { 31 class API NotificationManager { 32 public: GetInstance()33 static NotificationManager& GetInstance() 34 { 35 static NotificationManager notificationMgr; 36 return notificationMgr; 37 } 38 void HandleNotification(const std::string& popupName, uint32_t popupAction, 39 const std::unordered_map<std::string, BatteryConfig::NotificationConf>& nConfMap); 40 void CancleNotification(const std::string& popupName); 41 private: 42 NotificationManager() = default; 43 virtual ~NotificationManager() = default; 44 void PublishNotification(BatteryConfig::NotificationConf& nCfg); 45 std::shared_ptr<IBatteryNotification> CreateButtonStyle( 46 const std::shared_ptr<IBatteryNotification>& batteryNotification, 47 const std::pair<std::string, std::string>& nButton); 48 BatteryConfig::NotificationConf FillNotificationCfg(const BatteryConfig::NotificationConf& cfg); 49 std::mutex mapMutex_; 50 std::unordered_map<std::string, std::shared_ptr<IBatteryNotification>> notificationMap_; 51 }; 52 53 extern "C" API void HandleNotification(const std::string& name, int32_t action, 54 const std::unordered_map<std::string, BatteryConfig::NotificationConf>& nConfMap); 55 56 } // namespace PowerMgr 57 } // namespace OHOS 58 59 #endif // BATTERY_NOTIFICATION_MANAGER_H