blob: dfd965aa5a45134a6d20dcb9f62760a58e0fe122 [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
Yifan Hongeb159af2018-06-18 14:39:01 -07009 PRODUCT_PACKAGES += android.hardware.health@2.0-service
Yifan Hong8ef23352018-04-03 13:25:42 -070010
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080011 Otherwise, continue to Step 2.
12
132. Create directory
14 device/<manufacturer>/<device>/health
15
163. Create device/<manufacturer>/<device>/health/Android.bp
17 (or equivalent device/<manufacturer>/<device>/health/Android.mk)
18
19cc_binary {
20 name: "android.hardware.health@2.0-service.<device>",
21 init_rc: ["android.hardware.health@2.0-service.<device>.rc"],
22 proprietary: true,
23 relative_install_path: "hw",
24 srcs: [
25 "HealthService.cpp",
26 ],
27
28 cflags: [
29 "-Wall",
30 "-Werror",
31 ],
32
33 static_libs: [
34 "android.hardware.health@2.0-impl",
35 "android.hardware.health@1.0-convert",
36 "libhealthservice",
37 "libbatterymonitor",
38 ],
39
40 shared_libs: [
41 "libbase",
42 "libcutils",
43 "libhidlbase",
44 "libhidltransport",
45 "libutils",
46 "android.hardware.health@2.0",
47 ],
48
49 header_libs: ["libhealthd_headers"],
Yifan Hong8ef23352018-04-03 13:25:42 -070050
51 // Uncomment the following to remove healthd from the build.
52 // overrides: [
53 // "healthd",
54 // ],
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080055}
56
Yifan Hong8ef23352018-04-03 13:25:42 -070057 3.1 (recommended) To remove healthd from the build, keep "overrides"
58 section, and include the following in device.mk:
59 DEVICE_FRAMEWORK_MANIFEST_FILE += \
60 system/libhidl/vintfdata/manifest_healthd_exclude.xml
61 3.2 To keep healthd in the build, remove "overrides" section.
62
Yifan Hong3e6dbcb2018-01-19 13:17:34 -0800634. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc
64
65service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device>
66 class hal
67 user system
68 group system
Yifan Hongd7b297d2018-04-05 19:11:10 -070069 file /dev/kmsg w
Yifan Hong3e6dbcb2018-01-19 13:17:34 -080070
715. Create device/<manufacturer>/<device>/health/HealthService.cpp:
72
73#include <health2/service.h>
74int main() { return health_service_main(); }
75
766. libhealthd dependency:
77
786.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs.
79
806.2 If the device does not have a vendor-specific libhealthd, add the following
81 lines to HealthService.cpp:
82
83#include <healthd/healthd.h>
84void healthd_board_init(struct healthd_config*) {}
85
86int healthd_board_battery_update(struct android::BatteryProperties*) {
87 // return 0 to log periodic polled battery status to kernel log
88 return 0;
89}
90
917. Storage related APIs:
92
937.1 If the device does not implement IHealth.getDiskStats and
94 IHealth.getStorageInfo, add libstoragehealthdefault to static_libs.
95
967.2 If the device implements one of these two APIs, add and implement the
97 following functions in HealthService.cpp:
98
99void get_storage_info(std::vector<struct StorageInfo>& info) {
100 // ...
101}
102void get_disk_stats(std::vector<struct DiskStats>& stats) {
103 // ...
104}
105
1068. Update necessary SELinux permissions. For example,
107
108# device/<manufacturer>/<device>/sepolicy/vendor/file_contexts
109/vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0
110
111# device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te
112# Add device specific permissions to hal_health_default domain, especially
Yifan Hongde542ac2018-01-30 15:32:30 -0800113# if Step 6.1 or Step 7.2 is done.