Merge "Temporary hacks to make tests pass on Taimen" into ub-launcher3-qt-dev
diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
index 960d907..20fdff2 100644
--- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
+++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
@@ -44,7 +44,6 @@
import com.android.launcher3.testcomponent.TestCommandReceiver;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
@@ -98,7 +97,6 @@
@NavigationModeSwitch(mode = THREE_BUTTON)
@Test
- @Ignore // b/131630813
public void goToOverviewFromHome() {
mDevice.pressHome();
assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg(
@@ -109,7 +107,6 @@
@NavigationModeSwitch(mode = THREE_BUTTON)
@Test
- @Ignore // b/131630813
public void goToOverviewFromApp() {
startAppFast("com.android.settings");
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index 93e403c..e552f56 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -71,8 +71,7 @@
@Override
public Statement apply(Statement base, Description description) {
- // b/130558787; b/131419978
- if (false && TestHelpers.isInLauncherProcess() &&
+ if (TestHelpers.isInLauncherProcess() &&
description.getAnnotation(NavigationModeSwitch.class) != null) {
Mode mode = description.getAnnotation(NavigationModeSwitch.class).mode();
return new Statement() {
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 26364be..35b967f 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -167,7 +167,7 @@
public static float getDescendantCoordRelativeToAncestor(
View descendant, View ancestor, float[] coord, boolean includeRootScroll) {
return getDescendantCoordRelativeToAncestor(descendant, ancestor, coord, includeRootScroll,
- false);
+ false, null);
}
/**
@@ -180,12 +180,15 @@
* @param includeRootScroll Whether or not to account for the scroll of the descendant:
* sometimes this is relevant as in a child's coordinates within the descendant.
* @param ignoreTransform If true, view transform is ignored
+ * @param outRotation If not null, and {@param ignoreTransform} is true, this is set to the
+ * overall rotation of the view in degrees.
* @return The factor by which this descendant is scaled relative to this DragLayer. Caution
* this scale factor is assumed to be equal in X and Y, and so if at any point this
* assumption fails, we will need to return a pair of scale factors.
*/
public static float getDescendantCoordRelativeToAncestor(View descendant, View ancestor,
- float[] coord, boolean includeRootScroll, boolean ignoreTransform) {
+ float[] coord, boolean includeRootScroll, boolean ignoreTransform,
+ float[] outRotation) {
float scale = 1.0f;
View v = descendant;
while(v != ancestor && v != null) {
@@ -201,6 +204,10 @@
if (m.isTransposed) {
sMatrix.setRotate(m.surfaceRotation, v.getPivotX(), v.getPivotY());
sMatrix.mapPoints(coord);
+
+ if (outRotation != null) {
+ outRotation[0] += m.surfaceRotation;
+ }
}
}
} else {
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 24a8be5..020e380 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -15,8 +15,6 @@
*/
package com.android.launcher3.views;
-import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
-import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.Utilities.mapToRange;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
@@ -86,6 +84,7 @@
private @Nullable Drawable mForeground;
private @Nullable Drawable mBackground;
+ private float mRotation;
private ValueAnimator mRevealAnimator;
private final Rect mStartRevealRect = new Rect();
private final Rect mEndRevealRect = new Rect();
@@ -190,7 +189,7 @@
* @param positionOut Rect that will hold the size and position of v.
*/
private void matchPositionOf(Launcher launcher, View v, RectF positionOut) {
- getLocationBoundsForView(launcher, v, positionOut);
+ mRotation = getLocationBoundsForView(launcher, v, positionOut);
final LayoutParams lp = new LayoutParams(
Math.round(positionOut.width()),
Math.round(positionOut.height()));
@@ -207,54 +206,43 @@
}
/**
- * Returns the location bounds of a view.
+ * Gets the location bounds of a view and returns the overall rotation.
* - For DeepShortcutView, we return the bounds of the icon view.
* - For BubbleTextView, we return the icon bounds.
*/
- private void getLocationBoundsForView(Launcher launcher, View v, RectF outRect) {
- final boolean isBubbleTextView = v instanceof BubbleTextView;
- final boolean isFolderIcon = v instanceof FolderIcon;
-
- // Deep shortcut views have their icon drawn in a separate view.
- final boolean fromDeepShortcutView = v.getParent() instanceof DeepShortcutView;
-
- final View targetView;
- boolean ignoreTransform = false;
-
+ private float getLocationBoundsForView(Launcher launcher, View v, RectF outRect) {
+ boolean ignoreTransform = true;
if (v instanceof DeepShortcutView) {
- targetView = ((DeepShortcutView) v).getIconView();
- } else if (fromDeepShortcutView) {
- DeepShortcutView view = (DeepShortcutView) v.getParent();
- targetView = view.getIconView();
- } else if ((isBubbleTextView || isFolderIcon) && v.getTag() instanceof ItemInfo
- && (((ItemInfo) v.getTag()).container == CONTAINER_DESKTOP
- || ((ItemInfo) v.getTag()).container == CONTAINER_HOTSEAT)) {
- targetView = v;
- ignoreTransform = true;
- } else {
- targetView = v;
+ v = ((DeepShortcutView) v).getBubbleText();
+ ignoreTransform = false;
+ } else if (v.getParent() instanceof DeepShortcutView) {
+ v = ((DeepShortcutView) v.getParent()).getIconView();
+ ignoreTransform = false;
+ }
+ if (v == null) {
+ return 0;
}
- float[] points = new float[] {0, 0, targetView.getWidth(), targetView.getHeight()};
- Utilities.getDescendantCoordRelativeToAncestor(targetView, launcher.getDragLayer(), points,
- false, ignoreTransform);
-
- float viewLocationLeft = Math.min(points[0], points[2]);
- float viewLocationTop = Math.min(points[1], points[3]);
-
- final Rect iconRect = new Rect();
- if (isBubbleTextView && !fromDeepShortcutView) {
- ((BubbleTextView) v).getIconBounds(iconRect);
- } else if (isFolderIcon) {
- ((FolderIcon) v).getPreviewBounds(iconRect);
+ Rect iconBounds = new Rect();
+ if (v instanceof BubbleTextView) {
+ ((BubbleTextView) v).getIconBounds(iconBounds);
+ } else if (v instanceof FolderIcon) {
+ ((FolderIcon) v).getPreviewBounds(iconBounds);
} else {
- iconRect.set(0, 0, Math.abs(Math.round(points[2] - points[0])),
- Math.abs(Math.round(points[3] - points[1])));
+ iconBounds.set(0, 0, v.getWidth(), v.getHeight());
}
- viewLocationLeft += iconRect.left;
- viewLocationTop += iconRect.top;
- outRect.set(viewLocationLeft, viewLocationTop, viewLocationLeft + iconRect.width(),
- viewLocationTop + iconRect.height());
+
+ float[] points = new float[] {iconBounds.left, iconBounds.top, iconBounds.right,
+ iconBounds.bottom};
+ float[] rotation = new float[] {0};
+ Utilities.getDescendantCoordRelativeToAncestor(v, launcher.getDragLayer(), points,
+ false, ignoreTransform, rotation);
+ outRect.set(
+ Math.min(points[0], points[2]),
+ Math.min(points[1], points[3]),
+ Math.max(points[0], points[2]),
+ Math.max(points[1], points[3]));
+ return rotation[0];
}
@WorkerThread
@@ -425,27 +413,22 @@
invalidate();
}
- private void drawAdaptiveIconIfExists(Canvas canvas) {
+ @Override
+ public void draw(Canvas canvas) {
+ int count = canvas.save();
+ canvas.rotate(mRotation,
+ mFinalDrawableBounds.exactCenterX(), mFinalDrawableBounds.exactCenterY());
+ if (mClipPath != null) {
+ canvas.clipPath(mClipPath);
+ }
+ super.draw(canvas);
if (mBackground != null) {
mBackground.draw(canvas);
}
if (mForeground != null) {
mForeground.draw(canvas);
}
- }
-
- @Override
- public void draw(Canvas canvas) {
- if (mClipPath == null) {
- super.draw(canvas);
- drawAdaptiveIconIfExists(canvas);
- } else {
- int count = canvas.save();
- canvas.clipPath(mClipPath);
- super.draw(canvas);
- drawAdaptiveIconIfExists(canvas);
- canvas.restoreToCount(count);
- }
+ canvas.restoreToCount(count);
}
public void onListenerViewClosed() {
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 43bdb9f..75db2f1 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -18,9 +18,6 @@
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
-import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY;
-import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY;
-import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -35,7 +32,6 @@
import android.content.IntentFilter;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageManager;
-import android.os.Build;
import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
@@ -64,7 +60,6 @@
import com.android.launcher3.util.rule.ShellCommandRule;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestRule;
@@ -75,7 +70,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -111,68 +105,6 @@
}
if (TestHelpers.isInLauncherProcess()) Utilities.enableRunningInTestHarnessForTests();
mLauncher = new LauncherInstrumentation(instrumentation);
-
- // b/130558787; b/131419978
- if (TestHelpers.isInLauncherProcess() && !LauncherInstrumentation.needSlowGestures()) {
- try {
- Class systemProps = Class.forName("android.os.SystemProperties");
- Method getInt = systemProps.getMethod("getInt", String.class, int.class);
- int apiLevel = (int) getInt.invoke(null, "ro.product.first_api_level", 0);
-
- if (apiLevel >= Build.VERSION_CODES.P) {
- setActiveOverlay(NAV_BAR_MODE_2BUTTON_OVERLAY,
- LauncherInstrumentation.NavigationModel.TWO_BUTTON);
- }
- if (apiLevel >= Build.VERSION_CODES.O && apiLevel < Build.VERSION_CODES.P) {
- setActiveOverlay(NAV_BAR_MODE_GESTURAL_OVERLAY,
- LauncherInstrumentation.NavigationModel.ZERO_BUTTON);
- }
- if (apiLevel < Build.VERSION_CODES.O) {
- setActiveOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY,
- LauncherInstrumentation.NavigationModel.THREE_BUTTON);
- }
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
- public void setActiveOverlay(String overlayPackage,
- LauncherInstrumentation.NavigationModel expectedMode) {
- setOverlayPackageEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY,
- overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY);
- setOverlayPackageEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY,
- overlayPackage == NAV_BAR_MODE_2BUTTON_OVERLAY);
- setOverlayPackageEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY,
- overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY);
-
- for (int i = 0; i != 100; ++i) {
- if (mLauncher.getNavigationModel() == expectedMode) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return;
- }
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- Assert.fail("Couldn't switch to " + overlayPackage);
- }
-
- private void setOverlayPackageEnabled(String overlayPackage, boolean enable) {
- Log.d(TAG, "setOverlayPackageEnabled: " + overlayPackage + " " + enable);
- final String action = enable ? "enable" : "disable";
- try {
- UiDevice.getInstance(getInstrumentation()).executeShellCommand(
- "cmd overlay " + action + " " + overlayPackage);
- } catch (IOException e) {
- e.printStackTrace();
- }
}
@Rule