diff options
author | Yifan Hong <elsk@google.com> | 2018-01-19 13:17:34 -0800 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2018-01-30 15:06:21 -0800 |
commit | 3e6dbcbc30ca0c7c5550defe89f6993b1be08b50 (patch) | |
tree | c366ea73df729afb027c5a8d7bd407a3085a61a7 /health | |
parent | 241e5aba9ebfe85a9599b333f89be51905148f81 (diff) | |
download | android_hardware_interfaces-3e6dbcbc30ca0c7c5550defe89f6993b1be08b50.tar.gz android_hardware_interfaces-3e6dbcbc30ca0c7c5550defe89f6993b1be08b50.tar.bz2 android_hardware_interfaces-3e6dbcbc30ca0c7c5550defe89f6993b1be08b50.zip |
health: add README.
Test: none
Bug: 63702641
Change-Id: I1d23c0cdf56516585e7c6dd0db577784baa7b74e
Merged-In: I1d23c0cdf56516585e7c6dd0db577784baa7b74e
Diffstat (limited to 'health')
-rw-r--r-- | health/2.0/README | 99 | ||||
-rw-r--r-- | health/2.0/utils/README | 28 |
2 files changed, 127 insertions, 0 deletions
diff --git a/health/2.0/README b/health/2.0/README new file mode 100644 index 000000000..a0a5f0866 --- /dev/null +++ b/health/2.0/README @@ -0,0 +1,99 @@ +Upgrading from health@1.0 HAL + +0. Remove android.hardware.health@1.0* from PRDOUCT_PACKAGES + in device/<manufacturer>/<device>/device.mk + +1. If the device does not have a vendor-specific libhealthd AND does not + implement storage-related APIs, just add the following to PRODUCT_PACKAGES: + android.hardware.health@2.0-service + Otherwise, continue to Step 2. + +2. Create directory + device/<manufacturer>/<device>/health + +3. Create device/<manufacturer>/<device>/health/Android.bp + (or equivalent device/<manufacturer>/<device>/health/Android.mk) + +cc_binary { + name: "android.hardware.health@2.0-service.<device>", + init_rc: ["android.hardware.health@2.0-service.<device>.rc"], + proprietary: true, + relative_install_path: "hw", + srcs: [ + "HealthService.cpp", + ], + + cflags: [ + "-Wall", + "-Werror", + ], + + static_libs: [ + "android.hardware.health@2.0-impl", + "android.hardware.health@1.0-convert", + "libhealthservice", + "libbatterymonitor", + ], + + shared_libs: [ + "libbase", + "libcutils", + "libhidlbase", + "libhidltransport", + "libutils", + "android.hardware.health@2.0", + ], + + header_libs: ["libhealthd_headers"], +} + +4. Create device/<manufacturer>/<device>/health/android.hardware.health@2.0-service.<device>.rc + +service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.<device> + class hal + user system + group system + +5. Create device/<manufacturer>/<device>/health/HealthService.cpp: + +#include <health2/service.h> +int main() { return health_service_main(); } + +6. libhealthd dependency: + +6.1 If the device has a vendor-specific libhealthd.<soc>, add it to static_libs. + +6.2 If the device does not have a vendor-specific libhealthd, add the following + lines to HealthService.cpp: + +#include <healthd/healthd.h> +void healthd_board_init(struct healthd_config*) {} + +int healthd_board_battery_update(struct android::BatteryProperties*) { + // return 0 to log periodic polled battery status to kernel log + return 0; +} + +7. Storage related APIs: + +7.1 If the device does not implement IHealth.getDiskStats and + IHealth.getStorageInfo, add libstoragehealthdefault to static_libs. + +7.2 If the device implements one of these two APIs, add and implement the + following functions in HealthService.cpp: + +void get_storage_info(std::vector<struct StorageInfo>& info) { + // ... +} +void get_disk_stats(std::vector<struct DiskStats>& stats) { + // ... +} + +8. Update necessary SELinux permissions. For example, + +# device/<manufacturer>/<device>/sepolicy/vendor/file_contexts +/vendor/bin/hw/android\.hardware\.health@2\.0-service.<device> u:object_r:hal_health_default_exec:s0 + +# device/<manufacturer>/<device>/sepolicy/vendor/hal_health_default.te +# Add device specific permissions to hal_health_default domain, especially +# if Step 6.2 or Step 7.2 is done. diff --git a/health/2.0/utils/README b/health/2.0/utils/README new file mode 100644 index 000000000..1d5c27f35 --- /dev/null +++ b/health/2.0/utils/README @@ -0,0 +1,28 @@ +* libhealthhalutils + +A convenience library for (hwbinder) clients of health HAL to choose between +the "default" instance (served by vendor service) or "backup" instance (served +by healthd). C++ clients of health HAL should use this library instead of +calling IHealth::getService() directly. + +Its Java equivalent can be found in BatteryService.HealthServiceWrapper. + +* libhealthservice + +Common code for all (hwbinder) services of the health HAL, including healthd and +vendor health service android.hardware.health@2.0-service(.<vendor>). main() in +those binaries calls health_service_main() directly. + +* libhealthstoragedefault + +Default implementation for storage related APIs for (hwbinder) services of the +health HAL. If an implementation of the health HAL do not wish to provide any +storage info, include this library. Otherwise, it should implement the following +two functions: + +void get_storage_info(std::vector<struct StorageInfo>& info) { + // ... +} +void get_disk_stats(std::vector<struct DiskStats>& stats) { + // ... +} |