LAUNCHER_APP_LAUNCH_TAP should log correctly for icons inside folder

Bug: 137777105

Change-Id: I5c1552481fc1b788ba41c57bfe97f126f55e5b16
This commit is contained in:
Hyunyoung Song 2020-06-10 00:35:35 -07:00
parent 662796d18b
commit 13c2bc7303
15 changed files with 144 additions and 142 deletions

View File

@ -54,6 +54,7 @@ message ContainerInfo {
ShortcutsContainer shortcuts_container = 8; ShortcutsContainer shortcuts_container = 8;
SettingsContainer settings_container = 9; SettingsContainer settings_container = 9;
PredictedHotseatContainer predicted_hotseat_container = 10; PredictedHotseatContainer predicted_hotseat_container = 10;
TaskSwitcherContainer task_switcher_container = 11;
} }
} }
@ -82,6 +83,9 @@ message ShortcutsContainer {
message SettingsContainer { message SettingsContainer {
} }
message TaskSwitcherContainer {
}
enum Attribute { enum Attribute {
UNKNOWN = 0; UNKNOWN = 0;
DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat

View File

@ -26,23 +26,18 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch
import android.app.Activity; import android.app.Activity;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.UserHandle;
import android.view.View; import android.view.View;
import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile; import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logging.StatsLogManager.LauncherEvent; import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
import com.android.launcher3.model.WellbeingModel; import com.android.launcher3.model.WellbeingModel;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.popup.SystemShortcut.AppInfo; import com.android.launcher3.popup.SystemShortcut.AppInfo;
import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto;
@ -71,28 +66,7 @@ public interface TaskShortcutFactory {
SystemShortcut getShortcut(BaseDraggingActivity activity, TaskView view); SystemShortcut getShortcut(BaseDraggingActivity activity, TaskView view);
static WorkspaceItemInfo dummyInfo(TaskView view) { TaskShortcutFactory APP_INFO = (activity, view) -> new AppInfo(activity, view.getItemInfo());
Task task = view.getTask();
WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo(){
/**
* Helps to log events as {@link LauncherAtom.Task}
* instead of {@link LauncherAtom.ItemInfo}.
*/
@Override
public LauncherAtom.ItemInfo buildProto() {
return view.buildProto();
}
};
dummyInfo.intent = new Intent();
ComponentName component = task.getTopComponent();
dummyInfo.getIntent().setComponent(component);
dummyInfo.user = UserHandle.of(task.key.userId);
dummyInfo.title = TaskUtils.getTitle(view.getContext(), task);
return dummyInfo;
}
TaskShortcutFactory APP_INFO = (activity, view) -> new AppInfo(activity, dummyInfo(view));
abstract class MultiWindowFactory implements TaskShortcutFactory { abstract class MultiWindowFactory implements TaskShortcutFactory {
@ -136,7 +110,7 @@ public interface TaskShortcutFactory {
public MultiWindowSystemShortcut(int iconRes, int textRes, BaseDraggingActivity activity, public MultiWindowSystemShortcut(int iconRes, int textRes, BaseDraggingActivity activity,
TaskView taskView, MultiWindowFactory factory, LauncherEvent launcherEvent) { TaskView taskView, MultiWindowFactory factory, LauncherEvent launcherEvent) {
super(iconRes, textRes, activity, dummyInfo(taskView)); super(iconRes, textRes, activity, taskView.getItemInfo());
mLauncherEvent = launcherEvent; mLauncherEvent = launcherEvent;
mHandler = new Handler(Looper.getMainLooper()); mHandler = new Handler(Looper.getMainLooper());
mTaskView = taskView; mTaskView = taskView;
@ -222,7 +196,7 @@ public interface TaskShortcutFactory {
WindowManagerWrapper.getInstance().overridePendingAppTransitionMultiThumbFuture( WindowManagerWrapper.getInstance().overridePendingAppTransitionMultiThumbFuture(
future, animStartedListener, mHandler, true /* scaleUp */, future, animStartedListener, mHandler, true /* scaleUp */,
taskKey.displayId); taskKey.displayId);
mTarget.getStatsLogManager().log(mLauncherEvent, mTaskView.buildProto()); mTarget.getStatsLogManager().log(mLauncherEvent, mTaskView.getItemInfo());
} }
} }
} }
@ -306,7 +280,7 @@ public interface TaskShortcutFactory {
private final TaskView mTaskView; private final TaskView mTaskView;
public PinSystemShortcut(BaseDraggingActivity target, TaskView tv) { public PinSystemShortcut(BaseDraggingActivity target, TaskView tv) {
super(R.drawable.ic_pin, R.string.recent_task_option_pin, target, dummyInfo(tv)); super(R.drawable.ic_pin, R.string.recent_task_option_pin, target, tv.getItemInfo());
mTaskView = tv; mTaskView = tv;
} }
@ -323,29 +297,29 @@ public interface TaskShortcutFactory {
mTaskView.launchTask(true, resultCallback, Executors.MAIN_EXECUTOR.getHandler()); mTaskView.launchTask(true, resultCallback, Executors.MAIN_EXECUTOR.getHandler());
dismissTaskMenuView(mTarget); dismissTaskMenuView(mTarget);
mTarget.getStatsLogManager().log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP, mTarget.getStatsLogManager().log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP,
mTaskView.buildProto()); mTaskView.getItemInfo());
} }
} }
TaskShortcutFactory INSTALL = (activity, view) -> TaskShortcutFactory INSTALL = (activity, view) ->
InstantAppResolver.newInstance(activity).isInstantApp(activity, InstantAppResolver.newInstance(activity).isInstantApp(activity,
view.getTask().getTopComponent().getPackageName()) view.getTask().getTopComponent().getPackageName())
? new SystemShortcut.Install(activity, dummyInfo(view)) : null; ? new SystemShortcut.Install(activity, view.getItemInfo()) : null;
TaskShortcutFactory WELLBEING = (activity, view) -> TaskShortcutFactory WELLBEING = (activity, view) ->
WellbeingModel.SHORTCUT_FACTORY.getShortcut(activity, dummyInfo(view)); WellbeingModel.SHORTCUT_FACTORY.getShortcut(activity, view.getItemInfo());
TaskShortcutFactory SCREENSHOT = (activity, tv) -> { TaskShortcutFactory SCREENSHOT = (activity, tv) -> {
if (ENABLE_OVERVIEW_ACTIONS.get()) { if (ENABLE_OVERVIEW_ACTIONS.get()) {
return tv.getThumbnail().getTaskOverlay() return tv.getThumbnail().getTaskOverlay()
.getScreenshotShortcut(activity, dummyInfo(tv)); .getScreenshotShortcut(activity, tv.getItemInfo());
} }
return null; return null;
}; };
TaskShortcutFactory MODAL = (activity, tv) -> { TaskShortcutFactory MODAL = (activity, tv) -> {
if (ENABLE_OVERVIEW_ACTIONS.get() && ENABLE_OVERVIEW_SELECTIONS.get()) { if (ENABLE_OVERVIEW_ACTIONS.get() && ENABLE_OVERVIEW_SELECTIONS.get()) {
return tv.getThumbnail().getTaskOverlay().getModalStateSystemShortcut(dummyInfo(tv)); return tv.getThumbnail().getTaskOverlay().getModalStateSystemShortcut(tv.getItemInfo());
} }
return null; return null;
}; };

View File

@ -1347,7 +1347,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss( mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
endState.logAction, Direction.UP, index, compKey); endState.logAction, Direction.UP, index, compKey);
mActivity.getStatsLogManager().log( mActivity.getStatsLogManager().log(
LAUNCHER_TASK_DISMISS_SWIPE_UP, taskView.buildProto()); LAUNCHER_TASK_DISMISS_SWIPE_UP, taskView.getItemInfo());
} }
} }
@ -1930,7 +1930,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
endState.logAction, Direction.DOWN, indexOfChild(tv), endState.logAction, Direction.DOWN, indexOfChild(tv),
TaskUtils.getLaunchComponentKeyForTask(task.key)); TaskUtils.getLaunchComponentKeyForTask(task.key));
mActivity.getStatsLogManager().log( mActivity.getStatsLogManager().log(
LAUNCHER_TASK_LAUNCH_SWIPE_DOWN, tv.buildProto()); LAUNCHER_TASK_LAUNCH_SWIPE_DOWN, tv.getItemInfo());
} }
} else { } else {
onTaskLaunched(false); onTaskLaunched(false);

View File

@ -40,6 +40,7 @@ import android.animation.TimeInterpolator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Outline; import android.graphics.Outline;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
@ -48,7 +49,6 @@ import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.InsetDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Process;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.FloatProperty; import android.util.FloatProperty;
import android.util.Log; import android.util.Log;
@ -61,13 +61,14 @@ import android.widget.Toast;
import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile; import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.Utilities; import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.testing.TestProtocol;
@ -213,7 +214,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss( mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
Touch.TAP, Direction.NONE, getRecentsView().indexOfChild(this), Touch.TAP, Direction.NONE, getRecentsView().indexOfChild(this),
TaskUtils.getLaunchComponentKeyForTask(getTask().key)); TaskUtils.getLaunchComponentKeyForTask(getTask().key));
mActivity.getStatsLogManager().log(LAUNCHER_TASK_LAUNCH_TAP, buildProto()); mActivity.getStatsLogManager().log(LAUNCHER_TASK_LAUNCH_TAP, getItemInfo());
}); });
mCurrentFullscreenParams = new FullscreenDrawParams(context); mCurrentFullscreenParams = new FullscreenDrawParams(context);
@ -226,14 +227,16 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
/** /**
* Builds proto for logging * Builds proto for logging
*/ */
public LauncherAtom.ItemInfo buildProto() { public WorkspaceItemInfo getItemInfo() {
ComponentKey componentKey = TaskUtils.getLaunchComponentKeyForTask(getTask().key); ComponentKey componentKey = TaskUtils.getLaunchComponentKeyForTask(getTask().key);
LauncherAtom.ItemInfo.Builder itemBuilder = LauncherAtom.ItemInfo.newBuilder(); WorkspaceItemInfo dummyInfo = new WorkspaceItemInfo();
itemBuilder.setIsWork(componentKey.user != Process.myUserHandle()); dummyInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK;
itemBuilder.setTask(LauncherAtom.Task.newBuilder() dummyInfo.container = LauncherSettings.Favorites.CONTAINER_TASKSWITCHER;
.setComponentName(componentKey.componentName.flattenToShortString()) dummyInfo.user = componentKey.user;
.setIndex(getRecentsView().indexOfChild(this))); dummyInfo.intent = new Intent().setComponent(componentKey.componentName);
return itemBuilder.build(); dummyInfo.title = TaskUtils.getTitle(getContext(), getTask());
dummyInfo.screenId = getRecentsView().indexOfChild(this);
return dummyInfo;
} }
@Override @Override
@ -429,7 +432,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
getRecentsView().snapToPage(getRecentsView().indexOfChild(this)); getRecentsView().snapToPage(getRecentsView().indexOfChild(this));
} else { } else {
mMenuView = TaskMenuView.showForTask(this); mMenuView = TaskMenuView.showForTask(this);
mActivity.getStatsLogManager().log(LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS, buildProto()); mActivity.getStatsLogManager().log(LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS, getItemInfo());
UserEventDispatcher.newInstance(getContext()).logActionOnItem(action, Direction.NONE, UserEventDispatcher.newInstance(getContext()).logActionOnItem(action, Direction.NONE,
LauncherLogProto.ItemType.TASK_ICON); LauncherLogProto.ItemType.TASK_ICON);
if (mMenuView != null) { if (mMenuView != null) {

View File

@ -64,6 +64,9 @@ public class StatsLogCompatManager extends StatsLogManager {
private static Context sContext; private static Context sContext;
private static final InstanceId DEFAULT_INSTANCE_ID = InstanceId.fakeInstanceId(0); private static final InstanceId DEFAULT_INSTANCE_ID = InstanceId.fakeInstanceId(0);
// LauncherAtom.ItemInfo.getDefaultInstance() should be used but until launcher proto migrates
// from nano to lite, bake constant to prevent robo test failure.
private static final int DEFAULT_PAGE_INDEX = -2;
private static final int FOLDER_HIERARCHY_OFFSET = 100; private static final int FOLDER_HIERARCHY_OFFSET = 100;
public StatsLogCompatManager(Context context) { public StatsLogCompatManager(Context context) {
@ -75,7 +78,7 @@ public class StatsLogCompatManager extends StatsLogManager {
*/ */
@Override @Override
public void log(EventEnum event) { public void log(EventEnum event) {
log(event, DEFAULT_INSTANCE_ID, LauncherAtom.ItemInfo.getDefaultInstance()); log(event, DEFAULT_INSTANCE_ID, null);
} }
/** /**
@ -83,31 +86,27 @@ public class StatsLogCompatManager extends StatsLogManager {
*/ */
@Override @Override
public void log(EventEnum event, InstanceId instanceId) { public void log(EventEnum event, InstanceId instanceId) {
log(event, instanceId, LauncherAtom.ItemInfo.getDefaultInstance()); log(event, instanceId, null);
} }
/** /**
* Logs an event and accompanying {@link ItemInfo}. * Logs an event and accompanying {@link ItemInfo}.
*/ */
@Override @Override
public void log(EventEnum event, @Nullable LauncherAtom.ItemInfo info) { public void log(EventEnum event, @Nullable ItemInfo info) {
log(event, DEFAULT_INSTANCE_ID, info); log(event, DEFAULT_INSTANCE_ID, info);
} }
@Override
public void log(EventEnum event, ItemInfo itemInfo) {
logInternal(event, DEFAULT_INSTANCE_ID, itemInfo);
}
/** /**
* Logs an event and accompanying {@link InstanceId} and {@link LauncherAtom.ItemInfo}. * Logs an event and accompanying {@link InstanceId} and {@link LauncherAtom.ItemInfo}.
*/ */
@Override @Override
public void log(EventEnum event, InstanceId instanceId, public void log(EventEnum event, InstanceId instanceId,
@Nullable LauncherAtom.ItemInfo info) { @Nullable ItemInfo info) {
logInternal(event, instanceId, info, logInternal(event, instanceId, info,
LAUNCHER_UICHANGED__DST_STATE__HOME, LAUNCHER_UICHANGED__DST_STATE__HOME,
LAUNCHER_UICHANGED__DST_STATE__BACKGROUND); LAUNCHER_UICHANGED__DST_STATE__BACKGROUND,
DEFAULT_PAGE_INDEX);
} }
/** /**
@ -129,58 +128,60 @@ public class StatsLogCompatManager extends StatsLogManager {
*/ */
@Override @Override
public void log(EventEnum event, int srcState, int dstState, int pageIndex) { public void log(EventEnum event, int srcState, int dstState, int pageIndex) {
LauncherAtom.ItemInfo info = LauncherAtom.ItemInfo.getDefaultInstance(); logInternal(event, DEFAULT_INSTANCE_ID, null, srcState, dstState, pageIndex);
if (srcState == LAUNCHER_UICHANGED__DST_STATE__HOME
|| dstState == LAUNCHER_UICHANGED__SRC_STATE__HOME) {
info = LauncherAtom.ItemInfo.newBuilder().setContainerInfo(
LauncherAtom.ContainerInfo.newBuilder().setWorkspace(
LauncherAtom.WorkspaceContainer.newBuilder().setPageIndex(pageIndex)
)).build();
}
logInternal(event, DEFAULT_INSTANCE_ID, info, srcState, dstState);
} }
private void logInternal(EventEnum event, InstanceId instanceId, @Nullable ItemInfo info) { /**
* Logs an event and accompanying {@link InstanceId} and {@link ItemInfo}.
*/
private void logInternal(EventEnum event, InstanceId instanceId,
@Nullable ItemInfo info, int srcState, int dstState, int pageIndex) {
LauncherAppState.getInstance(sContext).getModel().enqueueModelUpdateTask( LauncherAppState.getInstance(sContext).getModel().enqueueModelUpdateTask(
new BaseModelUpdateTask() { new BaseModelUpdateTask() {
@Override @Override
public void execute(LauncherAppState app, BgDataModel dataModel, public void execute(LauncherAppState app, BgDataModel dataModel,
AllAppsList apps) { AllAppsList apps) {
LauncherAtom.ItemInfo atomInfo = LauncherAtom.ItemInfo.getDefaultInstance(); writeEvent(event, instanceId, info, srcState, dstState, pageIndex,
if (info != null) { dataModel.folders);
if (info.container >= 0) {
atomInfo = info.buildProto(dataModel.folders.get(info.container));
} else {
atomInfo = info.buildProto();
}
}
logInternal(event, instanceId, atomInfo,
LAUNCHER_UICHANGED__DST_STATE__HOME,
LAUNCHER_UICHANGED__DST_STATE__BACKGROUND);
} }
}); });
} }
/** private static void writeEvent(EventEnum event, InstanceId instanceId,
* Logs an event and accompanying {@link InstanceId} and {@link LauncherAtom.ItemInfo}. @Nullable ItemInfo info, int srcState, int dstState, int pageIndex,
*/ IntSparseArrayMap<FolderInfo> folders) {
private void logInternal(EventEnum event, InstanceId instanceId,
@Nullable LauncherAtom.ItemInfo info, int srcState, int dstState) { if (!Utilities.ATLEAST_R) {
info = info == null ? LauncherAtom.ItemInfo.getDefaultInstance() : info; return;
}
LauncherAtom.ItemInfo atomInfo = LauncherAtom.ItemInfo.getDefaultInstance();
if (info != null) {
if (info.container >= 0) {
atomInfo = info.buildProto(folders.get(info.container));
} else {
atomInfo = info.buildProto();
}
} else {
if (srcState == LAUNCHER_UICHANGED__DST_STATE__HOME
|| dstState == LAUNCHER_UICHANGED__SRC_STATE__HOME) {
atomInfo = LauncherAtom.ItemInfo.newBuilder().setContainerInfo(
LauncherAtom.ContainerInfo.newBuilder().setWorkspace(
LauncherAtom.WorkspaceContainer.newBuilder().setPageIndex(pageIndex)
)).build();
}
}
if (IS_VERBOSE) { if (IS_VERBOSE) {
String name = (event instanceof Enum) ? ((Enum) event).name() : String name = (event instanceof Enum) ? ((Enum) event).name() :
event.getId() + ""; event.getId() + "";
Log.d(TAG, instanceId == DEFAULT_INSTANCE_ID Log.d(TAG, instanceId == DEFAULT_INSTANCE_ID
? String.format("\n%s (State:%s->%s) \n%s", name, getStateString(srcState), ? String.format("\n%s (State:%s->%s) \n%s\n%s", name, getStateString(srcState),
getStateString(dstState), info) getStateString(dstState), info, atomInfo)
: String.format("\n%s (State:%s->%s) (InstanceId:%s)\n%s", name, : String.format("\n%s (State:%s->%s) (InstanceId:%s)\n%s\n%s", name,
getStateString(srcState), getStateString(dstState), instanceId, info)); getStateString(srcState), getStateString(dstState), instanceId, info,
} atomInfo));
if (!Utilities.ATLEAST_R) {
return;
} }
SysUiStatsLog.write( SysUiStatsLog.write(
@ -191,24 +192,24 @@ public class StatsLogCompatManager extends StatsLogManager {
null /* launcher extensions, deprecated */, null /* launcher extensions, deprecated */,
false /* quickstep_enabled, deprecated */, false /* quickstep_enabled, deprecated */,
event.getId() /* event_id */, event.getId() /* event_id */,
info.getItemCase().getNumber() /* target_id */, atomInfo.getItemCase().getNumber() /* target_id */,
instanceId.getId() /* instance_id TODO */, instanceId.getId() /* instance_id TODO */,
0 /* uid TODO */, 0 /* uid TODO */,
getPackageName(info) /* package_name */, getPackageName(atomInfo) /* package_name */,
getComponentName(info) /* component_name */, getComponentName(atomInfo) /* component_name */,
getGridX(info, false) /* grid_x */, getGridX(atomInfo, false) /* grid_x */,
getGridY(info, false) /* grid_y */, getGridY(atomInfo, false) /* grid_y */,
getPageId(info, false) /* page_id */, getPageId(atomInfo, false) /* page_id */,
getGridX(info, true) /* grid_x_parent */, getGridX(atomInfo, true) /* grid_x_parent */,
getGridY(info, true) /* grid_y_parent */, getGridY(atomInfo, true) /* grid_y_parent */,
getPageId(info, true) /* page_id_parent */, getPageId(atomInfo, true) /* page_id_parent */,
getHierarchy(info) /* hierarchy */, getHierarchy(atomInfo) /* hierarchy */,
info.getIsWork() /* is_work_profile */, atomInfo.getIsWork() /* is_work_profile */,
info.getRank() /* rank */, atomInfo.getRank() /* rank */,
info.getFolderIcon().getFromLabelState().getNumber() /* fromState */, atomInfo.getFolderIcon().getFromLabelState().getNumber() /* fromState */,
info.getFolderIcon().getToLabelState().getNumber() /* toState */, atomInfo.getFolderIcon().getToLabelState().getNumber() /* toState */,
info.getFolderIcon().getLabelInfo() /* edittext */, atomInfo.getFolderIcon().getLabelInfo() /* edittext */,
getCardinality(info) /* cardinality */); getCardinality(atomInfo) /* cardinality */);
} }
/** /**

View File

@ -188,7 +188,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
} }
getUserEventDispatcher().logAppLaunch(v, intent, user); getUserEventDispatcher().logAppLaunch(v, intent, user);
if (item != null) { if (item != null) {
getStatsLogManager().log(LAUNCHER_APP_LAUNCH_TAP, item.buildProto()); getStatsLogManager().log(LAUNCHER_APP_LAUNCH_TAP, item);
} }
return true; return true;
} catch (NullPointerException|ActivityNotFoundException|SecurityException e) { } catch (NullPointerException|ActivityNotFoundException|SecurityException e) {

View File

@ -163,6 +163,7 @@ public class LauncherSettings {
public static final int CONTAINER_SEARCH_RESULTS = -106; public static final int CONTAINER_SEARCH_RESULTS = -106;
public static final int CONTAINER_SHORTCUTS = -107; public static final int CONTAINER_SHORTCUTS = -107;
public static final int CONTAINER_SETTINGS = -108; public static final int CONTAINER_SETTINGS = -108;
public static final int CONTAINER_TASKSWITCHER = -109;
public static final String containerToString(int container) { public static final String containerToString(int container) {
switch (container) { switch (container) {
@ -249,6 +250,12 @@ public class LauncherSettings {
*/ */
public static final int ITEM_TYPE_DEEP_SHORTCUT = 6; public static final int ITEM_TYPE_DEEP_SHORTCUT = 6;
/**
* Type of the item is recents task.
* TODO(hyunyoungs): move constants not related to Favorites DB to a better location.
*/
public static final int ITEM_TYPE_TASK = 7;
/** /**
* The appWidgetId of the widget * The appWidgetId of the widget
* *

View File

@ -418,10 +418,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mStatsLogManager.log( mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED, LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED,
dragObject.logInstanceId, dragObject.logInstanceId,
dragObject.dragSource instanceof Folder dragObject.originalDragInfo
? dragObject.originalDragInfo
.buildProto(((Folder) dragObject.dragSource).mInfo)
: dragObject.originalDragInfo.buildProto()
); );
} }
@ -1652,7 +1649,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mStatsLogManager.log( mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_FOLDER_CREATED, LauncherEvent.LAUNCHER_ITEM_DROP_FOLDER_CREATED,
d.logInstanceId, d.logInstanceId,
destInfo.buildProto(null)); destInfo);
FolderIcon fi = mLauncher.addFolder(target, container, screenId, targetCell[0], FolderIcon fi = mLauncher.addFolder(target, container, screenId, targetCell[0],
targetCell[1]); targetCell[1]);
destInfo.cellX = -1; destInfo.cellX = -1;
@ -1693,7 +1690,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mStatsLogManager.log( mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED, LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId, d.logInstanceId,
fi.mInfo.buildProto(null)); fi.mInfo);
fi.onDrop(d, false /* itemReturnedOnFailedDrop */); fi.onDrop(d, false /* itemReturnedOnFailedDrop */);
// if the drag started here, we need to remove it from the workspace // if the drag started here, we need to remove it from the workspace
@ -1899,7 +1896,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mStatsLogManager.log( mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED, LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId, d.logInstanceId,
d.dragInfo.buildProto(null)); d.dragInfo);
} }
if (d.stateAnnouncer != null && !droppedOnOriginalCell) { if (d.stateAnnouncer != null && !droppedOnOriginalCell) {
@ -2440,7 +2437,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mStatsLogManager.log( mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED, LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId, d.logInstanceId,
d.dragInfo.buildProto(null)); d.dragInfo);
} }
}; };
boolean isWidget = pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET boolean isWidget = pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
@ -2532,7 +2529,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mStatsLogManager.log( mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED, LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId, d.logInstanceId,
d.dragInfo.buildProto(null)); d.dragInfo);
} }
} }

View File

@ -1338,7 +1338,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
d.stateAnnouncer.completeAction(R.string.item_moved); d.stateAnnouncer.completeAction(R.string.item_moved);
} }
mStatsLogManager mStatsLogManager
.log(LAUNCHER_ITEM_DROP_COMPLETED, d.logInstanceId, d.dragInfo.buildProto(mInfo)); .log(LAUNCHER_ITEM_DROP_COMPLETED, d.logInstanceId, d.dragInfo);
} }
// This is used so the item doesn't immediately appear in the folder when added. In one case // This is used so the item doesn't immediately appear in the folder when added. In one case
@ -1443,7 +1443,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
if (hasFocus) { if (hasFocus) {
startEditingFolderName(); startEditingFolderName();
} else { } else {
mStatsLogManager.log(LAUNCHER_FOLDER_LABEL_UPDATED, mInfo.buildProto()); mStatsLogManager.log(LAUNCHER_FOLDER_LABEL_UPDATED, mInfo);
logFolderLabelState(); logFolderLabelState();
mFolderName.dispatchBackKey(); mFolderName.dispatchBackKey();
} }

View File

@ -450,7 +450,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
} }
mInfo.setTitle(nameInfos[0].getLabel()); mInfo.setTitle(nameInfos[0].getLabel());
StatsLogManager.newInstance(getContext()) StatsLogManager.newInstance(getContext())
.log(LAUNCHER_FOLDER_LABEL_UPDATED, instanceId, mInfo.buildProto()); .log(LAUNCHER_FOLDER_LABEL_UPDATED, instanceId, mInfo);
onTitleChanged(mInfo.title); onTitleChanged(mInfo.title);
mFolder.mFolderName.setText(mInfo.title); mFolder.mFolderName.setText(mInfo.title);
mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo); mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo);

View File

@ -21,8 +21,8 @@ import androidx.annotation.Nullable;
import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherState;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.logger.LauncherAtom.ItemInfo;
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.util.ResourceBasedOverride;
/** /**
@ -191,32 +191,37 @@ public class StatsLogManager implements ResourceBasedOverride {
} }
/** /**
* Logs a {@link EventEnum}. * Logs an event.
*
* @param event an enum implementing EventEnum interface.
*/ */
public void log(EventEnum event) { public void log(EventEnum event) {
} }
/** /**
* Logs an event and accompanying {@link InstanceId}. * Logs an event.
*
* @param event an enum implementing EventEnum interface.
* @param instanceId an identifier obtained from an InstanceIdSequence.
*/ */
public void log(EventEnum event, InstanceId instanceId) { public void log(EventEnum event, InstanceId instanceId) {
} }
/** /**
* Logs an event and accompanying {@link ItemInfo}. * Logs an event.
*
* @param event an enum implementing EventEnum interface.
* @param itemInfo item typically containing app or task launch related information.
*/ */
public void log(EventEnum event, @Nullable ItemInfo itemInfo) { public void log(EventEnum event, @Nullable ItemInfo itemInfo) {
} }
/** /**
* Logs an event and accompanying {@link com.android.launcher3.model.data.ItemInfo}. * Logs an event.
*/ *
public void log(EventEnum event, * @param event an enum implementing EventEnum interface.
com.android.launcher3.model.data.ItemInfo itemInfo) { * @param instanceId an identifier obtained from an InstanceIdSequence.
} * @param itemInfo item typically containing app or task launch related information.
/**
* Logs an event and accompanying {@link InstanceId} and {@link ItemInfo}.
*/ */
public void log(EventEnum event, InstanceId instanceId, @Nullable ItemInfo itemInfo) { public void log(EventEnum event, InstanceId instanceId, @Nullable ItemInfo itemInfo) {
} }
@ -225,7 +230,7 @@ public class StatsLogManager implements ResourceBasedOverride {
* Log an event with ranked-choice information along with package. Does nothing if event.getId() * Log an event with ranked-choice information along with package. Does nothing if event.getId()
* <= 0. * <= 0.
* *
* @param rankingEvent an enum implementing UiEventEnum interface. * @param rankingEvent an enum implementing EventEnum interface.
* @param instanceId An identifier obtained from an InstanceIdSequence. * @param instanceId An identifier obtained from an InstanceIdSequence.
* @param packageName the package name of the relevant app, if known (null otherwise). * @param packageName the package name of the relevant app, if known (null otherwise).
* @param position the position picked. * @param position the position picked.

View File

@ -24,11 +24,13 @@ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICT
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SEARCH_RESULTS; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SEARCH_RESULTS;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SETTINGS; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SETTINGS;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_TASKSWITCHER;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_TASK;
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.CONTAINER_NOT_SET; import static com.android.launcher3.logger.LauncherAtom.ContainerInfo.ContainerCase.CONTAINER_NOT_SET;
import android.content.ComponentName; import android.content.ComponentName;
@ -49,6 +51,7 @@ import com.android.launcher3.logger.LauncherAtom.PredictionContainer;
import com.android.launcher3.logger.LauncherAtom.SearchResultContainer; import com.android.launcher3.logger.LauncherAtom.SearchResultContainer;
import com.android.launcher3.logger.LauncherAtom.SettingsContainer; import com.android.launcher3.logger.LauncherAtom.SettingsContainer;
import com.android.launcher3.logger.LauncherAtom.ShortcutsContainer; import com.android.launcher3.logger.LauncherAtom.ShortcutsContainer;
import com.android.launcher3.logger.LauncherAtom.TaskSwitcherContainer;
import com.android.launcher3.util.ContentWriter; import com.android.launcher3.util.ContentWriter;
import java.util.Optional; import java.util.Optional;
@ -298,6 +301,12 @@ public class ItemInfo {
.setSpanX(spanX) .setSpanX(spanX)
.setSpanY(spanY)); .setSpanY(spanY));
break; break;
case ITEM_TYPE_TASK:
itemBuilder
.setTask(LauncherAtom.Task.newBuilder()
.setComponentName(getTargetComponent().flattenToShortString())
.setIndex(screenId));
break;
default: default:
break; break;
} }
@ -378,6 +387,11 @@ public class ItemInfo {
return ContainerInfo.newBuilder() return ContainerInfo.newBuilder()
.setSettingsContainer(SettingsContainer.getDefaultInstance()) .setSettingsContainer(SettingsContainer.getDefaultInstance())
.build(); .build();
case CONTAINER_TASKSWITCHER:
return ContainerInfo.newBuilder()
.setTaskSwitcherContainer(TaskSwitcherContainer.getDefaultInstance())
.build();
} }
return ContainerInfo.getDefaultInstance(); return ContainerInfo.getDefaultInstance();
} }

View File

@ -108,7 +108,7 @@ public class NotificationInfo implements View.OnClickListener {
intent.send(null, 0, null, null, null, null, activityOptions); intent.send(null, 0, null, null, null, null, activityOptions);
launcher.getUserEventDispatcher().logNotificationLaunch(view, intent); launcher.getUserEventDispatcher().logNotificationLaunch(view, intent);
launcher.getStatsLogManager() launcher.getStatsLogManager()
.log(LAUNCHER_NOTIFICATION_LAUNCH_TAP, mItemInfo.buildProto()); .log(LAUNCHER_NOTIFICATION_LAUNCH_TAP, mItemInfo);
} catch (PendingIntent.CanceledException e) { } catch (PendingIntent.CanceledException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -78,7 +78,7 @@ public class RemoteActionShortcut extends SystemShortcut<BaseDraggingActivity> {
public void onClick(View view) { public void onClick(View view) {
AbstractFloatingView.closeAllOpenViews(mTarget); AbstractFloatingView.closeAllOpenViews(mTarget);
mTarget.getStatsLogManager() mTarget.getStatsLogManager()
.log(LAUNCHER_SYSTEM_SHORTCUT_PAUSE_TAP, mItemInfo.buildProto()); .log(LAUNCHER_SYSTEM_SHORTCUT_PAUSE_TAP, mItemInfo);
final String actionIdentity = mAction.getTitle() + ", " final String actionIdentity = mAction.getTitle() + ", "
+ mItemInfo.getTargetComponent().getPackageName(); + mItemInfo.getTargetComponent().getPackageName();

View File

@ -119,9 +119,7 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
widgetsBottomSheet.populateAndShow(mItemInfo); widgetsBottomSheet.populateAndShow(mItemInfo);
mTarget.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP, mTarget.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.WIDGETS_BUTTON, view); ControlType.WIDGETS_BUTTON, view);
// TODO(thiruram): Fix missing container info when item is inside folder. mTarget.getStatsLogManager().log(LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP, mItemInfo);
mTarget.getStatsLogManager().log(LAUNCHER_SYSTEM_SHORTCUT_WIDGETS_TAP,
mItemInfo.buildProto());
} }
} }
@ -142,9 +140,8 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
mItemInfo, sourceBounds, ActivityOptions.makeBasic().toBundle()); mItemInfo, sourceBounds, ActivityOptions.makeBasic().toBundle());
mTarget.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP, mTarget.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.APPINFO_TARGET, view); ControlType.APPINFO_TARGET, view);
// TODO(thiruram): Fix missing container info when item is inside folder.
mTarget.getStatsLogManager() mTarget.getStatsLogManager()
.log(LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP, mItemInfo.buildProto()); .log(LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP, mItemInfo);
} }
} }