openharmony 鸿蒙 changelogs-power

2023-06-24 浏览 (531)

Power Subsystem Changelog

cl.powermgr.1 CommonEventBatteryChangedCode API Change

Changed the CommonEventBatteryChangedCode enum class in @ohos.batteryInfo as follows:

  • Changed the class name to CommonEventBatteryChangedKey.
  • Deleted EXTRA_MAX_CURRENT, EXTRA_MAX_VOLTAGE, and EXTRA_CHARGE_COUNTER.
  • Changed the enum value type from numeric to string.

Change Impact

The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected.

Key API/Component Changes

Before change:

NameValueDescription
EXTRA_SOC0Remaining battery level in percentage.
EXTRA_VOLTAGE1Battery voltage of the device.
EXTRA_TEMPERATURE2Battery temperature of the device.
EXTRA_HEALTH_STATE3Battery health status of the device.
EXTRA_PLUGGED_TYPE4Type of the charger connected to the device.
EXTRA_MAX_CURRENT5Maximum battery current of the device.
EXTRA_MAX_VOLTAGE6Maximum battery voltage of the device.
EXTRA_CHARGE_STATE7Battery charging status of the device.
EXTRA_CHARGE_COUNTER8Number of battery charging times of the device.
EXTRA_PRESENT9Whether the battery is supported by the device or installed.
EXTRA_TECHNOLOGY10Battery technology of the device.
EXTRA_CAPACITY_LEVEL11Battery level of the device.

After change:

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.

Adaptation Guide

For details, see the API reference of the @ohos.batteryInfo API.

cl.powermgr.2 estimatedRemainingChargeTime API Change

Changed the estimatedRemainingChargeTime API in @ohos.batteryInfo to a system API.

Change Impact

The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected.

Adaptation Guide

For details, see the API reference of the @ohos.batteryInfo API.

cl.powermgr.3 System Common Event Behavior Change

The following common events are provided in the battery information through @ohos.commonEventManager (common event module):

  • COMMON_EVENT_BATTERY_LOW: common event for low battery level. It includes the remaining battery in percentage.
  • COMMON_EVENT_BATTERY_OKAY: common event for normal battery level. It includes the remaining battery in percentage.
  • COMMON_EVENT_POWER_CONNECTED: common event for connection to an external power supply. It includes the type of the power supply to which the device is connected.
  • COMMON_EVENT_POWER_DISCONNECTED: common event for disconnection from an external power supply. It includes the type of the power supply from which the device is disconnected.
  • COMMON_EVENT_CHARGING: common event for starting of battery charging. It includes the battery charging status.
  • COMMON_EVENT_DISCHARGING: common event for ending of battery charging. It includes the battery charging status.

Changed the method of obtaining data from common events from CommonEventData.data to CommonEventData.code.

Change Impact

The application developed based on earlier versions needs to adapt the method for obtaining common events in the battery information. Otherwise, the original service logic will be affected.

Adaptation Guide

For details, see the API reference of the @ohos.commonEventManager (Common Event Manager) API.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙App Access Control Subsystem ChangeLog

harmony 鸿蒙Security Subsystem Changelog

harmony 鸿蒙Web Subsystem Changelog

harmony 鸿蒙Account Subsystem Changelog

harmony 鸿蒙ArkUI Subsystem Changelog

harmony 鸿蒙Bundle Manager Subsystem Changelog

harmony 鸿蒙Common Event Subsystem Changelog

harmony 鸿蒙File Management Subsystem Changelog

harmony 鸿蒙Pasteboard Subsystem Changelog

harmony 鸿蒙Pan-sensor Subsystem Changelog

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