TWRP: Enable qti input haptics vibrators support

* these type of vibrators are present in newer devices based on
   board sm8150 & above. Like Oneplus 7 series, Redmi K20 Pro, etc.
 * to enable it add TW_SUPPORT_INPUT_1_2_HAPTICS := true in Boardconfig.mk
 * you will need to add the vendor vibrator service to init and run it in your device tree
Change-Id: I0fe6612def149e70808ca41829b6f7ba0b23cd62
Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
(cherry picked from commit 909daa959c99cf3a6abbe224ec3fc45669df4440)
This commit is contained in:
Mohd Faraz
2020-05-30 21:06:32 +05:30
committed by bigbiff
parent f654e8483b
commit bc576cde4b
3 changed files with 24 additions and 1 deletions

View File

@@ -10,6 +10,13 @@ LOCAL_SRC_FILES := \
graphics_utils.cpp \
events.cpp
ifeq ($(TW_SUPPORT_INPUT_1_2_HAPTICS),true)
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
LOCAL_SHARED_LIBRARIES += android.hardware.vibrator@1.2 libhidlbase
LOCAL_CFLAGS += -DUSE_QTI_HAPTICS
endif
endif
ifneq ($(TW_BOARD_CUSTOM_GRAPHICS),)
$(warning ****************************************************************************)
$(warning * TW_BOARD_CUSTOM_GRAPHICS support has been deprecated in TWRP. *)

View File

@@ -28,6 +28,10 @@
#include <string.h>
#include <fstream>
#ifdef USE_QTI_HAPTICS
#include <android/hardware/vibrator/1.2/IVibrator.h>
#endif
#include "../common.h"
#include "minui.h"
@@ -130,12 +134,18 @@ int vibrate(int timeout_ms)
char tout[6];
sprintf(tout, "%i", timeout_ms);
#ifdef USE_QTI_HAPTICS
android::sp<android::hardware::vibrator::V1_2::IVibrator> vib = android::hardware::vibrator::V1_2::IVibrator::getService();
if (vib != nullptr) {
vib->on((uint32_t)timeout_ms);
}
#else
if (std::ifstream(LEDS_HAPTICS_ACTIVATE_FILE).good()) {
write_to_file(LEDS_HAPTICS_DURATION_FILE, tout);
write_to_file(LEDS_HAPTICS_ACTIVATE_FILE, "1");
} else
write_to_file(VIBRATOR_TIMEOUT_FILE, tout);
#endif
return 0;
}
#endif

View File

@@ -280,6 +280,12 @@ ifeq ($(TW_INCLUDE_CRYPTO), true)
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/keystore_cli
RELINK_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/servicemanager
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.system.wifi.keystore@1.0.so
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.0.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.1.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.vibrator@1.2.so
endif
ifneq ($(wildcard system/keymaster/keymaster_stl.cpp),)
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_portable.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster_staging.so