Using StatsLog for notifyingAppPredictor

> Adding a listener in StartsLogManager for listening to events.
  This allows events to be directored to the predictor only if
  it is already running, instead of creating it.
> Unifying the event format to be same as hotseat predictor

Bug: 160748731
Change-Id: Ib00e6249ff642c030f00bcad5b748255e704d16a
This commit is contained in:
Sunny Goyal
2020-07-15 17:02:16 -07:00
parent 2c0cdfb100
commit 852537fd98
24 changed files with 259 additions and 345 deletions

View File

@@ -18,7 +18,6 @@ package com.android.launcher3.touch;
import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET;
import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_ALL_APPS;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_BY_PUBLISHER;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_QUIET_USER;
@@ -37,8 +36,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
@@ -72,13 +69,9 @@ public class ItemClickHandler {
/**
* Instance used for click handling on items
*/
public static final OnClickListener INSTANCE = getInstance(null);
public static final OnClickListener INSTANCE = ItemClickHandler::onClick;
public static final OnClickListener getInstance(String sourceContainer) {
return v -> onClick(v, sourceContainer);
}
private static void onClick(View v, String sourceContainer) {
private static void onClick(View v) {
// Make sure that rogue clicks don't get through while allapps is launching, or after the
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null) return;
@@ -88,14 +81,14 @@ public class ItemClickHandler {
Object tag = v.getTag();
if (tag instanceof WorkspaceItemInfo) {
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher, sourceContainer);
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
} else if (tag instanceof FolderInfo) {
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
}
} else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher,
sourceContainer == null ? CONTAINER_ALL_APPS: sourceContainer);
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher
);
} else if (tag instanceof LauncherAppWidgetInfo) {
if (v instanceof PendingAppWidgetHostView) {
onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
@@ -191,7 +184,7 @@ public class ItemClickHandler {
// Fallback to using custom market intent.
Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName);
launcher.startActivitySafely(v, intent, item, null);
launcher.startActivitySafely(v, intent, item);
}
/**
@@ -199,8 +192,7 @@ public class ItemClickHandler {
*
* @param v The view that was clicked. Must be a tagged with a {@link WorkspaceItemInfo}.
*/
public static void onClickAppShortcut(View v, WorkspaceItemInfo shortcut, Launcher launcher,
@Nullable String sourceContainer) {
public static void onClickAppShortcut(View v, WorkspaceItemInfo shortcut, Launcher launcher) {
if (shortcut.isDisabled()) {
final int disabledFlags = shortcut.runtimeStatusFlags
& WorkspaceItemInfo.FLAG_DISABLED_MASK;
@@ -241,11 +233,10 @@ public class ItemClickHandler {
}
// Start activities
startAppShortcutOrInfoActivity(v, shortcut, launcher, sourceContainer);
startAppShortcutOrInfoActivity(v, shortcut, launcher);
}
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher,
@Nullable String sourceContainer) {
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
Intent intent;
@@ -274,6 +265,6 @@ public class ItemClickHandler {
// Preload the icon to reduce latency b/w swapping the floating view with the original.
FloatingIconView.fetchIcon(launcher, v, item, true /* isOpening */);
}
launcher.startActivitySafely(v, intent, item, sourceContainer);
launcher.startActivitySafely(v, intent, item);
}
}