Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 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 | |
| 29 | namespace android |
| 30 | { |
| 31 | |
Andreas Gampe | 26872f4 | 2014-09-24 21:39:34 -0700 | [diff] [blame] | 32 | static jboolean vibratorExists(JNIEnv* /* env */, jobject /* clazz */) |
Dianne Hackborn | ea9020e | 2010-11-04 11:39:12 -0700 | [diff] [blame] | 33 | { |
| 34 | return vibrator_exists() > 0 ? JNI_TRUE : JNI_FALSE; |
| 35 | } |
| 36 | |
Andreas Gampe | 26872f4 | 2014-09-24 21:39:34 -0700 | [diff] [blame] | 37 | static void vibratorOn(JNIEnv* /* env */, jobject /* clazz */, jlong timeout_ms) |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 38 | { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 39 | // ALOGI("vibratorOn\n"); |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 40 | vibrator_on(timeout_ms); |
| 41 | } |
| 42 | |
Andreas Gampe | 26872f4 | 2014-09-24 21:39:34 -0700 | [diff] [blame] | 43 | static void vibratorOff(JNIEnv* /* env */, jobject /* clazz */) |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 44 | { |
Steve Block | 6215d3f | 2012-01-04 20:05:49 +0000 | [diff] [blame] | 45 | // ALOGI("vibratorOff\n"); |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 46 | vibrator_off(); |
| 47 | } |
| 48 | |
| 49 | static JNINativeMethod method_table[] = { |
Dianne Hackborn | ea9020e | 2010-11-04 11:39:12 -0700 | [diff] [blame] | 50 | { "vibratorExists", "()Z", (void*)vibratorExists }, |
Mike Lockwood | 3a32213 | 2009-11-24 00:30:52 -0500 | [diff] [blame] | 51 | { "vibratorOn", "(J)V", (void*)vibratorOn }, |
| 52 | { "vibratorOff", "()V", (void*)vibratorOff } |
| 53 | }; |
| 54 | |
| 55 | int register_android_server_VibratorService(JNIEnv *env) |
| 56 | { |
| 57 | return jniRegisterNativeMethods(env, "com/android/server/VibratorService", |
| 58 | method_table, NELEM(method_table)); |
| 59 | } |
| 60 | |
| 61 | }; |