Disabling updating All Apps during a long-press recognition

This is supposed to eliminate test flakes in the lab.

When an app gets updated while all apps is opened, all-apps will be
re-laid-out.

If the layout happens while we are recognizing a long-press on an app
icon in all Apps, the long-press won't be recognized.

In the lab, this happened so frequently that it caused considerable
flakiness. Even after we started running tests in airplane mode, this
still keeps happening. The bug refers an example with airplane mode on.

The fix will be also mildly beneficial for users.

Bug: 132177321
Change-Id: Ie7c7473fe94b8af83f04cd719286bae69e2d9de0
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index e2a5160..41252aa 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -604,4 +604,18 @@
 
         return super.performAccessibilityAction(action, arguments);
     }
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        switch (ev.getActionMasked()) {
+            case MotionEvent.ACTION_DOWN:
+                mAllAppsStore.setDeferUpdates(true);
+                break;
+            case MotionEvent.ACTION_UP:
+            case MotionEvent.ACTION_CANCEL:
+                mAllAppsStore.setDeferUpdates(false);
+                break;
+        }
+        return super.dispatchTouchEvent(ev);
+    }
 }