Support AIDL Vibrator
co-authored by: SebaUbuntu <barezzisebastiano@gmail.com>
Change-Id: Ifaa0af4cb0fe0dee7d2a9ad4c58a5ede5ce46d59
diff --git a/minuitwrp/events.cpp b/minuitwrp/events.cpp
index 34c01e3..8abf055 100644
--- a/minuitwrp/events.cpp
+++ b/minuitwrp/events.cpp
@@ -32,6 +32,13 @@
#include <android/hardware/vibrator/1.2/IVibrator.h>
#endif
+#ifdef USE_QTI_AIDL_HAPTICS
+#include <aidl/android/hardware/vibrator/IVibrator.h>
+#include <android/binder_manager.h>
+using ::aidl::android::hardware::vibrator::IVibrator;
+static const std::string kVibratorInstance = std::string(IVibrator::descriptor) + "/default";
+#endif
+
#include "common.h"
#include "minuitwrp/minui.h"
@@ -140,6 +147,11 @@
if (vib != nullptr) {
vib->on((uint32_t)timeout_ms);
}
+#elif defined(USE_QTI_AIDL_HAPTICS)
+ std::shared_ptr<IVibrator> vib = IVibrator::fromBinder(ndk::SpAIBinder(AServiceManager_getService(kVibratorInstance.c_str())));
+ if (vib != nullptr) {
+ vib->on((uint32_t)timeout_ms, nullptr);
+ }
#else
if (std::ifstream(LEDS_HAPTICS_ACTIVATE_FILE).good()) {
write_to_file(LEDS_HAPTICS_DURATION_FILE, tout);