From 7c4bc7dd746a39a48c3ea94dd5acc798c54972ae Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 9 Nov 2021 19:01:23 +0000 Subject: [PATCH 1/3] Don't skip adding stub home task if applyLoadPlan hasn't run - In FallbackRecentsTest.goToOverviewFromHome, home task gesture starts before applyLoadPlan, causing shouldAddStubTaskView to return false because getTaskViewCount is 0. This falsely avoid home task to be added to RecentsView, causing the animation to be drastically different from what user sees outside the test - Added a check on whether applyLoadPlan is ever called to solve the problem Fix: 205580523 Test: FallbackRecentsTest.goToOverviewFromHome Change-Id: I2e435e56008e916e8f7e1037d3fa3c8177437d13 --- .../com/android/quickstep/fallback/FallbackRecentsView.java | 3 ++- quickstep/src/com/android/quickstep/views/RecentsView.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index 48315d0c8f..15a5c3efe2 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -145,9 +145,10 @@ public class FallbackRecentsView extends RecentsView Date: Wed, 3 Nov 2021 23:16:53 -0700 Subject: [PATCH 2/3] Fix wrong getIconBounds method inside BubbleTextView Bug: 205065809 Test: screenshot on the bug TL;DR;; created two variants depending on the layout direction Change-Id: I9c5e74409c701b1f219ca450de0dca2291507045 --- src/com/android/launcher3/BubbleTextView.java | 34 +++++++++++++------ src/com/android/launcher3/Utilities.java | 12 +++++++ .../android/launcher3/folder/FolderIcon.java | 5 ++- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 35c257f53e..1f1d57adc9 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -141,6 +141,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private final CheckLongPressHelper mLongPressHelper; private final boolean mLayoutHorizontal; + private final boolean mIsRtl; private final int mIconSize; @ViewDebug.ExportedProperty(category = "launcher") @@ -185,6 +186,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BubbleTextView, defStyle, 0); mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false); + mIsRtl = (getResources().getConfiguration().getLayoutDirection() + == View.LAYOUT_DIRECTION_RTL); DeviceProfile grid = mActivity.getDeviceProfile(); mDisplay = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE); @@ -581,19 +584,29 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, return mDotInfo != null; } + /** + * Get the icon bounds on the view depending on the layout type. + */ public void getIconBounds(Rect outBounds) { - getIconBounds(this, outBounds, mIconSize); + getIconBounds(mIconSize, outBounds); } - public static void getIconBounds(View iconView, Rect outBounds, int iconSize) { - int top = iconView.getPaddingTop(); - int left = (iconView.getWidth() - iconSize) / 2; - int right = left + iconSize; - int bottom = top + iconSize; - outBounds.set(left, top, right, bottom); + /** + * Get the icon bounds on the view depending on the layout type. + */ + public void getIconBounds(int iconSize, Rect outBounds) { + Utilities.setRectToViewCenter(this, iconSize, outBounds); + if (mLayoutHorizontal) { + if (mIsRtl) { + outBounds.offsetTo(getWidth() - iconSize - getPaddingRight(), outBounds.top); + } else { + outBounds.offsetTo(getPaddingLeft(), outBounds.top); + } + } else { + outBounds.offsetTo(outBounds.left, getPaddingTop()); + } } - /** * Sets whether to vertically center the content. */ @@ -980,8 +993,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, @Override public void getWorkspaceVisualDragBounds(Rect bounds) { - DeviceProfile grid = mActivity.getDeviceProfile(); - BubbleTextView.getIconBounds(this, bounds, grid.iconSizePx); + getIconBounds(mIconSize, bounds); } private int getIconSizeForDisplay(int display) { @@ -998,7 +1010,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } public void getSourceVisualDragBounds(Rect bounds) { - BubbleTextView.getIconBounds(this, bounds, getIconSizeForDisplay(mDisplay)); + getIconBounds(mIconSize, bounds); } @Override diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 7a38fe736a..d2fe483c96 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -526,6 +526,18 @@ public final class Utilities { return defaultValue; } + /** + * Using the view's bounds and icon size, calculate where the icon bounds will + * be if it was positioned at the center of the view. + */ + public static void setRectToViewCenter(View iconView, int iconSize, Rect outBounds) { + int top = (iconView.getHeight() - iconSize) / 2; + int left = (iconView.getWidth() - iconSize) / 2; + int right = left + iconSize; + int bottom = top + iconSize; + outBounds.set(left, top, right, bottom); + } + /** * Ensures that a value is within given bounds. Specifically: * If value is less than lowerBound, return lowerBound; else if value is greater than upperBound, diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 439df80284..98be72a6b9 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -628,7 +628,10 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel public void drawDot(Canvas canvas) { if (!mForceHideDot && ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0)) { Rect iconBounds = mDotParams.iconBounds; - BubbleTextView.getIconBounds(this, iconBounds, mActivity.getDeviceProfile().iconSizePx); + + Utilities.setRectToViewCenter(this, mActivity.getDeviceProfile().iconSizePx, + iconBounds); + iconBounds.offsetTo(iconBounds.left, getPaddingTop()); float iconScale = (float) mBackground.previewSize / iconBounds.width(); Utilities.scaleRectAboutCenter(iconBounds, iconScale); From 8568602aafa202c8c8931dfec79af496d5153ce2 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 9 Nov 2021 17:02:31 -0800 Subject: [PATCH 3/3] Add back waitForStateTransitionToEnd to fix flakiness. Bug: 202735477 Test: presubmit Change-Id: I03c7e8b0c40177f4e6e38a7d9aa3e01b029effd6 --- .../com/android/launcher3/ui/AbstractLauncherUiTest.java | 8 ++++++++ tests/src/com/android/launcher3/ui/WorkProfileTest.java | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 314aee4285..44f2719a02 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -352,6 +352,14 @@ public abstract class AbstractLauncherUiTest { launcher -> launcher.getStateManager().getCurrentStableState() == state.get()); } + // Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call + // expecting the results of that gesture because the wait can hide flakeness. + protected void waitForStateTransitionToEnd(String message, Supplier state) { + waitForLauncherCondition(message, + launcher -> launcher.getStateManager().isInStableState(state.get()) + && !launcher.getStateManager().isInTransition()); + } + protected void waitForResumed(String message) { waitForLauncherCondition(message, launcher -> launcher.hasBeenResumed()); } diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java index 4bb6e91a09..45d20e2e4c 100644 --- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java +++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java @@ -62,10 +62,12 @@ public class WorkProfileTest extends AbstractLauncherUiTest { mDevice.pressHome(); waitForLauncherCondition("Launcher didn't start", Objects::nonNull); - waitForState("Launcher internal state didn't switch to Normal", () -> NORMAL); + waitForStateTransitionToEnd("Launcher internal state didn't switch to Normal", + () -> NORMAL); waitForResumed("Launcher internal state is still Background"); executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS)); - waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS); + waitForStateTransitionToEnd("Launcher internal state didn't switch to All Apps", + () -> ALL_APPS); } @After