am 81451030: Merge "Fix JNI" into jb-mr1-dev
* commit '814510305c21b3081414e75e040dec4b73f6cdf3': Fix JNImain
commit
f9b2841fb5
|
@ -44,6 +44,10 @@
|
||||||
<init>(...);
|
<init>(...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
native <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
-keep class com.android.inputmethod.research.ResearchLogger {
|
-keep class com.android.inputmethod.research.ResearchLogger {
|
||||||
void flush();
|
void flush();
|
||||||
void publishCurrentLogUnit(...);
|
void publishCurrentLogUnit(...);
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
mUseFullEditDistance = useFullEditDistance;
|
mUseFullEditDistance = useFullEditDistance;
|
||||||
loadDictionary(filename, offset, length);
|
loadDictionary(filename, offset, length);
|
||||||
mDicTraverseSession = new DicTraverseSession(locale);
|
mDicTraverseSession = new DicTraverseSession(locale);
|
||||||
|
mDicTraverseSession.initSession(mNativeDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -23,8 +23,8 @@ public class DicTraverseSession {
|
||||||
JniUtils.loadNativeLibrary();
|
JniUtils.loadNativeLibrary();
|
||||||
}
|
}
|
||||||
private native long setDicTraverseSessionNative(String locale);
|
private native long setDicTraverseSessionNative(String locale);
|
||||||
//private native void initDicTraverseSessionNative(long nativeDicTraverseSession,
|
private native void initDicTraverseSessionNative(long nativeDicTraverseSession,
|
||||||
//long dictionary, int[] previousWord, int previousWordLength);
|
long dictionary, int[] previousWord, int previousWordLength);
|
||||||
private native void releaseDicTraverseSessionNative(long nativeDicTraverseSession);
|
private native void releaseDicTraverseSessionNative(long nativeDicTraverseSession);
|
||||||
|
|
||||||
private long mNativeDicTraverseSession;
|
private long mNativeDicTraverseSession;
|
||||||
|
@ -43,8 +43,8 @@ public class DicTraverseSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initSession(long dictionary, int[] previousWord, int previousWordLength) {
|
public void initSession(long dictionary, int[] previousWord, int previousWordLength) {
|
||||||
//initDicTraverseSessionNative(
|
initDicTraverseSessionNative(
|
||||||
//mNativeDicTraverseSession, dictionary, previousWord, previousWordLength);
|
mNativeDicTraverseSession, dictionary, previousWord, previousWordLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final long createNativeDicTraverseSession(String locale) {
|
private final long createNativeDicTraverseSession(String locale) {
|
||||||
|
|
|
@ -28,18 +28,20 @@ static jlong latinime_setDicTraverseSession(JNIEnv *env, jobject object, jstring
|
||||||
return reinterpret_cast<jlong>(traverseSession);
|
return reinterpret_cast<jlong>(traverseSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void latinime_initDicTraverseSession(JNIEnv *env, jobject object, jlong traverseSession,
|
static void latinime_initDicTraverseSession(JNIEnv *env, jobject object, jlong traverseSession,
|
||||||
jlong dictionary, jintArray previousWord, jint previousWordLength) {
|
jlong dictionary, jintArray previousWord, jint previousWordLength) {
|
||||||
void *ts = reinterpret_cast<void*>(traverseSession);
|
void *ts = reinterpret_cast<void*>(traverseSession);
|
||||||
Dictionary *dict = reinterpret_cast<Dictionary*>(dictionary);
|
Dictionary *dict = reinterpret_cast<Dictionary*>(dictionary);
|
||||||
|
if (!previousWord) {
|
||||||
|
DicTraverseWrapper::initDicTraverseSession(ts, dict, 0, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int prevWord[previousWordLength];
|
int prevWord[previousWordLength];
|
||||||
env->GetIntArrayRegion(previousWord, 0, previousWordLength, prevWord);
|
env->GetIntArrayRegion(previousWord, 0, previousWordLength, prevWord);
|
||||||
DicTraverseWrapper::initDicTraverseSession(ts, dict, prevWord, previousWordLength);
|
DicTraverseWrapper::initDicTraverseSession(ts, dict, prevWord, previousWordLength);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void latinime_DicTraverseSession_release(
|
static void latinime_releaseDicTraverseSession(
|
||||||
JNIEnv *env, jobject object, jlong traverseSession) {
|
JNIEnv *env, jobject object, jlong traverseSession) {
|
||||||
void *ts = reinterpret_cast<void*>(traverseSession);
|
void *ts = reinterpret_cast<void*>(traverseSession);
|
||||||
DicTraverseWrapper::releaseDicTraverseSession(ts);
|
DicTraverseWrapper::releaseDicTraverseSession(ts);
|
||||||
|
@ -47,8 +49,8 @@ static void latinime_DicTraverseSession_release(
|
||||||
|
|
||||||
static JNINativeMethod sMethods[] = {
|
static JNINativeMethod sMethods[] = {
|
||||||
{"setDicTraverseSessionNative", "(Ljava/lang/String;)J", (void*)latinime_setDicTraverseSession},
|
{"setDicTraverseSessionNative", "(Ljava/lang/String;)J", (void*)latinime_setDicTraverseSession},
|
||||||
//{"initDicTraverseSessionNative", "(JJ[II)V", (void*)latinime_initDicTraverseSession},
|
{"initDicTraverseSessionNative", "(JJ[II)V", (void*)latinime_initDicTraverseSession},
|
||||||
{"releaseDicTraverseSessionNative", "(J)V", (void*)latinime_DicTraverseSession_release}
|
{"releaseDicTraverseSessionNative", "(J)V", (void*)latinime_releaseDicTraverseSession}
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_DicTraverseSession(JNIEnv *env) {
|
int register_DicTraverseSession(JNIEnv *env) {
|
||||||
|
|
Loading…
Reference in New Issue