harmony 鸿蒙@ohos.batteryInfo (Battery Information)

2022-08-09 浏览 (971)

@ohos.batteryInfo (Battery Information)

The batteryInfo module provides APIs for querying the charger type, battery health status, and battery charging status.

NOTE

The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import batteryInfo from '@ohos.batteryInfo';

Attributes

Describes battery information.

System capability: SystemCapability.PowerManager.BatteryManager.Core

NameTypeReadableWritableDescription
batterySOCnumberYesNoBattery state of charge (SoC) of the device, in unit of percentage.
chargingStatusBatteryChargeStateYesNoBattery charging status of the device.
healthStatusBatteryHealthStateYesNoBattery health status of the device.
pluggedTypeBatteryPluggedTypeYesNoCharger type of the device.
voltagenumberYesNoBattery voltage of the device, in unit of microvolt.
technologystringYesNoBattery technology of the device.
batteryTemperaturenumberYesNoBattery temperature of the device, in unit of 0.1°C.
isBatteryPresent7+booleanYesNoWhether the battery is supported or present.
batteryCapacityLevel9+BatteryCapacityLevelYesNoBattery level of the device.
estimatedRemainingChargeTime9+numberYesNoEstimated time for fully charging the current device, in unit of milliseconds. This is a system API.
totalEnergy9+numberYesNoTotal battery capacity of the device, in unit of mAh. This is a system API.
nowCurrent9+numberYesNoBattery current of the device, in unit of mA. This is a system API.
remainingEnergy9+numberYesNoRemaining battery capacity of the device, in unit of mAh. This is a system API.

BatteryPluggedType

Enumerates charger types.

System capability: SystemCapability.PowerManager.BatteryManager.Core

NameValueDescription
NONE0Unknown charger type.
AC1AC charger.
USB2USB charger.
WIRELESS3Wireless charger.

BatteryChargeState

Enumerates charging states.

System capability: SystemCapability.PowerManager.BatteryManager.Core

NameValueDescription
NONE0Unknown state.
ENABLE1The battery is being charged.
DISABLE2The battery is not being charged.
FULL3The battery is fully charged.

BatteryHealthState

Enumerates battery health states.

System capability: SystemCapability.PowerManager.BatteryManager.Core

NameValueDescription
UNKNOWN0Unknown state.
GOOD1The battery is in the healthy state.
OVERHEAT2The battery is overheated.
OVERVOLTAGE3The battery voltage is over high.
COLD4The battery temperature is low.
DEAD5The battery is dead.

BatteryCapacityLevel9+

Enumerates battery levels.

System capability: SystemCapability.PowerManager.BatteryManager.Core

NameValueDescription
LEVEL_FULL1Full battery level.
LEVEL_HIGH2High battery level.
LEVEL_NORMAL3Normal battery level.
LEVEL_LOW4Low battery level.
LEVEL_WARNING5Alarm battery level.
LEVEL_CRITICAL6Ultra-low battery level.
LEVEL_SHUTDOWN7Power-down battery level.

CommonEventBatteryChangedKey9+

Enumerates keys for querying the additional information about the COMMON_EVENT_BATTERY_CHANGED event.

System capability: SystemCapability.PowerManager.BatteryManager.Core

NameValueDescription
EXTRA_SOC"soc"Remaining battery level in percentage.
EXTRA_CHARGE_STATE"chargeState"Battery charging status of the device.
EXTRA_HEALTH_STATE"healthState"Battery health status of the device.
EXTRA_PLUGGED_TYPE"pluggedType"Type of the charger connected to the device.
EXTRA_VOLTAGE"voltage"Battery voltage of the device.
EXTRA_TECHNOLOGY"technology"Battery technology of the device.
EXTRA_TEMPERATURE"temperature"Battery temperature of the device.
EXTRA_PRESENT"present"Whether the battery is supported by the device or installed.
EXTRA_CAPACITY_LEVEL"capacityLevel"Battery level of the device.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/487a3c80b3f24050aa7a59f93489c14b