From 17114054e91d9172f0432171862a72e832838e96 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Wed, 8 Aug 2012 09:38:24 -0700 Subject: [PATCH] ResearchLog uploadingService now waits for logging to finish Bug: 6188932 Change-Id: I31c0f380b334d9117990f2d92de8d385e4a52c7c --- .../android/inputmethod/research/ResearchLog.java | 5 ++++- .../android/inputmethod/research/ResearchLogger.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java index cd9ff85f8..369c6e0df 100644 --- a/java/src/com/android/inputmethod/research/ResearchLog.java +++ b/java/src/com/android/inputmethod/research/ResearchLog.java @@ -93,7 +93,7 @@ public class ResearchLog { mFile = outputFile; } - public synchronized void close() { + public synchronized void close(final Runnable onClosed) { mExecutor.submit(new Callable() { @Override public Object call() throws Exception { @@ -111,6 +111,9 @@ public class ResearchLog { if (mFile.exists()) { mFile.setWritable(false, false); } + if (onClosed != null) { + onClosed.run(); + } } return null; } diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 5c2487195..816db5806 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -376,11 +376,11 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang if (mMainLogBuffer != null) { publishLogBuffer(mMainLogBuffer, mMainResearchLog, false /* isIncludingPrivateData */); - mMainResearchLog.close(); + mMainResearchLog.close(null /* callback */); mMainLogBuffer = null; } if (mFeedbackLogBuffer != null) { - mFeedbackLog.close(); + mFeedbackLog.close(null /* callback */); mFeedbackLogBuffer = null; } } @@ -549,8 +549,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang false /* isPotentiallyPrivate */); mFeedbackLogBuffer.shiftIn(feedbackLogUnit); publishLogBuffer(mFeedbackLogBuffer, mFeedbackLog, true /* isIncludingPrivateData */); - mFeedbackLog.close(); - uploadNow(); + mFeedbackLog.close(new Runnable() { + @Override + public void run() { + uploadNow(); + } + }); mFeedbackLog = new ResearchLog(createLogFile(mFilesDir)); }