Always use INSIDE_TO_OUTSIDE scope when swiping to home in tablets

- In tablets user is either in home screen or there is a taskbar on screen, so swipe to home will always touches the launcher

Bug: 193653850
Test: StartLauncherViaGestureTests
Change-Id: Id1b05708324302eb4b4c2d623ca9fe27090188fc
This commit is contained in:
Alex Chau 2021-07-21 14:52:01 +01:00
parent 015ab224f4
commit 2450adf56f
3 changed files with 4 additions and 51 deletions

View File

@ -67,7 +67,6 @@ import androidx.annotation.BinderThread;
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 @@ public class TouchInteractionService extends Service implements PluginListener<O
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 @@ public class TouchInteractionService extends Service implements PluginListener<O
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 @@ public class TouchInteractionService extends Service implements PluginListener<O
mDeviceState.runOnUserUnlocked(mTaskbarManager::onUserUnlocked);
ProtoTracer.INSTANCE.get(this).add(this);
sConnected = true;
sInstance = this;
}
private void disposeEventHandlers() {
@ -523,7 +511,6 @@ public class TouchInteractionService extends Service implements PluginListener<O
mTaskbarManager.destroy();
sConnected = false;
sInstance = null;
super.onDestroy();
}

View File

@ -25,12 +25,7 @@ import androidx.test.filters.LargeTest;
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 class StartLauncherViaGestureTests extends AbstractQuickStepTest {
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 class StartLauncherViaGestureTests extends AbstractQuickStepTest {
public void testStressSwipeToOverview() {
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
// Destroy Launcher activity.
destroyLauncherActivityAndWaitForTaskbarVisible();
closeLauncherActivity();
// The test action.
mLauncher.getBackground().switchToOverview();
}
destroyLauncherActivityAndWaitForTaskbarVisible();
closeLauncherActivity();
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);
}
}

View File

@ -749,7 +749,7 @@ public final class LauncherInstrumentation {
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);
}