blob: 2281f989699e2ed0225ab2ca1bc4c27c91d4c541 [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
74
755. Create device/<manufacturer>/<device>/health/HealthService.cpp:
76
77#include <health2/service.h>
78int main() { return health_service_main(); }
79
806. libhealthd dependency:
81
826.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs.
83
846.2 If the device does not have a vendor-specific libhealthd, add the following
85 lines to HealthService.cpp:
86
87#include <healthd/healthd.h>
88void healthd_board_init(struct healthd_config*) {}
89
90int healthd_board_battery_update(struct android::BatteryProperties*) {
91 // return 0 to log periodic polled battery status to kernel log
92 return 0;
93}
94
957. Storage related APIs:
96
977.1 If the device does not implement IHealth.getDiskStats and
98 IHealth.getStorageInfo, add libstoragehealthdefault to static_libs.
99
1007.2 If the device implements one of these two APIs, add and implement the
101 following functions in HealthService.cpp:
102
103void get_storage_info(std::vector<struct StorageInfo>& info) {
104 // ...
105}
106void get_disk_stats(std::vector<struct DiskStats>& stats) {
107 // ...
108}
109
1108. Update necessary SELinux permissions. For example,
111
112# device/<manufacturer>/<device>/sepolicy/vendor/file_contexts
113/vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0
114
115# device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te
116# Add device specific permissions to hal_health_default domain, especially
Yifan Hongde542ac2018-01-30 15:32:30 -0800117# if Step 6.1 or Step 7.2 is done.