summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-11-04 11:39:12 -0700
committerDianne Hackborn <hackbod@google.com>2010-11-04 13:01:56 -0700
commitea9020e0854427d47e566a1394df6749f3265410 (patch)
tree6d0ec3569fc36c5bbf368a5317d119508feddb8d /services
parentd8d7b555cb45bf55f74e89a7cf9312e400f7cd1c (diff)
downloadframeworks_base-ea9020e0854427d47e566a1394df6749f3265410.zip
frameworks_base-ea9020e0854427d47e566a1394df6749f3265410.tar.gz
frameworks_base-ea9020e0854427d47e566a1394df6749f3265410.tar.bz2
Add API to find out if there is a vibrator.
Change-Id: If29f6ee19448222433cad9fad325d0095a8e5737
Diffstat (limited to 'services')
-rwxr-xr-xservices/java/com/android/server/VibratorService.java5
-rw-r--r--services/jni/com_android_server_VibratorService.cpp6
2 files changed, 11 insertions, 0 deletions
diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java
index f0b5955..2fcdb5d 100755
--- a/services/java/com/android/server/VibratorService.java
+++ b/services/java/com/android/server/VibratorService.java
@@ -112,6 +112,10 @@ public class VibratorService extends IVibratorService.Stub {
context.registerReceiver(mIntentReceiver, filter);
}
+ public boolean hasVibrator() {
+ return vibratorExists();
+ }
+
public void vibrate(long milliseconds, IBinder token) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED) {
@@ -380,6 +384,7 @@ public class VibratorService extends IVibratorService.Stub {
volatile VibrateThread mThread;
+ native static boolean vibratorExists();
native static void vibratorOn(long milliseconds);
native static void vibratorOff();
}
diff --git a/services/jni/com_android_server_VibratorService.cpp b/services/jni/com_android_server_VibratorService.cpp
index 6ec5c07..0912d43 100644
--- a/services/jni/com_android_server_VibratorService.cpp
+++ b/services/jni/com_android_server_VibratorService.cpp
@@ -29,6 +29,11 @@
namespace android
{
+static jboolean vibratorExists(JNIEnv *env, jobject clazz)
+{
+ return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE;
+}
+
static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
{
// LOGI("vibratorOn\n");
@@ -42,6 +47,7 @@ static void vibratorOff(JNIEnv *env, jobject clazz)
}
static JNINativeMethod method_table[] = {
+ { "vibratorExists", "()Z", (void*)vibratorExists },
{ "vibratorOn", "(J)V", (void*)vibratorOn },
{ "vibratorOff", "()V", (void*)vibratorOff }
};