Merge "Fix SDK check to use Utilities.ATLEAST_Q." into ub-launcher3-qt-dev
diff --git a/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java b/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java
index d189c50..bcb1f5c 100644
--- a/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java
+++ b/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java
@@ -1,16 +1,20 @@
package com.android.launcher3;
+import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.quickstep.views.IconRecentsView.CONTENT_ALPHA;
+import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
-import android.app.ActivityOptions;
import android.content.Context;
+import android.os.Handler;
import android.view.View;
import com.android.quickstep.views.IconRecentsView;
+import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
/**
@@ -29,6 +33,12 @@
}
@Override
+ RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) {
+ return new GoWallpaperOpenLauncherAnimationRunner(mHandler,
+ false /* startAtFrontOfQueue */, fromUnlock);
+ }
+
+ @Override
protected void composeRecentsLaunchAnimator(AnimatorSet anim, View v,
RemoteAnimationTargetCompat[] targets, boolean launcherClosing) {
// Stubbed. Recents launch animation will come from the recents view itself and will not
@@ -51,4 +61,34 @@
return mLauncher.getStateManager()::reapplyState;
}
+
+ /**
+ * Remote animation runner for animation from app to Launcher. For Go, when going to recents,
+ * we need to ensure that the recents view is ready for remote animation before starting.
+ */
+ private final class GoWallpaperOpenLauncherAnimationRunner extends
+ WallpaperOpenLauncherAnimationRunner {
+ public GoWallpaperOpenLauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue,
+ boolean fromUnlock) {
+ super(handler, startAtFrontOfQueue, fromUnlock);
+ }
+
+ @Override
+ public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
+ AnimationResult result) {
+ boolean isGoingToRecents =
+ taskIsATargetWithMode(targetCompats, mLauncher.getTaskId(), MODE_OPENING)
+ && (mLauncher.getStateManager().getState() == LauncherState.OVERVIEW);
+ if (isGoingToRecents) {
+ IconRecentsView recentsView = mLauncher.getOverviewPanel();
+ if (!recentsView.isReadyForRemoteAnim()) {
+ recentsView.setOnReadyForRemoteAnimCallback(() ->
+ postAsyncCallback(mHandler, () -> onCreateAnimation(targetCompats, result))
+ );
+ return;
+ }
+ }
+ super.onCreateAnimation(targetCompats, result);
+ }
+ }
}
diff --git a/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java b/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java
index 9282345..87ae695 100644
--- a/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java
+++ b/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java
@@ -250,7 +250,7 @@
}
mPendingAnims.remove(i);
}
- for (int i = 0; i < mRunningAnims.size(); i++) {
+ for (int i = mRunningAnims.size() - 1; i >= 0; i--) {
ObjectAnimator anim = mRunningAnims.get(i);
anim.end();
}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index 7225e57..07faa4b 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -379,6 +379,36 @@
}
/**
+ * Whether this view has processed all data changes and is ready to animate from the app to
+ * the overview.
+ *
+ * @return true if ready to animate app to overview, false otherwise
+ */
+ public boolean isReadyForRemoteAnim() {
+ return !mTaskRecyclerView.hasPendingAdapterUpdates();
+ }
+
+ /**
+ * Set a callback for whenever this view is ready to do a remote animation from the app to
+ * overview. See {@link #isReadyForRemoteAnim()}.
+ *
+ * @param callback callback to run when view is ready to animate
+ */
+ public void setOnReadyForRemoteAnimCallback(onReadyForRemoteAnimCallback callback) {
+ mTaskRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(
+ new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ if (isReadyForRemoteAnim()) {
+ callback.onReadyForRemoteAnim();
+ mTaskRecyclerView.getViewTreeObserver().
+ removeOnGlobalLayoutListener(this);
+ }
+ }
+ });
+ }
+
+ /**
* Clear all tasks and animate out.
*/
private void animateClearAllTasks() {
@@ -557,4 +587,12 @@
mTaskRecyclerView.setPadding(insets.left, insets.top, insets.right, insets.bottom);
mTaskRecyclerView.invalidateItemDecorations();
}
+
+ /**
+ * Callback for when this view is ready for a remote animation from app to overview.
+ */
+ public interface onReadyForRemoteAnimCallback {
+
+ void onReadyForRemoteAnim();
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
index 829e478..335e8b1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
@@ -21,9 +21,9 @@
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
-
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPLEFT;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPRIGHT;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.FLING;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.SWIPE;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.SWIPE_NOOP;
import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType.NAVBAR;
@@ -38,11 +38,11 @@
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
-
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.logging.UserEventDispatcher;
+import com.android.launcher3.touch.SwipeDetector;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.InputMonitorCompat;
import com.android.systemui.shared.system.QuickStepContract;
@@ -50,12 +50,15 @@
/**
* Touch consumer for handling events to launch assistant from launcher
*/
-public class AssistantTouchConsumer extends DelegateInputConsumer {
+public class AssistantTouchConsumer extends DelegateInputConsumer
+ implements SwipeDetector.Listener {
+
private static final String TAG = "AssistantTouchConsumer";
private static final long RETRACT_ANIMATION_DURATION_MS = 300;
private static final String INVOCATION_TYPE_KEY = "invocation_type";
private static final int INVOCATION_TYPE_GESTURE = 1;
+ private static final int INVOCATION_TYPE_FLING = 6;
private final PointF mDownPos = new PointF();
private final PointF mLastPos = new PointF();
@@ -77,6 +80,7 @@
private final float mSlop;
private final ISystemUiProxy mSysUiProxy;
private final Context mContext;
+ private final SwipeDetector mSwipeDetector;
public AssistantTouchConsumer(Context context, ISystemUiProxy systemUiProxy,
ActivityControlHelper activityControlHelper, InputConsumer delegate,
@@ -90,6 +94,8 @@
mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold);
mSlop = QuickStepContract.getQuickStepDragSlopPx();
mActivityControlHelper = activityControlHelper;
+ mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL);
+ mSwipeDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
}
@Override
@@ -100,6 +106,7 @@
@Override
public void onMotionEvent(MotionEvent ev) {
// TODO add logging
+ mSwipeDetector.onTouchEvent(ev);
switch (ev.getActionMasked()) {
case ACTION_DOWN: {
@@ -146,7 +153,7 @@
// Determine if angle is larger than threshold for assistant detection
float angle = (float) Math.toDegrees(
- Math.atan2(mDownPos.y - mLastPos.y, mDownPos.x - mLastPos.x));
+ Math.atan2(mDownPos.y - mLastPos.y, mDownPos.x - mLastPos.x));
mDirection = angle > 90 ? UPLEFT : UPRIGHT;
angle = angle > 90 ? 180 - angle : angle;
@@ -159,7 +166,7 @@
} else {
// Movement
mDistance = (float) Math.hypot(mLastPos.x - mStartDragPos.x,
- mLastPos.y - mStartDragPos.y);
+ mLastPos.y - mStartDragPos.y);
if (mDistance >= 0) {
final long diff = SystemClock.uptimeMillis() - mDragTime;
mTimeFraction = Math.min(diff * 1f / mTimeThreshold, 1);
@@ -172,18 +179,18 @@
case ACTION_UP:
if (mState != STATE_DELEGATE_ACTIVE && !mLaunchedAssistant) {
ValueAnimator animator = ValueAnimator.ofFloat(mLastProgress, 0)
- .setDuration(RETRACT_ANIMATION_DURATION_MS);
+ .setDuration(RETRACT_ANIMATION_DURATION_MS);
UserEventDispatcher.newInstance(mContext).logActionOnContainer(
- SWIPE_NOOP, mDirection, NAVBAR);
+ SWIPE_NOOP, mDirection, NAVBAR);
animator.addUpdateListener(valueAnimator -> {
- float progress = (float) valueAnimator.getAnimatedValue();
- try {
+ float progress = (float) valueAnimator.getAnimatedValue();
+ try {
- mSysUiProxy.onAssistantProgress(progress);
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to send SysUI start/send assistant progress: "
- + progress, e);
- }
+ mSysUiProxy.onAssistantProgress(progress);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to send SysUI start/send assistant progress: "
+ + progress, e);
+ }
});
animator.setInterpolator(Interpolators.DEACCEL_2);
animator.start();
@@ -200,30 +207,32 @@
private void updateAssistantProgress() {
if (!mLaunchedAssistant) {
- float progress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction;
- mLastProgress = progress;
- try {
- mSysUiProxy.onAssistantProgress(progress);
- if (mDistance >= mDistThreshold && mTimeFraction >= 1) {
- UserEventDispatcher.newInstance(mContext).logActionOnContainer(
- SWIPE, mDirection, NAVBAR);
- Bundle args = new Bundle();
- args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
+ mLastProgress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction;
+ updateAssistant(SWIPE);
+ }
+ }
- BaseDraggingActivity launcherActivity =
- mActivityControlHelper.getCreatedActivity();
- if (launcherActivity != null) {
- launcherActivity.getRootView().
- performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
- HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
- }
+ private void updateAssistant(int gestureType) {
+ try {
+ mSysUiProxy.onAssistantProgress(mLastProgress);
+ if (gestureType == FLING || (mDistance >= mDistThreshold && mTimeFraction >= 1)) {
+ UserEventDispatcher.newInstance(mContext)
+ .logActionOnContainer(gestureType, mDirection, NAVBAR);
+ Bundle args = new Bundle();
+ args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
- mSysUiProxy.startAssistant(args);
- mLaunchedAssistant = true;
+ BaseDraggingActivity launcherActivity = mActivityControlHelper.getCreatedActivity();
+ if (launcherActivity != null) {
+ launcherActivity.getRootView().performHapticFeedback(
+ 13, // HapticFeedbackConstants.GESTURE_END
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + progress, e);
+
+ mSysUiProxy.startAssistant(args);
+ mLaunchedAssistant = true;
}
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, e);
}
}
@@ -234,4 +243,22 @@
final int size = res.getDimensionPixelSize(R.dimen.gestures_assistant_size);
return (ev.getX() > width - size || ev.getX() < size) && ev.getY() > height - size;
}
+
+ @Override
+ public void onDragStart(boolean start) {
+ // do nothing
+ }
+
+ @Override
+ public boolean onDrag(float displacement) {
+ return false;
+ }
+
+ @Override
+ public void onDragEnd(float velocity, boolean fling) {
+ if (fling) {
+ mLastProgress = 1;
+ updateAssistant(FLING);
+ }
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java
index e3dcadc..e20ef52 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
+import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP;
import android.app.Activity;
@@ -116,21 +117,22 @@
mHandler = new Handler(Looper.getMainLooper());
}
- protected abstract boolean isAvailable(BaseDraggingActivity activity);
+ protected abstract boolean isAvailable(BaseDraggingActivity activity, int displayId);
protected abstract ActivityOptions makeLaunchOptions(Activity activity);
protected abstract boolean onActivityStarted(BaseDraggingActivity activity);
@Override
public View.OnClickListener getOnClickListener(
BaseDraggingActivity activity, TaskView taskView) {
- if (!isAvailable(activity)) {
- return null;
- }
final Task task = taskView.getTask();
final int taskId = task.key.id;
+ final int displayId = task.key.displayId;
if (!task.isDockable) {
return null;
}
+ if (!isAvailable(activity, displayId)) {
+ return null;
+ }
final RecentsView recentsView = activity.getOverviewPanel();
final TaskThumbnailView thumbnailView = taskView.getThumbnail();
@@ -218,9 +220,13 @@
}
@Override
- protected boolean isAvailable(BaseDraggingActivity activity) {
- // Don't show menu-item if already in multi-window
- return !activity.getDeviceProfile().isMultiWindowMode;
+ protected boolean isAvailable(BaseDraggingActivity activity, int displayId) {
+ // Don't show menu-item if already in multi-window and the task is from
+ // the secondary display.
+ // TODO(b/118266305): Temporarily disable splitscreen for secondary display while new
+ // implementation is enabled
+ return !activity.getDeviceProfile().isMultiWindowMode
+ && displayId == DEFAULT_DISPLAY;
}
@Override
@@ -256,7 +262,7 @@
}
@Override
- protected boolean isAvailable(BaseDraggingActivity activity) {
+ protected boolean isAvailable(BaseDraggingActivity activity, int displayId) {
return ActivityManagerWrapper.getInstance().supportsFreeformMultiWindow(activity);
}
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index e1a115a..3b75304 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -132,7 +132,7 @@
private final DragLayer mDragLayer;
private final AlphaProperty mDragLayerAlpha;
- private final Handler mHandler;
+ final Handler mHandler;
private final boolean mIsRtl;
private final float mContentTransY;
@@ -573,70 +573,9 @@
* @return Runner that plays when user goes to Launcher
* ie. pressing home, swiping up from nav bar.
*/
- private RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) {
- return new LauncherAnimationRunner(mHandler, false /* startAtFrontOfQueue */) {
- @Override
- public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
- AnimationResult result) {
- if (!mLauncher.hasBeenResumed()) {
- // If launcher is not resumed, wait until new async-frame after resume
- mLauncher.setOnResumeCallback(() ->
- postAsyncCallback(mHandler, () ->
- onCreateAnimation(targetCompats, result)));
- return;
- }
-
- if (mLauncher.hasSomeInvisibleFlag(PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION)) {
- mLauncher.addForceInvisibleFlag(INVISIBLE_BY_PENDING_FLAGS);
- mLauncher.getStateManager().moveToRestState();
- }
-
- AnimatorSet anim = null;
- RemoteAnimationProvider provider = mRemoteAnimationProvider;
- if (provider != null) {
- anim = provider.createWindowAnimation(targetCompats);
- }
-
- if (anim == null) {
- anim = new AnimatorSet();
- anim.play(fromUnlock
- ? getUnlockWindowAnimator(targetCompats)
- : getClosingWindowAnimators(targetCompats));
-
- // Normally, we run the launcher content animation when we are transitioning
- // home, but if home is already visible, then we don't want to animate the
- // contents of launcher unless we know that we are animating home as a result
- // of the home button press with quickstep, which will result in launcher being
- // started on touch down, prior to the animation home (and won't be in the
- // targets list because it is already visible). In that case, we force
- // invisibility on touch down, and only reset it after the animation to home
- // is initialized.
- if (launcherIsATargetWithMode(targetCompats, MODE_OPENING)
- || mLauncher.isForceInvisible()) {
- // Only register the content animation for cancellation when state changes
- mLauncher.getStateManager().setCurrentAnimation(anim);
- if (fromUnlock) {
- Pair<AnimatorSet, Runnable> contentAnimator =
- getLauncherContentAnimator(false /* isAppOpening */,
- new float[] {mContentTransY, 0});
- contentAnimator.first.setStartDelay(0);
- anim.play(contentAnimator.first);
- anim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- contentAnimator.second.run();
- }
- });
- } else {
- createLauncherResumeAnimation(anim);
- }
- }
- }
-
- mLauncher.clearForceInvisibleFlag(INVISIBLE_ALL);
- result.setAnimation(anim);
- }
- };
+ RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) {
+ return new WallpaperOpenLauncherAnimationRunner(mHandler, false /* startAtFrontOfQueue */,
+ fromUnlock);
}
/**
@@ -773,4 +712,79 @@
return mLauncher.checkSelfPermission(CONTROL_REMOTE_APP_TRANSITION_PERMISSION)
== PackageManager.PERMISSION_GRANTED;
}
+
+ /**
+ * Remote animation runner for animation from the app to Launcher, including recents.
+ */
+ class WallpaperOpenLauncherAnimationRunner extends LauncherAnimationRunner {
+ private final boolean mFromUnlock;
+
+ public WallpaperOpenLauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue,
+ boolean fromUnlock) {
+ super(handler, startAtFrontOfQueue);
+ mFromUnlock = fromUnlock;
+ }
+
+ @Override
+ public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
+ LauncherAnimationRunner.AnimationResult result) {
+ if (!mLauncher.hasBeenResumed()) {
+ // If launcher is not resumed, wait until new async-frame after resume
+ mLauncher.setOnResumeCallback(() ->
+ postAsyncCallback(mHandler, () ->
+ onCreateAnimation(targetCompats, result)));
+ return;
+ }
+
+ if (mLauncher.hasSomeInvisibleFlag(PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION)) {
+ mLauncher.addForceInvisibleFlag(INVISIBLE_BY_PENDING_FLAGS);
+ mLauncher.getStateManager().moveToRestState();
+ }
+
+ AnimatorSet anim = null;
+ RemoteAnimationProvider provider = mRemoteAnimationProvider;
+ if (provider != null) {
+ anim = provider.createWindowAnimation(targetCompats);
+ }
+
+ if (anim == null) {
+ anim = new AnimatorSet();
+ anim.play(mFromUnlock
+ ? getUnlockWindowAnimator(targetCompats)
+ : getClosingWindowAnimators(targetCompats));
+
+ // Normally, we run the launcher content animation when we are transitioning
+ // home, but if home is already visible, then we don't want to animate the
+ // contents of launcher unless we know that we are animating home as a result
+ // of the home button press with quickstep, which will result in launcher being
+ // started on touch down, prior to the animation home (and won't be in the
+ // targets list because it is already visible). In that case, we force
+ // invisibility on touch down, and only reset it after the animation to home
+ // is initialized.
+ if (launcherIsATargetWithMode(targetCompats, MODE_OPENING)
+ || mLauncher.isForceInvisible()) {
+ // Only register the content animation for cancellation when state changes
+ mLauncher.getStateManager().setCurrentAnimation(anim);
+ if (mFromUnlock) {
+ Pair<AnimatorSet, Runnable> contentAnimator =
+ getLauncherContentAnimator(false /* isAppOpening */,
+ new float[] {mContentTransY, 0});
+ contentAnimator.first.setStartDelay(0);
+ anim.play(contentAnimator.first);
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ contentAnimator.second.run();
+ }
+ });
+ } else {
+ createLauncherResumeAnimation(anim);
+ }
+ }
+ }
+
+ mLauncher.clearForceInvisibleFlag(INVISIBLE_ALL);
+ result.setAnimation(anim);
+ }
+ }
}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 581e886..7578dff 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -24,7 +24,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import android.content.Intent;
import android.util.Log;
import androidx.test.filters.LargeTest;
@@ -241,9 +240,8 @@
}
public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
- final AppIcon app = allApps.getAppIcon("Calculator");
- assertNotNull("AppIcon.launch returned null", app.launch(
- test.resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)));
+ final AppIcon app = allApps.getAppIcon("TestActivity7");
+ assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
test.executeOnLauncher(launcher -> assertTrue(
"Launcher activity is the top activity; expecting another activity to be the top "
+ "one",
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 3b2a7b8..60d2850 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -78,7 +78,8 @@
final long downTime = SystemClock.uptimeMillis();
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start);
- mLauncher.movePointer(downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end);
+ mLauncher.movePointer(
+ downTime, downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end);
LauncherInstrumentation.sleep(ZERO_BUTTON_SWIPE_UP_HOLD_DURATION);
mLauncher.sendPointer(
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 87ef044..fd2eabb 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -70,6 +70,7 @@
private static final String TAG = "Tapl";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
+ private static final int GESTURE_STEP_MS = 16;
// Types for launcher containers that the user is interacting with. "Background" is a
// pseudo-container corresponding to inactive launcher covered by another app.
@@ -359,7 +360,7 @@
? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL;
final Point displaySize = getRealDisplaySize();
- swipe(
+ swipeViaMovePointer(
displaySize.x / 2, displaySize.y - 1,
displaySize.x / 2, 0,
finalState, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
@@ -543,8 +544,28 @@
}
void swipe(int startX, int startY, int endX, int endY, int expectedState, int steps) {
+ changeStateViaGesture(startX, startY, endX, endY, expectedState,
+ () -> mDevice.swipe(startX, startY, endX, endY, steps));
+ }
+
+ void swipeViaMovePointer(
+ int startX, int startY, int endX, int endY, int expectedState, int steps) {
+ changeStateViaGesture(startX, startY, endX, endY, expectedState, () -> {
+ final long downTime = SystemClock.uptimeMillis();
+ final Point start = new Point(startX, startY);
+ final Point end = new Point(endX, endY);
+ sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start);
+ final long endTime = movePointer(downTime, downTime, steps * GESTURE_STEP_MS, start,
+ end);
+ sendPointer(
+ downTime, endTime, MotionEvent.ACTION_UP, end);
+ });
+ }
+
+ private void changeStateViaGesture(int startX, int startY, int endX, int endY,
+ int expectedState, Runnable gesture) {
final Bundle parcel = (Bundle) executeAndWaitForEvent(
- () -> mDevice.swipe(startX, startY, endX, endY, steps),
+ gesture,
event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
"Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+ ", " + endX + ", " + endY);
@@ -589,21 +610,22 @@
event.recycle();
}
- void movePointer(long downTime, long duration, Point from, Point to) {
+ long movePointer(long downTime, long startTime, long duration, Point from, Point to) {
final Point point = new Point();
- final long startTime = SystemClock.uptimeMillis();
- for (; ; ) {
- sleep(16);
+ long steps = duration / GESTURE_STEP_MS;
+ long currentTime = startTime;
+ for (long i = 0; i < steps; ++i) {
+ sleep(GESTURE_STEP_MS);
- final long currentTime = SystemClock.uptimeMillis();
+ currentTime += GESTURE_STEP_MS;
final float progress = (currentTime - startTime) / (float) duration;
- if (progress > 1) return;
point.x = from.x + (int) (progress * (to.x - from.x));
point.y = from.y + (int) (progress * (to.y - from.y));
sendPointer(downTime, currentTime, MotionEvent.ACTION_MOVE, point);
}
+ return currentTime;
}
public static boolean isGesturalMode(Context context) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 9a47aef..e8a0b54 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -150,7 +150,8 @@
LauncherInstrumentation.log("dragIconToWorkspace: sent down");
launcher.waitForLauncherObject(longPressIndicator);
LauncherInstrumentation.log("dragIconToWorkspace: indicator");
- launcher.movePointer(downTime, DRAG_DURACTION, launchableCenter, dest);
+ launcher.movePointer(
+ downTime, SystemClock.uptimeMillis(), DRAG_DURACTION, launchableCenter, dest);
LauncherInstrumentation.log("dragIconToWorkspace: moved pointer");
launcher.sendPointer(
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest);