Home | History | Annotate | Download | only in 2.0
      1 Upgrading from health (a] 1.0 HAL
      2 
      3 0. Remove android.hardware.health (a] 1.0* from PRODUCT_PACKAGES
      4    in device/<manufacturer>/<device>/device.mk
      5 
      6 1. If the device does not have a vendor-specific libhealthd AND does not
      7    implement storage-related APIs, just do the following:
      8 
      9     1.1 (recommended) To remove healthd from the build,
     10         PRODUCT_PACKAGES += android.hardware.health (a] 2.0-service.override
     11         DEVICE_FRAMEWORK_MANIFEST_FILE += \
     12             system/libhidl/vintfdata/manifest_healthd_exclude.xml
     13     1.2 To keep healthd in the build,
     14         PRODUCT_PACKAGES += android.hardware.health (a] 2.0-service
     15 
     16    Otherwise, continue to Step 2.
     17 
     18 2. Create directory
     19    device/<manufacturer>/<device>/health
     20 
     21 3. Create device/<manufacturer>/<device>/health/Android.bp
     22    (or equivalent device/<manufacturer>/<device>/health/Android.mk)
     23 
     24 cc_binary {
     25     name: "android.hardware.health (a] 2.0-service.<device>",
     26     init_rc: ["android.hardware.health (a] 2.0-service.<device>.rc"],
     27     proprietary: true,
     28     relative_install_path: "hw",
     29     srcs: [
     30         "HealthService.cpp",
     31     ],
     32 
     33     cflags: [
     34         "-Wall",
     35         "-Werror",
     36     ],
     37 
     38     static_libs: [
     39         "android.hardware.health (a] 2.0-impl",
     40         "android.hardware.health (a] 1.0-convert",
     41         "libhealthservice",
     42         "libbatterymonitor",
     43     ],
     44 
     45     shared_libs: [
     46         "libbase",
     47         "libcutils",
     48         "libhidlbase",
     49         "libhidltransport",
     50         "libutils",
     51         "android.hardware.health (a] 2.0",
     52     ],
     53 
     54     header_libs: ["libhealthd_headers"],
     55 
     56     // Uncomment the following to remove healthd from the build.
     57     // overrides: [
     58     //     "healthd",
     59     // ],
     60 }
     61 
     62     3.1 (recommended) To remove healthd from the build, keep "overrides"
     63           section, and include the following in device.mk:
     64             DEVICE_FRAMEWORK_MANIFEST_FILE += \
     65                 system/libhidl/vintfdata/manifest_healthd_exclude.xml
     66     3.2 To keep healthd in the build, remove "overrides" section.
     67 
     68 4. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc
     69 
     70 service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device>
     71     class hal
     72     user system
     73     group system
     74     file /dev/kmsg w
     75 
     76 5. Create device/<manufacturer>/<device>/health/HealthService.cpp:
     77 
     78 #include <health2/service.h>
     79 int main() { return health_service_main(); }
     80 
     81 6. libhealthd dependency:
     82 
     83 6.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs.
     84 
     85 6.2 If the device does not have a vendor-specific libhealthd, add the following
     86     lines to HealthService.cpp:
     87 
     88 #include <healthd/healthd.h>
     89 void healthd_board_init(struct healthd_config*) {}
     90 
     91 int healthd_board_battery_update(struct android::BatteryProperties*) {
     92     // return 0 to log periodic polled battery status to kernel log
     93     return 0;
     94 }
     95 
     96 7. Storage related APIs:
     97 
     98 7.1 If the device does not implement IHealth.getDiskStats and
     99     IHealth.getStorageInfo, add libstoragehealthdefault to static_libs.
    100 
    101 7.2 If the device implements one of these two APIs, add and implement the
    102     following functions in HealthService.cpp:
    103 
    104 void get_storage_info(std::vector<struct StorageInfo>& info) {
    105     // ...
    106 }
    107 void get_disk_stats(std::vector<struct DiskStats>& stats) {
    108     // ...
    109 }
    110 
    111 8. Update necessary SELinux permissions. For example,
    112 
    113 # device/<manufacturer>/<device>/sepolicy/vendor/file_contexts
    114 /vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0
    115 
    116 # device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te
    117 # Add device specific permissions to hal_health_default domain, especially
    118 # if Step 6.1 or Step 7.2 is done.
    119