Merge "Report AUTO_SELECTION as a smart selection event." into qt-dev

This commit is contained in:
Abodunrinwa Toki
2019-05-20 16:09:43 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 12 deletions

View File

@@ -80,12 +80,16 @@ public final class SelectionSessionLogger {
.addTaggedData(INDEX, event.getEventIndex())
.addTaggedData(WIDGET_TYPE, event.getWidgetType())
.addTaggedData(WIDGET_VERSION, event.getWidgetVersion())
.addTaggedData(MODEL_NAME, SignatureParser.getModelName(event.getResultId()))
.addTaggedData(ENTITY_TYPE, event.getEntityType())
.addTaggedData(SMART_START, event.getSmartStart())
.addTaggedData(SMART_END, event.getSmartEnd())
.addTaggedData(EVENT_START, event.getStart())
.addTaggedData(EVENT_END, event.getEnd());
if (isPlatformLocalTextClassifierSmartSelection(event.getResultId())) {
// Ensure result id and smart indices are only set for events with smart selection from
// the platform's textclassifier.
log.addTaggedData(MODEL_NAME, SignatureParser.getModelName(event.getResultId()))
.addTaggedData(SMART_START, event.getSmartStart())
.addTaggedData(SMART_END, event.getSmartEnd());
}
if (event.getSessionId() != null) {
log.addTaggedData(SESSION_ID, event.getSessionId().flattenToString());
}
@@ -193,6 +197,11 @@ public final class SelectionSessionLogger {
}
}
static boolean isPlatformLocalTextClassifierSmartSelection(String signature) {
return SelectionSessionLogger.CLASSIFIER_ID.equals(
SelectionSessionLogger.SignatureParser.getClassifierId(signature));
}
private static void debugLog(LogMaker log) {
if (!Log.ENABLE_FULL_LOGGING) {
return;

View File

@@ -158,11 +158,11 @@ final class TextClassificationSession implements TextClassifier {
mStartEvent = event;
break;
case SelectionEvent.EVENT_SMART_SELECTION_SINGLE: // fall through
case SelectionEvent.EVENT_SMART_SELECTION_MULTI:
case SelectionEvent.EVENT_SMART_SELECTION_MULTI: // fall through
case SelectionEvent.EVENT_AUTO_SELECTION:
mSmartEvent = event;
break;
case SelectionEvent.EVENT_SELECTION_MODIFIED: // fall through
case SelectionEvent.EVENT_AUTO_SELECTION:
case SelectionEvent.EVENT_SELECTION_MODIFIED:
if (mPrevEvent != null
&& mPrevEvent.getAbsoluteStart() == event.getAbsoluteStart()
&& mPrevEvent.getAbsoluteEnd() == event.getAbsoluteEnd()) {
@@ -215,7 +215,8 @@ final class TextClassificationSession implements TextClassifier {
case SelectionEvent.EVENT_SMART_SELECTION_SINGLE: // fall through
case SelectionEvent.EVENT_SMART_SELECTION_MULTI: // fall through
case SelectionEvent.EVENT_AUTO_SELECTION:
if (isPlatformLocalTextClassifierSmartSelection(event.getResultId())) {
if (SelectionSessionLogger.isPlatformLocalTextClassifierSmartSelection(
event.getResultId())) {
if (event.getAbsoluteEnd() - event.getAbsoluteStart() > 1) {
event.setEventType(SelectionEvent.EVENT_SMART_SELECTION_MULTI);
} else {
@@ -229,10 +230,5 @@ final class TextClassificationSession implements TextClassifier {
return;
}
}
private static boolean isPlatformLocalTextClassifierSmartSelection(String signature) {
return SelectionSessionLogger.CLASSIFIER_ID.equals(
SelectionSessionLogger.SignatureParser.getClassifierId(signature));
}
}
}