Merge "Always use INSIDE_TO_OUTSIDE scope when swiping to home in tablets" into sc-v2-dev am: 582a23260a am: 4a052020b1

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15346897

Change-Id: I7094fe43aeb7ef9ca40cce3e300162e6a81b70ad
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 7bb0b94..b038c7b 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -67,7 +67,6 @@
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.UiThread;
-import androidx.annotation.VisibleForTesting;
 import androidx.annotation.WorkerThread;
 
 import com.android.launcher3.BaseDraggingActivity;
@@ -302,7 +301,6 @@
 
     private static boolean sConnected = false;
     private static boolean sIsInitialized = false;
-    private static TouchInteractionService sInstance;
     private RotationTouchHelper mRotationTouchHelper;
 
     public static boolean isConnected() {
@@ -313,15 +311,6 @@
         return sIsInitialized;
     }
 
-    @VisibleForTesting
-    @Nullable
-    public static TaskbarManager getTaskbarManagerForTesting() {
-        if (sInstance == null) {
-            return null;
-        }
-        return sInstance.mTaskbarManager;
-    }
-
     private final AbsSwipeUpHandler.Factory mLauncherSwipeHandlerFactory =
             this::createLauncherSwipeHandler;
     private final AbsSwipeUpHandler.Factory mFallbackSwipeHandlerFactory =
@@ -365,7 +354,6 @@
         mDeviceState.runOnUserUnlocked(mTaskbarManager::onUserUnlocked);
         ProtoTracer.INSTANCE.get(this).add(this);
         sConnected = true;
-        sInstance = this;
     }
 
     private void disposeEventHandlers() {
@@ -523,7 +511,6 @@
 
         mTaskbarManager.destroy();
         sConnected = false;
-        sInstance = null;
         super.onDestroy();
     }
 
diff --git a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
index fe1bb2e..f44a812 100644
--- a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
+++ b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
@@ -25,12 +25,7 @@
 import androidx.test.runner.AndroidJUnit4;
 
 import com.android.launcher3.Launcher;
-import com.android.launcher3.taskbar.TaskbarActivityContext;
-import com.android.launcher3.taskbar.TaskbarDragLayer;
-import com.android.launcher3.taskbar.TaskbarManager;
-import com.android.launcher3.taskbar.TaskbarView;
 import com.android.launcher3.ui.TaplTestsLauncher3;
-import com.android.launcher3.ui.TestViewHelpers;
 import com.android.launcher3.util.RaceConditionReproducer;
 import com.android.quickstep.NavigationModeSwitchRule.Mode;
 import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
@@ -90,7 +85,7 @@
     public void testStressPressHome() {
         for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
             // Destroy Launcher activity.
-            destroyLauncherActivityAndWaitForTaskbarVisible();
+            closeLauncherActivity();
 
             // The test action.
             mLauncher.pressHome();
@@ -102,41 +97,12 @@
     public void testStressSwipeToOverview() {
         for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
             // Destroy Launcher activity.
-            destroyLauncherActivityAndWaitForTaskbarVisible();
+            closeLauncherActivity();
 
             // The test action.
             mLauncher.getBackground().switchToOverview();
         }
-        destroyLauncherActivityAndWaitForTaskbarVisible();
-        mLauncher.pressHome();
-    }
-
-    private void destroyLauncherActivityAndWaitForTaskbarVisible() {
         closeLauncherActivity();
-
-        // After Launcher is destroyed, calculator app started in setup() will be launched, wait for
-        // taskbar to settle before further interaction if it's a tablet.
-        if (!mLauncher.isTablet()) {
-            return;
-        }
-
-        waitForLauncherCondition(
-                "Taskbar not yet visible", launcher -> {
-                    TaskbarManager taskbarManager =
-                            TouchInteractionService.getTaskbarManagerForTesting();
-                    if (taskbarManager == null) {
-                        return false;
-                    }
-
-                    TaskbarActivityContext taskbarActivityContext =
-                            taskbarManager.getCurrentActivityContext();
-                    if (taskbarActivityContext == null) {
-                        return false;
-                    }
-
-                    TaskbarDragLayer taskbarDragLayer = taskbarActivityContext.getDragLayer();
-                    return TestViewHelpers.findChildView(taskbarDragLayer,
-                            view -> view instanceof TaskbarView && view.isVisibleToUser()) != null;
-                }, DEFAULT_UI_TIMEOUT);
+        mLauncher.pressHome();
     }
 }
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 7f9f1b6..1f64131 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -749,7 +749,7 @@
                             displaySize.x / 2, displaySize.y - 1,
                             displaySize.x / 2, 0,
                             ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME, NORMAL_STATE_ORDINAL,
-                            launcherWasVisible
+                            launcherWasVisible || isTablet()
                                     ? GestureScope.INSIDE_TO_OUTSIDE
                                     : GestureScope.OUTSIDE_WITH_PILFER);
                 }