Project: /_project.yaml Book: /_book.yaml
{% include “_versions.html” %}
Android {{ androidPVersionNumber }} includes android.hardware.health
HAL 2.0, a major version upgrade from health@1.0 HAL. This new HAL has the following advantages:
healthd
daemon.Devices launching with Android {{ androidPVersionNumber }} must provide the 2.0 HAL (and must not provide the 1.0 HAL). Devices not launching with Android {{ androidPVersionNumber }} but planning to update the vendor image to Target Framework Compatibility Matrix Version 3 (released in Android {{ androidPVersionNumber }}) must remove existing 1.0 HAL implementations and provide the 2.0 HAL.
AOSP includes multiple helper libraries designed to help you implement the 2.0 HAL and the transition from the old 1.0 HAL.
android.hardware.health@1.0
. Refers to health HIDL HAL version 1.0 released in Android 8.0.android.hardware.health@2.0
. Refers to health HIDL HAL version 2.0 released in Android {{ androidPVersionNumber }}.In Android 8.x, the health component works as detailed in the following diagram:
Figure 1. Health in Android 8.x
In this diagram:
healthd
statically links to libhealthd_android
, libbatterymonitor
, and libbatteryservice
.Each board can customize a different libhealthd.BOARD; it is determined at build time what charger, health@1.0-impl, and recovery link to.
For other modes:
Figure 2. Health in Android 8.x, off-mode charging and recovery mode
libhealthd_charger
and libbatterymonitor
.libbatterymonitor
.In Android {{ androidPVersionNumber }}, the health component works as detailed in the following diagram:
Figure 3. Health in Android {{ androidPVersionNumber }}
The framework attempts to retrieve health@2.0 service from hwservicemanager
. If it fails, it calls into health@1.0 (in Android 8.x). The legacy code path is kept so the Android {{ androidPVersionNumber }} system image is compatible with the Android 8.x vendor image. The framework does not retrieve information from both HALs because only one service version (1.0 or 2.0) can exist on the device.
Note: For the legacy code path, the processes/libraries will be kept until health@1.0 is deprecated.
For other modes:
Figure 4. Health in Android {{ androidPVersionNumber }}, off-mode charging and recovery mode
The health@2.0 HAL provides the same functionality to the framework as the old healthd daemon. It also provides APIs that are similar to what healthd previously provided as a binder service (i.e. IBatteryPropertiesRegistrar{: .external}).
The main interface, IHealth{: .external} , provides the following functions:
registerCallback
, to replace IBatteryPropertiesRegistrar.registerListener
unregisterCallback
, to replace IBatteryPropertiesRegistrar.unregisterListener
update
, to replace IBatteryPropertiesRegistrar.scheduleUpdate
IBatteryPropertiesRegistrar.getProperties
are replaced by the following:getChargeCounter
getCurrentNow
getCurrentAverage
getCapacity
getEnergyCounter
getChargeStatus
getHealthInfo
In addition, IHealth
provides the following new APIs for storaged
to retrieve vendor-specific storage related information:
getStorageInfo
getDiskStats
A new struct, @2.0::HealthInfo
, is returned via callbacks and getHealthInfo
. This struct contains all device health information available through health@2.0 HAL, including:
For information on implementing the Health service, see Implementing Health.