Create vibrator manager HAL wrapper
Create wrapper class for the future IVibratorManager HAL service, with a
legacy implementation over existing IVibrator HAL services (using
existing wrappers and controller for those).
Bug: 166586119
Test: atest libvibratorservice_test
Change-Id: If20a7ab8398e4456d0665d8c3bd1d6806697ed5b
diff --git a/services/vibratorservice/VibratorHalController.cpp b/services/vibratorservice/VibratorHalController.cpp
index 46175ad..e8606ca 100644
--- a/services/vibratorservice/VibratorHalController.cpp
+++ b/services/vibratorservice/VibratorHalController.cpp
@@ -46,8 +46,6 @@
// -------------------------------------------------------------------------------------------------
-static constexpr int MAX_RETRIES = 1;
-
std::shared_ptr<HalWrapper> HalConnector::connect(std::shared_ptr<CallbackScheduler> scheduler) {
static bool gHalExists = true;
if (!gHalExists) {
@@ -89,6 +87,8 @@
// -------------------------------------------------------------------------------------------------
+static constexpr int MAX_RETRIES = 1;
+
template <typename T>
HalResult<T> HalController::processHalResult(HalResult<T> result, const char* functionName) {
if (result.isFailed()) {
@@ -126,11 +126,12 @@
// -------------------------------------------------------------------------------------------------
-void HalController::init() {
+bool HalController::init() {
std::lock_guard<std::mutex> lock(mConnectedHalMutex);
if (mConnectedHal == nullptr) {
mConnectedHal = mHalConnector->connect(mCallbackScheduler);
}
+ return mConnectedHal != nullptr;
}
HalResult<void> HalController::ping() {