am de4e579c: Merge "Fix punctuation logging"

* commit 'de4e579c68e74fa0c85b376769e9428cd822add7':
  Fix punctuation logging
main
Kurt Partridge 2013-05-17 10:47:00 -07:00 committed by Android Git Automerger
commit ec6e5d37be
2 changed files with 40 additions and 14 deletions

View File

@ -2021,9 +2021,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Returns true if we did an autocorrection, false otherwise. // Returns true if we did an autocorrection, false otherwise.
private boolean handleSeparator(final int primaryCode, final int x, final int y, private boolean handleSeparator(final int primaryCode, final int x, final int y,
final int spaceState) { final int spaceState) {
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_handleSeparator(primaryCode, mWordComposer.isComposingWord());
}
boolean didAutoCorrect = false; boolean didAutoCorrect = false;
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) { if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection // If we are in the middle of a recorrection, we need to commit the recorrection
@ -2047,6 +2044,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mSettings.getCurrent().isUsuallyPrecededBySpace(primaryCode)) { mSettings.getCurrent().isUsuallyPrecededBySpace(primaryCode)) {
promotePhantomSpace(); promotePhantomSpace();
} }
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_handleSeparator(primaryCode, mWordComposer.isComposingWord());
}
sendKeyCodePoint(primaryCode); sendKeyCodePoint(primaryCode);
if (Constants.CODE_SPACE == primaryCode) { if (Constants.CODE_SPACE == primaryCode) {
@ -2594,10 +2594,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void promotePhantomSpace() { public void promotePhantomSpace() {
if (mSettings.getCurrent().shouldInsertSpacesAutomatically() if (mSettings.getCurrent().shouldInsertSpacesAutomatically()
&& !mConnection.textBeforeCursorLooksLikeURL()) { && !mConnection.textBeforeCursorLooksLikeURL()) {
sendKeyCodePoint(Constants.CODE_SPACE);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_promotePhantomSpace(); ResearchLogger.latinIME_promotePhantomSpace();
} }
sendKeyCodePoint(Constants.CODE_SPACE);
} }
} }

View File

@ -198,6 +198,11 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private Handler mUserRecordingTimeoutHandler; private Handler mUserRecordingTimeoutHandler;
private static final long USER_RECORDING_TIMEOUT_MS = 30L * DateUtils.SECOND_IN_MILLIS; private static final long USER_RECORDING_TIMEOUT_MS = 30L * DateUtils.SECOND_IN_MILLIS;
// Stores a temporary LogUnit while generating a phantom space. Needed because phantom spaces
// are issued out-of-order, immediately before the characters generated by other operations that
// have already outputted LogStatements.
private LogUnit mPhantomSpaceLogUnit = null;
private ResearchLogger() { private ResearchLogger() {
mStatistics = Statistics.getInstance(); mStatistics = Statistics.getInstance();
} }
@ -1291,18 +1296,33 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
/** /**
* Log a call to LatinIME.sendKeyCodePoint(). * Log a call to LatinIME.sendKeyCodePoint().
* *
* SystemResponse: The IME is inserting text into the TextView for numbers, fixed strings, or * SystemResponse: The IME is inserting text into the TextView for non-word-constituent,
* some other unusual mechanism. * strings (separators, numbers, other symbols).
*/ */
private static final LogStatement LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT = private static final LogStatement LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT =
new LogStatement("LatinIMESendKeyCodePoint", true, false, "code"); new LogStatement("LatinIMESendKeyCodePoint", true, false, "code");
public static void latinIME_sendKeyCodePoint(final int code) { public static void latinIME_sendKeyCodePoint(final int code) {
final ResearchLogger researchLogger = getInstance(); final ResearchLogger researchLogger = getInstance();
final LogUnit phantomSpaceLogUnit = researchLogger.mPhantomSpaceLogUnit;
if (phantomSpaceLogUnit == null) {
researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT, researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT,
Constants.printableCode(scrubDigitFromCodePoint(code))); Constants.printableCode(scrubDigitFromCodePoint(code)));
if (Character.isDigit(code)) { if (Character.isDigit(code)) {
researchLogger.setCurrentLogUnitContainsDigitFlag(); researchLogger.setCurrentLogUnitContainsDigitFlag();
} }
researchLogger.commitCurrentLogUnit();
} else {
researchLogger.enqueueEvent(phantomSpaceLogUnit, LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT,
Constants.printableCode(scrubDigitFromCodePoint(code)));
if (Character.isDigit(code)) {
phantomSpaceLogUnit.setMayContainDigit();
}
researchLogger.mMainLogBuffer.shiftIn(phantomSpaceLogUnit);
if (researchLogger.mUserRecordingLogBuffer != null) {
researchLogger.mUserRecordingLogBuffer.shiftIn(phantomSpaceLogUnit);
}
researchLogger.mPhantomSpaceLogUnit = null;
}
} }
/** /**
@ -1311,12 +1331,18 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
* SystemResponse: The IME is inserting a real space in place of a phantom space. * SystemResponse: The IME is inserting a real space in place of a phantom space.
*/ */
private static final LogStatement LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE = private static final LogStatement LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE =
new LogStatement("LatinIMEPromotPhantomSpace", false, false); new LogStatement("LatinIMEPromotePhantomSpace", false, false);
public static void latinIME_promotePhantomSpace() { public static void latinIME_promotePhantomSpace() {
// A phantom space is always added before the text that triggered it. The triggering text
// and the events that created it will be in mCurrentLogUnit, but the phantom space should
// be in its own LogUnit, committed before the triggering text. Although it is created
// here, it is not added to the LogBuffer until the following call to
// latinIME_sendKeyCodePoint, because SENDKEYCODEPOINT LogStatement also must go into that
// LogUnit.
final ResearchLogger researchLogger = getInstance(); final ResearchLogger researchLogger = getInstance();
final LogUnit logUnit; researchLogger.mPhantomSpaceLogUnit = new LogUnit();
logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit(); researchLogger.enqueueEvent(researchLogger.mPhantomSpaceLogUnit,
researchLogger.enqueueEvent(logUnit, LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE); LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE);
} }
/** /**