summaryrefslogtreecommitdiffstats
path: root/sensors
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@google.com>2016-11-17 00:14:07 -0800
committerNick Vaccaro <nvaccaro@google.com>2016-12-16 11:12:11 -0800
commitd133e4c326a9a7b5df11c016902ec6806be42f38 (patch)
treeb8844871ef927a97f9b5deb915d16aed78c25ed0 /sensors
parentabd17ba8b9e497704a77104059966f6025a51550 (diff)
downloadandroid_hardware_interfaces-d133e4c326a9a7b5df11c016902ec6806be42f38.tar.gz
android_hardware_interfaces-d133e4c326a9a7b5df11c016902ec6806be42f38.tar.bz2
android_hardware_interfaces-d133e4c326a9a7b5df11c016902ec6806be42f38.zip
Sensors: MultiHal: Add HIDL-based Multi-Hal
Add the ability to use more than a single sensor HAL to the HIDL sensor service. Bug: 32022308 Change-Id: I99866adbbbee6d93350327aaaba136682ae069ae
Diffstat (limited to 'sensors')
-rw-r--r--sensors/1.0/default/Android.bp3
-rw-r--r--sensors/1.0/default/Android.mk24
-rw-r--r--sensors/1.0/default/Sensors.cpp22
3 files changed, 32 insertions, 17 deletions
diff --git a/sensors/1.0/default/Android.bp b/sensors/1.0/default/Android.bp
index 7fbe117bb..994febe22 100644
--- a/sensors/1.0/default/Android.bp
+++ b/sensors/1.0/default/Android.bp
@@ -8,7 +8,6 @@ cc_library_shared {
"libhardware",
"libhwbinder",
"libbase",
- "libcutils",
"libutils",
"libhidlbase",
"libhidltransport",
@@ -16,6 +15,7 @@ cc_library_shared {
],
static_libs: [
"android.hardware.sensors@1.0-convert",
+ "multihal",
],
local_include_dirs: ["include/sensors"],
}
@@ -30,7 +30,6 @@ cc_library_static {
"libhardware",
"libhwbinder",
"libbase",
- "libcutils",
"libutils",
"libhidlbase",
"libhidltransport",
diff --git a/sensors/1.0/default/Android.mk b/sensors/1.0/default/Android.mk
index b2b2c609f..f37c3cb8f 100644
--- a/sensors/1.0/default/Android.mk
+++ b/sensors/1.0/default/Android.mk
@@ -5,21 +5,21 @@ LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE := android.hardware.sensors@1.0-service
LOCAL_INIT_RC := android.hardware.sensors@1.0-service.rc
LOCAL_SRC_FILES := \
- service.cpp \
+ service.cpp \
LOCAL_SHARED_LIBRARIES := \
- liblog \
- libcutils \
- libdl \
- libbase \
- libutils \
- libhardware_legacy \
- libhardware \
+ liblog \
+ libcutils \
+ libdl \
+ libbase \
+ libutils \
+ libhardware_legacy \
+ libhardware \
LOCAL_SHARED_LIBRARIES += \
- libhwbinder \
- libhidlbase \
- libhidltransport \
- android.hardware.sensors@1.0 \
+ libhwbinder \
+ libhidlbase \
+ libhidltransport \
+ android.hardware.sensors@1.0 \
include $(BUILD_EXECUTABLE)
diff --git a/sensors/1.0/default/Sensors.cpp b/sensors/1.0/default/Sensors.cpp
index ef052c3ed..c76369fb0 100644
--- a/sensors/1.0/default/Sensors.cpp
+++ b/sensors/1.0/default/Sensors.cpp
@@ -15,17 +15,29 @@
*/
#include "Sensors.h"
-
#include "convert.h"
+#include "multihal.h"
#include <android-base/logging.h>
+#include <sys/stat.h>
+
namespace android {
namespace hardware {
namespace sensors {
namespace V1_0 {
namespace implementation {
+/*
+ * If a multi-hal configuration file exists in the proper location,
+ * return true indicating we need to use multi-hal functionality.
+ */
+static bool UseMultiHal() {
+ const std::string& name = MULTI_HAL_CONFIG_FILE_PATH;
+ struct stat buffer;
+ return (stat (name.c_str(), &buffer) == 0);
+}
+
static Result ResultFromStatus(status_t err) {
switch (err) {
case OK:
@@ -43,10 +55,14 @@ Sensors::Sensors()
: mInitCheck(NO_INIT),
mSensorModule(nullptr),
mSensorDevice(nullptr) {
- status_t err = hw_get_module(
+ status_t err = OK;
+ if (UseMultiHal()) {
+ mSensorModule = ::get_multi_hal_module_info();
+ } else {
+ err = hw_get_module(
SENSORS_HARDWARE_MODULE_ID,
(hw_module_t const **)&mSensorModule);
-
+ }
if (mSensorModule == NULL) {
err = UNKNOWN_ERROR;
}