blob: 11e6a7aaf1e018a20cc4ac5d1796f558ed1111c6 [file] [log] [blame]
Yifan Hong3e6dbcb2018-01-19 13:17:34 -08001Upgrading from health@1.0 HAL
2
Yifan Hong8ef23352018-04-03 13:25:42 -070030. Remove android.hardware.health@1.0* from PRODUCT_PACKAGES
Yifan Hong3e6dbcb2018-01-19 13:17:34 -08004 in device/<manufacturer>/<device>/device.mk
5
61. If the device does not have a vendor-specific libhealthd AND does not
Yifan Hong8ef23352018-04-03 13:25:42 -07007 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@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@2.0-service
15
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080016 Otherwise, continue to Step 2.
17
182. Create directory
19 device/<manufacturer>/<device>/health
20
213. Create device/<manufacturer>/<device>/health/Android.bp
22 (or equivalent device/<manufacturer>/<device>/health/Android.mk)
23
24cc_binary {
25 name: "android.hardware.health@2.0-service.<device>",
26 init_rc: ["android.hardware.health@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@2.0-impl",
40 "android.hardware.health@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@2.0",
52 ],
53
54 header_libs: ["libhealthd_headers"],
Yifan Hong8ef23352018-04-03 13:25:42 -070055
56 // Uncomment the following to remove healthd from the build.
57 // overrides: [
58 // "healthd",
59 // ],
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080060}
61
Yifan Hong8ef23352018-04-03 13:25:42 -070062 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
Yifan Hong3e6dbcb2018-01-19 13:17:34 -0800684. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc
69
70service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device>
71 class hal
72 user system
73 group system
Yifan Hongd7b297d2018-04-05 19:11:10 -070074 file /dev/kmsg w
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080075
765. Create device/<manufacturer>/<device>/health/HealthService.cpp:
77
78#include <health2/service.h>
79int main() { return health_service_main(); }
80
816. libhealthd dependency:
82
836.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs.
84
856.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>
89void healthd_board_init(struct healthd_config*) {}
90
91int healthd_board_battery_update(struct android::BatteryProperties*) {
92 // return 0 to log periodic polled battery status to kernel log
93 return 0;
94}
95
967. Storage related APIs:
97
987.1 If the device does not implement IHealth.getDiskStats and
99 IHealth.getStorageInfo, add libstoragehealthdefault to static_libs.
100
1017.2 If the device implements one of these two APIs, add and implement the
102 following functions in HealthService.cpp:
103
104void get_storage_info(std::vector<struct StorageInfo>& info) {
105 // ...
106}
107void get_disk_stats(std::vector<struct DiskStats>& stats) {
108 // ...
109}
110
1118. 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
Yifan Hongde542ac2018-01-30 15:32:30 -0800118# if Step 6.1 or Step 7.2 is done.