2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "VibratorService"
21 #include "android_runtime/AndroidRuntime.h"
23 #include <utils/misc.h>
24 #include <utils/Log.h>
25 #include <hardware_legacy/vibrator.h>
32 static jboolean vibratorExists(JNIEnv *env, jobject clazz)
34 return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE;
37 static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
39 // ALOGI("vibratorOn\n");
40 vibrator_on(timeout_ms);
43 static void vibratorOff(JNIEnv *env, jobject clazz)
45 // ALOGI("vibratorOff\n");
49 static JNINativeMethod method_table[] = {
50 { "vibratorExists", "()Z", (void*)vibratorExists },
51 { "vibratorOn", "(J)V", (void*)vibratorOn },
52 { "vibratorOff", "()V", (void*)vibratorOff }
55 int register_android_server_VibratorService(JNIEnv *env)
57 return jniRegisterNativeMethods(env, "com/android/server/VibratorService",
58 method_table, NELEM(method_table));