From fe05b881342645f75428cc51849f7326cb76a408 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Wed, 8 Aug 2012 20:13:41 -0700 Subject: [PATCH] add logging code Change-Id: I0abb4a1ad67666162ab6703ffdb33c5e0675be93 --- .../inputmethod/research/ResearchLog.java | 7 ++++++ .../inputmethod/research/ResearchLogger.java | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java index 369c6e0df..70c38e909 100644 --- a/java/src/com/android/inputmethod/research/ResearchLog.java +++ b/java/src/com/android/inputmethod/research/ResearchLog.java @@ -102,7 +102,14 @@ public class ResearchLog { mJsonWriter.endArray(); mJsonWriter.flush(); mJsonWriter.close(); + if (DEBUG) { + Log.d(TAG, "wrote log to " + mFile); + } mHasWrittenData = false; + } else { + if (DEBUG) { + Log.d(TAG, "close() called, but no data, not outputting"); + } } } catch (Exception e) { Log.d(TAG, "error when closing ResearchLog:"); diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 4f71a3aa6..763fd6e00 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -84,6 +84,7 @@ import java.util.UUID; */ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = ResearchLogger.class.getSimpleName(); + private static final boolean DEBUG = false; private static final boolean OUTPUT_ENTIRE_BUFFER = false; // true may disclose private info public static final boolean DEFAULT_USABILITY_STUDY_MODE = false; /* package */ static boolean sIsLogging = false; @@ -344,6 +345,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } private void start() { + if (DEBUG) { + Log.d(TAG, "start called"); + } maybeShowSplashScreen(); updateSuspendedState(); requestIndicatorRedraw(); @@ -371,6 +375,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } /* package */ void stop() { + if (DEBUG) { + Log.d(TAG, "stop called"); + } logStatistics(); commitCurrentLogUnit(); @@ -386,6 +393,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } public boolean abort() { + if (DEBUG) { + Log.d(TAG, "abort called"); + } boolean didAbortMainLog = false; if (mMainLogBuffer != null) { mMainLogBuffer.clear(); @@ -559,6 +569,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } public void uploadNow() { + if (DEBUG) { + Log.d(TAG, "calling uploadNow()"); + } mInputMethodService.startService(mUploadIntent); } @@ -578,6 +591,13 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } private boolean isAllowedToLog() { + if (DEBUG) { + Log.d(TAG, "iatl: " + + "mipw=" + mIsPasswordView + + ", mils=" + mIsLoggingSuspended + + ", sil=" + sIsLogging + + ", mInFeedbackDialog=" + mInFeedbackDialog); + } return !mIsPasswordView && !mIsLoggingSuspended && sIsLogging && !mInFeedbackDialog; } @@ -666,6 +686,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } /* package for test */ void commitCurrentLogUnit() { + if (DEBUG) { + Log.d(TAG, "commitCurrentLogUnit"); + } if (!mCurrentLogUnit.isEmpty()) { if (mMainLogBuffer != null) { mMainLogBuffer.shiftIn(mCurrentLogUnit);