MH2 | Add rough proxy callback postEvents method
Add post events method to HalProxyCallback without fully implementing
the wakeup events handling and pending blocking writes. Also change
mSensorList of the halProxy to mSensors which is a map from sensorHandle
to sensorInfo so that getNumWakeupEvents method of callback can find
sensorinfo info from sensorhandle of event type. Instantiate
halproxycallback vector in HalProxy for each subhal in the ctor as well.
Add very simple test for the postEvents method of callback.
Bug: 136511617
Test: New unit test passes.
Change-Id: I39c861cff286f24992bfcfcaa6bb468b4544b0e0
diff --git a/sensors/2.0/multihal/include/SubHal.h b/sensors/2.0/multihal/include/SubHal.h
index e84cba5..6181e0b 100644
--- a/sensors/2.0/multihal/include/SubHal.h
+++ b/sensors/2.0/multihal/include/SubHal.h
@@ -21,10 +21,6 @@
#include <vector>
-using ::android::hardware::sensors::V1_0::Event;
-using ::android::hardware::sensors::V1_0::Result;
-using ::android::hardware::sensors::V1_0::SensorInfo;
-
// Indicates the current version of the multiHAL interface formatted as (HAL major version) << 24 |
// (HAL minor version) << 16 | (multiHAL version)
#define SUB_HAL_2_0_VERSION 0x02000000
@@ -35,6 +31,10 @@
namespace V2_0 {
namespace implementation {
+using ::android::hardware::sensors::V1_0::Event;
+using ::android::hardware::sensors::V1_0::Result;
+using ::android::hardware::sensors::V1_0::SensorInfo;
+
/**
* Wrapper around wake lock acquisition functions (acquire/release_wake_lock) that provides a
* RAII-style mechanism for keeping a wake lock held for the duration of a scoped block.
@@ -68,7 +68,7 @@
bool mLocked;
private:
- // TODO: Mark HalProxy's subclass of ScopedWakelock as a friend so that it can be initialized.
+ friend class HalProxyCallback;
ScopedWakelock();
ScopedWakelock(const ScopedWakelock&) = delete;
ScopedWakelock& operator=(const ScopedWakelock&) = delete;
@@ -169,7 +169,9 @@
/**
* First method invoked on the sub-HAL after it's allocated through sensorsHalGetSubHal() by the
* HalProxy. Sub-HALs should use this to initialize any state and retain the callback given in
- * order to communicate with the HalProxy.
+ * order to communicate with the HalProxy. Method will be called anytime the sensors framework
+ * restarts. Therefore, this method will be responsible for reseting the state of the subhal and
+ * cleaning up and reallocating any previously allocated data.
*
* @param halProxyCallback callback used to inform the HalProxy when a dynamic sensor's state
* changes, new sensor events should be sent to the framework, and when a new ScopedWakelock