aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research/ResearchLogger.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/research/ResearchLogger.java')
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java70
1 files changed, 43 insertions, 27 deletions
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index 83a6a3f05..a2bcf4441 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -521,8 +521,25 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
*/
private boolean mInFeedbackDialog = false;
+
+ // The feedback dialog causes stop() to be called for the keyboard connected to the original
+ // window. This is because the feedback dialog must present its own EditText box that displays
+ // a keyboard. stop() normally causes mFeedbackLogBuffer, which contains the user's data, to be
+ // cleared, and causes mFeedbackLog, which is ready to collect information in case the user
+ // wants to upload, to be closed. This is good because we don't need to log information about
+ // what the user is typing in the feedback dialog, but bad because this data must be uploaded.
+ // Here we save the LogBuffer and Log so the feedback dialog can later access their data.
+ private LogBuffer mSavedFeedbackLogBuffer;
+ private ResearchLog mSavedFeedbackLog;
+
public void presentFeedbackDialog(LatinIME latinIME) {
mInFeedbackDialog = true;
+ mSavedFeedbackLogBuffer = mFeedbackLogBuffer;
+ mSavedFeedbackLog = mFeedbackLog;
+ // Set the non-saved versions to null so that the stop() caused by switching to the
+ // Feedback dialog will not close them.
+ mFeedbackLogBuffer = null;
+ mFeedbackLog = null;
latinIME.launchKeyboardedDialogActivity(FeedbackActivity.class);
}
@@ -588,28 +605,25 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
private static final LogStatement LOGSTATEMENT_FEEDBACK =
- new LogStatement("UserTimestamp", false, false, "contents");
+ new LogStatement("UserFeedback", false, false, "contents");
public void sendFeedback(final String feedbackContents, final boolean includeHistory) {
- if (mFeedbackLogBuffer == null) {
+ if (mSavedFeedbackLogBuffer == null) {
return;
}
- if (includeHistory) {
- commitCurrentLogUnit();
- } else {
- mFeedbackLogBuffer.clear();
+ if (!includeHistory) {
+ mSavedFeedbackLogBuffer.clear();
}
final LogUnit feedbackLogUnit = new LogUnit();
feedbackLogUnit.addLogStatement(LOGSTATEMENT_FEEDBACK, SystemClock.uptimeMillis(),
feedbackContents);
mFeedbackLogBuffer.shiftIn(feedbackLogUnit);
- publishLogBuffer(mFeedbackLogBuffer, mFeedbackLog, true /* isIncludingPrivateData */);
- mFeedbackLog.close(new Runnable() {
+ publishLogBuffer(mFeedbackLogBuffer, mSavedFeedbackLog, true /* isIncludingPrivateData */);
+ mSavedFeedbackLog.close(new Runnable() {
@Override
public void run() {
uploadNow();
}
});
- mFeedbackLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
}
public void uploadNow() {
@@ -642,13 +656,6 @@ 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;
}
@@ -851,6 +858,11 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mCurrentLogUnit = newLogUnit;
}
+ /**
+ * Record the time of a MotionEvent.ACTION_DOWN.
+ *
+ * Warning: Not thread safe. Only call from the main thread.
+ */
private void setSavedDownEventTime(final long time) {
mSavedDownEventTime = time;
}
@@ -1474,20 +1486,20 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private boolean isExpectingCommitText = false;
/**
- * Log a call to RichInputConnection.commitPartialText
+ * Log a call to (UnknownClass).commitPartialText
*
* SystemResponse: The IME is committing part of a word. This happens if a space is
* automatically inserted to split a single typed string into two or more words.
*/
// TODO: This method is currently unused. Find where it should be called from in the IME and
// add invocations.
- private static final LogStatement LOGSTATEMENT_LATINIME_COMMIT_PARTIAL_TEXT =
- new LogStatement("LatinIMECommitPartialText", true, false, "newCursorPosition");
- public static void latinIME_commitPartialText(final String committedWord,
+ private static final LogStatement LOGSTATEMENT_COMMIT_PARTIAL_TEXT =
+ new LogStatement("CommitPartialText", true, false, "newCursorPosition");
+ public static void commitPartialText(final String committedWord,
final long lastTimestampOfWordData, final boolean isBatchMode) {
final ResearchLogger researchLogger = getInstance();
final String scrubbedWord = scrubDigitsFromString(committedWord);
- researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_COMMIT_PARTIAL_TEXT);
+ researchLogger.enqueueEvent(LOGSTATEMENT_COMMIT_PARTIAL_TEXT);
researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, lastTimestampOfWordData,
isBatchMode);
}
@@ -1704,12 +1716,16 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
researchLogger.enqueueEvent(LOGSTATEMENT_ONUSERPAUSE, interval);
}
- public static void latinIME_handleSeparator() {
- // Reset the saved down event time. For tapping, motion events, etc. before the separator
- // are assigned to the previous LogUnit, and events after the separator are assigned to the
- // next LogUnit. In the case of multitap, this might capture down events corresponding to
- // the next word, however it should not be more than a character or two.
- getInstance().setSavedDownEventTime(SystemClock.uptimeMillis());
+ /**
+ * Record the current time in case the LogUnit is later split.
+ *
+ * If the current logUnitis split, then tapping, motion events, etc. before this time should
+ * be assigned to one LogUnit, and events after this time should go into the following LogUnit.
+ */
+ public static void recordTimeForLogUnitSplit() {
+ final ResearchLogger researchLogger = getInstance();
+ researchLogger.setSavedDownEventTime(SystemClock.uptimeMillis());
+ researchLogger.mSavedDownEventTime = Long.MAX_VALUE;
}
/**