Merge "Makes deep press for LPNH toggelable" into main
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index 2f84ac9..73b786f 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -174,7 +174,7 @@
dismissTaskMenuView(mTarget);
RecentsView rv = mTarget.getOverviewPanel();
rv.switchToScreenshot(() -> {
- rv.finishRecentsAnimation(true /* toHome */, () -> {
+ rv.finishRecentsAnimation(true /* toRecents */, false /* shouldPip */, () -> {
mTarget.returnToHomescreen();
rv.getHandler().post(this::startActivity);
});
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index ff8537b..7c43bfb 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -294,7 +294,6 @@
}
@Test
- @ScreenRecord // b/242163205
@TaskbarModeSwitch(mode = PERSISTENT)
public void testQuickSwitchToPreviousAppForTablet() throws Exception {
assumeTrue(mLauncher.isTablet());
@@ -352,6 +351,7 @@
@TaskbarModeSwitch(mode = PERSISTENT)
@PlatinumTest(focusArea = "launcher")
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/309820115
+ @ScreenRecord // b/309820115
public void testOverviewForTablet() throws Exception {
assumeTrue(mLauncher.isTablet());
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
index 0e382a4..28473cd 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
@@ -22,7 +22,6 @@
import androidx.test.filters.LargeTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
-import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -90,7 +89,6 @@
}
@Test
- @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchAppInSplitscreen() {
getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
@@ -104,7 +102,6 @@
}
@Test
- @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchShortcutInSplitscreen() {
getTaskbar().getAppIcon(TEST_APP_NAME)
@@ -133,7 +130,6 @@
}
@Test
- @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchAppInSplitscreen_fromTaskbarAllApps() {
getTaskbar().openAllApps()
@@ -142,7 +138,6 @@
}
@Test
- @ScreenRecord // b/231615831
@PortraitLandscape
public void testLaunchShortcutInSplitscreen_fromTaskbarAllApps() {
getTaskbar().openAllApps()
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 94e5970..1a0f2cf 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -57,6 +57,7 @@
import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.ViewCompat;
@@ -1657,15 +1658,16 @@
}
}
- // For a given cell and span, fetch the set of views intersecting the region.
- public void getViewsIntersectingRegion(int cellX, int cellY, int spanX, int spanY,
- View dragView, Rect boundingRect, ArrayList<View> intersectingViews) {
- if (boundingRect != null) {
- boundingRect.set(cellX, cellY, cellX + spanX, cellY + spanY);
- }
- intersectingViews.clear();
- Rect r0 = new Rect(cellX, cellY, cellX + spanX, cellY + spanY);
+ /**
+ * For a given region, return the rectangle of the overlapping cell and span with the given
+ * region including the region itself. If there is no overlap the rectangle will be
+ * invalid i.e. -1, 0, -1, 0.
+ */
+ @Nullable
+ public Rect getIntersectingRectanglesInRegion(final Rect region, final View dragView) {
+ Rect boundingRect = new Rect(region);
Rect r1 = new Rect();
+ boolean isOverlapping = false;
final int count = mShortcutsAndWidgets.getChildCount();
for (int i = 0; i < count; i++) {
View child = mShortcutsAndWidgets.getChildAt(i);
@@ -1674,21 +1676,21 @@
lp = (CellLayoutLayoutParams) child.getLayoutParams();
r1.set(lp.getCellX(), lp.getCellY(), lp.getCellX() + lp.cellHSpan,
lp.getCellY() + lp.cellVSpan);
- if (Rect.intersects(r0, r1)) {
- mIntersectingViews.add(child);
- if (boundingRect != null) {
- boundingRect.union(r1);
- }
+ if (Rect.intersects(region, r1)) {
+ isOverlapping = true;
+ boundingRect.union(r1);
}
}
+ return isOverlapping ? boundingRect : null;
}
public boolean isNearestDropLocationOccupied(int pixelX, int pixelY, int spanX, int spanY,
View dragView, int[] result) {
result = findNearestAreaIgnoreOccupied(pixelX, pixelY, spanX, spanY, result);
- getViewsIntersectingRegion(result[0], result[1], spanX, spanY, dragView, null,
- mIntersectingViews);
- return !mIntersectingViews.isEmpty();
+ return getIntersectingRectanglesInRegion(
+ new Rect(result[0], result[1], result[0] + spanX, result[1] + spanY),
+ dragView
+ ) != null;
}
void revertTempState() {
@@ -2241,9 +2243,10 @@
cellToRect(targetDestination[0], targetDestination[1], spanX, spanY, dragRect);
dragRect.offset(dragViewCenterX - dragRect.centerX(), dragViewCenterY - dragRect.centerY());
- Rect dropRegionRect = new Rect();
- getViewsIntersectingRegion(targetDestination[0], targetDestination[1], spanX, spanY,
- dragView, dropRegionRect, mIntersectingViews);
+ Rect region = new Rect(targetDestination[0], targetDestination[1],
+ targetDestination[0] + spanX, targetDestination[1] + spanY);
+ Rect dropRegionRect = getIntersectingRectanglesInRegion(region, dragView);
+ if (dropRegionRect == null) dropRegionRect = new Rect(region);
int dropRegionSpanX = dropRegionRect.width();
int dropRegionSpanY = dropRegionRect.height();
diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
index 3e80e6b..e1b06a8 100644
--- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
@@ -158,6 +158,7 @@
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
public static final String TWO_TASKBAR_LONG_CLICKS = "b/262282528";
public static final String ICON_MISSING = "b/282963545";
+ public static final String WORKSPACE_LONG_PRESS = "b/311099513";
public static final String REQUEST_EMULATE_DISPLAY = "emulate-display";
public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display";
diff --git a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java
index fe9464a..d71bf84 100644
--- a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java
+++ b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java
@@ -16,6 +16,8 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
+import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -30,6 +32,7 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.ui.AbstractLauncherUiTest;
+import com.android.launcher3.util.rule.TestStabilityRule;
import org.junit.Before;
import org.junit.Test;
@@ -80,6 +83,7 @@
}
@Test
+ @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/311410127
public void testAllAppsExitSearchAndFocusSearchResults() {
final HomeAllApps allApps = mLauncher.goHome().switchToAllApps();
assertTrue("Launcher internal state is not All Apps",
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 406de35..720c8e5 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -28,6 +28,8 @@
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_NUM_ALL_APPS_COLUMNS;
+import static com.android.launcher3.testing.shared.TestProtocol.WORKSPACE_LONG_PRESS;
+import static com.android.launcher3.testing.shared.TestProtocol.testLogD;
import android.app.ActivityManager;
import android.app.Instrumentation;
@@ -1705,6 +1707,7 @@
final Point start = new Point(startX, startY);
final Point end = new Point(endX, endY);
sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start, gestureScope);
+ testLogD(WORKSPACE_LONG_PRESS, "Sent ACTION_DOWN");
if (mTrackpadGestureType != TrackpadGestureType.NONE) {
sendPointer(downTime, downTime, getPointerAction(MotionEvent.ACTION_POINTER_DOWN, 1),
start, gestureScope);
@@ -1909,6 +1912,10 @@
long steps = duration / GESTURE_STEP_MS;
long currentTime = startTime;
+ testLogD(WORKSPACE_LONG_PRESS, "movingPointer" +
+ " downTime: " + downTime + " startTime: " + startTime +
+ " duration: " + duration + " isDecel? " + isDecelerating +
+ " gestureScope: " + gestureScope);
if (isDecelerating) {
// formula: V = V0 - D*T, assuming V = 0 when T = duration