TRON logging for TextView gesture - Long press.

Bug: 32572232
Test: Manually confirmed that stats were sent for logging by checking
  adb logs according to go/tron-howto.
Change-Id: I1ea09174190247c219ce42f70c7db75148033685
This commit is contained in:
Abodunrinwa Toki
2016-11-03 23:27:58 +00:00
parent 75ec5465f0
commit 1b304e4073
4 changed files with 73 additions and 0 deletions

View File

@@ -111,6 +111,8 @@ import android.widget.TextView.Drawables;
import android.widget.TextView.OnEditorActionListener;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.GrowingArrayUtils;
import com.android.internal.util.Preconditions;
@@ -1119,14 +1121,26 @@ public class Editor {
getInsertionController().show();
mIsInsertionActionModeStartPending = true;
handled = true;
MetricsLogger.action(
mTextView.getContext(),
MetricsEvent.TEXT_LONGPRESS,
TextViewMetrics.SUBTYPE_LONG_PRESS_OTHER);
}
if (!handled && mTextActionMode != null) {
if (touchPositionIsInSelection()) {
startDragAndDrop();
MetricsLogger.action(
mTextView.getContext(),
MetricsEvent.TEXT_LONGPRESS,
TextViewMetrics.SUBTYPE_LONG_PRESS_DRAG_AND_DROP);
} else {
stopTextActionMode();
selectCurrentWordAndStartDrag();
MetricsLogger.action(
mTextView.getContext(),
MetricsEvent.TEXT_LONGPRESS,
TextViewMetrics.SUBTYPE_LONG_PRESS_SELECTION);
}
handled = true;
}
@@ -1134,6 +1148,12 @@ public class Editor {
// Start a new selection
if (!handled) {
handled = selectCurrentWordAndStartDrag();
if (handled) {
MetricsLogger.action(
mTextView.getContext(),
MetricsEvent.TEXT_LONGPRESS,
TextViewMetrics.SUBTYPE_LONG_PRESS_SELECTION);
}
}
return handled;

View File

@@ -148,6 +148,8 @@ import android.view.textservice.TextServicesManager;
import android.widget.RemoteViews.RemoteView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.FastMath;
import com.android.internal.widget.EditableInputConnection;
@@ -9685,6 +9687,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (handled) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
if (mEditor != null) mEditor.mDiscardNextActionUp = true;
} else {
MetricsLogger.action(
mContext,
MetricsEvent.TEXT_LONGPRESS,
TextViewMetrics.SUBTYPE_LONG_PRESS_OTHER);
}
return handled;

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.widget;
/**
* {@link com.android.internal.logging.MetricsLogger} values for TextView.
*
* @hide
*/
final class TextViewMetrics {
private TextViewMetrics() {}
/**
* Long press on TextView - no special classification.
*/
static final int SUBTYPE_LONG_PRESS_OTHER = 0;
/**
* Long press on TextView - selection started.
*/
static final int SUBTYPE_LONG_PRESS_SELECTION = 1;
/**
* Long press on TextView - drag and drop started.
*/
static final int SUBTYPE_LONG_PRESS_DRAG_AND_DROP = 2;
}