[1 of 4][ALM:10923711] [FP4]:develope aw8695 vibrator

 &&&%%%comment:[FP4]:develope aw8695 vibrator
 &&&%%%bug number:10923711
 &&&%%%product name:sm7225_r_fp4
 &&&%%%root cause:Coding
 &&&%%%Bug category:T2M
 &&&%%%Module_Impact:vendor
 &&&%%%Test_Suggestion:reset
 &&&%%%Solution:develope hal
 &&&%%%Test_Report:local test is ok
 &&&%%%VAL Can Test:NO

Change-Id: I19233a33132004ee9fb1472c10513b9773b0c6ad
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);
 };