blob: a0a5f08669d425b9af9dba06d9a50083d4754a67 [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
56
575. Create device/<manufacturer>/<device>/health/HealthService.cpp:
58
59#include <health2/service.h>
60int main() { return health_service_main(); }
61
626. libhealthd dependency:
63
646.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs.
65
666.2 If the device does not have a vendor-specific libhealthd, add the following
67 lines to HealthService.cpp:
68
69#include <healthd/healthd.h>
70void healthd_board_init(struct healthd_config*) {}
71
72int healthd_board_battery_update(struct android::BatteryProperties*) {
73 // return 0 to log periodic polled battery status to kernel log
74 return 0;
75}
76
777. Storage related APIs:
78
797.1 If the device does not implement IHealth.getDiskStats and
80 IHealth.getStorageInfo, add libstoragehealthdefault to static_libs.
81
827.2 If the device implements one of these two APIs, add and implement the
83 following functions in HealthService.cpp:
84
85void get_storage_info(std::vector<struct StorageInfo>& info) {
86 // ...
87}
88void get_disk_stats(std::vector<struct DiskStats>& stats) {
89 // ...
90}
91
928. Update necessary SELinux permissions. For example,
93
94# device/<manufacturer>/<device>/sepolicy/vendor/file_contexts
95/vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0
96
97# device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te
98# Add device specific permissions to hal_health_default domain, especially
99# if Step 6.2 or Step 7.2 is done.