From 829b97b28d948cbdd38b6d9997e62a2a2eecf60b Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 25 Mar 2011 17:06:35 -0700 Subject: [PATCH] Fix lib and compat bugs. Compat issues will be merged to master. Change-Id: I3285606006483e247bea25ee77979cf71095b9c1 --- CleanSpec.mk | 2 +- java/Android.mk | 2 +- java/src/com/android/inputmethod/compat/CompatUtils.java | 1 + .../inputmethod/compat/InputMethodManagerCompatWrapper.java | 4 +++- .../inputmethod/compat/InputMethodSubtypeCompatWrapper.java | 3 ++- java/src/com/android/inputmethod/latin/Utils.java | 4 ++-- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index 44ff0a29d..f5db351bb 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -47,7 +47,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/LatinIME*) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/LatinIME.apk) -$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime2_intermediates) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ diff --git a/java/Android.mk b/java/Android.mk index 60c321ab2..1bbcd5315 100644 --- a/java/Android.mk +++ b/java/Android.mk @@ -9,7 +9,7 @@ LOCAL_PACKAGE_NAME := LatinIME LOCAL_CERTIFICATE := shared -LOCAL_JNI_SHARED_LIBRARIES := libjni_latinime +LOCAL_JNI_SHARED_LIBRARIES := libjni_latinime2 LOCAL_STATIC_JAVA_LIBRARIES := android-common diff --git a/java/src/com/android/inputmethod/compat/CompatUtils.java b/java/src/com/android/inputmethod/compat/CompatUtils.java index a8086919c..f06760e8a 100644 --- a/java/src/com/android/inputmethod/compat/CompatUtils.java +++ b/java/src/com/android/inputmethod/compat/CompatUtils.java @@ -68,6 +68,7 @@ public class CompatUtils { public static Method getMethod(Class targetClass, String name, Class... parameterTypes) { + if (targetClass == null || TextUtils.isEmpty(name)) return null; try { return targetClass.getMethod(name, parameterTypes); } catch (SecurityException e) { diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java index e0d54da3b..5f3c60b93 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java @@ -24,6 +24,7 @@ import android.view.inputmethod.InputMethodManager; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -78,7 +79,8 @@ public class InputMethodManagerCompatWrapper { public Map> getShortcutInputMethodsAndSubtypes() { Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes); - if (!(retval instanceof Map)) return null; + // Returns an empty map + if (!(retval instanceof Map)) return Collections.emptyMap(); Map> shortcutMap = new HashMap>(); final Map retvalMap = (Map)retval; diff --git a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java index 90b7df949..011f524f8 100644 --- a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java +++ b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatWrapper.java @@ -48,7 +48,8 @@ public final class InputMethodSubtypeCompatWrapper extends AbstractCompatWrapper CompatUtils.getMethod(CLASS_InputMethodSubtype, "getExtraValueOf", String.class); public InputMethodSubtypeCompatWrapper(Object subtype) { - super(CLASS_InputMethodSubtype.isInstance(subtype) ? subtype : null); + super((CLASS_InputMethodSubtype != null && CLASS_InputMethodSubtype.isInstance(subtype)) + ? subtype : null); if (DBG) { Log.d(TAG, "CreateInputMethodSubtypeCompatWrapper"); } diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 35b2b123c..f9080f41e 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -534,9 +534,9 @@ public class Utils { public static void loadNativeLibrary() { try { - System.loadLibrary("jni_latinime"); + System.loadLibrary("jni_latinime2"); } catch (UnsatisfiedLinkError ule) { - Log.e(TAG, "Could not load native library jni_latinime"); + Log.e(TAG, "Could not load native library jni_latinime2"); } }