aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/HermiteInterpolator.java5
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java10
-rw-r--r--java/src/com/android/inputmethod/research/MainLogBuffer.java16
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java47
-rw-r--r--java/src/com/android/inputmethod/research/Uploader.java4
5 files changed, 58 insertions, 24 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/HermiteInterpolator.java b/java/src/com/android/inputmethod/keyboard/internal/HermiteInterpolator.java
index 0ec8153f5..b526a942a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/HermiteInterpolator.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/HermiteInterpolator.java
@@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.annotations.UsedForTesting;
-
/**
* Interpolates XY-coordinates using Cubic Hermite Curve.
*/
@@ -54,7 +52,6 @@ public final class HermiteInterpolator {
* @param minPos the minimum index of left-open interval of valid data.
* @param maxPos the maximum index of left-open interval of valid data.
*/
- @UsedForTesting
public void reset(final int[] xCoords, final int[] yCoords, final int minPos,
final int maxPos) {
mXCoords = xCoords;
@@ -79,7 +76,6 @@ public final class HermiteInterpolator {
* valid points, <code>p3</code> must be equal or greater than <code>maxPos</code> of
* {@link #reset(int[],int[],int,int)}.
*/
- @UsedForTesting
public void setInterval(final int p0, final int p1, final int p2, final int p3) {
mP1X = mXCoords[p1];
mP1Y = mYCoords[p1];
@@ -152,7 +148,6 @@ public final class HermiteInterpolator {
*
* @param t the interpolation parameter. The value must be in close interval <code>[0,1]</code>.
*/
- @UsedForTesting
public void interpolate(final float t) {
final float omt = 1.0f - t;
final float tm2 = 2.0f * t;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index c464a7067..f85c16be3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2020,9 +2020,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Returns true if we did an autocorrection, false otherwise.
private boolean handleSeparator(final int primaryCode, final int x, final int y,
final int spaceState) {
- if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
- ResearchLogger.latinIME_handleSeparator(primaryCode, mWordComposer.isComposingWord());
- }
boolean didAutoCorrect = false;
if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) {
// If we are in the middle of a recorrection, we need to commit the recorrection
@@ -2046,6 +2043,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mSettings.getCurrent().isUsuallyPrecededBySpace(primaryCode)) {
promotePhantomSpace();
}
+ if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
+ ResearchLogger.latinIME_handleSeparator(primaryCode, mWordComposer.isComposingWord());
+ }
sendKeyCodePoint(primaryCode);
if (Constants.CODE_SPACE == primaryCode) {
@@ -2585,8 +2585,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_revertCommit(committedWord, originallyTypedWord,
mWordComposer.isBatchMode(), mLastComposedWord.mSeparatorString);
- ResearchLogger.getInstance().uncommitCurrentLogUnit(committedWord,
- true /* dumpCurrentLogUnit */);
}
// Don't restart suggestion yet. We'll restart if the user deletes the
// separator.
@@ -2599,10 +2597,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void promotePhantomSpace() {
if (mSettings.getCurrent().shouldInsertSpacesAutomatically()
&& !mConnection.textBeforeCursorLooksLikeURL()) {
- sendKeyCodePoint(Constants.CODE_SPACE);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_promotePhantomSpace();
}
+ sendKeyCodePoint(Constants.CODE_SPACE);
}
}
diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java
index 9aa349906..7e8f16697 100644
--- a/java/src/com/android/inputmethod/research/MainLogBuffer.java
+++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java
@@ -196,6 +196,22 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
}
}
+ /**
+ * If there is a safe n-gram at the front of this log buffer, publish it with all details, and
+ * remove the LogUnits that constitute it.
+ *
+ * An n-gram might not be "safe" if it violates privacy controls. E.g., it might contain
+ * numbers, an out-of-vocabulary word, or another n-gram may have been published recently. If
+ * there is no safe n-gram, then the LogUnits up through the first word-containing LogUnit are
+ * published, but without disclosing any privacy-related details, such as the word the LogUnit
+ * generated, motion data, etc.
+ *
+ * Note that a LogUnit can hold more than one word if the user types without explicit spaces.
+ * In this case, the words may be grouped together in such a way that pulling an n-gram off the
+ * front would require splitting a LogUnit. Splitting a LogUnit is not possible, so this case
+ * is treated just as the unsafe n-gram case. This may cause n-grams to be sampled at slightly
+ * less than the target frequency.
+ */
protected final void publishLogUnitsAtFrontOfBuffer() throws IOException {
// TODO: Refactor this method to require fewer passes through the LogUnits. Should really
// require only one pass.
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index 8b8ea21e9..f426d58d5 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -198,6 +198,11 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private Handler mUserRecordingTimeoutHandler;
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() {
mStatistics = Statistics.getInstance();
}
@@ -1291,17 +1296,32 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
/**
* Log a call to LatinIME.sendKeyCodePoint().
*
- * SystemResponse: The IME is inserting text into the TextView for numbers, fixed strings, or
- * some other unusual mechanism.
+ * SystemResponse: The IME is inserting text into the TextView for non-word-constituent,
+ * strings (separators, numbers, other symbols).
*/
private static final LogStatement LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT =
new LogStatement("LatinIMESendKeyCodePoint", true, false, "code");
public static void latinIME_sendKeyCodePoint(final int code) {
final ResearchLogger researchLogger = getInstance();
- researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT,
- Constants.printableCode(scrubDigitFromCodePoint(code)));
- if (Character.isDigit(code)) {
- researchLogger.setCurrentLogUnitContainsDigitFlag();
+ final LogUnit phantomSpaceLogUnit = researchLogger.mPhantomSpaceLogUnit;
+ if (phantomSpaceLogUnit == null) {
+ researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_SENDKEYCODEPOINT,
+ Constants.printableCode(scrubDigitFromCodePoint(code)));
+ if (Character.isDigit(code)) {
+ 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.
*/
private static final LogStatement LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE =
- new LogStatement("LatinIMEPromotPhantomSpace", false, false);
+ new LogStatement("LatinIMEPromotePhantomSpace", false, false);
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 LogUnit logUnit;
- logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit();
- researchLogger.enqueueEvent(logUnit, LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE);
+ researchLogger.mPhantomSpaceLogUnit = new LogUnit();
+ researchLogger.enqueueEvent(researchLogger.mPhantomSpaceLogUnit,
+ LOGSTATEMENT_LATINIME_PROMOTEPHANTOMSPACE);
}
/**
@@ -1418,7 +1444,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
logUnit.setContainsCorrection();
}
researchLogger.mStatistics.recordRevertCommit(SystemClock.uptimeMillis());
- researchLogger.commitCurrentLogUnitAsWord(originallyTypedWord, Long.MAX_VALUE, isBatchMode);
}
/**
diff --git a/java/src/com/android/inputmethod/research/Uploader.java b/java/src/com/android/inputmethod/research/Uploader.java
index ba05ec12b..c7ea3e69d 100644
--- a/java/src/com/android/inputmethod/research/Uploader.java
+++ b/java/src/com/android/inputmethod/research/Uploader.java
@@ -49,7 +49,7 @@ public final class Uploader {
private static final boolean DEBUG = false
&& ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG;
// Set IS_INHIBITING_AUTO_UPLOAD to true for local testing
- private static final boolean IS_INHIBITING_AUTO_UPLOAD = false
+ private static final boolean IS_INHIBITING_UPLOAD = false
&& ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG;
private static final int BUF_SIZE = 1024 * 8;
@@ -76,7 +76,7 @@ public final class Uploader {
}
public boolean isPossibleToUpload() {
- return hasUploadingPermission() && mUrl != null && !IS_INHIBITING_AUTO_UPLOAD;
+ return hasUploadingPermission() && mUrl != null && !IS_INHIBITING_UPLOAD;
}
private boolean hasUploadingPermission() {