Merge remote-tracking branch 'origin/Bitra.LA.3.2.1-target' into fp4t-target-0414
diff --git a/aidl/Vibrator.cpp b/aidl/Vibrator.cpp
index fab0415..49668d2 100644
--- a/aidl/Vibrator.cpp
+++ b/aidl/Vibrator.cpp
@@ -57,10 +57,15 @@
#define CUSTOM_DATA_LEN 3
#define NAME_BUF_SIZE 32
+#define VIB_LED 0x01
+#define VIB_AW 0x02
+
+#define VIB_ALL (VIB_LED|VIB_AW)
+
#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
static const char LED_DEVICE[] = "/sys/class/leds/vibrator";
-
+static const char AW_DEVICE[] = "/sys/class/leds/vibrator_aw8695";
InputFFDevice::InputFFDevice()
{
DIR *dp;
@@ -319,14 +324,26 @@
int fd;
mDetected = false;
+ vibrator_dev = VIB_ALL;
snprintf(devicename, sizeof(devicename), "%s/%s", LED_DEVICE, "activate");
fd = TEMP_FAILURE_RETRY(open(devicename, O_RDWR));
if (fd < 0) {
ALOGE("open %s failed, errno = %d", devicename, errno);
- return;
+ vibrator_dev &= ~ VIB_LED;
+ // return;
}
+ snprintf(devicename, sizeof(devicename), "%s/%s", AW_DEVICE, "activate");
+ fd = TEMP_FAILURE_RETRY(open(devicename, O_RDWR));
+ if (fd < 0) {
+ ALOGE("open %s failed, errno = %d", devicename, errno);
+ vibrator_dev &= ~ VIB_AW;
+ }
+ ALOGI("vibrator device = %d", vibrator_dev);
+ if(!vibrator_dev)
+ return;
+
mDetected = true;
}
@@ -364,6 +381,30 @@
char value[32];
int ret;
+ if(vibrator_dev & VIB_AW)
+ {
+ ALOGI("AwVibrator time = %d ",timeoutMs);
+
+ snprintf(file, sizeof(file), "%s/%s", AW_DEVICE, "activate_mode");
+ ret = write_value(file, "0");
+ if (ret < 0)
+ goto error;
+
+
+ snprintf(file, sizeof(file), "%s/%s", AW_DEVICE, "duration");
+ snprintf(value, sizeof(value), "%u\n", timeoutMs);
+ ret = write_value(file, value);
+ if (ret < 0)
+ goto error;
+
+ snprintf(file, sizeof(file), "%s/%s", AW_DEVICE, "activate");
+ ret = write_value(file, "1");
+ if (ret < 0)
+ goto error;
+
+ return 0;
+ }
+
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "state");
ret = write_value(file, "1");
if (ret < 0)
@@ -391,6 +432,13 @@
{
char file[PATH_MAX];
int ret;
+ ALOGI("LedVibrator device = %d ",vibrator_dev);
+ if(vibrator_dev & VIB_AW)
+ {
+ snprintf(file, sizeof(file), "%s/%s", AW_DEVICE, "activate");
+ ret = write_value(file, "0");
+ return ret;
+ }
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "activate");
ret = write_value(file, "0");
diff --git a/aidl/include/Vibrator.h b/aidl/include/Vibrator.h
index 8bfa9f5..dfecc65 100644
--- a/aidl/include/Vibrator.h
+++ b/aidl/include/Vibrator.h
@@ -60,6 +60,7 @@
int on(int32_t timeoutMs);
int off();
bool mDetected;
+ uint8_t vibrator_dev;
private:
int write_value(const char *file, const char *value);
};