diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 7 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 12 |
2 files changed, 15 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 38549436b..695bf8dce 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -454,6 +454,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Has to be package-visible for unit tests /* package */ void loadSettings() { + // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() + // is not guaranteed. It may even be called at the same time on a different thread. if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this); final RunInLocale<SettingsValues> job = new RunInLocale<SettingsValues>() { @Override @@ -495,6 +497,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen resetContactsDictionary(oldContactsDictionary); + // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() + // is not guaranteed. It may even be called at the same time on a different thread. + if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mUserHistoryDictionary = new UserHistoryDictionary( this, localeStr, Suggest.DIC_USER_HISTORY, mPrefs); mSuggest.setUserHistoryDictionary(mUserHistoryDictionary); @@ -624,6 +629,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { + // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() + // is not guaranteed. It may even be called at the same time on a different thread. mSubtypeSwitcher.updateSubtype(subtype); } diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index b3e46baf5..4178955bc 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -126,8 +126,9 @@ public class Utils { } public static RingCharBuffer init(InputMethodService context, boolean enabled, boolean usabilityStudy) { + if (!(enabled || usabilityStudy)) return null; sRingCharBuffer.mContext = context; - sRingCharBuffer.mEnabled = enabled || usabilityStudy; + sRingCharBuffer.mEnabled = true; UsabilityStudyLogUtils.getInstance().init(context); return sRingCharBuffer; } @@ -221,8 +222,6 @@ public class Utils { // TODO: remove code duplication with ResearchLog class private static final String USABILITY_TAG = UsabilityStudyLogUtils.class.getSimpleName(); private static final String FILENAME = "log.txt"; - private static final UsabilityStudyLogUtils sInstance = - new UsabilityStudyLogUtils(); private final Handler mLoggingHandler; private File mFile; private File mDirectory; @@ -241,8 +240,13 @@ public class Utils { mLoggingHandler = new Handler(handlerThread.getLooper()); } + // Initialization-on-demand holder + private static class OnDemandInitializationHolder { + public static final UsabilityStudyLogUtils sInstance = new UsabilityStudyLogUtils(); + } + public static UsabilityStudyLogUtils getInstance() { - return sInstance; + return OnDemandInitializationHolder.sInstance; } public void init(InputMethodService ims) { |