From 6a8d9415f22d1ab23af5d166f5fb059a30dba6b4 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Fri, 21 Feb 2020 16:51:09 -0500 Subject: [PATCH] Migrate QS_EDIT metrics to WW This migrates the previous Tron events into Westworld. Now we only log the spec/package for each tile, not the position. The position in most cases is not interesting as it can be obtained from other places (in the future, lift this info from QSTileHost for example). Fixes: 147508828 Test: manual using statsd_testdrive Change-Id: I7b27a31b303d6ebe894041433fbf9d81e57a9f3c --- .../systemui/qs/customize/QSCustomizer.java | 11 +++--- .../systemui/qs/customize/QSEditEvent.kt | 38 +++++++++++++++++++ .../systemui/qs/customize/TileAdapter.java | 20 +++------- 3 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/qs/customize/QSEditEvent.kt diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java index fb89ed264628d..bfac85bd4c104 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java @@ -37,8 +37,8 @@ import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.nano.MetricsProto; +import com.android.internal.logging.UiEventLogger; +import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.plugins.qs.QS; @@ -86,6 +86,7 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene private int mY; private boolean mOpening; private boolean mIsShowingNavBackdrop; + private UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); @Inject public QSCustomizer(Context context, AttributeSet attrs, @@ -187,7 +188,7 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene int containerLocation[] = findViewById(R.id.customize_container).getLocationOnScreen(); mX = x - containerLocation[0]; mY = y - containerLocation[1]; - MetricsLogger.visible(getContext(), MetricsProto.MetricsEvent.QS_EDIT); + mUiEventLogger.log(QSEditEvent.QS_EDIT_OPEN); isShown = true; mOpening = true; setTileSpecs(); @@ -224,7 +225,7 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene public void hide() { final boolean animate = mScreenLifecycle.getScreenState() != ScreenLifecycle.SCREEN_OFF; if (isShown) { - MetricsLogger.hidden(getContext(), MetricsProto.MetricsEvent.QS_EDIT); + mUiEventLogger.log(QSEditEvent.QS_EDIT_CLOSED); isShown = false; mToolbar.dismissPopupMenus(); setCustomizing(false); @@ -258,7 +259,7 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case MENU_RESET: - MetricsLogger.action(getContext(), MetricsProto.MetricsEvent.ACTION_QS_EDIT_RESET); + mUiEventLogger.log(QSEditEvent.QS_EDIT_RESET); reset(); break; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSEditEvent.kt b/packages/SystemUI/src/com/android/systemui/qs/customize/QSEditEvent.kt new file mode 100644 index 0000000000000..ff8ddec8397a2 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSEditEvent.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 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 com.android.systemui.qs.customize + +import com.android.internal.logging.UiEvent +import com.android.internal.logging.UiEventLogger + +enum class QSEditEvent(private val _id: Int) : UiEventLogger.UiEventEnum { + + @UiEvent(doc = "Tile removed from current tiles") + QS_EDIT_REMOVE(210), + @UiEvent(doc = "Tile added to current tiles") + QS_EDIT_ADD(211), + @UiEvent(doc = "Tile moved") + QS_EDIT_MOVE(212), + @UiEvent(doc = "QS customizer open") + QS_EDIT_OPEN(213), + @UiEvent(doc = "QS customizer closed") + QS_EDIT_CLOSED(214), + @UiEvent(doc = "QS tiles reset") + QS_EDIT_RESET(215); + + override fun getId() = _id +} \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java index 3afc46045a779..58de95d7ed6da 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java @@ -40,8 +40,8 @@ import androidx.recyclerview.widget.RecyclerView.ItemDecoration; import androidx.recyclerview.widget.RecyclerView.State; import androidx.recyclerview.widget.RecyclerView.ViewHolder; -import com.android.internal.logging.MetricsLogger; -import com.android.internal.logging.nano.MetricsProto; +import com.android.internal.logging.UiEventLogger; +import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.qs.QSTileHost; import com.android.systemui.qs.customize.TileAdapter.Holder; @@ -92,6 +92,7 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta private int mAccessibilityFromIndex; private CharSequence mAccessibilityFromLabel; private QSTileHost mHost; + private UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); public TileAdapter(Context context) { mContext = context; @@ -436,20 +437,11 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta move(from, to, mTiles); updateDividerLocations(); if (to >= mEditIndex) { - MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE_SPEC, - strip(mTiles.get(to))); - MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE, - from); + mUiEventLogger.log(QSEditEvent.QS_EDIT_REMOVE, 0, strip(mTiles.get(to))); } else if (from >= mEditIndex) { - MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_ADD_SPEC, - strip(mTiles.get(to))); - MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_ADD, - to); + mUiEventLogger.log(QSEditEvent.QS_EDIT_ADD, 0, strip(mTiles.get(to))); } else { - MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_MOVE_SPEC, - strip(mTiles.get(to))); - MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_MOVE, - to); + mUiEventLogger.log(QSEditEvent.QS_EDIT_MOVE, 0, strip(mTiles.get(to))); } saveSpecs(mHost); return true;