Include nanoTime in filename
System is fast enough that sometimes SystemClock.currentTimeMillis() is duplicated when used to make a unique filename. Change-Id: I9454fbb5e10265d36b8e17cba183a1591d52cc7bmain
parent
3970352ea9
commit
125f22dc58
|
@ -97,15 +97,17 @@ public class ResearchLogDirectory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getLogFilePath(final long time) {
|
public File getLogFilePath(final long time, final long nanoTime) {
|
||||||
return new File(mFilesDir, getUniqueFilename(LOG_FILENAME_PREFIX, time));
|
return new File(mFilesDir, getUniqueFilename(LOG_FILENAME_PREFIX, time, nanoTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getUserRecordingFilePath(final long time) {
|
public File getUserRecordingFilePath(final long time, final long nanoTime) {
|
||||||
return new File(mFilesDir, getUniqueFilename(USER_RECORDING_FILENAME_PREFIX, time));
|
return new File(mFilesDir, getUniqueFilename(USER_RECORDING_FILENAME_PREFIX, time,
|
||||||
|
nanoTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getUniqueFilename(final String prefix, final long time) {
|
private static String getUniqueFilename(final String prefix, final long time,
|
||||||
return prefix + "-" + time + FILENAME_SUFFIX;
|
final long nanoTime) {
|
||||||
|
return prefix + "-" + time + "-" + nanoTime + FILENAME_SUFFIX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,7 +389,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
if (mMainLogBuffer == null) {
|
if (mMainLogBuffer == null) {
|
||||||
mMainResearchLog = new ResearchLog(mResearchLogDirectory.getLogFilePath(
|
mMainResearchLog = new ResearchLog(mResearchLogDirectory.getLogFilePath(
|
||||||
System.currentTimeMillis()), mLatinIME);
|
System.currentTimeMillis(), System.nanoTime()), mLatinIME);
|
||||||
final int numWordsToIgnore = new Random().nextInt(NUMBER_OF_WORDS_BETWEEN_SAMPLES + 1);
|
final int numWordsToIgnore = new Random().nextInt(NUMBER_OF_WORDS_BETWEEN_SAMPLES + 1);
|
||||||
mMainLogBuffer = new MainLogBuffer(NUMBER_OF_WORDS_BETWEEN_SAMPLES, numWordsToIgnore,
|
mMainLogBuffer = new MainLogBuffer(NUMBER_OF_WORDS_BETWEEN_SAMPLES, numWordsToIgnore,
|
||||||
mSuggest) {
|
mSuggest) {
|
||||||
|
@ -420,7 +420,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
|
|
||||||
private void resetFeedbackLogging() {
|
private void resetFeedbackLogging() {
|
||||||
mFeedbackLog = new ResearchLog(mResearchLogDirectory.getLogFilePath(
|
mFeedbackLog = new ResearchLog(mResearchLogDirectory.getLogFilePath(
|
||||||
System.currentTimeMillis()), mLatinIME);
|
System.currentTimeMillis(), System.nanoTime()), mLatinIME);
|
||||||
mFeedbackLogBuffer = new FixedLogBuffer(FEEDBACK_WORD_BUFFER_SIZE);
|
mFeedbackLogBuffer = new FixedLogBuffer(FEEDBACK_WORD_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
mUserRecordingLog.blockingAbort(RESEARCHLOG_ABORT_TIMEOUT_IN_MS);
|
mUserRecordingLog.blockingAbort(RESEARCHLOG_ABORT_TIMEOUT_IN_MS);
|
||||||
}
|
}
|
||||||
mUserRecordingFile = mResearchLogDirectory.getUserRecordingFilePath(
|
mUserRecordingFile = mResearchLogDirectory.getUserRecordingFilePath(
|
||||||
System.currentTimeMillis());
|
System.currentTimeMillis(), System.nanoTime());
|
||||||
mUserRecordingLog = new ResearchLog(mUserRecordingFile, mLatinIME);
|
mUserRecordingLog = new ResearchLog(mUserRecordingFile, mLatinIME);
|
||||||
mUserRecordingLogBuffer = new LogBuffer();
|
mUserRecordingLogBuffer = new LogBuffer();
|
||||||
resetRecordingTimer();
|
resetRecordingTimer();
|
||||||
|
|
Loading…
Reference in New Issue