From 027448e08a3df50a2ae9513d972fa60b047f6766 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Sat, 2 Jun 2012 22:50:38 +0900 Subject: [PATCH] Remove an unnecessary thread. bug: 6584677 While looking at bug 6584677, we found that LatinIME always spawns an unnecessary thread for Usability Study Mode. We don't assume this change will address the root cause of the bug, but we'd like to remove any suspicious noises in bugreports. Change-Id: Ie47d104f6cd77ec2ad164f13b4212cb4a70bcf1d --- java/src/com/android/inputmethod/latin/Utils.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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) {