• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 BATTERY_SERVICE_SUBSCRIBER_H
17 #define BATTERY_SERVICE_SUBSCRIBER_H
18 
19 #include <cstdint>
20 
21 #include "want.h"
22 
23 #include "battery_info.h"
24 
25 namespace OHOS {
26 namespace PowerMgr {
27 class BatteryNotify {
28 public:
29     BatteryNotify();
30     ~BatteryNotify() = default;
31     int32_t PublishEvents(const BatteryInfo& info);
32 
33 private:
34     bool PublishChangedEvent(const BatteryInfo& info) const;
35     bool PublishLowEvent(const BatteryInfo& info) const;
36     bool PublishOkayEvent(const BatteryInfo& info) const;
37     bool PublishPowerConnectedEvent(const BatteryInfo& info) const;
38     bool PublishPowerDisconnectedEvent(const BatteryInfo& info) const;
39     bool PublishChargingEvent(const BatteryInfo& info) const;
40     bool PublishDischargingEvent(const BatteryInfo& info) const;
41     bool PublishChargeTypeChangedEvent(const BatteryInfo& info);
42     bool IsCommonEventServiceAbilityExist() const;
43 
44     int32_t lowCapacity_ = -1;
45     ChargeType batteryInfoChargeType_ = ChargeType::NONE;
46 };
47 } // namespace PowerMgr
48 } // namespace OHOS
49 #endif // BATTERY_SERVICE_SUBSCRIBER_H
50