From 0de35265c112bf8488a3d5c799808bf4cc0e5272 Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Wed, 12 Oct 2022 20:41:29 +0000 Subject: [PATCH] Add scroll up and scroll down logging. Bug: 247601175 Test: Manual. https://paste.googleplex.com/5757099224072192 Change-Id: Iec1697e1580c75572c9e77ec349942301ee87694 --- .../allapps/AllAppsRecyclerView.java | 34 +++++++++++++++++-- .../launcher3/logging/StatsLogManager.java | 14 ++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 21a7dfbb41..0efa7c4444 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -17,7 +17,11 @@ package com.android.launcher3.allapps; import static android.view.View.MeasureSpec.UNSPECIFIED; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED; +import static com.android.launcher3.logger.LauncherAtom.ContainerInfo; +import static com.android.launcher3.logger.LauncherAtom.SearchResultContainer; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED_DOWN; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED_UP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END; import static com.android.launcher3.util.LogConfig.SEARCH_LOGGING; @@ -31,6 +35,7 @@ import android.util.SparseIntArray; import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.ExtendedEditText; import com.android.launcher3.FastScrollRecyclerView; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; @@ -56,6 +61,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { private final SparseIntArray mViewHeights = new SparseIntArray(); private final SparseIntArray mCachedScrollPositions = new SparseIntArray(); private final AllAppsFastScrollHelper mFastScrollHelper; + private int mCumulativeVerticalScroll; private final AdapterDataObserver mObserver = new RecyclerView.AdapterDataObserver() { @@ -157,7 +163,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { StatsLogManager mgr = ActivityContext.lookupContext(getContext()).getStatsLogManager(); switch (state) { case SCROLL_STATE_DRAGGING: - mgr.logger().log(LAUNCHER_ALLAPPS_SCROLLED); + mCumulativeVerticalScroll = 0; requestFocus(); mgr.logger().sendToInteractionJankMonitor( LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN, this); @@ -166,10 +172,17 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { case SCROLL_STATE_IDLE: mgr.logger().sendToInteractionJankMonitor( LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END, this); + logCumulativeVerticalScroll(); break; } } + @Override + public void onScrolled(int dx, int dy) { + super.onScrolled(dx, dy); + mCumulativeVerticalScroll += dy; + } + /** * Maps the touch (from 0..1) to the adapter position that should be visible. */ @@ -349,4 +362,21 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { public boolean hasOverlappingRendering() { return false; } + + private void logCumulativeVerticalScroll() { + ActivityContext context = ActivityContext.lookupContext(getContext()); + StatsLogManager mgr = context.getStatsLogManager(); + ExtendedEditText editText = context.getAppsView().getSearchUiManager().getEditText(); + ContainerInfo containerInfo = ContainerInfo.newBuilder().setSearchResultContainer( + SearchResultContainer + .newBuilder() + .setQueryLength((editText == null) ? -1 : editText.length())).build(); + + // mCumulativeVerticalScroll == 0 when user comes back to original position, we don't + // know the direction of scrolling. + mgr.logger().withContainerInfo(containerInfo).log( + mCumulativeVerticalScroll == 0 ? LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION + : (mCumulativeVerticalScroll > 0) ? LAUNCHER_ALLAPPS_SCROLLED_DOWN + : LAUNCHER_ALLAPPS_SCROLLED_UP); + } } diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 22627b4ac2..837e47a4af 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -555,6 +555,20 @@ public class StatsLogManager implements ResourceBasedOverride { + "result page etc.") LAUNCHER_ALLAPPS_SCROLLED(985), + @UiEvent(doc = "User scrolled up on one of the all apps surfaces such as A-Z list, search " + + "result page etc.") + LAUNCHER_ALLAPPS_SCROLLED_UP(1229), + + @UiEvent(doc = + "User scrolled down on one of the all apps surfaces such as A-Z list, search " + + "result page etc.") + LAUNCHER_ALLAPPS_SCROLLED_DOWN(1230), + + @UiEvent(doc = "User scrolled on one of the all apps surfaces such as A-Z list, search " + + "result page etc and we don't know the direction since user came back to " + + "original position from which they scrolled.") + LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION(1231), + @UiEvent(doc = "User tapped taskbar home button") LAUNCHER_TASKBAR_HOME_BUTTON_TAP(1003),