Initial Contribution
diff --git a/vibrator/Android.mk b/vibrator/Android.mk
new file mode 100644
index 0000000..6681f84
--- /dev/null
+++ b/vibrator/Android.mk
@@ -0,0 +1,4 @@
+# Copyright 2006 The Android Open Source Project
+
+LOCAL_SRC_FILES += vibrator/vibrator.c
+
diff --git a/vibrator/vibrator.c b/vibrator/vibrator.c
new file mode 100644
index 0000000..fcea21c
--- /dev/null
+++ b/vibrator/vibrator.c
@@ -0,0 +1,36 @@
+#include <hardware/vibrator.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define THE_DEVICE "/sys/class/timed_output/vibrator/enable"
+
+static int sendit(int timeout_ms)
+{
+ int nwr, ret, fd;
+ char value[20];
+
+ fd = open(THE_DEVICE, O_RDWR);
+ if(fd < 0)
+ return errno;
+
+ nwr = sprintf(value, "%d\n", timeout_ms);
+ ret = write(fd, value, nwr);
+
+ close(fd);
+
+ return (ret == nwr) ? 0 : -1;
+}
+
+int vibrator_on()
+{
+ /* constant on, up to maximum allowed time */
+ return sendit(-1);
+}
+
+int vibrator_off()
+{
+ return sendit(0);
+}