Fix openAllApps:reset/scrollBackToBeginning for the new launcher

* Cannot flinger, otherwise it closes
* Avoid NPE, but fail with assertion

Bug: 29540388

Change-Id: I729ed80f3f2993ab8bf836237d02311d0cfaa6d7
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/BaseLauncher3Strategy.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/BaseLauncher3Strategy.java
index 40aec1d..e0cb084 100644
--- a/libraries/launcher-helper/src/android/support/test/launcherhelper/BaseLauncher3Strategy.java
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/BaseLauncher3Strategy.java
@@ -86,7 +86,9 @@
         if (!mDevice.hasObject(getAllAppsSelector())) {
             open();
             // taps on the "apps" button at the bottom of the screen
-            mDevice.findObject(By.desc("Apps")).click();
+            UiObject2 allAppsButton = mDevice.wait(Until.findObject(By.desc("Apps")), 2000);
+            Assert.assertNotNull("openAllApps: did not find open all apps button.");
+            allAppsButton.click();
             // wait until hotseat disappears, so that we know that we are no longer on home screen
             mDevice.wait(Until.gone(getHotSeatSelector()), 2000);
             mDevice.waitForIdle();
diff --git a/libraries/launcher-helper/src/android/support/test/launcherhelper/CommonLauncherHelper.java b/libraries/launcher-helper/src/android/support/test/launcherhelper/CommonLauncherHelper.java
index 1ed33d0..ec019a2 100644
--- a/libraries/launcher-helper/src/android/support/test/launcherhelper/CommonLauncherHelper.java
+++ b/libraries/launcher-helper/src/android/support/test/launcherhelper/CommonLauncherHelper.java
@@ -34,7 +34,7 @@
 public class CommonLauncherHelper {
 
     private static final String LOG_TAG = CommonLauncherHelper.class.getSimpleName();
-    private static final int MAX_SCROLL_ATTEMPTS = 20;
+    private static final int MAX_SCROLL_ATTEMPTS = 40;
     private static final int MIN_INTERACT_SIZE = 100;
     private static final int APP_LAUNCH_TIMEOUT = 10000;
     private static CommonLauncherHelper sInstance;
@@ -73,7 +73,7 @@
      */
     public void scrollBackToBeginning(UiObject2 container, Direction backDirection, int maxAttempts) {
         int attempts = 0;
-        while (container.fling(backDirection)) {
+        while (container.scroll(backDirection, 0.25f)) {
             attempts++;
             if (attempts > maxAttempts) {
                 throw new RuntimeException(