aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research/ResearchLog.java
diff options
context:
space:
mode:
authorKurt Partridge <kep@google.com>2013-01-11 10:35:51 -0800
committerKurt Partridge <kep@google.com>2013-01-14 07:11:42 -0800
commit67a61fc6bea2c4bf4e3d5096f9664547ecb47a9a (patch)
tree9309ceee2a1a36647b697fda99666ea1cab9327a /java/src/com/android/inputmethod/research/ResearchLog.java
parenta0970042642ef39c22149a896efe785ec1fcaf01 (diff)
downloadlatinime-67a61fc6bea2c4bf4e3d5096f9664547ecb47a9a.tar.gz
latinime-67a61fc6bea2c4bf4e3d5096f9664547ecb47a9a.tar.xz
latinime-67a61fc6bea2c4bf4e3d5096f9664547ecb47a9a.zip
[Rlog68] Logger; make filenames more unique to prevent filesys conflicts
multi-project commit with If6b9f8990d7cdbf570740a81096513698d0e0f4c Change-Id: I124aed24be0beb4c472869594184ecf003c2fed4
Diffstat (limited to 'java/src/com/android/inputmethod/research/ResearchLog.java')
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLog.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java
index a2356e6a3..5edb46e27 100644
--- a/java/src/com/android/inputmethod/research/ResearchLog.java
+++ b/java/src/com/android/inputmethod/research/ResearchLog.java
@@ -16,6 +16,7 @@
package com.android.inputmethod.research;
+import android.content.Context;
import android.util.JsonWriter;
import android.util.Log;
@@ -23,7 +24,7 @@ import com.android.inputmethod.latin.define.ProductionFlag;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@@ -50,6 +51,8 @@ public class ResearchLog {
/* package */ final ScheduledExecutorService mExecutor;
/* package */ final File mFile;
+ private final Context mContext;
+
private JsonWriter mJsonWriter = NULL_JSON_WRITER;
// true if at least one byte of data has been written out to the log file. This must be
// remembered because JsonWriter requires that calls matching calls to beginObject and
@@ -78,12 +81,13 @@ public class ResearchLog {
}
}
- public ResearchLog(final File outputFile) {
+ public ResearchLog(final File outputFile, Context context) {
if (outputFile == null) {
throw new IllegalArgumentException();
}
mExecutor = Executors.newSingleThreadScheduledExecutor();
mFile = outputFile;
+ mContext = context;
}
public synchronized void close(final Runnable onClosed) {
@@ -206,7 +210,9 @@ public class ResearchLog {
public JsonWriter getValidJsonWriterLocked() {
try {
if (mJsonWriter == NULL_JSON_WRITER) {
- mJsonWriter = new JsonWriter(new BufferedWriter(new FileWriter(mFile)));
+ final FileOutputStream fos =
+ mContext.openFileOutput(mFile.getName(), Context.MODE_PRIVATE);
+ mJsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(fos)));
mJsonWriter.beginArray();
mHasWrittenData = true;
}