Merge "Close system windows when triggering alt-tab" into ub-launcher3-master
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
index 2f73fc1..8ae4f06 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
@@ -2,6 +2,7 @@
import android.view.MotionEvent;
+import com.android.launcher3.testing.TestLogging;
import com.android.quickstep.InputConsumer;
import com.android.systemui.shared.system.InputMonitorCompat;
@@ -34,6 +35,7 @@
protected void setActive(MotionEvent ev) {
mState = STATE_ACTIVE;
+ TestLogging.recordEvent("pilferPointers");
mInputMonitor.pilferPointers();
// Send cancel event
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
index 5a34520..d01e1a4 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
@@ -37,6 +37,7 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.util.DefaultDisplay;
import com.android.quickstep.GestureState;
import com.android.quickstep.InputConsumer;
@@ -202,6 +203,7 @@
private void startRecentsTransition() {
mThresholdCrossed = true;
+ TestLogging.recordEvent("pilferPointers");
mInputMonitorCompat.pilferPointers();
Intent intent = new Intent(Intent.ACTION_MAIN)
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index bf2128d..1b0e05a 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -44,6 +44,7 @@
import androidx.annotation.UiThread;
import com.android.launcher3.R;
+import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.BaseActivityInterface;
@@ -302,6 +303,7 @@
if (mInteractionHandler == null) {
return;
}
+ TestLogging.recordEvent("pilferPointers");
mInputMonitorCompat.pilferPointers();
mActivityInterface.closeOverlay();
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
index c19754f..32a67ca 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
@@ -25,6 +25,7 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.Utilities;
+import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.GestureState;
@@ -106,6 +107,7 @@
ActiveGestureLog.INSTANCE.addLog("startQuickstep");
}
if (mInputMonitor != null) {
+ TestLogging.recordEvent("pilferPointers");
mInputMonitor.pilferPointers();
}
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java
index ca15ca1..6bfc3fd 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java
@@ -22,6 +22,7 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.logging.StatsLogUtils;
+import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.quickstep.GestureState;
@@ -63,6 +64,7 @@
private void onInterceptTouch() {
if (mInputMonitor != null) {
+ TestLogging.recordEvent("pilferPointers");
mInputMonitor.pilferPointers();
}
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
index 3bc1509..49f667e 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -20,7 +20,6 @@
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN;
import android.content.Context;
-import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
@@ -38,11 +37,11 @@
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Property;
+import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import com.android.launcher3.BaseActivity;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
@@ -102,7 +101,7 @@
private float mSaturation = 1f;
private boolean mOverlayEnabled;
- private boolean mRotated;
+ private boolean mIsOrientationChanged;
private OverviewScreenshotActions mOverviewScreenshotActionsPlugin;
public TaskThumbnailView(Context context) {
@@ -323,7 +322,7 @@
private void updateOverlay() {
// The overlay doesn't really work when the screenshot is rotated, so don't add it.
- if (mOverlayEnabled && !mRotated && mBitmapShader != null && mThumbnailData != null) {
+ if (mOverlayEnabled && !mIsOrientationChanged && mBitmapShader != null && mThumbnailData != null) {
mOverlay.initOverlay(mTask, mThumbnailData, mMatrix);
} else {
mOverlay.reset();
@@ -346,6 +345,7 @@
private void updateThumbnailMatrix() {
boolean isRotated = false;
+ boolean isOrientationDifferent = false;
mClipBottom = -1;
if (mBitmapShader != null && mThumbnailData != null) {
float scale = mThumbnailData.scale;
@@ -356,51 +356,40 @@
(thumbnailInsets.top + thumbnailInsets.bottom) * scale;
final float thumbnailScale;
- final DeviceProfile profile = mActivity.getDeviceProfile();
-
+ int thumbnailRotation = mThumbnailData.rotation;
+ int currentRotation = getDisplay() != null ? getDisplay().getRotation() : 0;
+ int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
+ // Landscape vs portrait change
+ boolean windowingModeSupportsRotation = !mActivity.isInMultiWindowMode()
+ && mThumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
+ isOrientationDifferent = isOrientationChange(deltaRotate)
+ && windowingModeSupportsRotation;
if (getMeasuredWidth() == 0) {
// If we haven't measured , skip the thumbnail drawing and only draw the background
// color
thumbnailScale = 0f;
} else {
- final Configuration configuration =
- getContext().getResources().getConfiguration();
// Rotate the screenshot if not in multi-window mode
- isRotated = configuration.orientation != mThumbnailData.orientation &&
- !mActivity.isInMultiWindowMode() &&
- mThumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
+ isRotated = deltaRotate > 0 && windowingModeSupportsRotation;
// Scale the screenshot to always fit the width of the card.
- thumbnailScale = isRotated
+
+ thumbnailScale = isOrientationDifferent
? getMeasuredWidth() / thumbnailHeight
: getMeasuredWidth() / thumbnailWidth;
}
- if (isRotated) {
- int rotationDir = profile.isVerticalBarLayout() && !profile.isSeascape() ? -1 : 1;
- mMatrix.setRotate(90 * rotationDir);
- int newLeftInset = rotationDir == 1 ? thumbnailInsets.bottom : thumbnailInsets.top;
- int newTopInset = rotationDir == 1 ? thumbnailInsets.left : thumbnailInsets.right;
- mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
- if (rotationDir == -1) {
- // Crop the right/bottom side of the screenshot rather than left/top
- float excessHeight = thumbnailWidth * thumbnailScale - getMeasuredHeight();
- mClippedInsets.offset(0, excessHeight);
- }
- mMatrix.postTranslate(-mClippedInsets.left, -mClippedInsets.top);
- // Move the screenshot to the thumbnail window (rotation moved it out).
- if (rotationDir == 1) {
- mMatrix.postTranslate(mThumbnailData.thumbnail.getHeight(), 0);
- } else {
- mMatrix.postTranslate(0, mThumbnailData.thumbnail.getWidth());
- }
- } else {
- mClippedInsets.offsetTo(thumbnailInsets.left * scale, thumbnailInsets.top * scale);
+ if (!isRotated) {
+ // No Rotation
+ mClippedInsets.offsetTo(thumbnailInsets.left * scale,
+ thumbnailInsets.top * scale);
mMatrix.setTranslate(-mClippedInsets.left, -mClippedInsets.top);
+ } else {
+ setThumbnailRotation(deltaRotate, thumbnailInsets, scale);
}
final float widthWithInsets;
final float heightWithInsets;
- if (isRotated) {
+ if (isOrientationDifferent) {
widthWithInsets = mThumbnailData.thumbnail.getHeight() * thumbnailScale;
heightWithInsets = mThumbnailData.thumbnail.getWidth() * thumbnailScale;
} else {
@@ -415,7 +404,7 @@
mMatrix.postScale(thumbnailScale, thumbnailScale);
mBitmapShader.setLocalMatrix(mMatrix);
- float bitmapHeight = Math.max((isRotated ? thumbnailWidth : thumbnailHeight)
+ float bitmapHeight = Math.max((isOrientationDifferent ? thumbnailWidth : thumbnailHeight)
* thumbnailScale, 0);
if (Math.round(bitmapHeight) < getMeasuredHeight()) {
mClipBottom = bitmapHeight;
@@ -423,7 +412,7 @@
mPaint.setShader(mBitmapShader);
}
- mRotated = isRotated;
+ mIsOrientationChanged = isOrientationDifferent;
invalidate();
// Update can be called from {@link #onSizeChanged} during layout, post handling of overlay
@@ -431,6 +420,51 @@
post(this::updateOverlay);
}
+ private int getRotationDelta(int oldRotation, int newRotation) {
+ int delta = newRotation - oldRotation;
+ if (delta < 0) delta += 4;
+ return delta;
+ }
+
+ /**
+ * @param deltaRotation the number of 90 degree turns from the current orientation
+ * @return {@code true} if the change in rotation results in a shift from landscape to portrait
+ * or vice versa, {@code false} otherwise
+ */
+ private boolean isOrientationChange(int deltaRotation) {
+ return deltaRotation == Surface.ROTATION_90 || deltaRotation == Surface.ROTATION_270;
+ }
+
+ private void setThumbnailRotation(int deltaRotate, Rect thumbnailInsets, float scale) {
+ int newLeftInset = 0;
+ int newTopInset = 0;
+ int translateX = 0;
+ int translateY = 0;
+
+ mMatrix.setRotate(90 * deltaRotate);
+ switch (deltaRotate) { /* Counter-clockwise */
+ case Surface.ROTATION_90:
+ newLeftInset = thumbnailInsets.bottom;
+ newTopInset = thumbnailInsets.left;
+ translateX = mThumbnailData.thumbnail.getHeight();
+ break;
+ case Surface.ROTATION_270:
+ newLeftInset = thumbnailInsets.top;
+ newTopInset = thumbnailInsets.right;
+ translateY = mThumbnailData.thumbnail.getWidth();
+ break;
+ case Surface.ROTATION_180:
+ newLeftInset = -thumbnailInsets.top;
+ newTopInset = -thumbnailInsets.left;
+ translateX = mThumbnailData.thumbnail.getWidth();
+ translateY = mThumbnailData.thumbnail.getHeight();
+ break;
+ }
+ mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
+ mMatrix.postTranslate(translateX - mClippedInsets.left,
+ translateY - mClippedInsets.top);
+ }
+
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
index 58e36bc..5954b86 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
@@ -243,6 +243,7 @@
getResources().getDimensionPixelSize(R.dimen.overview_actions_height),
Gravity.BOTTOM);
addView(mActionsView, params);
+ mActionsView.setAlpha(0);
}
}
}
@@ -447,7 +448,8 @@
mIconView.setScaleX(scale);
mIconView.setScaleY(scale);
- if (mActionsView != null) {
+
+ if (mActionsView != null && isRunningTask()) {
mActionsView.setAlpha(scale);
}
@@ -523,9 +525,11 @@
public void onPageScroll(ScrollState scrollState) {
float curveInterpolation =
CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation);
+ float curveScaleForCurveInterpolation = getCurveScaleForCurveInterpolation(
+ curveInterpolation);
mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
- setCurveScale(getCurveScaleForCurveInterpolation(curveInterpolation));
+ setCurveScale(curveScaleForCurveInterpolation);
mFooterAlpha = Utilities.boundToRange(1.0f - 2 * scrollState.linearInterpolation, 0f, 1f);
for (FooterWrapper footer : mFooters) {
@@ -539,6 +543,28 @@
mMenuView.setScaleX(getScaleX());
mMenuView.setScaleY(getScaleY());
}
+
+ // This is not the proper implementation and will be replaced with a proper layout.
+ if (mActionsView != null) {
+ if (mFocusTransitionProgress == 1f) {
+ mActionsView.setAlpha(1 - curveInterpolation / MAX_PAGE_SCRIM_ALPHA);
+ }
+ maintainActionViewPosition(curveScaleForCurveInterpolation);
+ }
+
+ }
+
+ private void maintainActionViewPosition(float curveScaleForCurveInterpolation) {
+ float inverseCurveScaleFactor = curveScaleForCurveInterpolation == 0 ? 0 :
+ (1f / curveScaleForCurveInterpolation);
+ mActionsView.setScaleX(inverseCurveScaleFactor);
+ mActionsView.setScaleY(inverseCurveScaleFactor);
+ mActionsView.setTranslationX(inverseCurveScaleFactor * (-getX()
+ + getRecentsView().getScrollX() + getRecentsView().scrollOffsetLeft()));
+ mActionsView.setTranslationY(
+ (1f - curveScaleForCurveInterpolation) * (mSnapshotView.getHeight()
+ + mActionsView.getHeight()) / 2f
+ + inverseCurveScaleFactor * (-getTranslationY()));
}
diff --git a/res/values/config.xml b/res/values/config.xml
index 0945642..ef34dcd 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -108,6 +108,7 @@
<item type="id" name="action_shortcuts_and_notifications"/>
<item type="id" name="action_dismiss_notification" />
<item type="id" name="action_remote_action_shortcut" />
+ <item type="id" name="action_dismiss_prediction" />
<!-- QSB IDs. DO not change -->
<item type="id" name="search_container_workspace" />
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index 3f723d1..c99465c 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -214,4 +214,11 @@
return id;
}
+ /**
+ * Returns if an Item is a predicted item
+ */
+ public boolean isPredictedItem() {
+ return container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION
+ || container == LauncherSettings.Favorites.CONTAINER_PREDICTION;
+ }
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index db2daee..43540ce 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -32,7 +32,6 @@
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.logging.LoggerUtils.newTarget;
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
-import static com.android.launcher3.popup.SystemShortcut.DISMISS_PREDICTION;
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
import static com.android.launcher3.popup.SystemShortcut.WIDGETS;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
@@ -2695,7 +2694,7 @@
}
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
- return Stream.of(APP_INFO, WIDGETS, INSTALL, DISMISS_PREDICTION);
+ return Stream.of(APP_INFO, WIDGETS, INSTALL);
}
public static Launcher getLauncher(Context context) {
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index a1888bf..ae4eae9 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -245,6 +245,13 @@
forceFinishScroller(true);
}
+ /**
+ * Returns left offset of a page. This is the gap between pages and prevents overlap.
+ */
+ public int scrollOffsetLeft() {
+ return mInsets.left + getPaddingLeft();
+ }
+
private void abortScrollerAnimation(boolean resetNextPage) {
mScroller.abortAnimation();
// We need to clean up the next page here to avoid computeScrollHelper from
diff --git a/src/com/android/launcher3/SecondaryDropTarget.java b/src/com/android/launcher3/SecondaryDropTarget.java
index 3c2ed72..1dbe195 100644
--- a/src/com/android/launcher3/SecondaryDropTarget.java
+++ b/src/com/android/launcher3/SecondaryDropTarget.java
@@ -6,6 +6,7 @@
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_MASK;
import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
+import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DISMISS_PREDICTION;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE;
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL;
@@ -29,9 +30,11 @@
import android.widget.Toast;
import com.android.launcher3.Launcher.OnResumeCallback;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.logging.LoggerUtils;
+import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.PackageManagerHelper;
@@ -43,6 +46,7 @@
* Drop target which provides a secondary option for an item.
* For app targets: shows as uninstall
* For configurable widgets: shows as setup
+ * For predicted app icons: don't suggest app
*/
public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmListener {
@@ -81,7 +85,11 @@
mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint);
setDrawable(R.drawable.ic_uninstall_shadow);
updateText(R.string.uninstall_drop_target_label);
- } else {
+ } else if (action == DISMISS_PREDICTION) {
+ mHoverColor = Themes.getColorAccent(getContext());
+ setDrawable(R.drawable.ic_block);
+ updateText(R.string.dismiss_prediction_label);
+ } else if (action == RECONFIGURE) {
mHoverColor = Themes.getColorAccent(getContext());
setDrawable(R.drawable.ic_setup_shadow);
updateText(R.string.gadget_setup_text);
@@ -101,8 +109,13 @@
@Override
public Target getDropTargetForLogging() {
Target t = LoggerUtils.newTarget(Target.Type.CONTROL);
- t.controlType = mCurrentAccessibilityAction == UNINSTALL ? ControlType.UNINSTALL_TARGET
- : ControlType.SETTINGS_BUTTON;
+ if (mCurrentAccessibilityAction == UNINSTALL) {
+ t.controlType = ControlType.UNINSTALL_TARGET;
+ } else if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
+ t.controlType = ControlType.DISMISS_PREDICTION;
+ } else {
+ t.controlType = ControlType.SETTINGS_BUTTON;
+ }
return t;
}
@@ -119,6 +132,9 @@
return true;
}
return false;
+ } else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
+ setupUi(DISMISS_PREDICTION);
+ return true;
}
setupUi(UNINSTALL);
@@ -229,6 +245,11 @@
}
return null;
}
+ if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
+ AppLaunchTracker.INSTANCE.get(getContext()).onDismissApp(info.getTargetComponent(),
+ info.user, AppLaunchTracker.CONTAINER_PREDICTIONS);
+ return null;
+ }
// else: mCurrentAccessibilityAction == UNINSTALL
ComponentName cn = getUninstallTarget(info);
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index ed869bb..0b439ec 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -54,6 +54,7 @@
public static final int REMOVE = R.id.action_remove;
public static final int UNINSTALL = R.id.action_uninstall;
+ public static final int DISMISS_PREDICTION = R.id.action_dismiss_prediction;
public static final int RECONFIGURE = R.id.action_reconfigure;
protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace;
protected static final int MOVE = R.id.action_move;
@@ -86,6 +87,8 @@
launcher.getText(R.string.remove_drop_target_label)));
mActions.put(UNINSTALL, new AccessibilityAction(UNINSTALL,
launcher.getText(R.string.uninstall_drop_target_label)));
+ mActions.put(DISMISS_PREDICTION, new AccessibilityAction(DISMISS_PREDICTION,
+ launcher.getText(R.string.dismiss_prediction_label)));
mActions.put(RECONFIGURE, new AccessibilityAction(RECONFIGURE,
launcher.getText(R.string.gadget_setup_text)));
mActions.put(ADD_TO_WORKSPACE, new AccessibilityAction(ADD_TO_WORKSPACE,
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index b152954..21c5ac5 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -16,14 +16,10 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.WorkspaceItemInfo;
-import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
-import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.PackageManagerHelper;
@@ -176,33 +172,6 @@
}
}
- public static final Factory<Launcher> DISMISS_PREDICTION = (launcher, itemInfo) -> {
- if (!FeatureFlags.ENABLE_PREDICTION_DISMISS.get()) return null;
- if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_PREDICTION
- && itemInfo.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
- return null;
- }
- return new DismissPrediction(launcher, itemInfo);
- };
-
- public static class DismissPrediction extends SystemShortcut<Launcher> {
- public DismissPrediction(Launcher launcher, ItemInfo itemInfo) {
- super(R.drawable.ic_block, R.string.dismiss_prediction_label, launcher,
- itemInfo);
- }
-
- @Override
- public void onClick(View view) {
- PopupContainerWithArrow.closeAllOpenViews(mTarget);
- mTarget.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
- ControlType.DISMISS_PREDICTION, ContainerType.DEEPSHORTCUTS);
- AppLaunchTracker.INSTANCE.get(view.getContext()).onDismissApp(
- mItemInfo.getTargetComponent(),
- mItemInfo.user,
- AppLaunchTracker.CONTAINER_PREDICTIONS);
- }
- }
-
public static void dismissTaskMenuView(BaseDraggingActivity activity) {
AbstractFloatingView.closeOpenViews(activity, true,
AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
index de9757f..9b9b2d6 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
@@ -41,6 +41,7 @@
import com.android.launcher3.util.rule.ShellCommandRule;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -76,6 +77,7 @@
@Test
@PortraitLandscape
+ @Ignore // b/148867106
public void testConfigCancelled() throws Throwable {
runTest(false);
}
diff --git a/tests/src/com/android/launcher3/util/rule/FailureWatcher.java b/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
index 7763cc2..02d07bb 100644
--- a/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
+++ b/tests/src/com/android/launcher3/util/rule/FailureWatcher.java
@@ -78,10 +78,14 @@
try {
base.evaluate();
} catch (Throwable e) {
- if (!Log.getStackTraceString(e).contains(
+ final String stackTrace = Log.getStackTraceString(e);
+ if (!stackTrace.contains(
"androidx.test.internal.runner.junit4.statement.RunBefores.evaluate")) {
// Test failed to deinitialize. Since the global state is probably
// corrupted, won't execute other tests.
+ Log.d(TAG,
+ "Detected an exception from test finalizer, will skip further "
+ + "tests: " + stackTrace);
sHadFailedTestDeinitialization = true;
}
throw e;
diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
index 1feb4e7..61f5e05 100644
--- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
+++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
@@ -73,8 +73,7 @@
return new Statement() {
@Override
public void evaluate() throws Throwable {
- if (sRunFlavor == 0) sRunFlavor = getRunFlavor();
- if ((stability.flavors() & sRunFlavor) != 0) {
+ if ((stability.flavors() & getRunFlavor()) != 0) {
Log.d(TAG, "Running " + description.getDisplayName());
base.evaluate();
} else {
@@ -87,7 +86,9 @@
}
}
- private static int getRunFlavor() {
+ public static int getRunFlavor() {
+ if (sRunFlavor != 0) return sRunFlavor;
+
final String flavorOverride = InstrumentationRegistry.getArguments().getString("flavor");
if (flavorOverride != null) {
@@ -130,34 +131,32 @@
throw new AssertionError("Platform build match not found");
}
- final int runFlavor;
-
if (launcherBuildMatcher.group("local") != null && (
platformBuildMatcher.group("commandLine") != null ||
platformBuildMatcher.group("postsubmit") != null)) {
Log.d(TAG, "LOCAL RUN");
- runFlavor = LOCAL;
+ sRunFlavor = LOCAL;
} else if (launcherBuildMatcher.group("presubmit") != null
&& platformBuildMatcher.group("postsubmit") != null) {
Log.d(TAG, "UNBUNDLED PRESUBMIT");
- runFlavor = UNBUNDLED_PRESUBMIT;
+ sRunFlavor = UNBUNDLED_PRESUBMIT;
} else if (launcherBuildMatcher.group("postsubmit") != null
&& platformBuildMatcher.group("postsubmit") != null) {
Log.d(TAG, "UNBUNDLED POSTSUBMIT");
- runFlavor = UNBUNDLED_POSTSUBMIT;
+ sRunFlavor = UNBUNDLED_POSTSUBMIT;
} else if (launcherBuildMatcher.group("platform") != null
&& platformBuildMatcher.group("presubmit") != null) {
Log.d(TAG, "PLATFORM PRESUBMIT");
- runFlavor = PLATFORM_PRESUBMIT;
+ sRunFlavor = PLATFORM_PRESUBMIT;
} else if (launcherBuildMatcher.group("platform") != null
&& (platformBuildMatcher.group("postsubmit") != null
|| platformBuildMatcher.group("commandLine") != null)) {
Log.d(TAG, "PLATFORM POSTSUBMIT");
- runFlavor = PLATFORM_POSTSUBMIT;
+ sRunFlavor = PLATFORM_POSTSUBMIT;
} else {
throw new AssertionError("Unrecognized run flavor");
}
- return runFlavor;
+ return sRunFlavor;
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index cf5b24e..4089897 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -106,6 +106,7 @@
private static final Pattern EVENT_TOUCH_DOWN = getTouchEventPattern("ACTION_DOWN");
private static final Pattern EVENT_TOUCH_UP = getTouchEventPattern("ACTION_UP");
private static final Pattern EVENT_TOUCH_CANCEL = getTouchEventPattern("ACTION_CANCEL");
+ private static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
// Types for launcher containers that the user is interacting with. "Background" is a
// pseudo-container corresponding to inactive launcher covered by another app.
@@ -633,6 +634,15 @@
log(action = "clicking home button from " + getVisibleStateMessage());
try (LauncherInstrumentation.Closable c = addContextLayer(action)) {
mDevice.waitForIdle();
+
+ if (getNavigationModel() == NavigationModel.TWO_BUTTON) {
+ if (hasLauncherObject(CONTEXT_MENU_RES_ID) ||
+ hasLauncherObject(WIDGETS_RES_ID)
+ && !mDevice.isNaturalOrientation()) {
+ expectEvent(EVENT_PILFER_POINTERS);
+ }
+ }
+
runToState(
waitForSystemUiObject("home")::click,
NORMAL_STATE_ORDINAL,
@@ -1051,16 +1061,21 @@
void sendPointer(long downTime, long currentTime, int action, Point point,
GestureScope gestureScope) {
- if (gestureScope != GestureScope.OUTSIDE) {
- switch (action) {
- case MotionEvent.ACTION_DOWN:
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
+ if (gestureScope != GestureScope.OUTSIDE) {
expectEvent(EVENT_TOUCH_DOWN);
- break;
- case MotionEvent.ACTION_UP:
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ if (gestureScope != GestureScope.INSIDE) {
+ expectEvent(EVENT_PILFER_POINTERS);
+ }
+ if (gestureScope != GestureScope.OUTSIDE) {
expectEvent(gestureScope == GestureScope.INSIDE
? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL);
- break;
- }
+ }
+ break;
}
final MotionEvent event = getMotionEvent(downTime, currentTime, action, point.x, point.y);
@@ -1226,6 +1241,12 @@
}
Closable eventsCheck() {
+ if ("com.android.launcher3".equals(getLauncherPackageName())) {
+ // Not checking specific Launcher3 event sequences.
+ return () -> {
+ };
+ }
+
// Entering events check block.
startRecordingEvents();