am f9b2841f: am 81451030: Merge "Fix JNI" into jb-mr1-dev

* commit 'f9b2841fb592778ad34b5181e1c0bcbf551e3632':
  Fix JNI
main
satok 2012-08-12 18:32:43 -07:00 committed by Android Git Automerger
commit 078a0028d6
4 changed files with 16 additions and 9 deletions

View File

@ -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(...);

View File

@ -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 {

View File

@ -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) {

View File

@ -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) {