diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java index 69812b6154..d4d46fbb2c 100644 --- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java +++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java @@ -65,10 +65,10 @@ public class StatsLogCompatManager extends StatsLogManager { } /** - * Logs a {@link LauncherEvent}. + * Logs a {@link EventEnum}. */ @Override - public void log(LauncherEvent event) { + public void log(EventEnum event) { log(event, DEFAULT_INSTANCE_ID, LauncherAtom.ItemInfo.getDefaultInstance()); } @@ -76,7 +76,7 @@ public class StatsLogCompatManager extends StatsLogManager { * Logs an event and accompanying {@link InstanceId}. */ @Override - public void log(LauncherEvent event, InstanceId instanceId) { + public void log(EventEnum event, InstanceId instanceId) { log(event, instanceId, LauncherAtom.ItemInfo.getDefaultInstance()); } @@ -84,7 +84,7 @@ public class StatsLogCompatManager extends StatsLogManager { * Logs an event and accompanying {@link ItemInfo}. */ @Override - public void log(LauncherEvent event, @Nullable LauncherAtom.ItemInfo info) { + public void log(EventEnum event, @Nullable LauncherAtom.ItemInfo info) { log(event, DEFAULT_INSTANCE_ID, info); } @@ -92,7 +92,7 @@ public class StatsLogCompatManager extends StatsLogManager { * Logs an event and accompanying {@link InstanceId} and {@link LauncherAtom.ItemInfo}. */ @Override - public void log(LauncherEvent event, InstanceId instanceId, + public void log(EventEnum event, InstanceId instanceId, @Nullable LauncherAtom.ItemInfo info) { logInternal(event, instanceId, info, LAUNCHER_UICHANGED__DST_STATE__HOME, @@ -102,14 +102,17 @@ public class StatsLogCompatManager extends StatsLogManager { /** * Logs an event and accompanying {@link InstanceId} and {@link LauncherAtom.ItemInfo}. */ - private void logInternal(LauncherEvent event, InstanceId instanceId, + private void logInternal(EventEnum event, InstanceId instanceId, @Nullable LauncherAtom.ItemInfo info, int startState, int endState) { info = info == null ? LauncherAtom.ItemInfo.getDefaultInstance() : info; if (IS_VERBOSE) { + String name = (event instanceof LauncherEvent) ? ((LauncherEvent) event).name() : + event.getId() + ""; + Log.d(TAG, instanceId == DEFAULT_INSTANCE_ID - ? String.format("\n%s\n%s", event.name(), info) - : String.format("%s(InstanceId:%s)\n%s", event.name(), instanceId, info)); + ? String.format("\n%s\n%s", name, info) + : String.format("%s(InstanceId:%s)\n%s", name, instanceId, info)); } if (!Utilities.ATLEAST_R) { diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 4c2c79d6dd..e11d21f34e 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -32,7 +32,7 @@ import com.android.launcher3.util.ResourceBasedOverride; */ public class StatsLogManager implements ResourceBasedOverride { - interface EventEnum { + public interface EventEnum { int getId(); } @@ -63,6 +63,18 @@ public class StatsLogManager implements ResourceBasedOverride { + "new/same value.") LAUNCHER_FOLDER_LABEL_UPDATED(460), + @UiEvent(doc = "User long pressed on the workspace empty space.") + LAUNCHER_WORKSPACE_LONGPRESS(461), + + @UiEvent(doc = "User tapped or long pressed on a wallpaper icon inside launcher settings.") + LAUNCHER_WALLPAPER_BUTTON_TAP_OR_LONGPRESS(462), + + @UiEvent(doc = "User tapped or long pressed on settings icon inside launcher settings.") + LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS(463), + + @UiEvent(doc = "User tapped or long pressed on widget tray icon inside launcher settings.") + LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS(464), + @UiEvent(doc = "A dragged item is dropped on 'Remove' button in the target bar") LAUNCHER_ITEM_DROPPED_ON_REMOVE(465), @@ -113,27 +125,27 @@ public class StatsLogManager implements ResourceBasedOverride { } /** - * Logs a {@link LauncherEvent}. + * Logs a {@link EventEnum}. */ - public void log(LauncherEvent event) { + public void log(EventEnum event) { } /** * Logs an event and accompanying {@link InstanceId}. */ - public void log(LauncherEvent event, InstanceId instanceId) { + public void log(EventEnum event, InstanceId instanceId) { } /** * Logs an event and accompanying {@link ItemInfo}. */ - public void log(LauncherEvent event, @Nullable ItemInfo info) { + public void log(EventEnum event, @Nullable ItemInfo itemInfo) { } /** * Logs an event and accompanying {@link InstanceId} and {@link ItemInfo}. */ - public void log(LauncherEvent event, InstanceId instanceId, @Nullable ItemInfo info) { + public void log(EventEnum event, InstanceId instanceId, @Nullable ItemInfo itemInfo) { } /** diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java index e6de06d6f0..7270ce28fb 100644 --- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java +++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java @@ -22,6 +22,7 @@ import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.LauncherState.NORMAL; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_LONGPRESS; import android.graphics.PointF; import android.graphics.Rect; @@ -41,8 +42,6 @@ import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.views.OptionsPopupView; -import com.android.launcher3.userevent.nano.LauncherLogProto.Action; -import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; /** * Helper class to handle touch on empty space in workspace and show options popup on long press @@ -175,9 +174,7 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - mLauncher.getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS, - Action.Direction.NONE, ContainerType.WORKSPACE, - mWorkspace.getCurrentPage()); + mLauncher.getStatsLogManager().log(LAUNCHER_WORKSPACE_LONGPRESS); OptionsPopupView.showDefaultOptions(mLauncher, mTouchDownPoint.x, mTouchDownPoint.y); } else { cancelLongPress(); diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index d5c3c1d30e..7467186721 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -17,6 +17,9 @@ package com.android.launcher3.views; import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_FLAVOR; import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WALLPAPER_BUTTON_TAP_OR_LONGPRESS; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS; import android.content.Context; import android.content.Intent; @@ -37,13 +40,12 @@ import androidx.annotation.VisibleForTesting; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.android.launcher3.logging.StatsLogManager.EventEnum; import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.popup.ArrowPopup; import com.android.launcher3.shortcuts.DeepShortcutView; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestProtocol; -import com.android.launcher3.userevent.nano.LauncherLogProto.Action; -import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; import com.android.launcher3.widget.WidgetsFullSheet; import java.util.ArrayList; @@ -68,21 +70,21 @@ public class OptionsPopupView extends ArrowPopup @Override public void onClick(View view) { - handleViewClick(view, Action.Touch.TAP); + handleViewClick(view); } @Override public boolean onLongClick(View view) { - return handleViewClick(view, Action.Touch.LONGPRESS); + return handleViewClick(view); } - private boolean handleViewClick(View view, int action) { + private boolean handleViewClick(View view) { OptionItem item = mItemMap.get(view); if (item == null) { return false; } - if (item.mControlTypeForLog > 0) { - logTap(action, item.mControlTypeForLog); + if (item.mEventId.getId() > 0) { + mLauncher.getStatsLogManager().log(item.mEventId); } if (item.mClickListener.onLongClick(view)) { close(true); @@ -91,10 +93,6 @@ public class OptionsPopupView extends ArrowPopup return false; } - private void logTap(int action, int controlType) { - mLauncher.getUserEventDispatcher().logActionOnControl(action, controlType); - } - @Override public boolean onControllerInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() != MotionEvent.ACTION_DOWN) { @@ -159,13 +157,16 @@ public class OptionsPopupView extends ArrowPopup int resDrawable = Utilities.existsStyleWallpapers(launcher) ? R.drawable.ic_palette : R.drawable.ic_wallpaper; options.add(new OptionItem(resString, resDrawable, - ControlType.WALLPAPER_BUTTON, OptionsPopupView::startWallpaperPicker)); + LAUNCHER_WALLPAPER_BUTTON_TAP_OR_LONGPRESS, + OptionsPopupView::startWallpaperPicker)); if (!WidgetsModel.GO_DISABLE_WIDGETS) { options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget, - ControlType.WIDGETS_BUTTON, OptionsPopupView::onWidgetsClicked)); + LAUNCHER_WIDGETSTRAY_BUTTON_TAP_OR_LONGPRESS, + OptionsPopupView::onWidgetsClicked)); } options.add(new OptionItem(R.string.settings_button_text, R.drawable.ic_setting, - ControlType.SETTINGS_BUTTON, OptionsPopupView::startSettings)); + LAUNCHER_SETTINGS_BUTTON_TAP_OR_LONGPRESS, + OptionsPopupView::startSettings)); show(launcher, target, options); } @@ -224,14 +225,14 @@ public class OptionsPopupView extends ArrowPopup private final int mLabelRes; private final int mIconRes; - private final int mControlTypeForLog; + private final EventEnum mEventId; private final OnLongClickListener mClickListener; - public OptionItem(int labelRes, int iconRes, int controlTypeForLog, + public OptionItem(int labelRes, int iconRes, EventEnum eventId, OnLongClickListener clickListener) { mLabelRes = labelRes; mIconRes = iconRes; - mControlTypeForLog = controlTypeForLog; + mEventId = eventId; mClickListener = clickListener; } }