1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
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
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#define LOG_TAG "VibratorService"
18
19#include "jni.h"
20#include "JNIHelp.h"
21#include "android_runtime/AndroidRuntime.h"
22
23#include <utils/misc.h>
24#include <utils/Log.h>
25#include <hardware_legacy/vibrator.h>
26
27#include <stdio.h>
28
29namespace android
30{
31
32static jboolean vibratorExists(JNIEnv *env, jobject clazz)
33{
34    return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE;
35}
36
37static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
38{
39    // ALOGI("vibratorOn\n");
40    vibrator_on(timeout_ms);
41}
42
43static void vibratorOff(JNIEnv *env, jobject clazz)
44{
45    // ALOGI("vibratorOff\n");
46    vibrator_off();
47}
48
49static JNINativeMethod method_table[] = {
50    { "vibratorExists", "()Z", (void*)vibratorExists },
51    { "vibratorOn", "(J)V", (void*)vibratorOn },
52    { "vibratorOff", "()V", (void*)vibratorOff }
53};
54
55int register_android_server_VibratorService(JNIEnv *env)
56{
57    return jniRegisterNativeMethods(env, "com/android/server/VibratorService",
58            method_table, NELEM(method_table));
59}
60
61};
62