Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 1 | Upgrading from health@1.0 HAL |
| 2 | |
Yifan Hong | 8ef2335 | 2018-04-03 13:25:42 -0700 | [diff] [blame] | 3 | 0. Remove android.hardware.health@1.0* from PRODUCT_PACKAGES |
Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 4 | in device/<manufacturer>/<device>/device.mk |
| 5 | |
| 6 | 1. If the device does not have a vendor-specific libhealthd AND does not |
Yifan Hong | 8ef2335 | 2018-04-03 13:25:42 -0700 | [diff] [blame] | 7 | implement storage-related APIs, just do the following: |
| 8 | |
Yifan Hong | eb159af | 2018-06-18 14:39:01 -0700 | [diff] [blame] | 9 | PRODUCT_PACKAGES += android.hardware.health@2.0-service |
Yifan Hong | 8ef2335 | 2018-04-03 13:25:42 -0700 | [diff] [blame] | 10 | |
Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 11 | Otherwise, continue to Step 2. |
| 12 | |
| 13 | 2. Create directory |
| 14 | device/<manufacturer>/<device>/health |
| 15 | |
| 16 | 3. Create device/<manufacturer>/<device>/health/Android.bp |
| 17 | (or equivalent device/<manufacturer>/<device>/health/Android.mk) |
| 18 | |
| 19 | cc_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 Hong | 8ef2335 | 2018-04-03 13:25:42 -0700 | [diff] [blame] | 50 | |
| 51 | // Uncomment the following to remove healthd from the build. |
| 52 | // overrides: [ |
| 53 | // "healthd", |
| 54 | // ], |
Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Yifan Hong | 8ef2335 | 2018-04-03 13:25:42 -0700 | [diff] [blame] | 57 | 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 Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 63 | 4. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc |
| 64 | |
| 65 | service 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 Hong | d7b297d | 2018-04-05 19:11:10 -0700 | [diff] [blame] | 69 | file /dev/kmsg w |
Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 70 | |
| 71 | 5. Create device/<manufacturer>/<device>/health/HealthService.cpp: |
| 72 | |
| 73 | #include <health2/service.h> |
| 74 | int main() { return health_service_main(); } |
| 75 | |
| 76 | 6. libhealthd dependency: |
| 77 | |
| 78 | 6.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs. |
| 79 | |
| 80 | 6.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> |
| 84 | void healthd_board_init(struct healthd_config*) {} |
| 85 | |
| 86 | int healthd_board_battery_update(struct android::BatteryProperties*) { |
| 87 | // return 0 to log periodic polled battery status to kernel log |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | 7. Storage related APIs: |
| 92 | |
| 93 | 7.1 If the device does not implement IHealth.getDiskStats and |
| 94 | IHealth.getStorageInfo, add libstoragehealthdefault to static_libs. |
| 95 | |
| 96 | 7.2 If the device implements one of these two APIs, add and implement the |
| 97 | following functions in HealthService.cpp: |
| 98 | |
| 99 | void get_storage_info(std::vector<struct StorageInfo>& info) { |
| 100 | // ... |
| 101 | } |
| 102 | void get_disk_stats(std::vector<struct DiskStats>& stats) { |
| 103 | // ... |
| 104 | } |
| 105 | |
| 106 | 8. 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 Hong | de542ac | 2018-01-30 15:32:30 -0800 | [diff] [blame] | 113 | # if Step 6.1 or Step 7.2 is done. |