blob: f02c9a052d18cd97a878a9575b18d8b0ab7b1030 [file] [log] [blame]
satok8fbd5522011-02-22 17:28:55 +09001/*
2**
3** Copyright 2011, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#define LOG_TAG "LatinIME: jni"
19
20#include "com_android_inputmethod_keyboard_ProximityInfo.h"
21#include "com_android_inputmethod_latin_BinaryDictionary.h"
22#include "jni.h"
23#include "proximity_info.h"
24
25#include <assert.h>
26#include <errno.h>
27#include <stdio.h>
28
29// ----------------------------------------------------------------------------
30
31using namespace latinime;
32
33
34/*
35 * Returns the JNI version on success, -1 on failure.
36 */
37jint JNI_OnLoad(JavaVM* vm, void* reserved) {
38 JNIEnv* env = NULL;
39 jint result = -1;
40
41 if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
42 LOGE("ERROR: GetEnv failed");
43 goto bail;
44 }
45 assert(env != NULL);
46
47 if (!register_BinaryDictionary(env)) {
48 LOGE("ERROR: BinaryDictionary native registration failed");
49 goto bail;
50 }
51
52 if (!register_ProximityInfo(env)) {
53 LOGE("ERROR: ProximityInfo native registration failed");
54 goto bail;
55 }
56
57 /* success -- return valid version number */
58 result = JNI_VERSION_1_4;
59
60bail:
61 return result;
62}