Merge "Change how to load native lib to be on the safe side"

This commit is contained in:
Ken Wakasa 2011-02-25 01:25:10 -08:00 committed by Android (Google) Code Review
commit 654db88d35
4 changed files with 16 additions and 8 deletions

View file

@ -16,6 +16,8 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import com.android.inputmethod.latin.Utils;
public class ProximityInfo { public class ProximityInfo {
public static final int MAX_PROXIMITY_CHARS_SIZE = 16; public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
@ -34,6 +36,9 @@ public class ProximityInfo {
} }
private int mNativeProximityInfo; private int mNativeProximityInfo;
static {
Utils.loadNativeLibrary();
}
private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth, private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth,
int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray); int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray);
private native void releaseProximityInfoNative(int nativeProximityInfo); private native void releaseProximityInfoNative(int nativeProximityInfo);

View file

@ -109,6 +109,9 @@ public class BinaryDictionary extends Dictionary {
return sInstance; return sInstance;
} }
static {
Utils.loadNativeLibrary();
}
private native int openNative(String sourceDir, long dictOffset, long dictSize, private native int openNative(String sourceDir, long dictOffset, long dictSize,
int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength,
int maxWords, int maxAlternatives); int maxWords, int maxAlternatives);

View file

@ -211,14 +211,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private final ArrayList<WordAlternatives> mWordHistory = new ArrayList<WordAlternatives>(); private final ArrayList<WordAlternatives> mWordHistory = new ArrayList<WordAlternatives>();
static {
try {
System.loadLibrary("jni_latinime");
} catch (UnsatisfiedLinkError ule) {
Log.e(TAG, "Could not load native library jni_latinime");
}
}
public abstract static class WordAlternatives { public abstract static class WordAlternatives {
protected CharSequence mChosenWord; protected CharSequence mChosenWord;

View file

@ -553,4 +553,12 @@ public class Utils {
public static int getMainDictionaryResourceId(Resources res) { public static int getMainDictionaryResourceId(Resources res) {
return res.getIdentifier("main", "raw", LatinIME.class.getPackage().getName()); return res.getIdentifier("main", "raw", LatinIME.class.getPackage().getName());
} }
public static void loadNativeLibrary() {
try {
System.loadLibrary("jni_latinime");
} catch (UnsatisfiedLinkError ule) {
Log.e(TAG, "Could not load native library jni_latinime");
}
}
} }