1/* 2 * Copyright (c) 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 OHOS_HDI_BATTERY_V2_0_TYPES_H 17#define OHOS_HDI_BATTERY_V2_0_TYPES_H 18 19#include <cstdbool> 20#include <cstdint> 21#include <string> 22 23#ifndef HDI_BUFF_MAX_SIZE 24#define HDI_BUFF_MAX_SIZE (1024 * 200) 25#endif 26 27#ifndef HDI_CHECK_VALUE_RETURN 28#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 29 if ((lv) compare (rv)) { \ 30 return ret; \ 31 } \ 32} while (false) 33#endif 34 35#ifndef HDI_CHECK_VALUE_RET_GOTO 36#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 37 if ((lv) compare (rv)) { \ 38 ret = value; \ 39 goto table; \ 40 } \ 41} while (false) 42#endif 43 44namespace OHOS { 45class MessageParcel; 46} 47 48namespace OHOS { 49namespace HDI { 50namespace Battery { 51namespace V2_0 { 52 53using namespace OHOS; 54 55enum BatteryHealthState : int32_t { 56 BATTERY_HEALTH_UNKNOWN = 0, 57 BATTERY_HEALTH_GOOD, 58 BATTERY_HEALTH_OVERHEAT, 59 BATTERY_HEALTH_OVERVOLTAGE, 60 BATTERY_HEALTH_COLD, 61 BATTERY_HEALTH_DEAD, 62 BATTERY_HEALTH_RESERVED, 63}; 64 65enum BatteryChargeState : int32_t { 66 CHARGE_STATE_NONE = 0, 67 CHARGE_STATE_ENABLE, 68 CHARGE_STATE_DISABLE, 69 CHARGE_STATE_FULL, 70 CHARGE_STATE_RESERVED, 71}; 72 73enum BatteryPluggedType : int32_t { 74 PLUGGED_TYPE_NONE = 0, 75 PLUGGED_TYPE_AC, 76 PLUGGED_TYPE_USB, 77 PLUGGED_TYPE_WIRELESS, 78 PLUGGED_TYPE_BUTT, 79}; 80 81struct BatteryInfo { 82 int32_t capacity; 83 int32_t voltage; 84 int32_t temperature; 85 int32_t healthState; 86 int32_t pluggedType; 87 int32_t pluggedMaxCurrent; 88 int32_t pluggedMaxVoltage; 89 int32_t chargeState; 90 int32_t chargeCounter; 91 int32_t totalEnergy; 92 int32_t curAverage; 93 int32_t curNow; 94 int32_t remainEnergy; 95 int8_t present; 96 std::string technology; 97 std::string uevent; 98}; 99 100enum ChargingLimitType : int32_t { 101 TYPE_CURRENT = 0, 102 TYPE_VOLTAGE, 103}; 104 105struct ChargingLimit { 106 OHOS::HDI::Battery::V2_0::ChargingLimitType type; 107 std::string protocol; 108 int32_t value; 109}; 110 111enum ChargeType : int32_t { 112 CHARGE_TYPE_NONE = 0, 113 CHARGE_TYPE_WIRED_NORMAL, 114 CHARGE_TYPE_WIRED_QUICK, 115 CHARGE_TYPE_WIRED_SUPER_QUICK, 116 CHARGE_TYPE_WIRELESS_NORMAL, 117 CHARGE_TYPE_WIRELESS_QUICK, 118 CHARGE_TYPE_WIRELESS_SUPER_QUICK, 119}; 120 121bool BatteryInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Battery::V2_0::BatteryInfo& dataBlock); 122 123bool BatteryInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Battery::V2_0::BatteryInfo& dataBlock); 124 125bool ChargingLimitBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Battery::V2_0::ChargingLimit& dataBlock); 126 127bool ChargingLimitBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Battery::V2_0::ChargingLimit& dataBlock); 128 129 130} // V2_0 131} // Battery 132} // HDI 133} // OHOS 134 135#endif // OHOS_HDI_BATTERY_V2_0_TYPES_H 136 137