Revert "Merging  ub-launcher3-master, build 5938524"

This reverts commit 7cb721fa819992391045e70e5c109d8d43099a78.

Reason for revert: <INSERT REASONING HERE>

Change-Id: I10ebd177cc98be896282147df481b05f28241758
diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml
index 56eca6d..c6f55a7 100644
--- a/tests/AndroidManifest-common.xml
+++ b/tests/AndroidManifest-common.xml
@@ -62,12 +62,6 @@
                 <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
             </intent-filter>
         </activity>
-        <activity android:name="com.android.launcher3.testcomponent.CustomShortcutConfigActivity">
-            <intent-filter>
-                <action android:name="android.intent.action.CREATE_SHORTCUT" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
         <activity
             android:name="com.android.launcher3.testcomponent.RequestPinItemActivity"
             android:icon="@drawable/test_drawable_pin_item"
@@ -79,12 +73,8 @@
             </intent-filter>
         </activity>
 
-        <service
-            android:name="com.android.launcher3.testcomponent.ListViewService"
-            android:permission="android.permission.BIND_REMOTEVIEWS" />
-
         <provider
-            android:name="com.android.launcher3.testcomponent.TestCommandProvider"
+            android:name="com.android.launcher3.testcomponent.TestCommandReceiver"
             android:authorities="${packageName}.commands"
             android:exported="true"/>
 
diff --git a/tests/res/layout/test_layout_widget_list.xml b/tests/res/layout/test_layout_widget_list.xml
deleted file mode 100644
index 0152040..0000000
--- a/tests/res/layout/test_layout_widget_list.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="#FFFFFF">
-
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="#FF0000FF"
-        android:id="@android:id/text1"
-        android:padding="10dp" />
-
-    <ListView
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
-        android:id="@android:id/list" />
-</LinearLayout>
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java b/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
index efbd9c9..7ef946d 100644
--- a/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
+++ b/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
@@ -48,7 +48,6 @@
     public void setUp() throws Exception {
         super.setUp();
         mDevice.pressHome();
-        waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
         waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
         mSessionId = -1;
     }
diff --git a/tests/src/com/android/launcher3/model/LoaderCursorTest.java b/tests/src/com/android/launcher3/model/LoaderCursorTest.java
index 7029ad5..64df8e0 100644
--- a/tests/src/com/android/launcher3/model/LoaderCursorTest.java
+++ b/tests/src/com/android/launcher3/model/LoaderCursorTest.java
@@ -1,5 +1,29 @@
 package com.android.launcher3.model;
 
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.database.MatrixCursor;
+import android.graphics.Bitmap;
+import android.os.Process;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.launcher3.WorkspaceItemInfo;
+import com.android.launcher3.icons.IconCache;
+import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.ItemInfo;
+import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.compat.LauncherAppsCompat;
+import com.android.launcher3.icons.BitmapInfo;
+import com.android.launcher3.util.PackageManagerHelper;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static com.android.launcher3.LauncherSettings.Favorites.INTENT;
 import static com.android.launcher3.LauncherSettings.Favorites.CELLX;
 import static com.android.launcher3.LauncherSettings.Favorites.CELLY;
 import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER;
@@ -8,7 +32,6 @@
 import static com.android.launcher3.LauncherSettings.Favorites.ICON;
 import static com.android.launcher3.LauncherSettings.Favorites.ICON_PACKAGE;
 import static com.android.launcher3.LauncherSettings.Favorites.ICON_RESOURCE;
-import static com.android.launcher3.LauncherSettings.Favorites.INTENT;
 import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE;
 import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
 import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
@@ -17,41 +40,15 @@
 import static com.android.launcher3.LauncherSettings.Favorites.SCREEN;
 import static com.android.launcher3.LauncherSettings.Favorites.TITLE;
 import static com.android.launcher3.LauncherSettings.Favorites._ID;
-
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.assertTrue;
-
 import static org.mockito.Mockito.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.LauncherApps;
-import android.database.MatrixCursor;
-import android.graphics.Bitmap;
-import android.os.Process;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.launcher3.InvariantDeviceProfile;
-import com.android.launcher3.ItemInfo;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.WorkspaceItemInfo;
-import com.android.launcher3.icons.BitmapInfo;
-import com.android.launcher3.icons.IconCache;
-import com.android.launcher3.util.PackageManagerHelper;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
 /**
  * Tests for {@link LoaderCursor}
  */
@@ -65,7 +62,7 @@
     private MatrixCursor mCursor;
     private InvariantDeviceProfile mIDP;
     private Context mContext;
-    private LauncherApps mLauncherApps;
+    private LauncherAppsCompat mLauncherApps;
 
     private LoaderCursor mLoaderCursor;
 
@@ -84,7 +81,7 @@
         when(mMockApp.getIconCache()).thenReturn(mMockIconCache);
         when(mMockApp.getInvariantDeviceProfile()).thenReturn(mIDP);
         when(mMockApp.getContext()).thenReturn(mContext);
-        mLauncherApps = mContext.getSystemService(LauncherApps.class);
+        mLauncherApps = LauncherAppsCompat.getInstance(mContext);
 
         mLoaderCursor = new LoaderCursor(mCursor, mMockApp);
         mLoaderCursor.allUsers.put(0, Process.myUserHandle());
diff --git a/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java b/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
index 27990f4..6fa8d62 100644
--- a/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
+++ b/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
@@ -1,11 +1,8 @@
 package com.android.launcher3.provider;
 
-import static org.junit.Assert.assertEquals;
-
 import android.content.ContentValues;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
-
 import androidx.test.InstrumentationRegistry;
 import androidx.test.filters.MediumTest;
 import androidx.test.runner.AndroidJUnit4;
@@ -16,6 +13,8 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import static org.junit.Assert.assertEquals;
+
 /**
  * Tests for {@link RestoreDbTask}
  */
@@ -83,7 +82,7 @@
         private final long mProfileId;
 
         MyDatabaseHelper(long profileId) {
-            super(InstrumentationRegistry.getContext(), null);
+            super(InstrumentationRegistry.getContext(), null, null);
             mProfileId = profileId;
         }
 
diff --git a/tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java b/tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java
deleted file mode 100644
index b673faa..0000000
--- a/tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2019 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.launcher3.testcomponent;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ShortcutInfo;
-import android.content.pm.ShortcutManager;
-import android.graphics.drawable.Icon;
-import android.os.Bundle;
-
-import com.android.launcher3.R;
-
-import java.util.UUID;
-
-/**
- * A custom shortcut is a 1x1 widget that launches a specific intent when user tap on it.
- * Custom shortcuts are replaced by deep shortcuts after api 25.
- */
-public class CustomShortcutConfigActivity extends BaseTestingActivity {
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        Intent launchIntent = new Intent(this, BaseTestingActivity.class)
-                .setAction("com.android.launcher3.intent.action.test_shortcut");
-        Intent shortcutIntent = createShortcutResultIntent(
-                this, UUID.randomUUID().toString(), "Shortcut",
-                R.drawable.ic_widget, launchIntent);
-        setResult(RESULT_OK, shortcutIntent);
-        finish();
-    }
-
-    private static Intent createShortcutResultIntent(
-            Context context, String uniqueId, String name, int iconId, Intent launchIntent) {
-        ShortcutInfo shortcutInfo =
-                createShortcutInfo(context, uniqueId, name, iconId, launchIntent);
-        ShortcutManager sm = context.getSystemService(ShortcutManager.class);
-        return sm.createShortcutResultIntent(shortcutInfo);
-    }
-
-    private static ShortcutInfo createShortcutInfo(
-            Context context, String uniqueId, String name, int iconId, Intent launchIntent) {
-        return new ShortcutInfo.Builder(context, uniqueId)
-                .setShortLabel(name)
-                .setLongLabel(name)
-                .setIcon(Icon.createWithResource(context, iconId))
-                .setIntent(launchIntent)
-                .build();
-    }
-}
diff --git a/tests/src/com/android/launcher3/testcomponent/ListViewService.java b/tests/src/com/android/launcher3/testcomponent/ListViewService.java
deleted file mode 100644
index 3da20e0..0000000
--- a/tests/src/com/android/launcher3/testcomponent/ListViewService.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2019 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.launcher3.testcomponent;
-
-import android.content.Intent;
-import android.os.IBinder;
-import android.widget.RemoteViews;
-import android.widget.RemoteViewsService;
-
-public class ListViewService extends RemoteViewsService {
-
-    public static IBinder sBinderForTest;
-
-    @Override
-    public RemoteViewsFactory onGetViewFactory(Intent intent) {
-        return new SimpleViewsFactory();
-    }
-
-    @Override
-    public IBinder onBind(Intent intent) {
-        return sBinderForTest != null ? sBinderForTest : super.onBind(intent);
-    }
-
-    public static class SimpleViewsFactory implements RemoteViewsFactory {
-
-        public int viewCount = 0;
-
-        @Override
-        public void onCreate() { }
-
-        @Override
-        public void onDataSetChanged() { }
-
-        @Override
-        public void onDestroy() { }
-
-        @Override
-        public int getCount() {
-            return viewCount;
-        }
-
-        @Override
-        public RemoteViews getViewAt(int i) {
-            RemoteViews views = new RemoteViews("android", android.R.layout.simple_list_item_1);
-            views.setTextViewText(android.R.id.text1, getLabel(i));
-            return views;
-        }
-
-        public String getLabel(int i) {
-            return "Item " + i;
-        }
-
-        @Override
-        public RemoteViews getLoadingView() {
-            return null;
-        }
-
-        @Override
-        public int getViewTypeCount() {
-            return 1;
-        }
-
-        @Override
-        public long getItemId(int i) {
-            return i;
-        }
-
-        @Override
-        public boolean hasStableIds() {
-            return false;
-        }
-
-        public IBinder toBinder() {
-            return new RemoteViewsService() {
-                @Override
-                public RemoteViewsFactory onGetViewFactory(Intent intent) {
-                    return SimpleViewsFactory.this;
-                }
-            }.onBind(new Intent("dummy_intent"));
-        }
-    }
-}
diff --git a/tests/src/com/android/launcher3/testcomponent/TestCommandProvider.java b/tests/src/com/android/launcher3/testcomponent/TestCommandProvider.java
deleted file mode 100644
index f9981a9..0000000
--- a/tests/src/com/android/launcher3/testcomponent/TestCommandProvider.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2019 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.launcher3.testcomponent;
-
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
-import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
-import static android.content.pm.PackageManager.DONT_KILL_APP;
-import static android.os.ParcelFileDescriptor.MODE_READ_WRITE;
-
-import static com.android.launcher3.testcomponent.TestCommandReceiver.DISABLE_TEST_LAUNCHER;
-import static com.android.launcher3.testcomponent.TestCommandReceiver.ENABLE_TEST_LAUNCHER;
-import static com.android.launcher3.testcomponent.TestCommandReceiver.EXTRA_VALUE;
-import static com.android.launcher3.testcomponent.TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE;
-import static com.android.launcher3.testcomponent.TestCommandReceiver.KILL_PROCESS;
-import static com.android.launcher3.testcomponent.TestCommandReceiver.SET_LIST_VIEW_SERVICE_BINDER;
-
-import android.app.Activity;
-import android.app.ActivityManager;
-import android.content.ComponentName;
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.ParcelFileDescriptor;
-import android.util.Base64;
-
-import com.android.launcher3.tapl.TestHelpers;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-public class TestCommandProvider extends ContentProvider {
-
-    @Override
-    public boolean onCreate() {
-        return true;
-    }
-
-    @Override
-    public int delete(Uri uri, String selection, String[] selectionArgs) {
-        throw new UnsupportedOperationException("unimplemented mock method");
-    }
-
-    @Override
-    public String getType(Uri uri) {
-        throw new UnsupportedOperationException("unimplemented mock method");
-    }
-
-    @Override
-    public Uri insert(Uri uri, ContentValues values) {
-        throw new UnsupportedOperationException("unimplemented mock method");
-    }
-
-    @Override
-    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
-            String sortOrder) {
-        throw new UnsupportedOperationException("unimplemented mock method");
-    }
-
-    @Override
-    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
-        throw new UnsupportedOperationException("unimplemented mock method");
-    }
-
-    @Override
-    public Bundle call(String method, String arg, Bundle extras) {
-        switch (method) {
-            case ENABLE_TEST_LAUNCHER: {
-                getContext().getPackageManager().setComponentEnabledSetting(
-                        new ComponentName(getContext(), TestLauncherActivity.class),
-                        COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
-                return null;
-            }
-            case DISABLE_TEST_LAUNCHER: {
-                getContext().getPackageManager().setComponentEnabledSetting(
-                        new ComponentName(getContext(), TestLauncherActivity.class),
-                        COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
-                return null;
-            }
-            case KILL_PROCESS: {
-                ((ActivityManager) getContext().getSystemService(Activity.ACTIVITY_SERVICE))
-                        .killBackgroundProcesses(arg);
-                return null;
-            }
-
-            case GET_SYSTEM_HEALTH_MESSAGE: {
-                final Bundle response = new Bundle();
-                response.putString("result",
-                        TestHelpers.getSystemHealthMessage(getContext(), Long.parseLong(arg)));
-                return response;
-            }
-
-            case SET_LIST_VIEW_SERVICE_BINDER: {
-                ListViewService.sBinderForTest = extras.getBinder(EXTRA_VALUE);
-                return null;
-            }
-        }
-        return super.call(method, arg, extras);
-    }
-
-    @Override
-    public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
-        String path = Base64.encodeToString(uri.getPath().getBytes(),
-                Base64.NO_CLOSE | Base64.NO_PADDING | Base64.NO_WRAP);
-        File file = new File(getContext().getCacheDir(), path);
-        if (!file.exists()) {
-            // Create an empty file so that we can pass its descriptor
-            try {
-                file.createNewFile();
-            } catch (IOException e) {
-            }
-        }
-
-        return ParcelFileDescriptor.open(file, MODE_READ_WRITE);
-    }
-}
diff --git a/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java b/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java
index eb6c3ed..6a6916e 100644
--- a/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java
+++ b/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java
@@ -15,36 +15,125 @@
  */
 package com.android.launcher3.testcomponent;
 
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+import static android.content.pm.PackageManager.DONT_KILL_APP;
+import static android.os.ParcelFileDescriptor.MODE_READ_WRITE;
+
+import android.app.Activity;
+import android.app.ActivityManager;
 import android.app.Instrumentation;
+import android.content.ComponentName;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.util.Base64;
 
 import androidx.test.InstrumentationRegistry;
 
+import com.android.launcher3.tapl.TestHelpers;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
 /**
  * Content provider to receive commands from tests
  */
-public class TestCommandReceiver {
+public class TestCommandReceiver extends ContentProvider {
 
     public static final String ENABLE_TEST_LAUNCHER = "enable-test-launcher";
     public static final String DISABLE_TEST_LAUNCHER = "disable-test-launcher";
     public static final String KILL_PROCESS = "kill-process";
     public static final String GET_SYSTEM_HEALTH_MESSAGE = "get-system-health-message";
-    public static final String SET_LIST_VIEW_SERVICE_BINDER = "set-list-view-service-binder";
 
-    public static final String EXTRA_VALUE = "value";
+    @Override
+    public boolean onCreate() {
+        return true;
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+        throw new UnsupportedOperationException("unimplemented mock method");
+    }
+
+    @Override
+    public String getType(Uri uri) {
+        throw new UnsupportedOperationException("unimplemented mock method");
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+        throw new UnsupportedOperationException("unimplemented mock method");
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+            String sortOrder) {
+        throw new UnsupportedOperationException("unimplemented mock method");
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+        throw new UnsupportedOperationException("unimplemented mock method");
+    }
+
+    @Override
+    public Bundle call(String method, String arg, Bundle extras) {
+        switch (method) {
+            case ENABLE_TEST_LAUNCHER: {
+                getContext().getPackageManager().setComponentEnabledSetting(
+                        new ComponentName(getContext(), TestLauncherActivity.class),
+                        COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
+                return null;
+            }
+            case DISABLE_TEST_LAUNCHER: {
+                getContext().getPackageManager().setComponentEnabledSetting(
+                        new ComponentName(getContext(), TestLauncherActivity.class),
+                        COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
+                return null;
+            }
+            case KILL_PROCESS: {
+                ((ActivityManager) getContext().getSystemService(Activity.ACTIVITY_SERVICE)).
+                        killBackgroundProcesses(arg);
+                return null;
+            }
+
+            case GET_SYSTEM_HEALTH_MESSAGE: {
+                final Bundle response = new Bundle();
+                response.putString("result", TestHelpers.getSystemHealthMessage(getContext()));
+                return response;
+            }
+        }
+        return super.call(method, arg, extras);
+    }
 
     public static Bundle callCommand(String command) {
         return callCommand(command, null);
     }
 
     public static Bundle callCommand(String command, String arg) {
-        return callCommand(command, arg, null);
-    }
-
-    public static Bundle callCommand(String command, String arg, Bundle extras) {
         Instrumentation inst = InstrumentationRegistry.getInstrumentation();
         Uri uri = Uri.parse("content://" + inst.getContext().getPackageName() + ".commands");
-        return inst.getTargetContext().getContentResolver().call(uri, command, arg, extras);
+        return inst.getTargetContext().getContentResolver().call(uri, command, arg, null);
+    }
+
+    @Override
+    public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+        String path = Base64.encodeToString(uri.getPath().getBytes(),
+                Base64.NO_CLOSE | Base64.NO_PADDING | Base64.NO_WRAP);
+        File file = new File(getContext().getCacheDir(), path);
+        if (!file.exists()) {
+            // Create an empty file so that we can pass its descriptor
+            try {
+                file.createNewFile();
+            } catch (IOException e) {
+            }
+        }
+
+        return ParcelFileDescriptor.open(file, MODE_READ_WRITE);
     }
 }
diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
index f209fae..e042357 100644
--- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
+++ b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
@@ -25,10 +25,6 @@
 import android.util.Log;
 import android.view.ViewConfiguration;
 
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
 import com.android.launcher3.testcomponent.TouchEventGenerator;
 
 import org.junit.Before;
@@ -37,6 +33,10 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
 @SmallTest
 @RunWith(AndroidJUnit4.class)
 public class SwipeDetectorTest {
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 62989a3..1fac708 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -17,7 +17,6 @@
 
 import static androidx.test.InstrumentationRegistry.getInstrumentation;
 
-import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID;
 import static com.android.launcher3.tapl.LauncherInstrumentation.ContainerType;
 import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
 import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -28,13 +27,11 @@
 
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
 import android.content.pm.LauncherActivityInfo;
-import android.content.pm.LauncherApps;
 import android.content.pm.PackageManager;
 import android.os.Process;
 import android.os.RemoteException;
@@ -46,19 +43,19 @@
 import androidx.test.uiautomator.UiDevice;
 import androidx.test.uiautomator.Until;
 
-import com.android.launcher3.ItemInfo;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.LauncherModel;
 import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.LauncherState;
 import com.android.launcher3.LauncherStateManager;
 import com.android.launcher3.Utilities;
+import com.android.launcher3.compat.LauncherAppsCompat;
 import com.android.launcher3.model.AppLaunchTracker;
 import com.android.launcher3.tapl.LauncherInstrumentation;
 import com.android.launcher3.tapl.TestHelpers;
 import com.android.launcher3.testcomponent.TestCommandReceiver;
 import com.android.launcher3.testing.TestProtocol;
-import com.android.launcher3.util.ContentWriter;
 import com.android.launcher3.util.LooperExecutor;
 import com.android.launcher3.util.PackageManagerHelper;
 import com.android.launcher3.util.Wait;
@@ -97,7 +94,8 @@
 
     protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR;
     protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
-    protected final LauncherInstrumentation mLauncher = new LauncherInstrumentation();
+    protected final LauncherInstrumentation mLauncher =
+            new LauncherInstrumentation(getInstrumentation());
     protected Context mTargetContext;
     protected String mTargetPackage;
 
@@ -109,9 +107,8 @@
         }
         if (TestHelpers.isInLauncherProcess()) {
             Utilities.enableRunningInTestHarnessForTests();
-            mLauncher.setSystemHealthSupplier(startTime -> TestCommandReceiver.callCommand(
-                    TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE, startTime.toString()).
-                    getString("result"));
+            mLauncher.setSystemHealthSupplier(() -> TestCommandReceiver.callCommand(
+                    TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE).getString("result"));
             mLauncher.setOnSettledStateAction(
                     containerType -> executeOnLauncher(
                             launcher ->
@@ -176,13 +173,15 @@
 
         mTargetContext = InstrumentationRegistry.getTargetContext();
         mTargetPackage = mTargetContext.getPackageName();
+        // Unlock the phone
+        mDevice.executeShellCommand("input keyevent 82");
     }
 
     @After
     public void verifyLauncherState() {
         try {
             // Limits UI tests affecting tests running after them.
-            mLauncher.waitForLauncherInitialized();
+            waitForModelLoaded();
         } catch (Throwable t) {
             Log.e(TAG,
                     "Couldn't deinit after a test, exiting tests, see logs for failures that "
@@ -221,36 +220,14 @@
         } catch (Throwable t) {
             throw new IllegalArgumentException(t);
         }
-        mLauncher.waitForLauncherInitialized();
+        waitForModelLoaded();
     }
 
-    /**
-     * Adds {@param item} on the homescreen on the 0th screen
-     */
-    protected void addItemToScreen(ItemInfo item) {
-        ContentResolver resolver = mTargetContext.getContentResolver();
-        int screenId = FIRST_SCREEN_ID;
-        // Update the screen id counter for the provider.
-        LauncherSettings.Settings.call(resolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
-
-        if (screenId > FIRST_SCREEN_ID) {
-            screenId = FIRST_SCREEN_ID;
-        }
-
-        // Insert the item
-        ContentWriter writer = new ContentWriter(mTargetContext);
-        item.id = LauncherSettings.Settings.call(
-                resolver, LauncherSettings.Settings.METHOD_NEW_ITEM_ID)
-                .getInt(LauncherSettings.Settings.EXTRA_VALUE);
-        item.screenId = screenId;
-        item.onAddToDatabase(writer);
-        writer.put(LauncherSettings.Favorites._ID, item.id);
-        resolver.insert(LauncherSettings.Favorites.CONTENT_URI, writer.getValues(mTargetContext));
-        resetLoaderState();
-
-        // Launch the home activity
-        mDevice.pressHome();
-        mLauncher.waitForLauncherInitialized();
+    protected void waitForModelLoaded() {
+        waitForLauncherCondition("Launcher model didn't load", launcher -> {
+            final LauncherModel model = LauncherAppState.getInstance(mTargetContext).getModel();
+            return model.getCallback() == null || model.isModelLoaded();
+        });
     }
 
     /**
@@ -335,8 +312,9 @@
     }
 
     protected LauncherActivityInfo getSettingsApp() {
-        return mTargetContext.getSystemService(LauncherApps.class)
-                .getActivityList("com.android.settings", Process.myUserHandle()).get(0);
+        return LauncherAppsCompat.getInstance(mTargetContext)
+                .getActivityList("com.android.settings",
+                        Process.myUserHandle()).get(0);
     }
 
     /**
diff --git a/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java b/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java
index 1d89d6e..a76b4a4 100644
--- a/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java
+++ b/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java
@@ -30,7 +30,7 @@
 import androidx.test.runner.AndroidJUnit4;
 
 import com.android.launcher3.LauncherAppWidgetProviderInfo;
-import com.android.launcher3.testcomponent.TestCommandProvider;
+import com.android.launcher3.testcomponent.TestCommandReceiver;
 import com.android.launcher3.util.LauncherLayoutBuilder;
 import com.android.launcher3.util.rule.ShellCommandRule;
 
@@ -63,7 +63,7 @@
 
         PackageManager pm = mTargetContext.getPackageManager();
         ProviderInfo pi = pm.getProviderInfo(new ComponentName(mContext,
-                TestCommandProvider.class), 0);
+                TestCommandReceiver.class), 0);
         mAuthority = pi.authority;
     }
 
@@ -73,6 +73,7 @@
 
         // Launch the home activity
         mDevice.pressHome();
+        waitForModelLoaded();
 
         mLauncher.getWorkspace().getHotseatAppIcon(getSettingsApp().getLabel().toString());
     }
@@ -88,6 +89,7 @@
 
         // Launch the home activity
         mDevice.pressHome();
+        waitForModelLoaded();
 
         // Verify widget present
         assertTrue("Widget is not present",
@@ -104,6 +106,7 @@
 
         // Launch the home activity
         mDevice.pressHome();
+        waitForModelLoaded();
 
         mLauncher.getWorkspace().getHotseatFolder("Folder: Copy");
     }
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 709822b..2cf6c2b 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -342,22 +342,6 @@
         }
     }
 
-    /**
-     * Test dragging a custom shortcut to the workspace and launch it.
-     *
-     * A custom shortcut is a 1x1 widget that launches a specific intent when user tap on it.
-     * Custom shortcuts are replaced by deep shortcuts after api 25.
-     */
-    @Test
-    @PortraitLandscape
-    public void testDragCustomShortcut() {
-        mLauncher.getWorkspace().openAllWidgets()
-                .getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity")
-                .dragToWorkspace();
-        mLauncher.getWorkspace().getWorkspaceAppIcon("Shortcut")
-                .launch(getAppPackageName());
-    }
-
     public static String getAppPackageName() {
         return getInstrumentation().getContext().getPackageName();
     }
diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
index e1b3ede..3f35a3a 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
@@ -41,6 +41,7 @@
 import com.android.launcher3.util.rule.ShellCommandRule;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -52,8 +53,7 @@
 @RunWith(AndroidJUnit4.class)
 public class AddConfigWidgetTest extends AbstractLauncherUiTest {
 
-    @Rule
-    public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
+    @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
 
     private LauncherAppWidgetProviderInfo mWidgetInfo;
     private AppWidgetManager mAppWidgetManager;
@@ -70,12 +70,14 @@
 
     @Test
     @PortraitLandscape
+    @org.junit.Ignore
     public void testWidgetConfig() throws Throwable {
         runTest(true);
     }
 
     @Test
     @PortraitLandscape
+    @org.junit.Ignore
     public void testConfigCancelled() throws Throwable {
         runTest(false);
     }
diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
index b8ca5de..1edce22 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
@@ -30,6 +30,7 @@
 import com.android.launcher3.ui.TestViewHelpers;
 import com.android.launcher3.util.rule.ShellCommandRule;
 
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,11 +42,11 @@
 @RunWith(AndroidJUnit4.class)
 public class AddWidgetTest extends AbstractLauncherUiTest {
 
-    @Rule
-    public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
+    @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
 
     @Test
     @PortraitLandscape
+    @org.junit.Ignore
     public void testDragIcon() throws Throwable {
         clearHomescreen();
         mDevice.pressHome();
diff --git a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java
index 3d691da..e6348d9 100644
--- a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java
@@ -15,9 +15,7 @@
  */
 package com.android.launcher3.ui.widget;
 
-import static androidx.test.InstrumentationRegistry.getTargetContext;
-
-import static com.android.launcher3.widget.WidgetHostViewLoader.getDefaultOptionsForWidget;
+import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -27,7 +25,6 @@
 import android.appwidget.AppWidgetManager;
 import android.content.ComponentName;
 import android.content.ContentResolver;
-import android.content.Context;
 import android.content.pm.PackageInstaller;
 import android.content.pm.PackageInstaller.SessionParams;
 import android.content.pm.PackageManager;
@@ -42,12 +39,15 @@
 import com.android.launcher3.LauncherAppWidgetProviderInfo;
 import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.pm.PackageInstallerCompat;
+import com.android.launcher3.compat.PackageInstallerCompat;
 import com.android.launcher3.tapl.Workspace;
 import com.android.launcher3.ui.AbstractLauncherUiTest;
 import com.android.launcher3.ui.TestViewHelpers;
+import com.android.launcher3.util.ContentWriter;
+import com.android.launcher3.util.PackageUserKey;
 import com.android.launcher3.util.rule.ShellCommandRule;
 import com.android.launcher3.widget.PendingAddWidgetInfo;
+import com.android.launcher3.widget.WidgetHostViewLoader;
 
 import org.junit.After;
 import org.junit.Before;
@@ -57,6 +57,7 @@
 
 import java.util.HashSet;
 import java.util.Set;
+import java.util.function.Consumer;
 
 /**
  * Tests for bind widget flow.
@@ -71,6 +72,7 @@
     public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
 
     private ContentResolver mResolver;
+    private AppWidgetManagerCompat mWidgetManager;
 
     // Objects created during test, which should be cleaned up in the end.
     private Cursor mCursor;
@@ -83,6 +85,7 @@
         super.setUp();
 
         mResolver = mTargetContext.getContentResolver();
+        mWidgetManager = AppWidgetManagerCompat.getInstance(mTargetContext);
 
         // Clear all existing data
         LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
@@ -105,7 +108,7 @@
         LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, true);
         LauncherAppWidgetInfo item = createWidgetInfo(info, true);
 
-        addItemToScreen(item);
+        setupContents(item);
         verifyWidgetPresent(info);
     }
 
@@ -114,7 +117,7 @@
         LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, false);
         LauncherAppWidgetInfo item = createWidgetInfo(info, true);
 
-        addItemToScreen(item);
+        setupContents(item);
         verifyWidgetPresent(info);
     }
 
@@ -124,7 +127,7 @@
         LauncherAppWidgetInfo item = createWidgetInfo(info, false);
         item.appWidgetId = -33;
 
-        addItemToScreen(item);
+        setupContents(item);
 
         final Workspace workspace = mLauncher.getWorkspace();
         // Item deleted from db
@@ -145,7 +148,7 @@
         LauncherAppWidgetInfo item = createWidgetInfo(info, false);
         item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID;
 
-        addItemToScreen(item);
+        setupContents(item);
         verifyWidgetPresent(info);
     }
 
@@ -158,7 +161,7 @@
         LauncherAppWidgetInfo item = createWidgetInfo(info, false);
         item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID;
 
-        addItemToScreen(item);
+        setupContents(item);
         verifyPendingWidgetPresent();
 
         // Item deleted from db
@@ -180,7 +183,7 @@
         item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID
                 | LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
 
-        addItemToScreen(item);
+        setupContents(item);
 
         assertTrue("Pending widget exists",
                 mLauncher.getWorkspace().tryGetPendingWidget(0) == null);
@@ -199,7 +202,7 @@
                 | LauncherAppWidgetInfo.FLAG_RESTORE_STARTED
                 | LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
 
-        addItemToScreen(item);
+        setupContents(item);
         verifyPendingWidgetPresent();
 
         // Verify item still exists in db
@@ -227,7 +230,7 @@
         PackageInstaller installer = mTargetContext.getPackageManager().getPackageInstaller();
         mSessionId = installer.createSession(params);
 
-        addItemToScreen(item);
+        setupContents(item);
         verifyPendingWidgetPresent();
 
         // Verify item still exists in db
@@ -242,6 +245,35 @@
                         & LauncherAppWidgetInfo.FLAG_ID_NOT_VALID);
     }
 
+    /**
+     * Adds {@param item} on the homescreen on the 0th screen at 0,0, and verifies that the
+     * widget class is displayed on the homescreen.
+     */
+    private void setupContents(LauncherAppWidgetInfo item) {
+        int screenId = FIRST_SCREEN_ID;
+        // Update the screen id counter for the provider.
+        LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_NEW_SCREEN_ID);
+
+        if (screenId > FIRST_SCREEN_ID) {
+            screenId = FIRST_SCREEN_ID;
+        }
+
+        // Insert the item
+        ContentWriter writer = new ContentWriter(mTargetContext);
+        item.id = LauncherSettings.Settings.call(
+                mResolver, LauncherSettings.Settings.METHOD_NEW_ITEM_ID)
+                .getInt(LauncherSettings.Settings.EXTRA_VALUE);
+        item.screenId = screenId;
+        item.onAddToDatabase(writer);
+        writer.put(LauncherSettings.Favorites._ID, item.id);
+        mResolver.insert(LauncherSettings.Favorites.CONTENT_URI, writer.getValues(mTargetContext));
+        resetLoaderState();
+
+        // Launch the home activity
+        mDevice.pressHome();
+        waitForModelLoaded();
+    }
+
     private void verifyWidgetPresent(LauncherAppWidgetProviderInfo info) {
         assertTrue("Widget is not present",
                 mLauncher.getWorkspace().tryGetWidget(info.label, DEFAULT_UI_TIMEOUT) != null);
@@ -257,10 +289,8 @@
      * @param bindWidget if true the info is bound and a valid widgetId is assigned to
      *                   the LauncherAppWidgetInfo
      */
-    public static LauncherAppWidgetInfo createWidgetInfo(
+    private LauncherAppWidgetInfo createWidgetInfo(
             LauncherAppWidgetProviderInfo info, boolean bindWidget) {
-        Context targetContext = getTargetContext();
-
         LauncherAppWidgetInfo item = new LauncherAppWidgetInfo(
                 LauncherAppWidgetInfo.NO_ID, info.provider);
         item.spanX = info.minSpanX;
@@ -278,12 +308,11 @@
             pendingInfo.spanY = item.spanY;
             pendingInfo.minSpanX = item.minSpanX;
             pendingInfo.minSpanY = item.minSpanY;
-            Bundle options = getDefaultOptionsForWidget(targetContext, pendingInfo);
+            Bundle options = WidgetHostViewLoader.getDefaultOptionsForWidget(mTargetContext, pendingInfo);
 
-            AppWidgetHost host = new LauncherAppWidgetHost(targetContext);
+            AppWidgetHost host = new LauncherAppWidgetHost(mTargetContext);
             int widgetId = host.allocateAppWidgetId();
-            if (!AppWidgetManagerCompat.getInstance(targetContext)
-                    .bindAppWidgetIdIfAllowed(widgetId, info, options)) {
+            if (!mWidgetManager.bindAppWidgetIdIfAllowed(widgetId, info, options)) {
                 host.deleteAppWidgetId(widgetId);
                 throw new IllegalArgumentException("Unable to bind widget id");
             }
@@ -302,7 +331,7 @@
 
         Set<String> activePackage = getOnUiThread(() -> {
             Set<String> packages = new HashSet<>();
-            PackageInstallerCompat.getInstance(mTargetContext).getActiveSessions()
+            PackageInstallerCompat.getInstance(mTargetContext).updateAndGetActiveSessionCache()
                     .keySet().forEach(packageUserKey -> packages.add(packageUserKey.mPackageName));
             return packages;
         });
diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
index d7f41bf..8391ae7 100644
--- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
+++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
@@ -37,11 +37,11 @@
     private static final String TAG = "TestStabilityRule";
     private static final Pattern LAUNCHER_BUILD =
             Pattern.compile("^("
-                    + "(?<local>(BuildFromAndroidStudio|"
-                    + "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|"
-                    + "(?<presubmit>([0-9]+|[A-Z])-P[0-9]+)|"
-                    + "(?<postsubmit>([0-9]+|[A-Z])-[0-9]+)|"
-                    + "(?<platform>[0-9]+|[A-Z])"
+                    + "(?<androidStudio>BuildFromAndroidStudio)|"
+                    + "(?<commandLine>[0-9]+-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+)|"
+                    + "(?<presubmit>[0-9]+-P[0-9]+)|"
+                    + "(?<postsubmit>[0-9]+-[0-9]+|"
+                    + "(?<platform>[0-9]+))"
                     + ")$");
     private static final Pattern PLATFORM_BUILD =
             Pattern.compile("^("
@@ -61,7 +61,71 @@
             return new Statement() {
                 @Override
                 public void evaluate() throws Throwable {
-                    getRunFlavor();
+                    final String launcherVersion =
+                            getInstrumentation().
+                                    getContext().
+                                    getPackageManager().
+                                    getPackageInfo(
+                                            UiDevice.getInstance(getInstrumentation()).
+                                                    getLauncherPackageName(),
+                                            0).
+                                    versionName;
+
+                    final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);
+
+                    boolean launcherLocalBuild = false;
+                    boolean launcherUnbundledPresubmit = false;
+                    boolean launcherUnbundledPostsubmit = false;
+                    boolean launcherPlatform = false;
+
+                    if (!launcherBuildMatcher.find()) {
+                        Log.e(TAG, "Match not found");
+                    } else if (launcherBuildMatcher.group("androidStudio") != null
+                            || launcherBuildMatcher.group("commandLine") != null) {
+                        launcherLocalBuild = true;
+                    } else if (launcherBuildMatcher.group("presubmit") != null) {
+                        launcherUnbundledPresubmit = true;
+                    } else if (launcherBuildMatcher.group("postsubmit") != null) {
+                        launcherUnbundledPostsubmit = true;
+                    } else if (launcherBuildMatcher.group("platform") != null) {
+                        launcherPlatform = true;
+                    } else {
+                        Log.e(TAG, "ERROR1");
+                    }
+
+                    boolean platformLocalBuild = false;
+                    boolean platformPresubmit = false;
+                    boolean platformPostsubmit = false;
+
+                    final String platformVersion = Build.VERSION.INCREMENTAL;
+                    final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);
+                    if (!platformBuildMatcher.find()) {
+                        Log.e(TAG, "Match not found");
+                    } else if (platformBuildMatcher.group("commandLine") != null) {
+                        platformLocalBuild = true;
+                    } else if (platformBuildMatcher.group("presubmit") != null) {
+                        platformPresubmit = true;
+                    } else if (platformBuildMatcher.group("postsubmit") != null) {
+                        platformPostsubmit = true;
+                    } else {
+                        Log.e(TAG, "ERROR2");
+                    }
+
+                    Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);
+
+                    if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) {
+                        Log.d(TAG, "LOCAL RUN");
+                    } else if (launcherUnbundledPresubmit && platformPostsubmit) {
+                        Log.d(TAG, "UNBUNDLED PRESUBMIT");
+                    } else if (launcherUnbundledPostsubmit && platformPostsubmit) {
+                        Log.d(TAG, "UNBUNDLED POSTSUBMIT");
+                    } else if (launcherPlatform && platformPresubmit) {
+                        Log.d(TAG, "PLATFORM PRESUBMIT");
+                    } else if (launcherPlatform && platformPostsubmit) {
+                        Log.d(TAG, "PLATFORM POSTSUBMIT");
+                    } else {
+                        Log.e(TAG, "ERROR3");
+                    }
 
                     base.evaluate();
                 }
@@ -70,50 +134,4 @@
             return base;
         }
     }
-
-    private static void getRunFlavor() throws Exception {
-        final String launcherVersion = getInstrumentation().
-                getContext().
-                getPackageManager().
-                getPackageInfo(
-                        UiDevice.getInstance(getInstrumentation()).
-                                getLauncherPackageName(),
-                        0).
-                versionName;
-
-        final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);
-
-        if (!launcherBuildMatcher.find()) {
-            Log.e(TAG, "Match not found");
-        }
-
-        final String platformVersion = Build.VERSION.INCREMENTAL;
-        final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);
-
-        if (!platformBuildMatcher.find()) {
-            Log.e(TAG, "Match not found");
-        }
-
-        Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);
-
-        if (launcherBuildMatcher.group("local") != null && (
-                platformBuildMatcher.group("commandLine") != null ||
-                        platformBuildMatcher.group("postsubmit") != null)) {
-            Log.d(TAG, "LOCAL RUN");
-        } else if (launcherBuildMatcher.group("presubmit") != null
-                && platformBuildMatcher.group("postsubmit") != null) {
-            Log.d(TAG, "UNBUNDLED PRESUBMIT");
-        } else if (launcherBuildMatcher.group("postsubmit") != null
-                && platformBuildMatcher.group("postsubmit") != null) {
-            Log.d(TAG, "UNBUNDLED POSTSUBMIT");
-        } else if (launcherBuildMatcher.group("platform") != null
-                && platformBuildMatcher.group("presubmit") != null) {
-            Log.d(TAG, "PLATFORM PRESUBMIT");
-        } else if (launcherBuildMatcher.group("platform") != null
-                && platformBuildMatcher.group("postsubmit") != null) {
-            Log.d(TAG, "PLATFORM POSTSUBMIT");
-        } else {
-            Log.e(TAG, "ERROR3");
-        }
-    }
 }
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index e1e9b8d..f070280 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -53,8 +53,8 @@
         return LauncherInstrumentation.ContainerType.ALL_APPS;
     }
 
-    private boolean hasClickableIcon(UiObject2 allAppsContainer, UiObject2 appListRecycler,
-            BySelector appIconSelector, int displayBottom) {
+    private boolean hasClickableIcon(
+            UiObject2 allAppsContainer, UiObject2 appListRecycler, BySelector appIconSelector) {
         final UiObject2 icon = appListRecycler.findObject(appIconSelector);
         if (icon == null) {
             LauncherInstrumentation.log("hasClickableIcon: icon not visible");
@@ -66,10 +66,6 @@
             LauncherInstrumentation.log("hasClickableIcon: icon center is under search box");
             return false;
         }
-        if (iconBounds.bottom > displayBottom) {
-            LauncherInstrumentation.log("hasClickableIcon: icon center bellow bottom offset");
-            return false;
-        }
         LauncherInstrumentation.log("hasClickableIcon: icon is clickable");
         return true;
     }
@@ -94,32 +90,21 @@
             final UiObject2 allAppsContainer = verifyActiveContainer();
             final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
                     "apps_list_view");
-            final UiObject2 searchBox = getSearchBox(allAppsContainer);
-
-            int bottomGestureMargin = ResourceUtils.getNavbarSize(
-                    ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
-            int deviceHeight = mLauncher.getDevice().getDisplayHeight();
-            int displayBottom = deviceHeight - bottomGestureMargin;
             allAppsContainer.setGestureMargins(
                     0,
                     getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1,
                     0,
-                    bottomGestureMargin);
+                    ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
+                            mLauncher.getResources()) + 1);
             final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
-            if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector,
-                    displayBottom)) {
+            if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
                 scrollBackToBeginning();
                 int attempts = 0;
-                int scroll = getAllAppsScroll();
+                int scroll = getScroll(allAppsContainer);
                 try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
-                    while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector,
-                            displayBottom)) {
-                        mLauncher.scrollToLastVisibleRow(
-                                allAppsContainer,
-                                mLauncher.getObjectsInContainer(allAppsContainer, "icon"),
-                                searchBox.getVisibleBounds().bottom
-                                        - allAppsContainer.getVisibleBounds().top);
-                        final int newScroll = getAllAppsScroll();
+                    while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
+                        mLauncher.scroll(allAppsContainer, Direction.DOWN, 0.8f, null, 50);
+                        final int newScroll = getScroll(allAppsContainer);
                         if (newScroll == scroll) break;
 
                         mLauncher.assertTrue(
@@ -132,11 +117,8 @@
                 verifyActiveContainer();
             }
 
-            // Ignore bottom offset selection here as there might not be any scroll more scroll
-            // region available.
             mLauncher.assertTrue("Unable to scroll to a clickable icon: " + appName,
-                    hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector,
-                            deviceHeight));
+                    hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector));
 
             final UiObject2 appIcon = mLauncher.waitForObjectInContainer(appListRecycler,
                     appIconSelector);
@@ -154,16 +136,16 @@
             int attempts = 0;
             final Rect margins = new Rect(0, searchBox.getVisibleBounds().bottom + 1, 0, 5);
 
-            for (int scroll = getAllAppsScroll();
+            for (int scroll = getScroll(allAppsContainer);
                     scroll != 0;
-                    scroll = getAllAppsScroll()) {
+                    scroll = getScroll(allAppsContainer)) {
                 mLauncher.assertTrue("Negative scroll position", scroll > 0);
 
                 mLauncher.assertTrue(
                         "Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
                         ++attempts <= MAX_SCROLL_ATTEMPTS);
 
-                mLauncher.scroll(allAppsContainer, Direction.UP, margins, 50);
+                mLauncher.scroll(allAppsContainer, Direction.UP, 1, margins, 50);
             }
 
             try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled up")) {
@@ -172,10 +154,9 @@
         }
     }
 
-    private int getAllAppsScroll() {
-        return mLauncher.getTestInfo(
-                TestProtocol.REQUEST_APPS_LIST_SCROLL_Y)
-                .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+    private int getScroll(UiObject2 allAppsContainer) {
+        return mLauncher.getAnswerFromLauncher(allAppsContainer, TestProtocol.GET_SCROLL_MESSAGE).
+                getInt(TestProtocol.SCROLL_Y_FIELD, -1);
     }
 
     private UiObject2 getSearchBox(UiObject2 allAppsContainer) {
@@ -191,7 +172,7 @@
             final UiObject2 allAppsContainer = verifyActiveContainer();
             // Start the gesture in the center to avoid starting at elements near the top.
             mLauncher.scroll(
-                    allAppsContainer, Direction.DOWN, new Rect(0, 0, 0, mHeight / 2), 10);
+                    allAppsContainer, Direction.DOWN, 1, new Rect(0, 0, 0, mHeight / 2), 10);
             verifyActiveContainer();
         }
     }
@@ -205,7 +186,7 @@
             final UiObject2 allAppsContainer = verifyActiveContainer();
             // Start the gesture in the center, for symmetry with forward.
             mLauncher.scroll(
-                    allAppsContainer, Direction.UP, new Rect(0, mHeight / 2, 0, 0), 10);
+                    allAppsContainer, Direction.UP, 1, new Rect(0, mHeight / 2, 0, 0), 10);
             verifyActiveContainer();
         }
     }
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 8b5792c..bcce8ef 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -23,7 +23,6 @@
 import android.view.MotionEvent;
 
 import androidx.annotation.NonNull;
-import androidx.test.uiautomator.UiObject2;
 
 import com.android.launcher3.testing.TestProtocol;
 
@@ -105,12 +104,7 @@
                     startY = endY = mLauncher.getDevice().getDisplayHeight() / 2;
                 }
 
-                if (mLauncher.isFallbackOverview()) {
-                    mLauncher.linearGesture(startX, startY, endX, endY, 10);
-                    new BaseOverview(mLauncher);
-                } else {
-                    mLauncher.swipeToState(startX, startY, endX, endY, 10, expectedState);
-                }
+                mLauncher.swipeToState(startX, startY, endX, endY, 10, expectedState);
                 break;
             }
 
@@ -120,46 +114,6 @@
         }
     }
 
-    /**
-     * Swipes right or double presses the square button to switch to the previous app.
-     */
-    public Background quickSwitchToPreviousApp() {
-        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
-                "want to quick switch to the previous app")) {
-            verifyActiveContainer();
-            quickSwitchToPreviousApp(getExpectedStateForQuickSwitch());
-            return new Background(mLauncher);
-        }
-    }
-
-    protected int getExpectedStateForQuickSwitch() {
-        return BACKGROUND_APP_STATE_ORDINAL;
-    }
-
-    protected void quickSwitchToPreviousApp(int expectedState) {
-        switch (mLauncher.getNavigationModel()) {
-            case ZERO_BUTTON:
-                // Fall through, zero button and two button modes behave the same.
-            case TWO_BUTTON: {
-                // Swipe from the bottom left to the bottom right of the screen.
-                final int startX = 0;
-                final int startY = getSwipeStartY();
-                final int endX = mLauncher.getDevice().getDisplayWidth();
-                final int endY = startY;
-                mLauncher.swipeToState(startX, startY, endX, endY, 20, expectedState);
-                break;
-            }
-
-            case THREE_BUTTON:
-                // Double press the recents button.
-                UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps");
-                recentsButton.click();
-                mLauncher.getOverview();
-                recentsButton.click();
-                break;
-        }
-    }
-
     protected String getSwipeHeightRequestName() {
         return TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT;
     }
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index 8ccfc05..eaa21ae 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -55,7 +55,7 @@
             final int leftMargin = mLauncher.getTestInfo(
                     TestProtocol.REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN).
                     getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
-            mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20);
+            mLauncher.scroll(overview, Direction.LEFT, 1, new Rect(leftMargin, 0, 0, 0), 20);
             verifyActiveContainer();
         }
     }
@@ -89,7 +89,7 @@
             final int rightMargin = mLauncher.getTestInfo(
                     TestProtocol.REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN).
                     getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
-            mLauncher.scroll(overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20);
+            mLauncher.scroll(overview, Direction.RIGHT, 1, new Rect(0, 0, rightMargin, 0), 20);
             verifyActiveContainer();
         }
     }
diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java
index e0fe933..cfc4374 100644
--- a/tests/tapl/com/android/launcher3/tapl/Home.java
+++ b/tests/tapl/com/android/launcher3/tapl/Home.java
@@ -17,7 +17,6 @@
 package com.android.launcher3.tapl;
 
 import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
-import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
 
 import androidx.annotation.NonNull;
 
@@ -59,9 +58,4 @@
             }
         }
     }
-
-    @Override
-    protected int getExpectedStateForQuickSwitch() {
-        return QUICK_SWITCH_STATE_ORDINAL;
-    }
 }
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 484cbb6..383c3ce 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -37,6 +37,7 @@
 import android.graphics.Point;
 import android.graphics.Rect;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Parcelable;
 import android.os.SystemClock;
@@ -51,7 +52,6 @@
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.test.InstrumentationRegistry;
 import androidx.test.uiautomator.By;
 import androidx.test.uiautomator.BySelector;
 import androidx.test.uiautomator.Configurator;
@@ -60,24 +60,20 @@
 import androidx.test.uiautomator.UiObject2;
 import androidx.test.uiautomator.Until;
 
-import com.android.launcher3.ResourceUtils;
 import com.android.launcher3.testing.TestProtocol;
 import com.android.systemui.shared.system.QuickStepContract;
 
-import java.util.ArrayList;
+import org.junit.Assert;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.lang.ref.WeakReference;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Deque;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.TimeoutException;
 import java.util.function.Consumer;
-import java.util.function.Function;
-
-import org.junit.Assert;
+import java.util.function.Supplier;
 
 /**
  * The main tapl object. The only object that can be explicitly constructed by the using code. It
@@ -88,7 +84,6 @@
     private static final String TAG = "Tapl";
     private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
     private static final int GESTURE_STEP_MS = 16;
-    private static long START_TIME = System.currentTimeMillis();
 
     // Types for launcher containers that the user is interacting with. "Background" is a
     // pseudo-container corresponding to inactive launcher covered by another app.
@@ -139,22 +134,13 @@
     private int mExpectedRotation = Surface.ROTATION_0;
     private final Uri mTestProviderUri;
     private final Deque<String> mDiagnosticContext = new LinkedList<>();
-    private Function<Long, String> mSystemHealthSupplier;
+    private Supplier<String> mSystemHealthSupplier;
 
     private Consumer<ContainerType> mOnSettledStateAction;
 
     /**
      * Constructs the root of TAPL hierarchy. You get all other objects from it.
      */
-    public LauncherInstrumentation() {
-        this(InstrumentationRegistry.getInstrumentation());
-    }
-
-    /**
-     * Constructs the root of TAPL hierarchy. You get all other objects from it.
-     * Deprecated: use the constructor without parameters instead.
-     */
-    @Deprecated
     public LauncherInstrumentation(Instrumentation instrumentation) {
         mInstrumentation = instrumentation;
         mDevice = UiDevice.getInstance(instrumentation);
@@ -252,6 +238,10 @@
         return null;
     }
 
+    public static boolean isAvd() {
+        return Build.MODEL.contains("Cuttlefish");
+    }
+
     static void log(String message) {
         Log.d(TAG, message);
     }
@@ -306,7 +296,7 @@
         return "Background";
     }
 
-    public void setSystemHealthSupplier(Function<Long, String> supplier) {
+    public void setSystemHealthSupplier(Supplier<String> supplier) {
         this.mSystemHealthSupplier = supplier;
     }
 
@@ -326,8 +316,8 @@
         }
 
         return mSystemHealthSupplier != null
-                ? mSystemHealthSupplier.apply(START_TIME)
-                : TestHelpers.getSystemHealthMessage(getContext(), START_TIME);
+                ? mSystemHealthSupplier.get()
+                : TestHelpers.getSystemHealthMessage(getContext());
     }
 
     private void fail(String message) {
@@ -496,7 +486,7 @@
         }
     }
 
-    public void waitForLauncherInitialized() {
+    private void waitForLauncherInitialized() {
         for (int i = 0; i < 100; ++i) {
             if (getTestInfo(
                     TestProtocol.REQUEST_IS_LAUNCHER_INITIALIZED).
@@ -522,6 +512,15 @@
         }
     }
 
+    Bundle getAnswerFromLauncher(UiObject2 view, String requestTag) {
+        // Send a fake set-text request to Launcher to initiate a response with requested data.
+        final String responseTag = requestTag + TestProtocol.RESPONSE_MESSAGE_POSTFIX;
+        return (Bundle) executeAndWaitForEvent(
+                () -> view.setText(requestTag),
+                event -> responseTag.equals(event.getClassName()),
+                "Launcher didn't respond to request: " + requestTag);
+    }
+
     /**
      * Presses nav bar home button.
      *
@@ -535,9 +534,6 @@
         // accessibility events prior to pressing Home.
         final String action;
         if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
-            final String anomaly = getAnomalyMessage();
-            if (anomaly != null) fail("Can't swipe up to Home: " + anomaly);
-
             final Point displaySize = getRealDisplaySize();
 
             if (hasLauncherObject("deep_shortcuts_container")) {
@@ -545,17 +541,13 @@
                         displaySize.x / 2, displaySize.y - 1,
                         displaySize.x / 2, 0,
                         ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
-                try (LauncherInstrumentation.Closable c = addContextLayer(
-                        "Swiped up from context menu to home")) {
-                    waitUntilGone("deep_shortcuts_container");
-                }
+                assertTrue("Context menu is still visible afterswiping up to home",
+                        !hasLauncherObject("deep_shortcuts_container"));
             }
             if (hasLauncherObject(WORKSPACE_RES_ID)) {
                 log(action = "already at home");
             } else {
-                log("Hierarchy before swiping up to home");
-                dumpViewHierarchy();
-                log(action = "swiping up to home from " + getVisibleStateMessage());
+                log(action = "swiping up to home");
                 final int finalState = mDevice.hasObject(By.pkg(getLauncherPackageName()))
                         ? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL;
 
@@ -777,36 +769,7 @@
                 TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
     }
 
-    int getBottomGestureSize() {
-        return ResourceUtils.getNavbarSize(
-                ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()) + 1;
-    }
-
-    int getBottomGestureMargin(UiObject2 container) {
-        return container.getVisibleBounds().bottom - getRealDisplaySize().y
-                + getBottomGestureSize();
-    }
-
-    void scrollToLastVisibleRow(UiObject2 container, Collection<UiObject2> items, int topPadding) {
-        final UiObject2 lowestItem = Collections.max(items, (i1, i2) ->
-                Integer.compare(i1.getVisibleBounds().top, i2.getVisibleBounds().top));
-
-        final int gestureStart = lowestItem.getVisibleBounds().top + getTouchSlop();
-        final int distance = gestureStart - container.getVisibleBounds().top - topPadding;
-        final int bottomMargin = container.getVisibleBounds().height() - distance;
-
-        scroll(
-                container,
-                Direction.DOWN,
-                new Rect(
-                        0,
-                        0,
-                        0,
-                        Math.max(bottomMargin, getBottomGestureMargin(container))),
-                150);
-    }
-
-    void scroll(UiObject2 container, Direction direction, Rect margins, int steps) {
+    void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
         final Rect rect = container.getVisibleBounds();
         if (margins != null) {
             rect.left += margins.left;
@@ -823,26 +786,34 @@
         switch (direction) {
             case UP: {
                 startX = endX = rect.centerX();
-                startY = rect.top;
-                endY = rect.bottom - 1;
+                final int vertCenter = rect.centerY();
+                final float halfGestureHeight = rect.height() * percent / 2.0f;
+                startY = (int) (vertCenter - halfGestureHeight) + 1;
+                endY = (int) (vertCenter + halfGestureHeight);
             }
             break;
             case DOWN: {
                 startX = endX = rect.centerX();
-                startY = rect.bottom - 1;
-                endY = rect.top;
+                final int vertCenter = rect.centerY();
+                final float halfGestureHeight = rect.height() * percent / 2.0f;
+                startY = (int) (vertCenter + halfGestureHeight) - 1;
+                endY = (int) (vertCenter - halfGestureHeight);
             }
             break;
             case LEFT: {
                 startY = endY = rect.centerY();
-                startX = rect.left;
-                endX = rect.right - 1;
+                final int horizCenter = rect.centerX();
+                final float halfGestureWidth = rect.width() * percent / 2.0f;
+                startX = (int) (horizCenter - halfGestureWidth) + 1;
+                endX = (int) (horizCenter + halfGestureWidth);
             }
             break;
             case RIGHT: {
                 startY = endY = rect.centerY();
-                startX = rect.right - 1;
-                endX = rect.left;
+                final int horizCenter = rect.centerX();
+                final float halfGestureWidth = rect.width() * percent / 2.0f;
+                startX = (int) (horizCenter + halfGestureWidth) - 1;
+                endX = (int) (horizCenter - halfGestureWidth);
             }
             break;
             default:
@@ -873,6 +844,10 @@
         mDevice.waitForIdle();
     }
 
+    float getDisplayDensity() {
+        return mInstrumentation.getTargetContext().getResources().getDisplayMetrics().density;
+    }
+
     int getTouchSlop() {
         return ViewConfiguration.get(getContext()).getScaledTouchSlop();
     }
@@ -994,18 +969,4 @@
     public void produceNativeLeak() {
         getTestInfo(TestProtocol.REQUEST_NATIVE_LEAK);
     }
-
-    public void produceViewLeak() {
-        getTestInfo(TestProtocol.REQUEST_VIEW_LEAK);
-    }
-
-    public ArrayList<ComponentName> getRecentTasks() {
-        ArrayList<ComponentName> tasks = new ArrayList<>();
-        ArrayList<String> components = getTestInfo(TestProtocol.REQUEST_RECENT_TASKS_LIST)
-                .getStringArrayList(TestProtocol.TEST_INFO_RESPONSE_FIELD);
-        for (String s : components) {
-            tasks.add(ComponentName.unflattenFromString(s));
-        }
-        return tasks;
-    }
 }
\ No newline at end of file
diff --git a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java
index e882171..a089a52 100644
--- a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java
+++ b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java
@@ -77,18 +77,13 @@
         return launchers.get(0).activityInfo;
     }
 
-    public static ComponentName getOverviewComponentName() {
+    public static String getOverviewPackageName() {
         Resources res = Resources.getSystem();
         int id = res.getIdentifier("config_recentsComponentName", "string", "android");
         if (id != 0) {
-            return ComponentName.unflattenFromString(res.getString(id));
+            return ComponentName.unflattenFromString(res.getString(id)).getPackageName();
         }
-        return new ComponentName("com.android.systemui",
-                "com.android.systemui.recents.RecentsActivity");
-    }
-
-    public static String getOverviewPackageName() {
-        return getOverviewComponentName().getPackageName();
+        return "com.android.systemui";
     }
 
     private static String truncateCrash(String text, int maxLines) {
@@ -106,11 +101,11 @@
         return ret.toString();
     }
 
-    private static String checkCrash(Context context, String label, long startTime) {
+    private static String checkCrash(Context context, String label) {
         DropBoxManager dropbox = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
         Assert.assertNotNull("Unable access the DropBoxManager service", dropbox);
 
-        long timestamp = startTime;
+        long timestamp = System.currentTimeMillis() - 5 * 60000;
         DropBoxManager.Entry entry;
         StringBuilder errorDetails = new StringBuilder();
         while (null != (entry = dropbox.getNextEntry(label, timestamp))) {
@@ -128,7 +123,7 @@
         return errorDetails.length() != 0 ? errorDetails.toString() : null;
     }
 
-    public static String getSystemHealthMessage(Context context, long startTime) {
+    public static String getSystemHealthMessage(Context context) {
         try {
             StringBuilder errors = new StringBuilder();
 
@@ -136,6 +131,7 @@
                     "system_app_anr",
                     "system_app_crash",
                     "system_app_native_crash",
+                    "system_app_wtf",
                     "system_server_anr",
                     "system_server_crash",
                     "system_server_native_crash",
@@ -143,7 +139,7 @@
             };
 
             for (String label : labels) {
-                final String crash = checkCrash(context, label, startTime);
+                final String crash = checkCrash(context, label);
                 if (crash != null) errors.append(crash);
             }
 
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index 5fcaa55..7d308af 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3.tapl;
 
+import static org.junit.Assert.fail;
+
 import android.graphics.Point;
 import android.graphics.Rect;
 
@@ -24,12 +26,13 @@
 import androidx.test.uiautomator.Direction;
 import androidx.test.uiautomator.UiObject2;
 
-import java.util.Collection;
+import com.android.launcher3.ResourceUtils;
 
 /**
  * All widgets container.
  */
 public final class Widgets extends LauncherInstrumentation.VisibleContainer {
+    private static final Rect MARGINS = new Rect(100, 100, 100, 100);
     private static final int FLING_STEPS = 10;
 
     Widgets(LauncherInstrumentation launcher) {
@@ -45,11 +48,7 @@
                 "want to fling forward in widgets")) {
             LauncherInstrumentation.log("Widgets.flingForward enter");
             final UiObject2 widgetsContainer = verifyActiveContainer();
-            mLauncher.scroll(
-                    widgetsContainer,
-                    Direction.DOWN,
-                    new Rect(0, 0, 0, mLauncher.getBottomGestureMargin(widgetsContainer) + 1),
-                    FLING_STEPS);
+            mLauncher.scroll(widgetsContainer, Direction.DOWN, 1f, MARGINS, FLING_STEPS);
             try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) {
                 verifyActiveContainer();
             }
@@ -65,11 +64,7 @@
                 "want to fling backwards in widgets")) {
             LauncherInstrumentation.log("Widgets.flingBackward enter");
             final UiObject2 widgetsContainer = verifyActiveContainer();
-            mLauncher.scroll(
-                    widgetsContainer,
-                    Direction.UP,
-                    new Rect(0, 0, widgetsContainer.getVisibleBounds().width(), 0),
-                    FLING_STEPS);
+            mLauncher.scroll(widgetsContainer, Direction.UP, 1f, MARGINS, FLING_STEPS);
             try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung back")) {
                 verifyActiveContainer();
             }
@@ -83,33 +78,32 @@
     }
 
     public Widget getWidget(String labelText) {
+        final int margin = ResourceUtils.getNavbarSize(
+                ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
         final UiObject2 widgetsContainer = verifyActiveContainer();
+        widgetsContainer.setGestureMargins(0, 0, 0, margin);
+
         final Point displaySize = mLauncher.getRealDisplaySize();
-        final BySelector labelSelector = By.clazz("android.widget.TextView").text(labelText);
 
         int i = 0;
-        for (; ; ) {
-            final Collection<UiObject2> cells = mLauncher.getObjectsInContainer(
-                    widgetsContainer, "widgets_cell_list_container");
-            mLauncher.assertTrue("Widgets doesn't have 2 rows", cells.size() >= 2);
-            for (UiObject2 cell : cells) {
-                final UiObject2 label = cell.findObject(labelSelector);
-                if (label == null) continue;
+        final BySelector selector = By.clazz("android.widget.TextView").text(labelText);
 
+        for (; ; ) {
+            final UiObject2 label = mLauncher.tryWaitForLauncherObject(selector, 300);
+            if (label != null) {
                 final UiObject2 widget = label.getParent().getParent();
                 mLauncher.assertEquals(
                         "View is not WidgetCell",
                         "com.android.launcher3.widget.WidgetCell",
                         widget.getClassName());
 
-                if (widget.getVisibleBounds().bottom
-                        <= displaySize.y - mLauncher.getBottomGestureSize()) {
+                if (widget.getVisibleBounds().bottom <= displaySize.y - margin) {
                     return new Widget(mLauncher, widget);
                 }
             }
 
-            mLauncher.assertTrue("Too many attempts", ++i <= 40);
-            mLauncher.scrollToLastVisibleRow(widgetsContainer, cells, 0);
+            if (++i > 40) fail("Too many attempts");
+            mLauncher.scroll(widgetsContainer, Direction.DOWN, 0.7f, MARGINS, 50);
         }
     }
 }
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index d1261e0..510ea14 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -38,6 +38,8 @@
  * Operations on the workspace screen.
  */
 public final class Workspace extends Home {
+    private static final float FLING_SPEED =
+            LauncherInstrumentation.isAvd() ? 1500.0F : 3500.0F;
     private static final int DRAG_DURACTION = 2000;
     private static final int FLING_STEPS = 10;
     private final UiObject2 mHotseat;
@@ -140,7 +142,7 @@
     }
 
     private boolean isWorkspaceScrollable(UiObject2 workspace) {
-        return workspace.getChildCount() > 1;
+        return workspace.isScrollable();
     }
 
     @NonNull
@@ -180,8 +182,8 @@
      */
     public void flingForward() {
         final UiObject2 workspace = verifyActiveContainer();
-        mLauncher.scroll(workspace, Direction.RIGHT,
-                new Rect(0, 0, mLauncher.getEdgeSensitivityWidth() + 1, 0),
+        mLauncher.scroll(workspace, Direction.RIGHT, 1f,
+                new Rect(0, 0, mLauncher.getEdgeSensitivityWidth(), 0),
                 FLING_STEPS);
         verifyActiveContainer();
     }
@@ -192,8 +194,8 @@
      */
     public void flingBackward() {
         final UiObject2 workspace = verifyActiveContainer();
-        mLauncher.scroll(workspace, Direction.LEFT,
-                new Rect(mLauncher.getEdgeSensitivityWidth() + 1, 0, 0, 0),
+        mLauncher.scroll(workspace, Direction.LEFT, 1f,
+                new Rect(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0),
                 FLING_STEPS);
         verifyActiveContainer();
     }