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/** 17 * Obtains battery information of a device. 18 * 19 * <p>Battery information includes the remaining battery power, 20 * voltage, temperature, model, and charger type. 21 * 22 * @syscap SystemCapability.PowerManager.BatteryManager.Core 23 * @since 6 24 */ 25declare namespace batteryInfo { 26 /** 27 * Battery state of charge (SoC) of the current device, in percent. 28 * @since 6 29 */ 30 const batterySOC: number; 31 32 /** 33 * Battery charging status of the current device. 34 * @since 6 35 */ 36 const chargingStatus: BatteryChargeState; 37 38 /** 39 * Battery health state of the current device. 40 * @since 6 41 */ 42 const healthStatus: BatteryHealthState; 43 44 /** 45 * Charger type of the current device. 46 * @since 6 47 */ 48 const pluggedType: BatteryPluggedType; 49 50 /** 51 * Battery voltage of the current device, in µV. 52 * @since 6 53 */ 54 const voltage: number; 55 56 /** 57 * Battery technology of the current device. 58 * @since 6 59 */ 60 const technology: string; 61 62 /** 63 * Battery temperature of the current device, in 0.1℃. 64 * @since 6 65 */ 66 const batteryTemperature: number; 67 68 /** 69 * Battery present state of the current device. 70 * @since 7 71 */ 72 const isBatteryPresent: boolean; 73 74 /** 75 * Battery capacity level of the current device. 76 * @since 9 77 */ 78 const batteryCapacityLevel: BatteryCapacityLevel; 79 80 /** 81 * Estimated remaining time for the current device to be fully charged, in ms. 82 * @since 9 83 * @systemapi 84 */ 85 const estimatedRemainingChargeTime: number; 86 87 /** 88 * Battery total energy of the current device, in mAh. 89 * @since 9 90 * @systemapi 91 */ 92 const totalEnergy: number; 93 94 /** 95 * Battery immediate current of the current device, in mA. 96 * @since 9 97 * @systemapi 98 */ 99 const nowCurrent: number; 100 101 /** 102 * Battery remaining energy of the current device, in mAh. 103 * @since 9 104 * @systemapi 105 */ 106 const remainingEnergy: number; 107 108 /** 109 * Charger type of a device. 110 * 111 * @syscap SystemCapability.PowerManager.BatteryManager.Core 112 * @since 6 113 */ 114 export enum BatteryPluggedType { 115 /** 116 * Unknown type 117 * @since 6 118 */ 119 NONE, 120 /** 121 * AC charger 122 * @since 6 123 */ 124 AC, 125 /** 126 * USB charger 127 * @since 6 128 */ 129 USB, 130 /** 131 * Wireless charger 132 * @since 6 133 */ 134 WIRELESS 135 } 136 137 /** 138 * Battery charging status of a device. 139 * 140 * @syscap SystemCapability.PowerManager.BatteryManager.Core 141 * @since 6 142 */ 143 export enum BatteryChargeState { 144 /** 145 * Unknown state. 146 * @since 6 147 */ 148 NONE, 149 /** 150 * The battery is being charged. 151 * @since 6 152 */ 153 ENABLE, 154 /** 155 * The battery is not being charged. 156 * @since 6 157 */ 158 DISABLE, 159 /** 160 * The battery is fully charged. 161 * @since 6 162 */ 163 FULL 164 } 165 166 /** 167 * Battery health status of a device. 168 * 169 * @syscap SystemCapability.PowerManager.BatteryManager.Core 170 * @since 6 171 */ 172 export enum BatteryHealthState { 173 /** 174 * Unknown state. 175 * @since 6 176 */ 177 UNKNOWN, 178 /** 179 * The battery is in healthy state. 180 * @since 6 181 */ 182 GOOD, 183 /** 184 * The battery is overheated. 185 * @since 6 186 */ 187 OVERHEAT, 188 /** 189 * The battery voltage is over high. 190 * @since 6 191 */ 192 OVERVOLTAGE, 193 /** 194 * The battery temperature is low. 195 * @since 6 196 */ 197 COLD, 198 /** 199 * The battery is dead. 200 * @since 6 201 */ 202 DEAD 203 } 204 205 /** 206 * Battery capacity level of a device. 207 * 208 * @syscap SystemCapability.PowerManager.BatteryManager.Core 209 * @since 9 210 */ 211 export enum BatteryCapacityLevel { 212 /** 213 * The battery is in full capacity level. 214 * @since 9 215 */ 216 LEVEL_FULL, 217 /** 218 * The battery is in high capacity level. 219 * @since 9 220 */ 221 LEVEL_HIGH, 222 /** 223 * The battery is in normal capacity level. 224 * @since 9 225 */ 226 LEVEL_NORMAL, 227 /** 228 * The battery is in low capacity level. 229 * @since 9 230 */ 231 LEVEL_LOW, 232 /** 233 * The battery is in warning low capacity level. 234 * @since 9 235 */ 236 LEVEL_WARNING, 237 /** 238 * The battery is in critical low capacity level. 239 * @since 9 240 */ 241 LEVEL_CRITICAL, 242 /** 243 * The battery is in the lowest capacity level, system will shut down automatically in a few seconds. 244 * @since 9 245 */ 246 LEVEL_SHUTDOWN 247 } 248 249 /** 250 * Extra key of common event COMMON_EVENT_BATTERY_CHANGED. 251 * 252 * @syscap SystemCapability.PowerManager.BatteryManager.Core 253 * @since 9 254 */ 255 export enum CommonEventBatteryChangedKey { 256 /** 257 * Extra code of batterySOC. 258 * @since 9 259 */ 260 EXTRA_SOC = "soc", 261 /** 262 * Extra code of chargingStatus. 263 * @since 9 264 */ 265 EXTRA_CHARGE_STATE = "chargeState", 266 /** 267 * Extra code of healthStatus. 268 * @since 9 269 */ 270 EXTRA_HEALTH_STATE = "healthState", 271 /** 272 * Extra code of pluggedType. 273 * @since 9 274 */ 275 EXTRA_PLUGGED_TYPE = "pluggedType", 276 /** 277 * Extra code of voltage. 278 * @since 9 279 */ 280 EXTRA_VOLTAGE = "voltage", 281 /** 282 * Extra code of technology. 283 * @since 9 284 */ 285 EXTRA_TECHNOLOGY = "technology", 286 /** 287 * Extra code of batteryTemperature. 288 * @since 9 289 */ 290 EXTRA_TEMPERATURE = "temperature", 291 /** 292 * Extra code of isBatteryPresent. 293 * @since 9 294 */ 295 EXTRA_PRESENT = "present", 296 /** 297 * Extra code of batteryCapacityLevel. 298 * @since 9 299 */ 300 EXTRA_CAPACITY_LEVEL = "capacityLevel", 301 } 302} 303export default batteryInfo; 304