Merge "[Rlog59d] Pass separatorString through revertCommit"
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index b2dd12d..974a30a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1667,7 +1667,7 @@
                 if (mWordComposer.isBatchMode()) {
                     if (ProductionFlag.IS_EXPERIMENTAL) {
                         final String word = mWordComposer.getTypedWord();
-                        ResearchLogger.latinIME_handleBackspace_batch(word);
+                        ResearchLogger.latinIME_handleBackspace_batch(word, 1);
                         ResearchLogger.getInstance().uncommitCurrentLogUnit(
                                 word, false /* dumpCurrentLogUnit */);
                     }
@@ -1718,14 +1718,17 @@
             // We should backspace one char and restart suggestion if at the end of a word.
             if (mLastSelectionStart != mLastSelectionEnd) {
                 // If there is a selection, remove it.
-                final int lengthToDelete = mLastSelectionEnd - mLastSelectionStart;
+                final int numCharsDeleted = mLastSelectionEnd - mLastSelectionStart;
                 mConnection.setSelection(mLastSelectionEnd, mLastSelectionEnd);
                 // Reset mLastSelectionEnd to mLastSelectionStart. This is what is supposed to
                 // happen, and if it's wrong, the next call to onUpdateSelection will correct it,
                 // but we want to set it right away to avoid it being used with the wrong values
                 // later (typically, in a subsequent press on backspace).
                 mLastSelectionEnd = mLastSelectionStart;
-                mConnection.deleteSurroundingText(lengthToDelete, 0);
+                mConnection.deleteSurroundingText(numCharsDeleted, 0);
+                if (ProductionFlag.IS_EXPERIMENTAL) {
+                    ResearchLogger.latinIME_handleBackspace(numCharsDeleted);
+                }
             } else {
                 // There is no selection, just delete one character.
                 if (NOT_A_CURSOR_POSITION == mLastSelectionEnd) {
@@ -1742,8 +1745,14 @@
                 } else {
                     mConnection.deleteSurroundingText(1, 0);
                 }
+                if (ProductionFlag.IS_EXPERIMENTAL) {
+                    ResearchLogger.latinIME_handleBackspace(1);
+                }
                 if (mDeleteCount > DELETE_ACCELERATE_AT) {
                     mConnection.deleteSurroundingText(1, 0);
+                    if (ProductionFlag.IS_EXPERIMENTAL) {
+                        ResearchLogger.latinIME_handleBackspace(1);
+                    }
                 }
             }
             if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) {
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index 3461aa7..d148f68 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -730,6 +730,8 @@
         }
     }
 
+    private static final LogStatement LOGSTATEMENT_UNCOMMIT_CURRENT_LOGUNIT =
+            new LogStatement("UncommitCurrentLogUnit", false, false);
     public void uncommitCurrentLogUnit(final String expectedWord,
             final boolean dumpCurrentLogUnit) {
         // The user has deleted this word and returned to the previous.  Check that the word in the
@@ -768,6 +770,7 @@
         if (mFeedbackLogBuffer != null) {
             mFeedbackLogBuffer.unshiftIn();
         }
+        enqueueEvent(LOGSTATEMENT_UNCOMMIT_CURRENT_LOGUNIT);
         if (DEBUG) {
             Log.d(TAG, "uncommitCurrentLogUnit (dump=" + dumpCurrentLogUnit + ") back to "
                     + (mCurrentLogUnit.hasWord() ? ": '" + mCurrentLogUnit.getWord() + "'" : ""));
@@ -1649,15 +1652,31 @@
     }
 
     /**
-     * Log a call to LatinIME.handleBackspace().
+     * Log a call to LatinIME.handleBackspace() that is not a batch delete.
+     *
+     * UserInput: The user is deleting one or more characters by hitting the backspace key once.
+     * The covers single character deletes as well as deleting selections.
+     */
+    private static final LogStatement LOGSTATEMENT_LATINIME_HANDLEBACKSPACE =
+            new LogStatement("LatinIMEHandleBackspace", true, false, "numCharacters");
+    public static void latinIME_handleBackspace(final int numCharacters) {
+        final ResearchLogger researchLogger = getInstance();
+        researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_HANDLEBACKSPACE, numCharacters);
+    }
+
+    /**
+     * Log a call to LatinIME.handleBackspace() that is a batch delete.
      *
      * UserInput: The user is deleting a gestured word by hitting the backspace key once.
      */
     private static final LogStatement LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH =
-            new LogStatement("LatinIMEHandleBackspaceBatch", true, false, "deletedText");
-    public static void latinIME_handleBackspace_batch(final CharSequence deletedText) {
+            new LogStatement("LatinIMEHandleBackspaceBatch", true, false, "deletedText",
+                    "numCharacters");
+    public static void latinIME_handleBackspace_batch(final CharSequence deletedText,
+            final int numCharacters) {
         final ResearchLogger researchLogger = getInstance();
-        researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH, deletedText);
+        researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_HANDLEBACKSPACE_BATCH, deletedText,
+                numCharacters);
         researchLogger.mStatistics.recordGestureDelete(deletedText.length(),
                 SystemClock.uptimeMillis());
     }