1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.hardware.health@1.0; 18 19/** 20 * Possible return values for optional HAL method(s) like 21 * IHealth::energyCounter() 22 */ 23enum Result : int32_t { 24 SUCCESS, 25 NOT_SUPPORTED, 26 UNKNOWN, 27}; 28 29/** 30 * Possible values for Battery Status. 31 * Note: These are currently in sync with BatteryManager and must not 32 * be extended / altered. 33 */ 34@export(name="", value_prefix="BATTERY_STATUS_") 35enum BatteryStatus : int32_t { 36 UNKNOWN = 1, 37 CHARGING = 2, 38 DISCHARGING = 3, 39 /** 40 * Battery is *not* charging - special case when charger is present 41 * but battery isn't charging 42 */ 43 NOT_CHARGING = 4, 44 FULL = 5, 45}; 46 47/** 48 * Possible values for Battery Health. 49 * Note: These are currently in sync with BatteryManager and must not 50 * be extended / altered. 51 */ 52@export(name="", value_prefix="BATTERY_HEALTH_") 53enum BatteryHealth : int32_t { 54 UNKNOWN = 1, 55 GOOD = 2, 56 OVERHEAT = 3, 57 DEAD = 4, 58 OVER_VOLTAGE = 5, 59 /** 60 * Battery experienced an unknown/unspecifid failure. 61 */ 62 UNSPECIFIED_FAILURE = 6, 63 COLD = 7, 64}; 65 66struct HealthConfig { 67 68 /** 69 * periodicChoresIntervalFast is used while the device is not in 70 * suspend, or in suspend and connected to a charger (to watch for battery 71 * overheat due to charging) 72 */ 73 int32_t periodicChoresIntervalFast; 74 75 /** 76 * periodicChoresIntervalSlow is used when the device is in suspend and 77 * not connected to a charger (to watch for a battery drained to zero 78 * remaining capacity). 79 */ 80 int32_t periodicChoresIntervalSlow; 81 82 /** 83 * power_supply sysfs attribute file paths. Set these to specific paths 84 * to use for the associated battery parameters. Clients must search 85 * for appropriate power_supply attribute files to use, for any paths 86 * left empty after the HAL is initialized. 87 */ 88 89 /** 90 * batteryStatusPath - file path to read battery charging status. 91 * (POWER_SUPPLY_PROP_STATUS) 92 */ 93 string batteryStatusPath; 94 95 96 /** 97 * batteryHealthPath - file path to read battery health. 98 * (POWER_SUPPLY_PROP_HEALTH) 99 */ 100 string batteryHealthPath; 101 102 /** 103 * batteryPresentPath - file path to read battery present status. 104 * (POWER_SUPPLY_PROP_PRESENT) 105 */ 106 string batteryPresentPath; 107 108 109 /** 110 * batteryCapacityPath - file path to read remaining battery capacity. 111 * (POWER_SUPPLY_PROP_CAPACITY) 112 */ 113 string batteryCapacityPath; 114 115 /** 116 * batteryVoltagePath - file path to read battery voltage. 117 * (POWER_SUPPLY_PROP_VOLTAGE_NOW) 118 */ 119 string batteryVoltagePath; 120 121 /** 122 * batteryTemperaturePath - file path to read battery temperature in tenths 123 * of degree celcius. (POWER_SUPPLY_PROP_TEMP) 124 */ 125 string batteryTemperaturePath; 126 127 /** 128 * batteryTechnologyPath - file path to read battery technology. 129 * (POWER_SUPPLY_PROP_TECHNOLOGY) 130 */ 131 string batteryTechnologyPath; 132 133 /** 134 * batteryCurrentNowPath - file path to read battery instantaneous current. 135 * (POWER_SUPPLY_PROP_CURRENT_NOW) 136 */ 137 string batteryCurrentNowPath; 138 139 /** 140 * batteryCurrentAvgPath - file path to read battery average current. 141 * (POWER_SUPPLY_PROP_CURRENT_AVG) 142 */ 143 string batteryCurrentAvgPath; 144 145 /** 146 * batteryChargeCounterPath - file path to read battery accumulated charge. 147 * (POWER_SUPPLY_PROP_CHARGE_COUNTER) 148 */ 149 string batteryChargeCounterPath; 150 151 /** 152 * batteryFullChargerPath - file path to read battery charge value when it 153 * is considered to be full. (POWER_SUPPLY_PROP_CHARGE_FULL) 154 */ 155 string batteryFullChargePath; 156 157 /** 158 * batteryCycleCountPath - file path to read battery charge cycle count. 159 * (POWER_SUPPLY_PROP_CYCLE_COUNT) 160 */ 161 string batteryCycleCountPath; 162}; 163 164/** 165 * The parameter to healthd mainloop update calls 166 */ 167struct HealthInfo { 168 /** AC charger state - 'true' if online */ 169 bool chargerAcOnline; 170 171 /** USB charger state - 'true' if online */ 172 bool chargerUsbOnline; 173 174 /** Wireless charger state - 'true' if online */ 175 bool chargerWirelessOnline; 176 177 /** Maximum charging current supported by charger in uA */ 178 int32_t maxChargingCurrent; 179 180 /** Maximum charging voltage supported by charger in uV */ 181 int32_t maxChargingVoltage; 182 183 BatteryStatus batteryStatus; 184 185 BatteryHealth batteryHealth; 186 187 /** 'true' if battery is present */ 188 bool batteryPresent; 189 190 /** Remaining battery capacity in percent */ 191 int32_t batteryLevel; 192 193 /** 194 * Instantaneous battery voltage in millivolts (mV). 195 * 196 * Historically, the unit of this field is microvolts (uV), but all 197 * clients and implementations uses millivolts in practice, making it 198 * the de-facto standard. 199 */ 200 int32_t batteryVoltage; 201 202 /** Instantaneous battery temperature in tenths of degree celcius */ 203 int32_t batteryTemperature; 204 205 /** Instantaneous battery current in uA */ 206 int32_t batteryCurrent; 207 208 /** Battery charge cycle count */ 209 int32_t batteryCycleCount; 210 211 /** Battery charge value when it is considered to be "full" in uA-h */ 212 int32_t batteryFullCharge; 213 214 /** Instantaneous battery capacity in uA-h */ 215 int32_t batteryChargeCounter; 216 217 /** Battery technology, e.g. "Li-ion, Li-Poly" etc. */ 218 string batteryTechnology; 219}; 220