1f16e0440Sopenharmony_ci/*
2f16e0440Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3f16e0440Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4f16e0440Sopenharmony_ci * you may not use this file except in compliance with the License.
5f16e0440Sopenharmony_ci * You may obtain a copy of the License at
6f16e0440Sopenharmony_ci *
7f16e0440Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8f16e0440Sopenharmony_ci *
9f16e0440Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10f16e0440Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11f16e0440Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12f16e0440Sopenharmony_ci * See the License for the specific language governing permissions and
13f16e0440Sopenharmony_ci * limitations under the License.
14f16e0440Sopenharmony_ci */
15f16e0440Sopenharmony_ci
16f16e0440Sopenharmony_ci#ifndef BATTERY_SERVICE_SUBSCRIBER_H
17f16e0440Sopenharmony_ci#define BATTERY_SERVICE_SUBSCRIBER_H
18f16e0440Sopenharmony_ci
19f16e0440Sopenharmony_ci#include <cstdint>
20f16e0440Sopenharmony_ci
21f16e0440Sopenharmony_ci#include "want.h"
22f16e0440Sopenharmony_ci
23f16e0440Sopenharmony_ci#include "battery_info.h"
24f16e0440Sopenharmony_ci
25f16e0440Sopenharmony_cinamespace OHOS {
26f16e0440Sopenharmony_cinamespace PowerMgr {
27f16e0440Sopenharmony_ciclass BatteryNotify {
28f16e0440Sopenharmony_cipublic:
29f16e0440Sopenharmony_ci    BatteryNotify();
30f16e0440Sopenharmony_ci    ~BatteryNotify() = default;
31f16e0440Sopenharmony_ci    int32_t PublishEvents(BatteryInfo& info);
32f16e0440Sopenharmony_ci    bool PublishCustomEvent(const BatteryInfo& info, const std::string& commonEventName) const;
33f16e0440Sopenharmony_ci
34f16e0440Sopenharmony_ciprivate:
35f16e0440Sopenharmony_ci    void HandleUevent(BatteryInfo& info);
36f16e0440Sopenharmony_ci    bool PublishChangedEvent(const BatteryInfo& info);
37f16e0440Sopenharmony_ci    bool PublishChangedEventInner(const BatteryInfo& info) const;
38f16e0440Sopenharmony_ci    bool PublishLowEvent(const BatteryInfo& info) const;
39f16e0440Sopenharmony_ci    bool PublishOkayEvent(const BatteryInfo& info) const;
40f16e0440Sopenharmony_ci    void StartVibrator() const;
41f16e0440Sopenharmony_ci    bool PublishPowerConnectedEvent(const BatteryInfo& info) const;
42f16e0440Sopenharmony_ci    bool PublishPowerDisconnectedEvent(const BatteryInfo& info) const;
43f16e0440Sopenharmony_ci    bool PublishChargingEvent(const BatteryInfo& info) const;
44f16e0440Sopenharmony_ci    bool PublishDischargingEvent(const BatteryInfo& info) const;
45f16e0440Sopenharmony_ci    bool PublishChargeTypeChangedEvent(const BatteryInfo& info);
46f16e0440Sopenharmony_ci    bool IsCommonEventServiceAbilityExist() const;
47f16e0440Sopenharmony_ci
48f16e0440Sopenharmony_ci    int32_t lowCapacity_ = -1;
49f16e0440Sopenharmony_ci    ChargeType batteryInfoChargeType_ = ChargeType::NONE;
50f16e0440Sopenharmony_ci    int32_t lastCapacity_ = -1;
51f16e0440Sopenharmony_ci    int32_t lastPluggedType_ = -1;
52f16e0440Sopenharmony_ci    int32_t lastTemperature_ = -1;
53f16e0440Sopenharmony_ci    int32_t lastHealthState_ = -1;
54f16e0440Sopenharmony_ci};
55f16e0440Sopenharmony_ci} // namespace PowerMgr
56f16e0440Sopenharmony_ci} // namespace OHOS
57f16e0440Sopenharmony_ci#endif // BATTERY_SERVICE_SUBSCRIBER_H
58