1/* 2 * Copyright (c) 2021 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 * Obtain the battery capacity level of a device. 76 * @since 9 77 */ 78 const batteryCapacityLevel: BatteryCapacityLevel; 79 80 /** 81 * Estimate the remaining time to fully charge, in ms. 82 * @since 9 83 */ 84 const estimatedRemainingChargeTime: number; 85 86 /** 87 * Battery total energy of the current device, in mAh. 88 * @since 9 89 * @systemapi 90 */ 91 const totalEnergy: number; 92 93 /** 94 * Battery immediate current of the current device, in mA. 95 * @since 9 96 * @systemapi 97 */ 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 * Indicates the 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 * Indicates the 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 * Indicates the 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 * Indicates the battery capacity level a device. 207 * 208 * @syscap SystemCapability.PowerManager.BatteryManager.Core 209 * @since 9 210 */ 211 export enum BatteryCapacityLevel { 212 /** 213 * The battery is in unknow capacity level. 214 * @since 9 215 */ 216 LEVEL_NONE, 217 /** 218 * The battery is in full capacity level. 219 * @since 9 220 */ 221 LEVEL_FULL, 222 /** 223 * The battery is in high capacity level. 224 * @since 9 225 */ 226 LEVEL_HIGH, 227 /** 228 * The battery is in normal capacity level. 229 * @since 9 230 */ 231 LEVEL_NORMAL, 232 /** 233 * The battery is in low capacity level. 234 * @since 9 235 */ 236 LEVEL_LOW, 237 /** 238 * The battery is in critical low capacity level. 239 * @since 9 240 */ 241 LEVEL_CRITICAL 242 } 243 244 /** 245 * Etra key code of common event COMMON_EVENT_BATTERY_CHANGED. 246 * 247 * @syscap SystemCapability.PowerManager.BatteryManager.Core 248 * @since 9 249 */ 250 export enum CommonEventBatteryChangedCode { 251 /** 252 * Extra code of state of charge (SoC). 253 * @since 9 254 */ 255 EXTRA_SOC = 0, 256 /** 257 * Extra code of voltage. 258 * @since 9 259 */ 260 EXTRA_VOLTAGE, 261 /** 262 * Extra code of temperature. 263 * @since 9 264 */ 265 EXTRA_TEMPERATURE, 266 /** 267 * Extra code of healthState. 268 * @since 9 269 */ 270 EXTRA_HEALTH_STATE, 271 /** 272 * Extra code of pluggedType. 273 * @since 9 274 */ 275 EXTRA_PLUGGED_TYPE, 276 /** 277 * Extra code of maxCurrent. 278 * @since 9 279 */ 280 EXTRA_MAX_CURRENT, 281 /** 282 * Extra code of maxVoltage. 283 * @since 9 284 */ 285 EXTRA_MAX_VOLTAGE, 286 /** 287 * Extra code of chargeState. 288 * @since 9 289 */ 290 EXTRA_CHARGE_STATE, 291 /** 292 * Extra code of chargeCounter. 293 * @since 9 294 */ 295 EXTRA_CHARGE_COUNTER, 296 /** 297 * Extra code of if battery is present. 298 * @since 9 299 */ 300 EXTRA_PRESENT, 301 /** 302 * Extra code of technology. 303 * @since 9 304 */ 305 EXTRA_TECHNOLOGY 306 } 307} 308export default batteryInfo; 309 310