diff options
| author | 2016-11-03 23:27:58 +0000 | |
|---|---|---|
| committer | 2016-11-17 10:51:26 +0000 | |
| commit | 1b304e40737ac7df8034dc4e0433e768635b5e7c (patch) | |
| tree | 80534ea9abe82f95ffb6255a007d0e80171a27b7 | |
| parent | 75ec5465f046149f4b53976a1cfd5f46dc51e944 (diff) | |
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
| -rw-r--r-- | core/java/android/widget/Editor.java | 20 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 7 | ||||
| -rw-r--r-- | core/java/android/widget/TextViewMetrics.java | 40 | ||||
| -rw-r--r-- | proto/src/metrics_constants.proto | 6 |
4 files changed, 73 insertions, 0 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 5eaabe7c137b..541fbe0528f1 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -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; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 5426a37cdd80..69f463cdd856 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -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; diff --git a/core/java/android/widget/TextViewMetrics.java b/core/java/android/widget/TextViewMetrics.java new file mode 100644 index 000000000000..0a14d3e8b466 --- /dev/null +++ b/core/java/android/widget/TextViewMetrics.java @@ -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; +} diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index 9b4b1868cdbb..45f2ec76588a 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -2653,6 +2653,12 @@ message MetricsEvent { // OS: O ENTERPRISE_PRIVACY_SETTINGS = 628; + // ACTION: Longpress on a TextView. + // SUBTYPE: 1 is for START_SELECTION, 2 is for START_DRAG_AND_DROP, 0 is for OTHER. + // CATEGORY: TEXT_CONTROLS + // OS: O + TEXT_LONGPRESS = 629; + // ---- End O Constants, all O constants go above this line ---- // Add new aosp constants above this line. |