blob: dc97d43e30664f61b9821332aeb220c715f820dd [file] [log] [blame]
Yifan Hong3e6dbcb2018-01-19 13:17:34 -08001Upgrading from health@1.0 HAL
2
30. Remove android.hardware.health@1.0* from PRDOUCT_PACKAGES
4 in device/<manufacturer>/<device>/device.mk
5
61. If the device does not have a vendor-specific libhealthd AND does not
7 implement storage-related APIs, just add the following to PRODUCT_PACKAGES:
8 android.hardware.health@2.0-service
9 Otherwise, continue to Step 2.
10
112. Create directory
12 device/<manufacturer>/<device>/health
13
143. Create device/<manufacturer>/<device>/health/Android.bp
15 (or equivalent device/<manufacturer>/<device>/health/Android.mk)
16
17cc_binary {
18 name: "android.hardware.health@2.0-service.<device>",
19 init_rc: ["android.hardware.health@2.0-service.<device>.rc"],
20 proprietary: true,
21 relative_install_path: "hw",
22 srcs: [
23 "HealthService.cpp",
24 ],
25
26 cflags: [
27 "-Wall",
28 "-Werror",
29 ],
30
31 static_libs: [
32 "android.hardware.health@2.0-impl",
33 "android.hardware.health@1.0-convert",
34 "libhealthservice",
35 "libbatterymonitor",
36 ],
37
38 shared_libs: [
39 "libbase",
40 "libcutils",
41 "libhidlbase",
42 "libhidltransport",
43 "libutils",
44 "android.hardware.health@2.0",
45 ],
46
47 header_libs: ["libhealthd_headers"],
48}
49
504. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc
51
52service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device>
53 class hal
54 user system
55 group system
Yifan Hongd7b297d2018-04-05 19:11:10 -070056 file /dev/kmsg w
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080057
585. Create device/<manufacturer>/<device>/health/HealthService.cpp:
59
60#include <health2/service.h>
61int main() { return health_service_main(); }
62
636. libhealthd dependency:
64
656.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs.
66
676.2 If the device does not have a vendor-specific libhealthd, add the following
68 lines to HealthService.cpp:
69
70#include <healthd/healthd.h>
71void healthd_board_init(struct healthd_config*) {}
72
73int healthd_board_battery_update(struct android::BatteryProperties*) {
74 // return 0 to log periodic polled battery status to kernel log
75 return 0;
76}
77
787. Storage related APIs:
79
807.1 If the device does not implement IHealth.getDiskStats and
81 IHealth.getStorageInfo, add libstoragehealthdefault to static_libs.
82
837.2 If the device implements one of these two APIs, add and implement the
84 following functions in HealthService.cpp:
85
86void get_storage_info(std::vector<struct StorageInfo>& info) {
87 // ...
88}
89void get_disk_stats(std::vector<struct DiskStats>& stats) {
90 // ...
91}
92
938. Update necessary SELinux permissions. For example,
94
95# device/<manufacturer>/<device>/sepolicy/vendor/file_contexts
96/vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0
97
98# device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te
99# Add device specific permissions to hal_health_default domain, especially
Yifan Hongde542ac2018-01-30 15:32:30 -0800100# if Step 6.1 or Step 7.2 is done.