Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 1 | Upgrading from health@1.0 HAL |
| 2 | |
| 3 | 0. Remove android.hardware.health@1.0* from PRDOUCT_PACKAGES |
| 4 | in device/<manufacturer>/<device>/device.mk |
| 5 | |
| 6 | 1. 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 | |
| 11 | 2. Create directory |
| 12 | device/<manufacturer>/<device>/health |
| 13 | |
| 14 | 3. Create device/<manufacturer>/<device>/health/Android.bp |
| 15 | (or equivalent device/<manufacturer>/<device>/health/Android.mk) |
| 16 | |
| 17 | cc_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 | |
| 50 | 4. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc |
| 51 | |
| 52 | service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device> |
| 53 | class hal |
| 54 | user system |
| 55 | group system |
Yifan Hong | d7b297d | 2018-04-05 19:11:10 -0700 | [diff] [blame^] | 56 | file /dev/kmsg w |
Yifan Hong | 3e6dbcb | 2018-01-19 13:17:34 -0800 | [diff] [blame] | 57 | |
| 58 | 5. Create device/<manufacturer>/<device>/health/HealthService.cpp: |
| 59 | |
| 60 | #include <health2/service.h> |
| 61 | int main() { return health_service_main(); } |
| 62 | |
| 63 | 6. libhealthd dependency: |
| 64 | |
| 65 | 6.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs. |
| 66 | |
| 67 | 6.2 If the device does not have a vendor-specific libhealthd, add the following |
| 68 | lines to HealthService.cpp: |
| 69 | |
| 70 | #include <healthd/healthd.h> |
| 71 | void healthd_board_init(struct healthd_config*) {} |
| 72 | |
| 73 | int healthd_board_battery_update(struct android::BatteryProperties*) { |
| 74 | // return 0 to log periodic polled battery status to kernel log |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | 7. Storage related APIs: |
| 79 | |
| 80 | 7.1 If the device does not implement IHealth.getDiskStats and |
| 81 | IHealth.getStorageInfo, add libstoragehealthdefault to static_libs. |
| 82 | |
| 83 | 7.2 If the device implements one of these two APIs, add and implement the |
| 84 | following functions in HealthService.cpp: |
| 85 | |
| 86 | void get_storage_info(std::vector<struct StorageInfo>& info) { |
| 87 | // ... |
| 88 | } |
| 89 | void get_disk_stats(std::vector<struct DiskStats>& stats) { |
| 90 | // ... |
| 91 | } |
| 92 | |
| 93 | 8. Update necessary SELinux permissions. For example, |
| 94 | |
| 95 | # device/<manufacturer>/<device>/sepolicy/vendor/file_contexts |
| 96 | /vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0 |
| 97 | |
| 98 | # device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te |
| 99 | # Add device specific permissions to hal_health_default domain, especially |
Yifan Hong | de542ac | 2018-01-30 15:32:30 -0800 | [diff] [blame] | 100 | # if Step 6.1 or Step 7.2 is done. |