Merge "Implementation of PredictionRowView. > Enable to use floating for prediction row even without tabs. > Behind ALL_APPS_PREDICTION_ROW_VIEW feature flag. > Expand/Collapse personal/work tabs in stopped intermediate state." into ub-launcher3-master
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index ef50ac4..9069698 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index c490c3f..20abdc7 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,12 +16,17 @@
 
 package com.android.launcher3.uioverrides;
 
+import android.content.Intent;
 import android.view.View.AccessibilityDelegate;
+import android.widget.PopupMenu;
+import android.widget.Toast;
 
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherStateManager.StateHandler;
+import com.android.launcher3.R;
 import com.android.launcher3.VerticalSwipeController;
 import com.android.launcher3.util.TouchController;
+import com.android.launcher3.widget.WidgetsFullSheet;
 
 public class UiFactory {
 
@@ -38,4 +43,29 @@
                 launcher.getAllAppsController(), launcher.getWorkspace(),
                 new RecentsViewStateController(launcher)};
     }
+
+    public static void onWorkspaceLongPress(Launcher launcher) {
+        PopupMenu menu = new PopupMenu(launcher, launcher.getWorkspace().getPageIndicator());
+        menu.getMenu().add(R.string.wallpaper_button_text).setOnMenuItemClickListener((i) -> {
+            launcher.onClickWallpaperPicker(null);
+            return true;
+        });
+        menu.getMenu().add(R.string.widget_button_text).setOnMenuItemClickListener((i) -> {
+            if (launcher.getPackageManager().isSafeMode()) {
+                Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
+            } else {
+                WidgetsFullSheet.show(launcher, true /* animated */);
+            }
+            return true;
+        });
+        if (launcher.hasSettings()) {
+            menu.getMenu().add(R.string.settings_button_text).setOnMenuItemClickListener((i) -> {
+                launcher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
+                        .setPackage(launcher.getPackageName())
+                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+                return true;
+            });
+        }
+        menu.show();
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/MotionEventQueue.java b/quickstep/src/com/android/quickstep/MotionEventQueue.java
new file mode 100644
index 0000000..e3c3a1b
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/MotionEventQueue.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.quickstep;
+
+import static android.view.MotionEvent.ACTION_CANCEL;
+import static android.view.MotionEvent.ACTION_MOVE;
+
+import android.view.Choreographer;
+import android.view.MotionEvent;
+
+import com.android.systemui.shared.system.ChoreographerCompat;
+
+import java.util.ArrayList;
+import java.util.function.Consumer;
+
+/**
+ * Helper class for batching input events
+ */
+public class MotionEventQueue implements Runnable {
+
+    // We use two arrays and swap the current index when one array is being consumed
+    private final EventArray[] mArrays = new EventArray[] {new EventArray(), new EventArray()};
+    private int mCurrentIndex = 0;
+
+    private final Choreographer mChoreographer;
+    private final Consumer<MotionEvent> mConsumer;
+
+    public MotionEventQueue(Choreographer choreographer, Consumer<MotionEvent> consumer) {
+        mChoreographer = choreographer;
+        mConsumer = consumer;
+    }
+
+    public void queue(MotionEvent event) {
+        synchronized (mArrays) {
+            EventArray array = mArrays[mCurrentIndex];
+            if (array.isEmpty()) {
+                ChoreographerCompat.postInputFrame(mChoreographer, this);
+            }
+
+            int eventAction = event.getAction();
+            if (eventAction == ACTION_MOVE && array.lastEventAction == ACTION_MOVE) {
+                // Replace and recycle the last event
+                array.set(array.size() - 1, event).recycle();
+            } else {
+                array.add(event);
+                array.lastEventAction = eventAction;
+            }
+        }
+    }
+
+    @Override
+    public void run() {
+        EventArray array = swapAndGetCurrentArray();
+        int size = array.size();
+        for (int i = 0; i < size; i++) {
+            MotionEvent event = array.get(i);
+            mConsumer.accept(event);
+            event.recycle();
+        }
+        array.clear();
+        array.lastEventAction = ACTION_CANCEL;
+    }
+
+    private EventArray swapAndGetCurrentArray() {
+        synchronized (mArrays) {
+            EventArray current = mArrays[mCurrentIndex];
+            mCurrentIndex = mCurrentIndex ^ 1;
+            return current;
+        }
+    }
+
+    private static class EventArray extends ArrayList<MotionEvent> {
+
+        public int lastEventAction = ACTION_CANCEL;
+
+        public EventArray() {
+            super(4);
+        }
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
index dc7d648..af82fe9 100644
--- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -28,11 +28,7 @@
 import android.os.Build;
 import android.os.Handler;
 import android.os.UserHandle;
-import android.support.annotation.BinderThread;
 import android.support.annotation.UiThread;
-import android.util.DisplayMetrics;
-import android.view.Choreographer;
-import android.view.Choreographer.FrameCallback;
 import android.view.View;
 import android.view.ViewTreeObserver.OnPreDrawListener;
 
@@ -46,16 +42,15 @@
 import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.dragndrop.DragLayer;
 import com.android.launcher3.states.InternalStateHandler;
+import com.android.launcher3.util.TraceHelper;
 import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
 import com.android.systemui.shared.recents.model.Task;
 import com.android.systemui.shared.recents.model.Task.TaskKey;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.WindowManagerWrapper;
 
-import java.util.concurrent.atomic.AtomicBoolean;
-
 @TargetApi(Build.VERSION_CODES.O)
-public class NavBarSwipeInteractionHandler extends InternalStateHandler implements FrameCallback {
+public class NavBarSwipeInteractionHandler extends InternalStateHandler {
 
     private static final int STATE_LAUNCHER_READY = 1 << 0;
     private static final int STATE_RECENTS_DELAY_COMPLETE = 1 << 1;
@@ -90,9 +85,6 @@
     // animated to 1, so allow for a smooth transition.
     private final AnimatedFloat mActivityMultiplier = new AnimatedFloat(this::updateFinalShift);
 
-    private final Choreographer mChoreographer;
-    private final AtomicBoolean mFrameScheduled = new AtomicBoolean(false);
-
     private final int mRunningTaskId;
     private final Context mContext;
 
@@ -106,18 +98,12 @@
 
     private boolean mLauncherReady;
     private boolean mTouchEndHandled;
+    private float mCurrentDisplacement;
 
     private Bitmap mTaskSnapshot;
 
-    // These are updated on the binder thread, and eventually picked up on doFrame
-    private volatile float mCurrentDisplacement;
-    private volatile float mEndVelocity;
-    private volatile boolean mTouchEnded = false;
-
-    NavBarSwipeInteractionHandler(
-            RunningTaskInfo runningTaskInfo, Choreographer choreographer, Context context) {
+    NavBarSwipeInteractionHandler(RunningTaskInfo runningTaskInfo, Context context) {
         mRunningTaskId = runningTaskInfo.id;
-        mChoreographer = choreographer;
         mContext = context;
         WindowManagerWrapper.getInstance().getStableInsets(mStableInsets);
 
@@ -168,11 +154,13 @@
 
     @Override
     public void onLauncherResume() {
+        TraceHelper.partitionSection("TouchInt", "Launcher On resume");
         mDragView.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
             @Override
             public boolean onPreDraw() {
                 mDragView.getViewTreeObserver().removeOnPreDrawListener(this);
                 mStateCallback.setState(STATE_LAUNCHER_READY);
+                TraceHelper.partitionSection("TouchInt", "Launcher drawn");
                 return true;
             }
         });
@@ -194,39 +182,12 @@
         // Optimization
         mLauncher.getAppsView().setVisibility(View.GONE);
         mRecentsView.setVisibility(View.GONE);
+        TraceHelper.partitionSection("TouchInt", "Launcher on new intent");
     }
 
-    /**
-     * This is updated on the binder thread and is picked up on the UI thread during the next
-     * scheduled frame.
-     * TODO: Instead of continuously scheduling frames, post the motion events to UI thread
-     * (can ignore all continuous move events until the last move).
-     */
-    @BinderThread
+    @UiThread
     public void updateDisplacement(float displacement) {
         mCurrentDisplacement = displacement;
-        scheduleFrameIfNeeded();
-    }
-
-    @BinderThread
-    public void endTouch(float endVelocity) {
-        mEndVelocity = endVelocity;
-        mTouchEnded = true;
-        scheduleFrameIfNeeded();
-    }
-
-    private void scheduleFrameIfNeeded() {
-        boolean alreadyScheduled = mFrameScheduled.getAndSet(true);
-        if (!alreadyScheduled) {
-            // TODO: Here we might end up scheduling one additional frame in some race conditions.
-            // This can be avoided by synchronising postFrameCallback as well
-            mChoreographer.postFrameCallback(this);
-        }
-    }
-
-    @Override
-    public void doFrame(long l) {
-        mFrameScheduled.set(false);
         executeFrameUpdate();
     }
 
@@ -238,14 +199,6 @@
             float shift = hotseatHeight == 0 ? 0 : translation / hotseatHeight;
             mCurrentShift.updateValue(shift);
         }
-
-        if (mTouchEnded) {
-            if (mTouchEndHandled) {
-                return;
-            }
-            mTouchEndHandled = true;
-            animateToFinalShift();
-        }
     }
 
     @UiThread
@@ -301,25 +254,30 @@
     }
 
     @UiThread
-    private void animateToFinalShift() {
+    public void endTouch(float endVelocity) {
+        if (mTouchEndHandled) {
+            return;
+        }
+        mTouchEndHandled = true;
+
         Resources res = mContext.getResources();
         float flingThreshold = res.getDimension(R.dimen.quickstep_fling_threshold_velocity);
-        boolean isFling = Math.abs(mEndVelocity) > flingThreshold;
+        boolean isFling = Math.abs(endVelocity) > flingThreshold;
 
         long duration = DEFAULT_SWIPE_DURATION;
         final float endShift;
         if (!isFling) {
             endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW ? 1 : 0;
         } else {
-            endShift = mEndVelocity < 0 ? 1 : 0;
+            endShift = endVelocity < 0 ? 1 : 0;
             float minFlingVelocity = res.getDimension(R.dimen.quickstep_fling_min_velocity);
-            if (Math.abs(mEndVelocity) > minFlingVelocity && mLauncherReady) {
+            if (Math.abs(endVelocity) > minFlingVelocity && mLauncherReady) {
                 float distanceToTravel = (endShift - mCurrentShift.value) * mHotseat.getHeight();
 
                 // we want the page's snap velocity to approximately match the velocity at
                 // which the user flings, so we scale the duration by a value near to the
                 // derivative of the scroll interpolator at zero, ie. 5.
-                duration = 5 * Math.round(1000 * Math.abs(distanceToTravel / mEndVelocity));
+                duration = 5 * Math.round(1000 * Math.abs(distanceToTravel / endVelocity));
             }
         }
 
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index a0340b6..f92d773 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -22,6 +22,7 @@
 import android.widget.ArrayAdapter;
 
 import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
+import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan.PreloadOptions;
 import com.android.systemui.shared.recents.model.RecentsTaskLoader;
 import com.android.systemui.shared.recents.model.Task;
 
@@ -37,7 +38,8 @@
         super.onCreate(savedInstanceState);
 
         RecentsTaskLoadPlan plan = new RecentsTaskLoadPlan(this);
-        plan.preloadPlan(new RecentsTaskLoader(this, 1, 1, 0), -1, UserHandle.myUserId());
+        plan.preloadPlan(new PreloadOptions(), new RecentsTaskLoader(this, 1, 1, 0), -1,
+                UserHandle.myUserId());
 
         mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
         mAdapter.addAll(plan.getTaskStack().getTasks());
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 50f5528..55fd448 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -42,9 +42,11 @@
 
 import com.android.launcher3.MainThreadExecutor;
 import com.android.launcher3.R;
+import com.android.launcher3.util.TraceHelper;
 import com.android.systemui.shared.recents.IOverviewProxy;
 import com.android.systemui.shared.recents.ISystemUiProxy;
 import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
+import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan.PreloadOptions;
 import com.android.systemui.shared.recents.model.RecentsTaskLoader;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.BackgroundExecutor;
@@ -62,7 +64,7 @@
 
         @Override
         public void onMotionEvent(MotionEvent ev) {
-            handleMotionEvent(ev);
+            mEventQueue.queue(ev);
         }
 
         @Override
@@ -75,7 +77,7 @@
     private RunningTaskInfo mRunningTask;
     private Intent mHomeIntent;
     private ComponentName mLauncher;
-    private Choreographer mChoreographer;
+    private MotionEventQueue mEventQueue;
     private MainThreadExecutor mMainThreadExecutor;
 
     private int mDisplayRotation;
@@ -110,8 +112,8 @@
             sRecentsTaskLoader.startLoader(this);
         }
 
-        mChoreographer = Choreographer.getInstance();
         mMainThreadExecutor = new MainThreadExecutor();
+        mEventQueue = new MotionEventQueue(Choreographer.getInstance(), this::handleMotionEvent);
     }
 
     @Override
@@ -130,6 +132,7 @@
         }
         switch (ev.getActionMasked()) {
             case MotionEvent.ACTION_DOWN: {
+                TraceHelper.beginSection("TouchInt");
                 mActivePointerId = ev.getPointerId(0);
                 mDownPos.set(ev.getX(), ev.getY());
                 mLastPos.set(mDownPos);
@@ -192,6 +195,7 @@
             case MotionEvent.ACTION_CANCEL:
                 // TODO: Should be different than ACTION_UP
             case MotionEvent.ACTION_UP: {
+                TraceHelper.endSection("TouchInt");
 
                 endInteraction();
                 break;
@@ -202,12 +206,13 @@
     private void startTouchTracking() {
         // Create the shared handler
         final NavBarSwipeInteractionHandler handler =
-                new NavBarSwipeInteractionHandler(mRunningTask, mChoreographer, this);
+                new NavBarSwipeInteractionHandler(mRunningTask, this);
 
         // Preload and start the recents activity on a background thread
         final Context context = this;
         final RecentsTaskLoadPlan loadPlan = new RecentsTaskLoadPlan(context);
         final int taskId = mRunningTask.id;
+        TraceHelper.partitionSection("TouchInt", "Thershold crossed ");
 
         BackgroundExecutor.get().submit(() -> {
             // Get the snap shot before
@@ -216,6 +221,8 @@
             // Start the launcher activity with our custom handler
             Intent homeIntent = handler.addToIntent(new Intent(mHomeIntent));
             startActivity(homeIntent, ActivityOptions.makeCustomAnimation(this, 0, 0).toBundle());
+            TraceHelper.partitionSection("TouchInt", "Home started");
+
             /*
             ActivityManagerWrapper.getInstance().startRecentsActivity(null, options,
                     ActivityOptions.makeCustomAnimation(this, 0, 0), UserHandle.myUserId(),
@@ -224,7 +231,9 @@
 
             // Preload the plan
             RecentsTaskLoader loader = TouchInteractionService.getRecentsTaskLoader();
-            loadPlan.preloadPlan(loader, taskId, UserHandle.myUserId());
+            PreloadOptions opts = new PreloadOptions();
+            opts.loadTitles = false;
+            loadPlan.preloadPlan(opts, loader, taskId, UserHandle.myUserId());
             // Set the load plan on UI thread
             mMainThreadExecutor.execute(() -> handler.setRecentsTaskLoadPlan(loadPlan));
         });
@@ -249,13 +258,16 @@
             return null;
         }
 
+        TraceHelper.beginSection("TaskSnapshot");
         // TODO: We are using some hardcoded layers for now, to best approximate the activity layers
         try {
             return mISystemUiProxy.screenshot(new Rect(), mDisplaySize.x, mDisplaySize.y, 0, 100000,
-                    false, mDisplayRotation);
+                    false, mDisplayRotation).toBitmap();
         } catch (RemoteException e) {
             Log.e(TAG, "Error capturing snapshot", e);
             return null;
+        } finally {
+            TraceHelper.endSection("TaskSnapshot");
         }
     }
 }
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 22699d5..b7986da 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -60,6 +60,7 @@
 import android.content.pm.PackageManager;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Point;
+import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.os.AsyncTask;
@@ -122,6 +123,7 @@
 import com.android.launcher3.shortcuts.DeepShortcutManager;
 import com.android.launcher3.states.AllAppsState;
 import com.android.launcher3.states.InternalStateHandler;
+import com.android.launcher3.uioverrides.UiFactory;
 import com.android.launcher3.userevent.nano.LauncherLogProto;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -2061,11 +2063,16 @@
             intent.setPackage(pickerPackage);
         }
 
-        intent.setSourceBounds(getViewBounds(v));
+        final Bundle launchOptions;
+        if (v != null) {
+            intent.setSourceBounds(getViewBounds(v));
+            // If there is no target package, use the default intent chooser animation
+            launchOptions = hasTargetPackage ? getActivityLaunchOptions(v) : null;
+        } else {
+            launchOptions = null;
+        }
         try {
-            startActivityForResult(intent, REQUEST_PICK_WALLPAPER,
-                    // If there is no target package, use the default intent chooser animation
-                    hasTargetPackage ? getActivityLaunchOptions(v) : null);
+            startActivityForResult(intent, REQUEST_PICK_WALLPAPER, launchOptions);
         } catch (ActivityNotFoundException e) {
             setWaitingForResult(null);
             Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
@@ -2221,7 +2228,7 @@
                     getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
                             Action.Direction.NONE, ContainerType.WORKSPACE,
                             mWorkspace.getCurrentPage());
-                    getStateManager().goToState(OVERVIEW);
+                    UiFactory.onWorkspaceLongPress(this);
                     mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                             HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
                     return true;
@@ -2258,7 +2265,7 @@
                     getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
                             Action.Direction.NONE, ContainerType.WORKSPACE,
                             mWorkspace.getCurrentPage());
-                    getStateManager().goToState(OVERVIEW);
+                    UiFactory.onWorkspaceLongPress(this);
                 }
                 mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                         HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java
index 816c1d4..8640401 100644
--- a/src/com/android/launcher3/model/BgDataModel.java
+++ b/src/com/android/launcher3/model/BgDataModel.java
@@ -118,9 +118,9 @@
         deepShortcutMap.clear();
     }
 
-     public synchronized void dump(String prefix, FileDescriptor fd, PrintWriter writer,
-             String[] args) {
-        if (args.length > 0 && TextUtils.equals(args[0], "--proto")) {
+    public synchronized void dump(String prefix, FileDescriptor fd, PrintWriter writer,
+            String[] args) {
+        if (Arrays.asList(args).contains("--proto")) {
             dumpProto(prefix, fd, writer, args);
             return;
         }
@@ -219,7 +219,7 @@
             targetList.addAll(workspaces.valueAt(i).getFlattenedList());
         }
 
-        if (args.length > 1 && TextUtils.equals(args[1], "--debug")) {
+        if (Arrays.asList(args).contains("--debug")) {
             for (int i = 0; i < targetList.size(); i++) {
                 writer.println(prefix + DumpTargetWrapper.getDumpTargetStr(targetList.get(i)));
             }
diff --git a/src/com/android/launcher3/util/TraceHelper.java b/src/com/android/launcher3/util/TraceHelper.java
index 5b66fcd..0f3ac57 100644
--- a/src/com/android/launcher3/util/TraceHelper.java
+++ b/src/com/android/launcher3/util/TraceHelper.java
@@ -33,9 +33,8 @@
 
     private static final boolean ENABLED = FeatureFlags.IS_DOGFOOD_BUILD;
 
-    private static final boolean SYSTEM_TRACE = true;
-    private static final ArrayMap<String, MutableLong> sUpTimes =
-            ENABLED ? new ArrayMap<String, MutableLong>() : null;
+    private static final boolean SYSTEM_TRACE = false;
+    private static final ArrayMap<String, MutableLong> sUpTimes = ENABLED ? new ArrayMap<>() : null;
 
     public static void beginSection(String sectionName) {
         if (ENABLED) {
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 8521334..51cf661 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3.uioverrides;
 
+import static com.android.launcher3.LauncherState.OVERVIEW;
+
 import android.view.View.AccessibilityDelegate;
 
 import com.android.launcher3.Launcher;
@@ -39,4 +41,8 @@
                 (OverviewPanel) launcher.getOverviewPanel(),
                 launcher.getAllAppsController(), launcher.getWorkspace() };
     }
+
+    public static void onWorkspaceLongPress(Launcher launcher) {
+        launcher.getStateManager().goToState(OVERVIEW);
+    }
 }