[DO NOT MERGE] Add component name to launcher home and overview gestures
Bug: 168805198

Change-Id: Idcc7d00b0f23c2a0f9be6f0ab2600278e18cc1a3
(cherry picked from commit e6477328aa8b82f516e1502e99343af265ad5fd6)
diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto
index 5611969..1a8ab65 100644
--- a/protos/launcher_atom.proto
+++ b/protos/launcher_atom.proto
@@ -55,6 +55,7 @@
     SettingsContainer settings_container = 9;
     PredictedHotseatContainer predicted_hotseat_container = 10;
     TaskSwitcherContainer task_switcher_container = 11;
+    TaskForegroundContainer task_foreground_container = 12;
   }
 }
 
@@ -92,8 +93,14 @@
 message SettingsContainer {
 }
 
-message TaskSwitcherContainer {
-}
+// Container for tasks in the Overview UI.
+// Typically entered using either the overview gesture or overview button.
+message TaskSwitcherContainer {}
+
+// Container for tasks from another foreground app, when not on launcher screen.
+// Typically home gesture or overview gesture can be triggered from
+// this container.
+message TaskForegroundContainer {}
 
 enum Attribute {
   UNKNOWN = 0;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
index 0aa1486..a4ea9b4 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
@@ -47,6 +47,7 @@
 import android.animation.ValueAnimator;
 import android.annotation.TargetApi;
 import android.app.ActivityManager;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.PointF;
@@ -62,12 +63,14 @@
 
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.logging.StatsLogManager;
 import com.android.launcher3.logging.UserEventDispatcher;
+import com.android.launcher3.model.data.WorkspaceItemInfo;
 import com.android.launcher3.statemanager.StatefulActivity;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -928,12 +931,25 @@
             default:
                 event = IGNORE;
         }
+        ComponentName componentName = mGestureState.getRunningTask().baseActivity;
         StatsLogManager.newInstance(mContext).logger()
                 .withSrcState(LAUNCHER_STATE_BACKGROUND)
                 .withDstState(StatsLogManager.containerTypeToAtomState(endTarget.containerType))
+                .withItemInfo(getItemInfo(componentName))
                 .log(event);
     }
 
+    /**
+     * Builds proto for logging
+     */
+    public WorkspaceItemInfo getItemInfo(ComponentName componentName) {
+        WorkspaceItemInfo placeholderInfo = new WorkspaceItemInfo();
+        placeholderInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK;
+        placeholderInfo.container = LauncherSettings.Favorites.CONTAINER_TASKFOREGROUND;
+        placeholderInfo.intent = new Intent().setComponent(componentName);
+        return placeholderInfo;
+    }
+
     /** Animates to the given progress, where 0 is the current app and 1 is overview. */
     @UiThread
     private void animateToProgress(float start, float end, long duration, Interpolator interpolator,
diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java
index 58a418e..a1ac229 100644
--- a/src/com/android/launcher3/LauncherSettings.java
+++ b/src/com/android/launcher3/LauncherSettings.java
@@ -164,6 +164,7 @@
         public static final int CONTAINER_SHORTCUTS = -107;
         public static final int CONTAINER_SETTINGS = -108;
         public static final int CONTAINER_TASKSWITCHER = -109;
+        public static final int CONTAINER_TASKFOREGROUND = -110;
 
         public static final String containerToString(int container) {
             switch (container) {
diff --git a/src/com/android/launcher3/model/data/ItemInfo.java b/src/com/android/launcher3/model/data/ItemInfo.java
index 0d3ddad..b9b3d38 100644
--- a/src/com/android/launcher3/model/data/ItemInfo.java
+++ b/src/com/android/launcher3/model/data/ItemInfo.java
@@ -24,6 +24,7 @@
 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_SHORTCUTS;
+import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_TASKFOREGROUND;
 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.ITEM_TYPE_APPLICATION;
@@ -51,6 +52,7 @@
 import com.android.launcher3.logger.LauncherAtom.SearchResultContainer;
 import com.android.launcher3.logger.LauncherAtom.SettingsContainer;
 import com.android.launcher3.logger.LauncherAtom.ShortcutsContainer;
+import com.android.launcher3.logger.LauncherAtom.TaskForegroundContainer;
 import com.android.launcher3.logger.LauncherAtom.TaskSwitcherContainer;
 import com.android.launcher3.model.ModelWriter;
 import com.android.launcher3.util.ContentWriter;
@@ -392,6 +394,11 @@
                 return ContainerInfo.newBuilder()
                         .setTaskSwitcherContainer(TaskSwitcherContainer.getDefaultInstance())
                         .build();
+            case CONTAINER_TASKFOREGROUND:
+                return ContainerInfo.newBuilder()
+                        .setTaskForegroundContainer(TaskForegroundContainer.getDefaultInstance())
+                        .build();
+
 
         }
         return ContainerInfo.getDefaultInstance();