From eaef1c500703b4ee378821884c7b108815ed2983 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 25 Feb 2011 18:21:02 +0900 Subject: [PATCH] Change how to load native lib to be on the safe side Change-Id: If170d4821b8dbc187f29137ea99d10e30c20955f --- .../com/android/inputmethod/keyboard/ProximityInfo.java | 5 +++++ .../com/android/inputmethod/latin/BinaryDictionary.java | 3 +++ java/src/com/android/inputmethod/latin/LatinIME.java | 8 -------- java/src/com/android/inputmethod/latin/Utils.java | 8 ++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index fe836c1e2..fcada3762 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -16,6 +16,8 @@ package com.android.inputmethod.keyboard; +import com.android.inputmethod.latin.Utils; + public class ProximityInfo { public static final int MAX_PROXIMITY_CHARS_SIZE = 16; @@ -34,6 +36,9 @@ public class ProximityInfo { } private int mNativeProximityInfo; + static { + Utils.loadNativeLibrary(); + } private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth, int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray); private native void releaseProximityInfoNative(int nativeProximityInfo); diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 33b8c7af6..55cd0848a 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -109,6 +109,9 @@ public class BinaryDictionary extends Dictionary { return sInstance; } + static { + Utils.loadNativeLibrary(); + } private native int openNative(String sourceDir, long dictOffset, long dictSize, int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int maxWords, int maxAlternatives); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 97f6b8d83..91fd5b01e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -211,14 +211,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private final ArrayList mWordHistory = new ArrayList(); - static { - try { - System.loadLibrary("jni_latinime"); - } catch (UnsatisfiedLinkError ule) { - Log.e(TAG, "Could not load native library jni_latinime"); - } - } - public abstract static class WordAlternatives { protected CharSequence mChosenWord; diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index f26766768..727e3f16d 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -553,4 +553,12 @@ public class Utils { public static int getMainDictionaryResourceId(Resources res) { 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"); + } + } }