Make libhardware host_supported
This requires dropping a header file and avoiding a missing strlcpy API.
Required for host_supported fuzzers that include this lib.
Test: libsensorserviceaidl_fuzzer
Bug: 205764765
Change-Id: Ib1d2851e915ed87ef2936a044e7a72bab3077f40
diff --git a/hardware.c b/hardware.c
index 6e72ce9..d0e91e9 100644
--- a/hardware.c
+++ b/hardware.c
@@ -30,7 +30,7 @@
#define LOG_TAG "HAL"
#include <log/log.h>
-#if !defined(__ANDROID_RECOVERY__)
+#if !defined(__ANDROID_RECOVERY__) && defined(__ANDROID__)
#include <vndksupport/linker.h>
#endif
@@ -97,7 +97,7 @@
*/
handle = dlopen(path, RTLD_NOW);
} else {
-#if defined(__ANDROID_RECOVERY__)
+#if defined(__ANDROID_RECOVERY__) || !defined(__ANDROID__)
handle = dlopen(path, RTLD_NOW);
#else
handle = android_load_sphal_library(path, RTLD_NOW);
@@ -206,8 +206,13 @@
if (inst)
snprintf(name, PATH_MAX, "%s.%s", class_id, inst);
+#if defined(__ANDROID__)
else
strlcpy(name, class_id, PATH_MAX);
+#else
+ else
+ snprintf(name, PATH_MAX, "%s", class_id);
+#endif
/*
* Here we rely on the fact that calling dlopen multiple times on