Simplify EVS HAL and move to "agressive opens"
This adapts the API implementation to allow a duplicate "open" operation
to automatically close any previous connections to the device. This
works around a binder level issue that can cause destructors triggered
by remote clients to be delivered out of order to the server.
This was originally change ag/1969959 on master, but has been
recreated on oc-dev (cherry-picking was broken at the time).
The original master change will be abandoned in favor of this getting
merged down from oc-dev.
Test: Run Vts test (added in following change)
Change-Id: I7b417998e59a4d592fbb91811c4101f39097c5dd
diff --git a/automotive/evs/1.0/default/EvsEnumerator.h b/automotive/evs/1.0/default/EvsEnumerator.h
index 3d6e264..6b70f9b 100644
--- a/automotive/evs/1.0/default/EvsEnumerator.h
+++ b/automotive/evs/1.0/default/EvsEnumerator.h
@@ -22,7 +22,6 @@
#include <list>
-#include "EvsCamera.h"
namespace android {
namespace hardware {
@@ -31,6 +30,11 @@
namespace V1_0 {
namespace implementation {
+
+class EvsCamera; // from EvsCamera.h
+class EvsDisplay; // from EvsDisplay.h
+
+
class EvsEnumerator : public IEvsEnumerator {
public:
// Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow.
@@ -45,14 +49,18 @@
EvsEnumerator();
private:
+ // NOTE: All members values are static so that all clients operate on the same state
+ // That is to say, this is effectively a singleton despite the fact that HIDL
+ // constructs a new instance for each client.
struct CameraRecord {
- sp<EvsCamera> pCamera;
- bool inUse;
- CameraRecord(EvsCamera* p, bool b) : pCamera(p), inUse(b) {}
- };
- std::list<CameraRecord> mCameraList;
+ CameraDesc desc;
+ wp<EvsCamera> activeInstance;
- wp<IEvsDisplay> mActiveDisplay; // Weak pointer -> object destructs if client dies
+ CameraRecord(const char *cameraId) : desc() { desc.cameraId = cameraId; }
+ };
+ static std::list<CameraRecord> sCameraList;
+
+ static wp<EvsDisplay> sActiveDisplay; // Weak pointer. Object destructs if client dies.
};
} // namespace implementation