1/*
2 * Copyright 2006, 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#include <hardware_legacy/flashlight.h>
18#include <hardware_legacy/power.h>
19
20#include <nativehelper/jni.h>
21#include <android_runtime/AndroidRuntime.h>
22#include <nativehelper/JNIHelp.h>
23
24namespace android {
25
26static jint
27getFlashlightEnabled(JNIEnv *env, jobject clazz)
28{
29    return get_flashlight_enabled();
30}
31
32static void
33setFlashlightEnabled(JNIEnv *env, jobject clazz, jboolean on)
34{
35    set_flashlight_enabled(on);
36}
37
38static void
39enableCameraFlash(JNIEnv *env, jobject clazz, jint milliseconds)
40{
41    enable_camera_flash(milliseconds);
42}
43
44// ============================================================================
45/*
46 * JNI registration.
47 */
48
49static JNINativeMethod g_methods[] = {
50    /* name, signature, funcPtr */
51    { "getFlashlightEnabled", "()Z", (void*)getFlashlightEnabled },
52    { "setFlashlightEnabled", "(Z)V", (void*)setFlashlightEnabled },
53    { "enableCameraFlash", "(I)V", (void*)enableCameraFlash },
54};
55
56int register_android_os_Hardware(JNIEnv* env)
57{
58    return AndroidRuntime::registerNativeMethods(env,
59            "android/os/Hardware", g_methods, NELEM(g_methods));
60}
61
62}; // namespace android
63