1 /* 2 * Copyright (c) 2021-2022 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_SERVICE_SUBSCRIBER_H 17 #define BATTERY_SERVICE_SUBSCRIBER_H 18 19 #include <cstdint> 20 #include "common_event_data.h" 21 #include "common_event_manager.h" 22 #include "common_event_support.h" 23 #include "ipc_object_stub.h" 24 #include "battery_config.h" 25 #include "battery_info.h" 26 27 namespace OHOS { 28 namespace PowerMgr { 29 class BatteryNotify { 30 public: 31 BatteryNotify(); 32 ~BatteryNotify() = default; 33 int32_t PublishEvents(const BatteryInfo& info); 34 35 private: 36 void ChangedEventDeprecated(OHOS::AAFwk::Want& want, const BatteryInfo& info) const; 37 bool PublishChangedEvent(const BatteryInfo& info) const; 38 bool PublishLowEvent(const BatteryInfo& info) const; 39 bool PublishOkayEvent(const BatteryInfo& info) const; 40 bool PublishPowerConnectedEvent(const BatteryInfo& info) const; 41 bool PublishPowerDisconnectedEvent(const BatteryInfo& info) const; 42 bool PublishChargingEvent(const BatteryInfo& info) const; 43 bool PublishDischargingEvent(const BatteryInfo& info) const; 44 bool IsCommonEventServiceAbilityExist() const; 45 46 int32_t lowCapacity_ = -1; 47 }; 48 } // namespace PowerMgr 49 } // namespace OHOS 50 #endif // BATTERY_SERVICE_SUBSCRIBER_H 51