2011-02-22 08:28:55 +00:00
|
|
|
/*
|
2013-01-08 08:57:26 +00:00
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
2012-07-25 09:51:43 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
2013-01-08 08:57:26 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-07-25 09:51:43 +01:00
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-02-22 08:28:55 +00:00
|
|
|
|
|
|
|
#define LOG_TAG "LatinIME: jni"
|
|
|
|
|
2013-04-08 09:08:19 +01:00
|
|
|
#include "jni_common.h"
|
|
|
|
|
2023-07-06 19:57:49 +01:00
|
|
|
#include "org_futo_inputmethod_keyboard_ProximityInfo.h"
|
|
|
|
#include "org_futo_inputmethod_latin_BinaryDictionary.h"
|
|
|
|
#include "org_futo_inputmethod_latin_BinaryDictionaryUtils.h"
|
|
|
|
#include "org_futo_inputmethod_latin_DicTraverseSession.h"
|
2012-05-16 15:05:32 +01:00
|
|
|
#include "defines.h"
|
2011-02-22 08:28:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the JNI version on success, -1 on failure.
|
|
|
|
*/
|
2012-07-25 09:51:43 +01:00
|
|
|
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|
|
|
JNIEnv *env = 0;
|
2011-02-22 08:28:55 +00:00
|
|
|
|
2012-08-14 06:22:27 +01:00
|
|
|
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGE("ERROR: GetEnv failed");
|
2013-01-08 08:57:26 +00:00
|
|
|
return -1;
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
2013-01-09 06:21:44 +00:00
|
|
|
ASSERT(env);
|
2013-01-08 08:57:26 +00:00
|
|
|
if (!env) {
|
|
|
|
AKLOGE("ERROR: JNIEnv is invalid");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (!latinime::register_BinaryDictionary(env)) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGE("ERROR: BinaryDictionary native registration failed");
|
2014-03-05 03:49:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (!latinime::register_BinaryDictionaryUtils(env)) {
|
|
|
|
AKLOGE("ERROR: BinaryDictionaryUtils native registration failed");
|
2013-01-08 08:57:26 +00:00
|
|
|
return -1;
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
2013-01-08 08:57:26 +00:00
|
|
|
if (!latinime::register_DicTraverseSession(env)) {
|
2012-08-08 11:40:44 +01:00
|
|
|
AKLOGE("ERROR: DicTraverseSession native registration failed");
|
2013-01-08 08:57:26 +00:00
|
|
|
return -1;
|
2012-08-08 11:40:44 +01:00
|
|
|
}
|
2013-01-08 08:57:26 +00:00
|
|
|
if (!latinime::register_ProximityInfo(env)) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGE("ERROR: ProximityInfo native registration failed");
|
2013-01-08 08:57:26 +00:00
|
|
|
return -1;
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
|
|
|
/* success -- return valid version number */
|
2013-01-08 08:57:26 +00:00
|
|
|
return JNI_VERSION_1_6;
|
2011-02-22 08:28:55 +00:00
|
|
|
}
|
2011-06-18 05:09:55 +01:00
|
|
|
|
|
|
|
namespace latinime {
|
2013-06-04 11:16:47 +01:00
|
|
|
int registerNativeMethods(JNIEnv *env, const char *const className, const JNINativeMethod *methods,
|
|
|
|
const int numMethods) {
|
2011-06-18 05:09:55 +01:00
|
|
|
jclass clazz = env->FindClass(className);
|
2012-07-30 08:27:44 +01:00
|
|
|
if (!clazz) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGE("Native registration unable to find class '%s'", className);
|
2011-06-18 05:09:55 +01:00
|
|
|
return JNI_FALSE;
|
|
|
|
}
|
2014-03-26 11:47:14 +00:00
|
|
|
if (env->RegisterNatives(clazz, methods, numMethods) != 0) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGE("RegisterNatives failed for '%s'", className);
|
2011-06-18 05:09:55 +01:00
|
|
|
env->DeleteLocalRef(clazz);
|
|
|
|
return JNI_FALSE;
|
|
|
|
}
|
|
|
|
env->DeleteLocalRef(clazz);
|
|
|
|
return JNI_TRUE;
|
|
|
|
}
|
|
|
|
} // namespace latinime
|