Add health service 2.0 goldfish
Bug: 110263143
Test: Build and run emulator. lshal shows
android.hardware.health@2.0::IHealth/backup served by process
health service 2.0 goldfish
Change-Id: I1055d73cf001c5219c841a25e28eaa4d30f1af52
diff --git a/health/Android.bp b/health/Android.bp
new file mode 100644
index 0000000..aab4fa9
--- /dev/null
+++ b/health/Android.bp
@@ -0,0 +1,30 @@
+cc_binary {
+ name: "android.hardware.health@2.0-service.goldfish",
+ init_rc: ["android.hardware.health@2.0-service.goldfish.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",
+ "libhealthstoragedefault",
+ ],
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.health@2.0",
+ ],
+ header_libs: ["libhealthd_headers"],
+}
diff --git a/health/HealthService.cpp b/health/HealthService.cpp
new file mode 100644
index 0000000..2498a5c
--- /dev/null
+++ b/health/HealthService.cpp
@@ -0,0 +1,12 @@
+#include <health2/service.h>
+#include <healthd/healthd.h>
+
+int main() {
+ return health_service_main();
+}
+
+void healthd_board_init(struct healthd_config*) {}
+
+int healthd_board_battery_update(struct android::BatteryProperties*) {
+ return 0;
+}
diff --git a/health/android.hardware.health@2.0-service.goldfish.rc b/health/android.hardware.health@2.0-service.goldfish.rc
new file mode 100644
index 0000000..ecd42e4
--- /dev/null
+++ b/health/android.hardware.health@2.0-service.goldfish.rc
@@ -0,0 +1,5 @@
+service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.goldfish
+ class hal
+ user system
+ group system
+ file /dev/kmsg w
diff --git a/manifest.xml b/manifest.xml
index 8b7e695..413042d 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -219,6 +219,15 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="hidl">
+ <name>android.hardware.health</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IHealth</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<sepolicy>
<version>27.0</version>
</sepolicy>
diff --git a/sepolicy/common/file_contexts b/sepolicy/common/file_contexts
index c9712a2..c0c7e5e 100644
--- a/sepolicy/common/file_contexts
+++ b/sepolicy/common/file_contexts
@@ -30,6 +30,7 @@
/vendor/bin/hw/android\.hardware\.drm@1\.1-service\.widevine u:object_r:hal_drm_widevine_exec:s0
/vendor/bin/hw/android\.hardware\.drm@1\.1-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0
/vendor/bin/hw/android\.hardware\.keymaster@4\.0-strongbox-service u:object_r:hal_keymaster_default_exec:s0
+/vendor/bin/hw/android\.hardware\.health@2\.0-service.goldfish u:object_r:hal_health_default_exec:s0
/vendor/lib(64)?/hw/gralloc\.ranchu\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/hw/gralloc\.goldfish\.default\.so u:object_r:same_process_hal_file:s0
diff --git a/vendor.mk b/vendor.mk
index 416313e..5d702d9 100644
--- a/vendor.mk
+++ b/vendor.mk
@@ -75,6 +75,9 @@
android.hardware.soundtrigger@2.0-impl
PRODUCT_PACKAGES += \
+ android.hardware.health@2.0-service.goldfish
+
+PRODUCT_PACKAGES += \
android.hardware.keymaster@3.0-impl \
android.hardware.keymaster@3.0-service