Merge "Remove unnecessary dispatchInsets routing" into ub-launcher3-qt-dev
diff --git a/Android.bp b/Android.bp
index b80282e..4c38205 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,7 +25,7 @@
"tests/tapl/**/*.java",
"src/com/android/launcher3/util/SecureSettingsObserver.java",
"src/com/android/launcher3/ResourceUtils.java",
- "src/com/android/launcher3/TestProtocol.java",
+ "src/com/android/launcher3/testing/TestProtocol.java",
],
manifest: "tests/tapl/AndroidManifest.xml",
platform_apis: true,
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index ef5bb26..5318a12 100644
--- a/AndroidManifest-common.xml
+++ b/AndroidManifest-common.xml
@@ -176,5 +176,12 @@
</intent-filter>
</activity>
+ <provider
+ android:name="com.android.launcher3.testing.TestInformationProvider"
+ android:authorities="${packageName}.TestInfo"
+ android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
+ android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
+ android:exported="true"
+ android:enabled="false" />
</application>
</manifest>
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..6c1273f
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,12 @@
+# Use this reviewer by default.
+# gnl-eng@google.com (Googlers only)
+
+# People who can approve changes for submission
+#
+
+adamcohen@google.com
+hyunyoungs@google.com
+mrcasey@google.com
+sunnygoyal@google.com
+twickham@google.com
+winsonc@google.com
diff --git a/go/quickstep/res/layout/clear_all_button.xml b/go/quickstep/res/layout/clear_all_button.xml
index 2f7c8ae..eef66ad 100644
--- a/go/quickstep/res/layout/clear_all_button.xml
+++ b/go/quickstep/res/layout/clear_all_button.xml
@@ -29,5 +29,6 @@
android:text="@string/recents_clear_all"
android:textAllCaps="false"
android:textColor="@color/clear_all_button_text"
- android:textSize="14sp"/>
+ android:textSize="14sp"
+ style="@style/TextTitle"/>
</FrameLayout>
diff --git a/go/quickstep/res/layout/icon_recents_root_view.xml b/go/quickstep/res/layout/icon_recents_root_view.xml
index 595a380..8381ebc 100644
--- a/go/quickstep/res/layout/icon_recents_root_view.xml
+++ b/go/quickstep/res/layout/icon_recents_root_view.xml
@@ -36,5 +36,6 @@
android:text="@string/recents_empty_message"
android:textColor="@android:color/white"
android:textSize="25sp"
+ style="@style/TextTitle"
android:visibility="gone"/>
</com.android.quickstep.views.IconRecentsView>
\ No newline at end of file
diff --git a/go/quickstep/res/layout/task_item_view.xml b/go/quickstep/res/layout/task_item_view.xml
index ab2cf28..aeac477 100644
--- a/go/quickstep/res/layout/task_item_view.xml
+++ b/go/quickstep/res/layout/task_item_view.xml
@@ -41,5 +41,6 @@
android:layout_gravity="center_vertical"
android:singleLine="true"
android:textColor="@android:color/white"
- android:textSize="24sp"/>
+ android:textSize="24sp"
+ style="@style/TextTitle"/>
</com.android.quickstep.views.TaskItemView>
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index be275e0..a38979d 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -73,14 +73,6 @@
</intent-filter>
</provider>
- <provider
- android:name="com.android.quickstep.TestInformationProvider"
- android:authorities="${packageName}.TestInfo"
- android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
- android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
- android:exported="true">
- </provider>
-
<service
android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
tools:node="remove" />
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java
index 6dad9af..28ecce0 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java
@@ -197,7 +197,10 @@
}
}
+ public boolean mDebugHadStateUpdate;
+
private void updatePredictionStateAfterCallback() {
+ mDebugHadStateUpdate = true;
boolean validResults = false;
for (List l : mPredictionServicePredictions) {
validResults |= l != null && !l.isEmpty();
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index 90b5536..4b2e487 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -118,7 +118,8 @@
final RectF iconLocation = new RectF();
boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
FloatingIconView floatingIconView = canUseWorkspaceView
- ? recentsView.getFloatingIconView(activity, workspaceView, iconLocation)
+ ? FloatingIconView.getFloatingIconView(activity, workspaceView,
+ true /* hideOriginal */, iconLocation, false /* isOpening */)
: null;
return new HomeAnimationFactory() {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 0c997dd..6ba1bf5 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -331,16 +331,8 @@
defaultDisplay.getRealSize(realSize);
mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
if (mMode == Mode.NO_BUTTON) {
- switch (defaultDisplay.getRotation()) {
- case Surface.ROTATION_90:
- case Surface.ROTATION_270:
- mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(
- ResourceUtils.NAVBAR_LANDSCAPE_BOTTOM_SIZE);
- break;
- default:
- mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(
- ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE);
- }
+ mSwipeTouchRegion.top = mSwipeTouchRegion.bottom -
+ getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
} else {
switch (defaultDisplay.getRotation()) {
case Surface.ROTATION_90:
@@ -353,7 +345,7 @@
break;
default:
mSwipeTouchRegion.top = mSwipeTouchRegion.bottom
- - getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE);
+ - getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
}
}
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
index d69262e..a1bcb9b 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -170,7 +170,8 @@
STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED;
public enum GestureEndTarget {
- HOME(1, STATE_SCALED_CONTROLLER_HOME, true, false, ContainerType.WORKSPACE, false),
+ HOME(1, STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT, true, false,
+ ContainerType.WORKSPACE, false),
RECENTS(1, STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT
| STATE_SCREENSHOT_VIEW_SHOWN, true, false, ContainerType.TASKSWITCHER, true),
@@ -331,9 +332,8 @@
| STATE_SCALED_CONTROLLER_RECENTS,
this::finishCurrentTransitionToRecents);
- mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_GESTURE_COMPLETED
- | STATE_SCALED_CONTROLLER_HOME | STATE_APP_CONTROLLER_RECEIVED
- | STATE_LAUNCHER_DRAWN,
+ mStateCallback.addCallback(STATE_SCREENSHOT_CAPTURED | STATE_GESTURE_COMPLETED
+ | STATE_SCALED_CONTROLLER_HOME,
this::finishCurrentTransitionToHome);
mStateCallback.addCallback(STATE_SCALED_CONTROLLER_HOME | STATE_CURRENT_TASK_FINISHED,
this::reset);
@@ -902,7 +902,7 @@
float minFlingVelocity = mContext.getResources()
.getDimension(R.dimen.quickstep_fling_min_velocity);
if (Math.abs(endVelocity) > minFlingVelocity && mTransitionDragLength > 0) {
- if (endTarget == RECENTS) {
+ if (endTarget == RECENTS && mMode != Mode.NO_BUTTON) {
Interpolators.OvershootParams overshoot = new Interpolators.OvershootParams(
startShift, endShift, endShift, velocityPxPerMs.y,
mTransitionDragLength);
@@ -918,6 +918,10 @@
// derivative of the scroll interpolator at zero, ie. 2.
long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs.y));
duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
+
+ if (endTarget == RECENTS) {
+ interpolator = OVERSHOOT_1_2;
+ }
}
}
}
@@ -932,6 +936,9 @@
} else if (endTarget == RECENTS) {
mLiveTileOverlay.startIconAnimation();
if (mRecentsView != null) {
+ if (mRecentsView.getScroller().getDuration() > MAX_SWIPE_DURATION) {
+ mRecentsView.snapToPage(mRecentsView.getNextPage(), (int) MAX_SWIPE_DURATION);
+ }
duration = Math.max(duration, mRecentsView.getScroller().getDuration());
}
if (mMode == Mode.NO_BUTTON) {
@@ -1246,7 +1253,14 @@
if (mTaskSnapshot == null) {
mTaskSnapshot = controller.screenshotTask(mRunningTaskId);
}
- TaskView taskView = mRecentsView.updateThumbnail(mRunningTaskId, mTaskSnapshot);
+ final TaskView taskView;
+ if (mGestureEndTarget == HOME) {
+ // Capture the screenshot before finishing the transition to home to ensure it's
+ // taken in the correct orientation, but no need to update the thumbnail.
+ taskView = null;
+ } else {
+ taskView = mRecentsView.updateThumbnail(mRunningTaskId, mTaskSnapshot);
+ }
if (taskView != null) {
// Defer finishing the animation until the next launcher frame with the
// new thumbnail
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
index 20ea3a1..bf276e1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
@@ -23,6 +23,7 @@
import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
+import static com.android.launcher3.Utilities.squaredHypot;
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;
@@ -40,6 +41,7 @@
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
+import android.view.ViewConfiguration;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
@@ -81,7 +83,7 @@
private final float mDistThreshold;
private final long mTimeThreshold;
private final int mAngleThreshold;
- private final float mSlop;
+ private final float mSquaredSlop;
private final ISystemUiProxy mSysUiProxy;
private final Context mContext;
private final SwipeDetector mSwipeDetector;
@@ -96,7 +98,10 @@
mDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold);
mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold);
- mSlop = QuickStepContract.getQuickStepDragSlopPx();
+
+ float slop = ViewConfiguration.get(context).getScaledTouchSlop();
+
+ mSquaredSlop = slop * slop;
mActivityControlHelper = activityControlHelper;
mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL);
mSwipeDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
@@ -155,7 +160,8 @@
if (!mPassedSlop) {
// Normal gesture, ensure we pass the slop before we start tracking the gesture
- if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSlop) {
+ if (squaredHypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y)
+ > mSquaredSlop) {
mPassedSlop = true;
mStartDragPos.set(mLastPos.x, mLastPos.y);
@@ -218,31 +224,35 @@
private void updateAssistantProgress() {
if (!mLaunchedAssistant) {
mLastProgress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction;
- updateAssistant(SWIPE);
+ try {
+ if (mDistance >= mDistThreshold && mTimeFraction >= 1) {
+ mSysUiProxy.onAssistantGestureCompletion(0);
+ startAssistantInternal(SWIPE);
+
+ Bundle args = new Bundle();
+ args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
+ mSysUiProxy.startAssistant(args);
+ mLaunchedAssistant = true;
+ } else {
+ mSysUiProxy.onAssistantProgress(mLastProgress);
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress,
+ e);
+ }
}
}
- 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);
+ private void startAssistantInternal(int gestureType) {
+ UserEventDispatcher.newInstance(mContext)
+ .logActionOnContainer(gestureType, mDirection, NAVBAR);
- BaseDraggingActivity launcherActivity = mActivityControlHelper.getCreatedActivity();
- if (launcherActivity != null) {
- launcherActivity.getRootView().performHapticFeedback(
- 13, // HapticFeedbackConstants.GESTURE_END
- HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
- }
-
- mSysUiProxy.startAssistant(args);
- mLaunchedAssistant = true;
- }
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, e);
+ BaseDraggingActivity launcherActivity = mActivityControlHelper
+ .getCreatedActivity();
+ if (launcherActivity != null) {
+ launcherActivity.getRootView().performHapticFeedback(
+ 13, // HapticFeedbackConstants.GESTURE_END
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
}
@@ -266,9 +276,20 @@
@Override
public void onDragEnd(float velocity, boolean fling) {
- if (fling && !mLaunchedAssistant) {
+ if (fling && !mLaunchedAssistant && mState != STATE_DELEGATE_ACTIVE) {
mLastProgress = 1;
- updateAssistant(FLING);
+ try {
+ mSysUiProxy.onAssistantGestureCompletion(velocity);
+ startAssistantInternal(FLING);
+
+ Bundle args = new Bundle();
+ args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
+ mSysUiProxy.startAssistant(args);
+ mLaunchedAssistant = true;
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress,
+ e);
+ }
}
}
}
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 b1d175d..d01b5ec 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
@@ -15,11 +15,13 @@
*/
package com.android.quickstep.inputconsumers;
+import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.Utilities.squaredTouchSlop;
+
import android.content.Context;
import android.content.Intent;
import android.graphics.PointF;
import android.view.MotionEvent;
-import android.view.ViewConfiguration;
/**
* A dummy input consumer used when the device is still locked, e.g. from secure camera.
@@ -32,8 +34,7 @@
public DeviceLockedInputConsumer(Context context) {
mContext = context;
- float touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
- mTouchSlopSquared = touchSlop * touchSlop;
+ mTouchSlopSquared = squaredTouchSlop(context);
}
@Override
@@ -48,9 +49,7 @@
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mTouchDown.set(x, y);
} else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
- float xSquared = (x - mTouchDown.x) * (x - mTouchDown.x);
- float ySquared = (y - mTouchDown.y) * (y - mTouchDown.y);
- if (xSquared + ySquared > mTouchSlopSquared) {
+ if (squaredHypot(x - mTouchDown.x, y - mTouchDown.y) > mTouchSlopSquared) {
// For now, just start the home intent so user is prompted to unlock the device.
mContext.startActivity(new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
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 eb5366c..b0acffa 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
@@ -23,6 +23,7 @@
import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.INVALID_POINTER_ID;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
+import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE;
import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE;
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
@@ -109,7 +110,7 @@
private int mActivePointerId = INVALID_POINTER_ID;
private final float mDragSlop;
- private final float mTouchSlop;
+ private final float mSquaredTouchSlop;
// Slop used to check when we start moving window.
private boolean mPassedDragSlop;
@@ -157,7 +158,8 @@
mDisplayRotation = getSystemService(WindowManager.class).getDefaultDisplay().getRotation();
mDragSlop = QuickStepContract.getQuickStepDragSlopPx();
- mTouchSlop = QuickStepContract.getQuickStepTouchSlopPx();
+ float slop = QuickStepContract.getQuickStepTouchSlopPx();
+ mSquaredTouchSlop = slop * slop;
mPassedTouchSlop = mPassedDragSlop = continuingPreviousGesture;
}
@@ -256,7 +258,7 @@
}
if (!mPassedTouchSlop) {
- if (Math.hypot(displacementX, mLastPos.y - mDownPos.y) >= mTouchSlop) {
+ if (squaredHypot(displacementX, mLastPos.y - mDownPos.y) >= mSquaredTouchSlop) {
mPassedTouchSlop = true;
if (mIsDeferredDownTarget) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
index 3f4ad58..77dc6f3 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java
@@ -16,26 +16,22 @@
package com.android.quickstep.util;
import android.animation.Animator;
-import android.animation.ObjectAnimator;
-import android.animation.PropertyValuesHolder;
-import android.animation.ValueAnimator;
import android.content.res.Resources;
import android.graphics.PointF;
import android.graphics.RectF;
-import android.util.FloatProperty;
import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener;
import androidx.dynamicanimation.animation.FloatPropertyCompat;
+import androidx.dynamicanimation.animation.SpringAnimation;
+import androidx.dynamicanimation.animation.SpringForce;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.FlingSpringAnim;
import java.util.ArrayList;
import java.util.List;
-import static com.android.launcher3.anim.Interpolators.DEACCEL;
/**
* Applies spring forces to animate from a starting rect to a target rect,
@@ -43,14 +39,6 @@
*/
public class RectFSpringAnim {
- /**
- * Although the rect position animation takes an indefinite amount of time since it depends on
- * the initial velocity and applied forces, scaling from the starting rect to the target rect
- * can be done in parallel at a fixed duration. Update callbacks are sent based on the progress
- * of this animation, while the end callback is sent after all animations finish.
- */
- private static final long RECT_SCALE_DURATION = 250;
-
private static final FloatPropertyCompat<RectFSpringAnim> RECT_CENTER_X =
new FloatPropertyCompat<RectFSpringAnim>("rectCenterXSpring") {
@Override
@@ -79,17 +67,17 @@
}
};
- private static final FloatProperty<RectFSpringAnim> RECT_SCALE_PROGRESS =
- new FloatProperty<RectFSpringAnim>("rectScaleProgress") {
+ private static final FloatPropertyCompat<RectFSpringAnim> RECT_SCALE_PROGRESS =
+ new FloatPropertyCompat<RectFSpringAnim>("rectScaleProgress") {
@Override
- public Float get(RectFSpringAnim anim) {
- return anim.mCurrentScaleProgress;
+ public float getValue(RectFSpringAnim object) {
+ return object.mCurrentScaleProgress;
}
@Override
- public void setValue(RectFSpringAnim anim, float currentScaleProgress) {
- anim.mCurrentScaleProgress = currentScaleProgress;
- anim.onUpdate();
+ public void setValue(RectFSpringAnim object, float value) {
+ object.mCurrentScaleProgress = value;
+ object.onUpdate();
}
};
@@ -106,7 +94,7 @@
private float mCurrentScaleProgress;
private FlingSpringAnim mRectXAnim;
private FlingSpringAnim mRectYAnim;
- private ValueAnimator mRectScaleAnim;
+ private SpringAnimation mRectScaleAnim;
private boolean mAnimsStarted;
private boolean mRectXAnimEnded;
private boolean mRectYAnimEnded;
@@ -177,17 +165,18 @@
mRectYAnim = new FlingSpringAnim(this, RECT_Y, startY, endY, startVelocityY,
mMinVisChange, minYValue, maxYValue, springVelocityFactor, onYEndListener);
- mRectScaleAnim = ObjectAnimator.ofPropertyValuesHolder(this,
- PropertyValuesHolder.ofFloat(RECT_SCALE_PROGRESS, 1))
- .setDuration(RECT_SCALE_DURATION);
- mRectScaleAnim.setInterpolator(DEACCEL);
- mRectScaleAnim.addListener(new AnimationSuccessListener() {
- @Override
- public void onAnimationSuccess(Animator animator) {
- mRectScaleAnimEnded = true;
- maybeOnEnd();
- }
- });
+ float minVisibleChange = 1f / mStartRect.height();
+ mRectScaleAnim = new SpringAnimation(this, RECT_SCALE_PROGRESS)
+ .setSpring(new SpringForce(1f)
+ .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ .setStiffness(SpringForce.STIFFNESS_LOW))
+ .setStartVelocity(velocityPxPerMs.y * minVisibleChange)
+ .setMaxValue(1f)
+ .setMinimumVisibleChange(minVisibleChange)
+ .addEndListener((animation, canceled, value, velocity) -> {
+ mRectScaleAnimEnded = true;
+ maybeOnEnd();
+ });
mRectXAnim.start();
mRectYAnim.start();
@@ -202,7 +191,9 @@
if (mAnimsStarted) {
mRectXAnim.end();
mRectYAnim.end();
- mRectScaleAnim.end();
+ if (mRectScaleAnim.canSkipToEnd()) {
+ mRectScaleAnim.skipToEnd();
+ }
}
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index a835680..1e1007e 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -20,6 +20,8 @@
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
+import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
@@ -64,7 +66,6 @@
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
@@ -75,7 +76,6 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.InvariantDeviceProfile;
-import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils.ViewProgressProperty;
import com.android.launcher3.LauncherState;
import com.android.launcher3.PagedView;
@@ -93,7 +93,6 @@
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.ViewPool;
-import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.RecentsAnimationWrapper;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel.TaskThumbnailChangeListener;
@@ -281,7 +280,7 @@
private boolean mHandleTaskStackChanges;
private boolean mSwipeDownShouldLaunchApp;
private boolean mTouchDownToStartHome;
- private final int mTouchSlop;
+ private final float mSquaredTouchSlop;
private int mDownX;
private int mDownY;
@@ -306,8 +305,6 @@
private Layout mEmptyTextLayout;
private LiveTileOverlay mLiveTileOverlay;
- private FloatingIconView mFloatingIconView;
-
private BaseActivity.MultiWindowModeChangedListener mMultiWindowModeChangedListener =
(inMultiWindowMode) -> {
if (!inMultiWindowMode && mOverviewStateEnabled) {
@@ -339,7 +336,7 @@
setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
mTaskTopMargin = getResources()
.getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
- mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+ mSquaredTouchSlop = squaredTouchSlop(context);
mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents);
mEmptyIcon.setCallback(this);
@@ -496,7 +493,8 @@
case MotionEvent.ACTION_MOVE:
// Passing the touch slop will not allow dismiss to home
if (mTouchDownToStartHome &&
- (isHandlingTouch() || Math.hypot(mDownX - x, mDownY - y) > mTouchSlop)) {
+ (isHandlingTouch() ||
+ squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop)) {
mTouchDownToStartHome = false;
}
break;
@@ -1684,12 +1682,6 @@
}
}
- public FloatingIconView getFloatingIconView(Launcher launcher, View view, RectF iconLocation) {
- mFloatingIconView = FloatingIconView.getFloatingIconView(launcher, view,
- true /* hideOriginal */, iconLocation, false /* isOpening */, mFloatingIconView);
- return mFloatingIconView;
- }
-
public ClipAnimationHelper getTempClipAnimationHelper() {
return mTempClipAnimationHelper;
}
diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml
index e84543b..5c4d6d8 100644
--- a/quickstep/res/values/config.xml
+++ b/quickstep/res/values/config.xml
@@ -25,6 +25,8 @@
<string name="stats_log_manager_class" translatable="false">com.android.quickstep.logging.StatsLogCompatManager</string>
+ <string name="test_information_handler_class" translatable="false">com.android.quickstep.QuickstepTestInformationHandler</string>
+
<!-- The number of thumbnails and icons to keep in the cache. The thumbnail cache size also
determines how many thumbnails will be fetched in the background. -->
<integer name="recentsThumbnailCacheSize">3</integer>
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index 91c4601..95ae312 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -142,7 +142,6 @@
private final float mClosingWindowTransY;
private DeviceProfile mDeviceProfile;
- private FloatingIconView mFloatingView;
private RemoteAnimationProvider mRemoteAnimationProvider;
@@ -411,15 +410,15 @@
private ValueAnimator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] targets,
Rect windowTargetBounds, boolean toggleVisibility) {
RectF bounds = new RectF();
- mFloatingView = FloatingIconView.getFloatingIconView(mLauncher, v, toggleVisibility,
- bounds, true /* isOpening */, mFloatingView);
+ FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v,
+ toggleVisibility, bounds, true /* isOpening */);
Rect crop = new Rect();
Matrix matrix = new Matrix();
RemoteAnimationTargetSet openingTargets = new RemoteAnimationTargetSet(targets,
MODE_OPENING);
SyncRtSurfaceTransactionApplierCompat surfaceApplier =
- new SyncRtSurfaceTransactionApplierCompat(mFloatingView);
+ new SyncRtSurfaceTransactionApplierCompat(floatingView);
openingTargets.addDependentTransactionApplier(surfaceApplier);
// Scale the app icon to take up the entire screen. This simplifies the math when
@@ -463,7 +462,7 @@
ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setDuration(APP_LAUNCH_DURATION);
appAnimator.setInterpolator(LINEAR);
- appAnimator.addListener(mFloatingView);
+ appAnimator.addListener(floatingView);
appAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -557,7 +556,7 @@
} else {
currentBounds.bottom -= croppedHeight;
}
- mFloatingView.update(currentBounds, mIconAlpha.value, percent, 0f,
+ floatingView.update(currentBounds, mIconAlpha.value, percent, 0f,
cornerRadius * scale, true /* isOpening */);
} else {
matrix.setTranslate(target.position.x, target.position.y);
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
new file mode 100644
index 0000000..8951363
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -0,0 +1,36 @@
+package com.android.quickstep;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.launcher3.testing.TestInformationHandler;
+import com.android.launcher3.testing.TestProtocol;
+import com.android.launcher3.uioverrides.states.OverviewState;
+import com.android.quickstep.util.LayoutUtils;
+
+public class QuickstepTestInformationHandler extends TestInformationHandler {
+
+ public QuickstepTestInformationHandler(Context context) { }
+
+ @Override
+ public Bundle call(String method) {
+ final Bundle response = new Bundle();
+ switch (method) {
+ case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
+ final float swipeHeight =
+ OverviewState.getDefaultSwipeHeight(mDeviceProfile);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
+ return response;
+ }
+
+ case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
+ final float swipeHeight =
+ LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
+ return response;
+ }
+ }
+
+ return super.call(method);
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/TestInformationProvider.java b/quickstep/src/com/android/quickstep/TestInformationProvider.java
deleted file mode 100644
index b37ddda..0000000
--- a/quickstep/src/com/android/quickstep/TestInformationProvider.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.quickstep;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-
-import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.InvariantDeviceProfile;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.LauncherState;
-import com.android.launcher3.TestProtocol;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.uioverrides.states.OverviewState;
-import com.android.quickstep.util.LayoutUtils;
-
-public class TestInformationProvider extends ContentProvider {
- @Override
- public boolean onCreate() {
- return true;
- }
-
- @Override
- public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
- return 0;
- }
-
- @Override
- public int delete(Uri uri, String s, String[] strings) {
- return 0;
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues contentValues) {
- return null;
- }
-
- @Override
- public String getType(Uri uri) {
- return null;
- }
-
- @Override
- public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
- return null;
- }
-
- @Override
- public Bundle call(String method, String arg, Bundle extras) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- final Bundle response = new Bundle();
- final Context context = getContext();
- final DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.
- get(context).getDeviceProfile(context);
- final LauncherAppState launcherAppState = LauncherAppState.getInstanceNoCreate();
- final Launcher launcher = launcherAppState != null ?
- (Launcher) launcherAppState.getModel().getCallback() : null;
-
- switch (method) {
- case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
- final float swipeHeight =
- OverviewState.getDefaultSwipeHeight(deviceProfile);
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
- break;
- }
-
- case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
- final float swipeHeight =
- LayoutUtils.getShelfTrackingDistance(context, deviceProfile);
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
- break;
- }
-
- case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
- if (launcher == null) return null;
-
- final float progress = LauncherState.OVERVIEW.getVerticalProgress(launcher)
- - LauncherState.ALL_APPS.getVerticalProgress(launcher);
- final float distance =
- launcher.getAllAppsController().getShiftRange() * progress;
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
- break;
- }
-
- case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: {
- if (launcher == null) return null;
-
- final float progress = LauncherState.NORMAL.getVerticalProgress(launcher)
- - LauncherState.ALL_APPS.getVerticalProgress(launcher);
- final float distance =
- launcher.getAllAppsController().getShiftRange() * progress;
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
- break;
- }
- }
- return response;
- }
- return null;
- }
-}
diff --git a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
index 5e20e56..c6f7544 100644
--- a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
+++ b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
@@ -70,6 +70,9 @@
AppLaunchTracker.INSTANCE.initializeForTesting(new AppLaunchTracker());
PredictionUiStateManager.INSTANCE.initializeForTesting(null);
+ waitForLauncherCondition("Prediction never had state update",
+ launcher -> PredictionUiStateManager.INSTANCE.get(
+ mTargetContext).mDebugHadStateUpdate);
mCallback = PredictionUiStateManager.INSTANCE.get(mTargetContext).appPredictorCallback(
Client.HOME);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index 43d6311..f02859f 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -127,7 +127,7 @@
assertNotNull("OverviewTask.open returned null", task.open());
assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(
By.pkg(getAppPackageName()).text("TestActivity2")),
- LONG_WAIT_TIME_MS));
+ DEFAULT_UI_TIMEOUT));
executeOnLauncher(launcher -> assertTrue(
"Launcher activity is the top activity; expecting another activity to be the top "
+ "one",
diff --git a/res/layout/floating_icon_view.xml b/res/layout/floating_icon_view.xml
new file mode 100644
index 0000000..240c486
--- /dev/null
+++ b/res/layout/floating_icon_view.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<com.android.launcher3.views.FloatingIconView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
diff --git a/res/values/config.xml b/res/values/config.xml
index 83aea8b..638a411 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -71,6 +71,7 @@
<string name="main_process_initializer_class" translatable="false"></string>
<string name="system_shortcut_factory_class" translatable="false"></string>
<string name="app_launch_tracker_class" translatable="false"></string>
+ <string name="test_information_handler_class" translatable="false"></string>
<!-- Package name of the default wallpaper picker. -->
<string name="wallpaper_picker_package" translatable="false"></string>
@@ -86,7 +87,6 @@
<!-- View IDs to store item highlight information -->
<item type="id" name="view_unhighlight_background" />
- <item type="id" name="view_highlighted" />
<!-- Menu id for feature flags -->
<item type="id" name="menu_apply_flags" />
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 7f72242..424ffde 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -36,6 +36,7 @@
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.SystemUiController;
+import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
import java.io.FileDescriptor;
@@ -102,6 +103,12 @@
// animation
@InvisibilityFlags private int mForceInvisible;
+ private final ViewCache mViewCache = new ViewCache();
+
+ public ViewCache getViewCache() {
+ return mViewCache;
+ }
+
@Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index ccd9e25..f69b172 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -34,6 +34,7 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.shortcuts.DeepShortcutManager;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.Themes;
@@ -134,6 +135,10 @@
public boolean startActivitySafely(View v, Intent intent, @Nullable ItemInfo item,
@Nullable String sourceContainer) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "startActivitySafely 1");
+ }
if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
return false;
@@ -157,6 +162,10 @@
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
} else if (user == null || user.equals(Process.myUserHandle())) {
// Could be launching some bookkeeping activity
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "startActivitySafely 2");
+ }
startActivity(intent, optsBundle);
AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(),
Process.myUserHandle(), sourceContainer);
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index bff7f42..2f801e0 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -51,7 +51,6 @@
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.IconCache.IconLoadRequest;
import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver;
-import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.views.ActivityContext;
@@ -561,7 +560,10 @@
}
}
if (itemInfo.contentDescription != null) {
- if (hasDot()) {
+ if (itemInfo.isDisabled()) {
+ setContentDescription(getContext().getString(R.string.disabled_app_label,
+ itemInfo.contentDescription));
+ } else if (hasDot()) {
int count = mDotInfo.getNotificationCount();
setContentDescription(getContext().getResources().getQuantityString(
R.plurals.dotted_app_label, count, itemInfo.contentDescription, count));
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 40eb912..7790475 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -110,6 +110,7 @@
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.states.InternalStateHandler;
import com.android.launcher3.states.RotationHelper;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -1782,6 +1783,10 @@
public boolean startActivitySafely(View v, Intent intent, ItemInfo item,
@Nullable String sourceContainer) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "startActivitySafely outer");
+ }
boolean success = super.startActivitySafely(v, intent, item, sourceContainer);
if (success && v instanceof BubbleTextView) {
// This is set to the view that launched the activity that navigated the user away
@@ -2549,4 +2554,8 @@
void onLauncherResume();
}
+
+ public boolean debugIsPredictionInitialized() {
+ return true;
+ }
}
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index eff58a7..3a92dfb 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -18,13 +18,13 @@
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
-import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.NORMAL_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index b1a3fc9..3edd838 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -48,6 +48,7 @@
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.PropertySetter.AnimatedPropertySetter;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.uioverrides.UiFactory;
import java.io.PrintWriter;
@@ -447,6 +448,10 @@
}
private void onStateTransitionStart(LauncherState state) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "onStateTransitionStart");
+ }
if (mState != state) {
mState.onStateDisabled(mLauncher);
}
@@ -572,6 +577,10 @@
private final AnimatorSet mAnim;
public StartAnimRunnable(AnimatorSet anim) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "StartAnimRunnable");
+ }
mAnim = anim;
}
diff --git a/src/com/android/launcher3/ResourceUtils.java b/src/com/android/launcher3/ResourceUtils.java
index 0c80d13..73e705b 100644
--- a/src/com/android/launcher3/ResourceUtils.java
+++ b/src/com/android/launcher3/ResourceUtils.java
@@ -21,10 +21,9 @@
import android.util.TypedValue;
public class ResourceUtils {
- public static final String NAVBAR_PORTRAIT_BOTTOM_SIZE = "navigation_bar_frame_height";
public static final String NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE = "navigation_bar_width";
- public static final String NAVBAR_LANDSCAPE_BOTTOM_SIZE
- = "navigation_bar_frame_height_landscape";
+ public static final String NAVBAR_BOTTOM_GESTURE_SIZE = "navigation_bar_gesture_height";
+
public static int getNavbarSize(String resName, Resources res) {
return getDimenByName(resName, res, 48);
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 796fd25..cc9bda7 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -61,6 +61,7 @@
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.animation.Interpolator;
import com.android.launcher3.compat.LauncherAppsCompat;
@@ -726,6 +727,15 @@
return str.toString();
}
+ public static float squaredHypot(float x, float y) {
+ return x * x + y * y;
+ }
+
+ public static float squaredTouchSlop(Context context) {
+ float slop = ViewConfiguration.get(context).getScaledTouchSlop();
+ return slop * slop;
+ }
+
private static class FixedSizeEmptyDrawable extends ColorDrawable {
private final int mSize;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index a508ce5..f784226 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -20,8 +20,6 @@
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
-import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
-import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
@@ -86,6 +84,7 @@
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.WorkspaceTouchListener;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -371,6 +370,10 @@
@Override
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "onDragStart 1");
+ }
if (ENFORCE_DRAG_EVENT_ORDER) {
enforceDragParity("onDragStart", 0, 0);
}
@@ -421,6 +424,10 @@
}
// Always enter the spring loaded mode
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "onDragStart 2");
+ }
mLauncher.getStateManager().goToState(SPRING_LOADED);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 0db563f..053c570 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -42,8 +42,9 @@
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
@@ -194,11 +195,18 @@
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
+
+ // The AllAppsContainerView houses the QSB and is hence visible from the Workspace
+ // Overview states. We shouldn't intercept for the scrubber in these cases.
+ if (!mLauncher.isInState(LauncherState.ALL_APPS)) return false;
+
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv != null &&
rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(), mFastScrollerOffset)) {
mTouchHandler = rv.getScrollbar();
+ } else {
+ mTouchHandler = null;
}
}
if (mTouchHandler != null) {
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 86f773f..8e59d32 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -23,7 +23,7 @@
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.Utilities;
import java.util.function.Consumer;
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 7e20d11..54d0db1 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -105,7 +105,7 @@
"ENABLE_QUICKSTEP_LIVE_TILE", false, "Enable live tile in Quickstep overview");
public static final TogglableFlag ENABLE_HINTS_IN_OVERVIEW = new TogglableFlag(
- "ENABLE_HINTS_IN_OVERVIEW", false,
+ "ENABLE_HINTS_IN_OVERVIEW", true,
"Show chip hints and gleams on the overview screen");
public static final TogglableFlag FAKE_LANDSCAPE_UI = new TogglableFlag(
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index f92e00a..9d3c8f7 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -41,6 +41,7 @@
import com.android.launcher3.R;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TouchController;
@@ -472,6 +473,10 @@
}
private void handleMoveEvent(int x, int y) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "handleMoveEvent 1");
+ }
mDragObject.dragView.move(x, y);
// Drop on someone?
@@ -488,6 +493,10 @@
if (mIsInPreDrag && mOptions.preDragCondition != null
&& mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "handleMoveEvent 2");
+ }
callOnDragStart();
}
}
@@ -525,6 +534,10 @@
* Call this from a drag source view.
*/
public boolean onControllerTouchEvent(MotionEvent ev) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "onControllerTouchEvent");
+ }
if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) {
return false;
}
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index 7af12c5..9d46cf2 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -44,7 +44,6 @@
import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
@@ -55,6 +54,7 @@
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.UiThreadHelper;
import java.util.Arrays;
@@ -210,8 +210,7 @@
return;
}
// Load the adaptive icon on a background thread and add the view in ui thread.
- final Looper workerLooper = LauncherModel.getWorkerLooper();
- new Handler(workerLooper).postAtFrontOfQueue(new Runnable() {
+ new Handler(UiThreadHelper.getBackgroundLooper()).postAtFrontOfQueue(new Runnable() {
@Override
public void run() {
Object[] outObj = new Object[1];
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 0a9bc72..250169c 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -102,7 +102,6 @@
private List<BubbleTextView> mCurrentPreviewItems = new ArrayList<>();
boolean mAnimating = false;
- private Rect mTempBounds = new Rect();
private float mSlop;
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 047f486..7b14fa2 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -16,6 +16,8 @@
package com.android.launcher3.popup;
+import static com.android.launcher3.Utilities.squaredHypot;
+import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.notification.NotificationMainView.NOTIFICATION_ITEM_INFO;
import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS;
import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS_IF_NOTIFICATIONS;
@@ -37,7 +39,6 @@
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -51,6 +52,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
import com.android.launcher3.dot.DotInfo;
@@ -136,8 +138,8 @@
return true;
}
// Stop sending touch events to deep shortcut views if user moved beyond touch slop.
- return Math.hypot(mInterceptTouchDown.x - ev.getX(), mInterceptTouchDown.y - ev.getY())
- > ViewConfiguration.get(getContext()).getScaledTouchSlop();
+ return squaredHypot(mInterceptTouchDown.x - ev.getX(), mInterceptTouchDown.y - ev.getY())
+ > squaredTouchSlop(getContext());
}
@Override
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
new file mode 100644
index 0000000..b8476aa
--- /dev/null
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.testing;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
+import com.android.launcher3.util.ResourceBasedOverride;
+
+public class TestInformationHandler implements ResourceBasedOverride {
+
+ public static TestInformationHandler newInstance(Context context) {
+ return Overrides.getObject(TestInformationHandler.class,
+ context, R.string.test_information_handler_class);
+ }
+
+ protected Context mContext;
+ protected DeviceProfile mDeviceProfile;
+ protected LauncherAppState mLauncherAppState;
+ protected Launcher mLauncher;
+
+ public void init(Context context) {
+ mContext = context;
+ mDeviceProfile = InvariantDeviceProfile.INSTANCE.
+ get(context).getDeviceProfile(context);
+ mLauncherAppState = LauncherAppState.getInstanceNoCreate();
+ mLauncher = mLauncherAppState != null ?
+ (Launcher) mLauncherAppState.getModel().getCallback() : null;
+ }
+
+ public Bundle call(String method) {
+ final Bundle response = new Bundle();
+ switch (method) {
+ case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
+ if (mLauncher == null) return null;
+
+ final float progress = LauncherState.OVERVIEW.getVerticalProgress(mLauncher)
+ - LauncherState.ALL_APPS.getVerticalProgress(mLauncher);
+ final float distance = mLauncher.getAllAppsController().getShiftRange() * progress;
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
+ break;
+ }
+
+ case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: {
+ if (mLauncher == null) return null;
+
+ final float progress = LauncherState.NORMAL.getVerticalProgress(mLauncher)
+ - LauncherState.ALL_APPS.getVerticalProgress(mLauncher);
+ final float distance = mLauncher.getAllAppsController().getShiftRange() * progress;
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
+ break;
+ }
+
+ case TestProtocol.REQUEST_ENABLE_DEBUG_TRACING:
+ TestProtocol.sDebugTracing = true;
+ break;
+
+ case TestProtocol.REQUEST_DISABLE_DEBUG_TRACING:
+ TestProtocol.sDebugTracing = false;
+ break;
+ }
+ return response;
+ }
+}
diff --git a/src/com/android/launcher3/testing/TestInformationProvider.java b/src/com/android/launcher3/testing/TestInformationProvider.java
new file mode 100644
index 0000000..bd177c0
--- /dev/null
+++ b/src/com/android/launcher3/testing/TestInformationProvider.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.testing;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.android.launcher3.Utilities;
+
+public class TestInformationProvider extends ContentProvider {
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
+ return 0;
+ }
+
+ @Override
+ public int delete(Uri uri, String s, String[] strings) {
+ return 0;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues contentValues) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
+ return null;
+ }
+
+ @Override
+ public Bundle call(String method, String arg, Bundle extras) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
+ TestInformationHandler handler = TestInformationHandler.newInstance(getContext());
+ handler.init(getContext());
+ return handler.call(method);
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
similarity index 87%
rename from src/com/android/launcher3/TestProtocol.java
rename to src/com/android/launcher3/testing/TestProtocol.java
index eefecda..9fd44a1 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher3;
+package com.android.launcher3.testing;
/**
* Protocol for custom accessibility events for communication with UI Automation tests.
@@ -64,4 +64,9 @@
"all-apps-to-overview-swipe-height";
public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT =
"home-to-all-apps-swipe-height";
+ public static boolean sDebugTracing = false;
+ public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
+ public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing";
+ public static final String NO_DRAG_TAG = "b/133009122";
+ public static final String NO_START_TAG = "b/132900132";
}
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index 0650001..f858dc4 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -47,6 +47,7 @@
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.widget.PendingAppWidgetHostView;
import com.android.launcher3.widget.WidgetAddFlowHandler;
@@ -66,14 +67,26 @@
}
private static void onClick(View v, String sourceContainer) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "onClick 1");
+ }
// Make sure that rogue clicks don't get through while allapps is launching, or after the
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "onClick 2");
+ }
return;
}
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!launcher.getWorkspace().isFinishedSwitchingState()) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "onClick 3");
+ }
return;
}
@@ -85,6 +98,10 @@
onClickFolderIcon(v);
}
} else if (tag instanceof AppInfo) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "onClick 4");
+ }
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher,
sourceContainer == null ? CONTAINER_ALL_APPS: sourceContainer);
} else if (tag instanceof LauncherAppWidgetInfo) {
@@ -216,6 +233,10 @@
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher,
@Nullable String sourceContainer) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
+ "startAppShortcutOrInfoActivity");
+ }
Intent intent;
if (item instanceof PromiseAppInfo) {
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
diff --git a/src/com/android/launcher3/util/ViewCache.java b/src/com/android/launcher3/util/ViewCache.java
new file mode 100644
index 0000000..08b8744
--- /dev/null
+++ b/src/com/android/launcher3/util/ViewCache.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.util;
+
+import android.content.Context;
+import android.util.SparseArray;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * Utility class to cache views at an activity level
+ */
+public class ViewCache {
+
+ protected final SparseArray<CacheEntry> mCache = new SparseArray();
+
+ public void setCacheSize(int layoutId, int size) {
+ mCache.put(layoutId, new CacheEntry(size));
+ }
+
+ public <T extends View> T getView(int layoutId, Context context, ViewGroup parent) {
+ CacheEntry entry = mCache.get(layoutId);
+ if (entry == null) {
+ entry = new CacheEntry(1);
+ mCache.put(layoutId, entry);
+ }
+
+ if (entry.mCurrentSize > 0) {
+ entry.mCurrentSize --;
+ T result = (T) entry.mViews[entry.mCurrentSize];
+ entry.mViews[entry.mCurrentSize] = null;
+ return result;
+ }
+
+ return (T) LayoutInflater.from(context).inflate(layoutId, parent, false);
+ }
+
+ public void recycleView(int layoutId, View view) {
+ CacheEntry entry = mCache.get(layoutId);
+ if (entry != null && entry.mCurrentSize < entry.mMaxSize) {
+ entry.mViews[entry.mCurrentSize] = view;
+ entry.mCurrentSize++;
+ }
+ }
+
+ private static class CacheEntry {
+
+ final int mMaxSize;
+ final View[] mViews;
+
+ int mCurrentSize;
+
+ public CacheEntry(int maxSize) {
+ mMaxSize = maxSize;
+ mViews = new View[maxSize];
+ mCurrentSize = 0;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java
index bcf299f..939b0f2 100644
--- a/src/com/android/launcher3/views/BaseDragLayer.java
+++ b/src/com/android/launcher3/views/BaseDragLayer.java
@@ -41,6 +41,7 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.Utilities;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.TouchController;
@@ -213,6 +214,10 @@
@Override
public boolean onTouchEvent(MotionEvent ev) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "onTouchEvent " + ev);
+ }
int action = ev.getAction();
if (action == ACTION_UP || action == ACTION_CANCEL) {
if (mTouchCompleteListener != null) {
@@ -222,6 +227,10 @@
}
if (mActiveController != null) {
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
+ "onTouchEvent 1");
+ }
return mActiveController.onControllerTouchEvent(ev);
} else {
// In case no child view handled the touch event, we may not get onIntercept anymore
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index a9e8f17..f63bcdd 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -27,6 +27,7 @@
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
+import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Outline;
@@ -40,6 +41,7 @@
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
+import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
@@ -61,6 +63,7 @@
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.shortcuts.DeepShortcutView;
+import com.android.launcher3.util.UiThreadHelper;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
@@ -148,12 +151,20 @@
private final SpringAnimation mFgSpringX;
private float mFgTransX;
- private FloatingIconView(Launcher launcher) {
- super(launcher);
- mLauncher = launcher;
+ public FloatingIconView(Context context) {
+ this(context, null);
+ }
+
+ public FloatingIconView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public FloatingIconView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ mLauncher = Launcher.getLauncher(context);
mBlurSizeOutline = getResources().getDimensionPixelSize(
R.dimen.blur_size_medium_outline);
- mListenerView = new ListenerView(launcher, null);
+ mListenerView = new ListenerView(context, attrs);
mFgSpringX = new SpringAnimation(this, mFgTransXProperty)
.setSpring(new SpringForce()
@@ -350,6 +361,7 @@
}
@WorkerThread
+ @SuppressWarnings("WrongThread")
private void getIcon(View v, ItemInfo info, boolean isOpening,
Runnable onIconLoadedRunnable, CancellationSignal loadIconSignal) {
final LayoutParams lp = (LayoutParams) getLayoutParams();
@@ -396,7 +408,7 @@
&& finalDrawable instanceof AdaptiveIconDrawable;
int iconOffset = getOffsetForIconBounds(finalDrawable);
- new Handler(Looper.getMainLooper()).post(() -> {
+ mLauncher.getMainExecutor().execute(() -> {
if (isAdaptiveIcon) {
mIsAdaptiveIcon = true;
boolean isFolderIcon = finalDrawable instanceof FolderAdaptiveIcon;
@@ -481,6 +493,7 @@
setClipToOutline(true);
} else {
setBackground(finalDrawable);
+ setClipToOutline(false);
}
if (!loadIconSignal.isCanceled()) {
@@ -504,6 +517,7 @@
}
@WorkerThread
+ @SuppressWarnings("WrongThread")
private int getOffsetForIconBounds(Drawable drawable) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ||
!(drawable instanceof AdaptiveIconDrawable)) {
@@ -514,7 +528,7 @@
Rect bounds = new Rect(0, 0, lp.width + mBlurSizeOutline, lp.height + mBlurSizeOutline);
bounds.inset(mBlurSizeOutline / 2, mBlurSizeOutline / 2);
- try (LauncherIcons li = LauncherIcons.obtain(getContext())) {
+ try (LauncherIcons li = LauncherIcons.obtain(mLauncher)) {
Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(drawable, null));
}
@@ -603,11 +617,14 @@
* @param isOpening True if this view replaces the icon for app open animation.
*/
public static FloatingIconView getFloatingIconView(Launcher launcher, View originalView,
- boolean hideOriginal, RectF positionOut, boolean isOpening, FloatingIconView recycle) {
- if (recycle != null) {
- recycle.recycle();
- }
- FloatingIconView view = recycle != null ? recycle : new FloatingIconView(launcher);
+ boolean hideOriginal, RectF positionOut, boolean isOpening) {
+ final DragLayer dragLayer = launcher.getDragLayer();
+ ViewGroup parent = (ViewGroup) dragLayer.getParent();
+
+ FloatingIconView view = launcher.getViewCache().getView(R.layout.floating_icon_view,
+ launcher, parent);
+ view.recycle();
+
view.mIsVerticalBarLayout = launcher.getDeviceProfile().isVerticalBarLayout();
view.mOriginalIcon = originalView;
@@ -625,16 +642,15 @@
originalView.setVisibility(INVISIBLE);
};
CancellationSignal loadIconSignal = view.mLoadIconSignal;
- new Handler(LauncherModel.getWorkerLooper()).postAtFrontOfQueue(() -> {
+ new Handler(UiThreadHelper.getBackgroundLooper()).postAtFrontOfQueue(() -> {
view.getIcon(originalView, (ItemInfo) originalView.getTag(), isOpening,
onIconLoaded, loadIconSignal);
});
}
// We need to add it to the overlay, but keep it invisible until animation starts..
- final DragLayer dragLayer = launcher.getDragLayer();
view.setVisibility(INVISIBLE);
- ((ViewGroup) dragLayer.getParent()).addView(view);
+ parent.addView(view);
dragLayer.addView(view.mListenerView);
view.mListenerView.setListener(view::onListenerViewClosed);
@@ -713,6 +729,7 @@
((ViewGroup) dragLayer.getParent()).removeView(this);
dragLayer.removeView(mListenerView);
recycle();
+ mLauncher.getViewCache().recycleView(R.layout.floating_icon_view, this);
}
private void recycle() {
@@ -751,5 +768,6 @@
mFgTransX = 0;
mFgSpringY.cancel();
mBadge = null;
+ sTmpObjArray[0] = null;
}
}
diff --git a/tests/Android.mk b/tests/Android.mk
index 0991a04..978209f 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -32,7 +32,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
../src/com/android/launcher3/ResourceUtils.java \
../src/com/android/launcher3/util/SecureSettingsObserver.java \
- ../src/com/android/launcher3/TestProtocol.java
+ ../src/com/android/launcher3/testing/TestProtocol.java
endif
LOCAL_MODULE := ub-launcher-aosp-tapl
diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml
index 75ff66e..61c7306 100644
--- a/tests/AndroidManifest-common.xml
+++ b/tests/AndroidManifest-common.xml
@@ -184,5 +184,13 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
+ <activity-alias android:name="Activity11"
+ android:label="TestActivity11"
+ android:targetActivity="com.android.launcher3.testcomponent.BaseTestingActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity-alias>
</application>
</manifest>
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 74cece8..a19857c 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -91,7 +91,6 @@
public static final long SHORT_UI_TIMEOUT = 300;
public static final long DEFAULT_UI_TIMEOUT = 10000;
- protected static final int LONG_WAIT_TIME_MS = 60000;
private static final String TAG = "AbstractLauncherUiTest";
private static int sScreenshotCount = 0;
@@ -243,7 +242,7 @@
*/
protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) {
final int margin = ResourceUtils.getNavbarSize(
- ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE, mLauncher.getResources()) + 1;
+ ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
container.setGestureMargins(0, 0, 0, margin);
int i = 0;
@@ -394,7 +393,7 @@
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
instrumentation.getTargetContext().startActivity(intent);
assertTrue(packageName + " didn't start",
- mDevice.wait(Until.hasObject(By.pkg(packageName).depth(0)), LONG_WAIT_TIME_MS));
+ mDevice.wait(Until.hasObject(By.pkg(packageName).depth(0)), DEFAULT_UI_TIMEOUT));
}
protected void startTestActivity(int activityNumber) {
@@ -410,7 +409,7 @@
assertTrue(packageName + " didn't start",
mDevice.wait(
Until.hasObject(By.pkg(packageName).text("TestActivity" + activityNumber)),
- LONG_WAIT_TIME_MS));
+ DEFAULT_UI_TIMEOUT));
}
protected static String resolveSystemApp(String category) {
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index d4cfe3a..d0ea142 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -64,6 +64,8 @@
test.mDevice.pressHome();
}
test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
+ test.waitForLauncherCondition("Prediction never had state update",
+ launcher -> launcher.debugIsPredictionInitialized());
test.waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
test.waitForResumed("Launcher internal state is still Background");
// Check that we switched to home.
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index 096a1d8..18a8f27 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -18,6 +18,7 @@
import static com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel.ZERO_BUTTON;
+import android.graphics.Point;
import android.graphics.Rect;
import androidx.annotation.NonNull;
@@ -26,7 +27,7 @@
import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.ResourceUtils;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
/**
* Operations on AllApps opened from Home. Also a parent for All Apps opened from Overview.
@@ -48,12 +49,34 @@
return LauncherInstrumentation.ContainerType.ALL_APPS;
}
- private boolean hasClickableIcon(UiObject2 allAppsContainer, BySelector appIconSelector) {
- final UiObject2 icon = allAppsContainer.findObject(appIconSelector);
- if (icon == null) return false;
- if (mLauncher.getNavigationModel() == ZERO_BUTTON) return true;
- final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
- return icon.getVisibleBounds().bottom < navBar.getVisibleBounds().top;
+ private boolean hasClickableIcon(
+ UiObject2 allAppsContainer, UiObject2 appListRecycler, BySelector appIconSelector) {
+ final UiObject2 icon = appListRecycler.findObject(appIconSelector);
+ if (icon == null) {
+ LauncherInstrumentation.log("hasClickableIcon: icon not visible");
+ return false;
+ }
+ final Rect iconBounds = icon.getVisibleBounds();
+ LauncherInstrumentation.log("hasClickableIcon: icon bounds: " + iconBounds);
+ if (mLauncher.getNavigationModel() != ZERO_BUTTON) {
+ final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
+ if (iconBounds.bottom >= navBar.getVisibleBounds().top) {
+ LauncherInstrumentation.log("hasClickableIcon: icon intersects with nav bar");
+ return false;
+ }
+ }
+ if (iconCenterInSearchBox(allAppsContainer, icon)) {
+ LauncherInstrumentation.log("hasClickableIcon: icon center is under search box");
+ return false;
+ }
+ LauncherInstrumentation.log("hasClickableIcon: icon is clickable");
+ return true;
+ }
+
+ private boolean iconCenterInSearchBox(UiObject2 allAppsContainer, UiObject2 icon) {
+ final Point iconCenter = icon.getVisibleCenter();
+ return getSearchBox(allAppsContainer).getVisibleBounds().contains(
+ iconCenter.x, iconCenter.y);
}
/**
@@ -66,17 +89,22 @@
@NonNull
public AppIcon getAppIcon(String appName) {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
- "want to get app icon on all apps")) {
+ "want to get app icon " + appName + " on all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
- allAppsContainer.setGestureMargins(0, 0, 0,
- ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE,
+ final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
+ "apps_list_view");
+ allAppsContainer.setGestureMargins(
+ 0,
+ getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1,
+ 0,
+ ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
mLauncher.getResources()) + 1);
final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
- if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
+ if (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
scrollBackToBeginning();
int attempts = 0;
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
- while (!hasClickableIcon(allAppsContainer, appIconSelector) &&
+ while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector) &&
allAppsContainer.scroll(Direction.DOWN, 0.8f)) {
mLauncher.assertTrue(
"Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS,
@@ -89,7 +117,7 @@
final UiObject2 appIcon = mLauncher.getObjectInContainer(allAppsContainer,
appIconSelector);
- ensureIconVisible(appIcon, allAppsContainer);
+ ensureIconVisible(appIcon, allAppsContainer, appListRecycler);
return new AppIcon(mLauncher, appIcon);
}
}
@@ -97,10 +125,9 @@
private void scrollBackToBeginning() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to scroll back in all apps")) {
+ LauncherInstrumentation.log("Scrolling to the beginning");
final UiObject2 allAppsContainer = verifyActiveContainer();
- final UiObject2 searchBox =
- mLauncher.waitForObjectInContainer(allAppsContainer,
- "search_container_all_apps");
+ final UiObject2 searchBox = getSearchBox(allAppsContainer);
int attempts = 0;
final Rect margins = new Rect(0, searchBox.getVisibleBounds().bottom + 1, 0, 5);
@@ -128,19 +155,26 @@
getInt(TestProtocol.SCROLL_Y_FIELD, -1);
}
- private void ensureIconVisible(UiObject2 appIcon, UiObject2 allAppsContainer) {
+ private void ensureIconVisible(
+ UiObject2 appIcon, UiObject2 allAppsContainer, UiObject2 appListRecycler) {
final int appHeight = appIcon.getVisibleBounds().height();
if (appHeight < MIN_INTERACT_SIZE) {
// Try to figure out how much percentage of the container needs to be scrolled in order
// to reveal the app icon to have the MIN_INTERACT_SIZE
final float pct = Math.max(((float) (MIN_INTERACT_SIZE - appHeight)) / mHeight, 0.2f);
- mLauncher.scroll(allAppsContainer, Direction.DOWN, pct, null, 10);
+ mLauncher.scroll(appListRecycler, Direction.DOWN, pct, null, 10);
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"scrolled an icon in all apps to make it visible - and then")) {
mLauncher.waitForIdle();
verifyActiveContainer();
}
}
+ mLauncher.assertTrue("Couldn't scroll app icon to not intersect with the search box",
+ !iconCenterInSearchBox(allAppsContainer, appIcon));
+ }
+
+ private UiObject2 getSearchBox(UiObject2 allAppsContainer) {
+ return mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps");
}
/**
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
index c3b671b..f48d4dd 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllAppsFromOverview.java
@@ -16,14 +16,14 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
import android.graphics.Point;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
/**
* Operations on AllApps opened from Overview.
@@ -53,9 +53,9 @@
TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT).
getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
- final int endY = start.y + swipeHeight + mLauncher.getTouchSlop();
+ final int endY = start.y + swipeHeight;
LauncherInstrumentation.log("AllAppsFromOverview.switchBackToOverview before swipe");
- mLauncher.swipe(start.x, start.y, start.x, endY, OVERVIEW_STATE_ORDINAL);
+ mLauncher.swipeToState(start.x, start.y, start.x, endY, 60, OVERVIEW_STATE_ORDINAL);
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("swiped down")) {
return new Overview(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 8f5e7fe..8627f48 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -16,7 +16,7 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import android.graphics.Point;
import android.os.SystemClock;
@@ -24,7 +24,7 @@
import androidx.annotation.NonNull;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
/**
* Indicates the base state with a UI other than Overview running as foreground. It can also
@@ -86,9 +86,10 @@
final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).
getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
- mLauncher.swipe(
+ mLauncher.swipeToState(
centerX, startY, centerX,
startY - swipeHeight - mLauncher.getTouchSlop(),
+ 60,
expectedState);
break;
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java
index 20c116c..cfc4374 100644
--- a/tests/tapl/com/android/launcher3/tapl/Home.java
+++ b/tests/tapl/com/android/launcher3/tapl/Home.java
@@ -16,7 +16,7 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
import androidx.annotation.NonNull;
diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java
index 1b372ec..ee90d37 100644
--- a/tests/tapl/com/android/launcher3/tapl/Launchable.java
+++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java
@@ -24,6 +24,8 @@
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
+import com.android.launcher3.testing.TestProtocol;
+
/**
* Ancestor for AppIcon and AppMenuItem.
*/
@@ -51,9 +53,11 @@
private Background launch(BySelector selector) {
LauncherInstrumentation.log("Launchable.launch before click " +
mObject.getVisibleCenter());
+ mLauncher.getTestInfo(TestProtocol.REQUEST_ENABLE_DEBUG_TRACING);
mLauncher.assertTrue(
"Launching an app didn't open a new window: " + mObject.getText(),
mObject.clickAndWait(Until.newWindow(), LauncherInstrumentation.WAIT_TIME_MS));
+ mLauncher.getTestInfo(TestProtocol.REQUEST_DISABLE_DEBUG_TRACING);
mLauncher.assertTrue(
"App didn't start: " + selector,
mLauncher.getDevice().wait(Until.hasObject(selector),
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 57fd4b9..8d69b37 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -16,16 +16,23 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+import static android.content.pm.PackageManager.DONT_KILL_APP;
+import static android.content.pm.PackageManager.MATCH_ALL;
+import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
+
+import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.NORMAL_STATE_ORDINAL;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.UiAutomation;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.pm.ProviderInfo;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
@@ -53,7 +60,7 @@
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
import com.android.systemui.shared.system.QuickStepContract;
import org.junit.Assert;
@@ -115,7 +122,7 @@
private static final String APPS_RES_ID = "apps_view";
private static final String OVERVIEW_RES_ID = "overview_panel";
private static final String WIDGETS_RES_ID = "widgets_list_view";
- public static final int WAIT_TIME_MS = 60000;
+ public static final int WAIT_TIME_MS = 10000;
private static final String SYSTEMUI_PACKAGE = "com.android.systemui";
private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);
@@ -149,9 +156,10 @@
getLauncherPackageName() :
targetPackage;
+ String testProviderAuthority = authorityPackage + ".TestInfo";
mTestProviderUri = new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
- .authority(authorityPackage + ".TestInfo")
+ .authority(testProviderAuthority)
.build();
try {
@@ -160,6 +168,25 @@
} catch (IOException e) {
fail(e.toString());
}
+
+
+ PackageManager pm = getContext().getPackageManager();
+ ProviderInfo pi = pm.resolveContentProvider(
+ testProviderAuthority, MATCH_ALL | MATCH_DISABLED_COMPONENTS);
+ ComponentName cn = new ComponentName(pi.packageName, pi.name);
+
+ if (pm.getComponentEnabledSetting(cn) != COMPONENT_ENABLED_STATE_ENABLED) {
+ if (TestHelpers.isInLauncherProcess()) {
+ getContext().getPackageManager().setComponentEnabledSetting(
+ cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
+ } else {
+ try {
+ mDevice.executeShellCommand("pm enable " + cn.flattenToString());
+ } catch (IOException e) {
+ fail(e.toString());
+ }
+ }
+ }
}
Context getContext() {
@@ -541,25 +568,22 @@
@NonNull
UiObject2 waitForLauncherObject(String resName) {
- final BySelector selector = getLauncherObjectSelector(resName);
- final UiObject2 object = mDevice.wait(Until.findObject(selector), WAIT_TIME_MS);
- assertNotNull("Can't find a launcher object; selector: " + selector, object);
- return object;
+ return waitForObjectBySelector(getLauncherObjectSelector(resName));
}
@NonNull
UiObject2 waitForLauncherObjectByClass(String clazz) {
- final BySelector selector = getLauncherObjectSelectorByClass(clazz);
- final UiObject2 object = mDevice.wait(Until.findObject(selector), WAIT_TIME_MS);
- assertNotNull("Can't find a launcher object; selector: " + selector, object);
- return object;
+ return waitForObjectBySelector(getLauncherObjectSelectorByClass(clazz));
}
@NonNull
UiObject2 waitForFallbackLauncherObject(String resName) {
- final BySelector selector = getFallbackLauncherObjectSelector(resName);
+ return waitForObjectBySelector(getFallbackLauncherObjectSelector(resName));
+ }
+
+ private UiObject2 waitForObjectBySelector(BySelector selector) {
final UiObject2 object = mDevice.wait(Until.findObject(selector), WAIT_TIME_MS);
- assertNotNull("Can't find a fallback launcher object; selector: " + selector, object);
+ assertNotNull("Can't find a launcher object; selector: " + selector, object);
return object;
}
@@ -584,18 +608,15 @@
return mDevice;
}
- void swipe(int startX, int startY, int endX, int endY, int expectedState) {
- swipe(startX, startY, endX, endY, expectedState, 60);
- }
-
- 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 swipeToState(int startX, int startY, int endX, int endY, int steps, int expectedState) {
- changeStateViaGesture(startX, startY, endX, endY, expectedState,
- () -> linearGesture(startX, startY, endX, endY, steps));
+ final Bundle parcel = (Bundle) executeAndWaitForEvent(
+ () -> linearGesture(startX, startY, endX, endY, steps),
+ event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
+ "Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+ + ", " + endX + ", " + endY);
+ assertEquals("Swipe switched launcher to a wrong state;",
+ TestProtocol.stateOrdinalToString(expectedState),
+ TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
}
void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
@@ -652,18 +673,6 @@
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(
- gesture,
- event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
- "Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
- + ", " + endX + ", " + endY);
- assertEquals("Swipe switched launcher to a wrong state;",
- TestProtocol.stateOrdinalToString(expectedState),
- TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
- }
-
void waitForIdle() {
mDevice.waitForIdle();
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Overview.java b/tests/tapl/com/android/launcher3/tapl/Overview.java
index ec99d26..1aa957a 100644
--- a/tests/tapl/com/android/launcher3/tapl/Overview.java
+++ b/tests/tapl/com/android/launcher3/tapl/Overview.java
@@ -16,7 +16,7 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index b780df4..94003be 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -41,7 +41,7 @@
LauncherInstrumentation.log("Widgets.flingForward enter");
final UiObject2 widgetsContainer = verifyActiveContainer();
widgetsContainer.setGestureMargins(0, 0, 0,
- ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_PORTRAIT_BOTTOM_SIZE,
+ ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
mLauncher.getResources()) + 1);
widgetsContainer.fling(Direction.DOWN,
(int) (FLING_SPEED * mLauncher.getDisplayDensity()));
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 11c0794..7dcc426 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -16,7 +16,7 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
import static junit.framework.TestCase.assertTrue;
@@ -30,7 +30,7 @@
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
/**
* Operations on the workspace screen.
@@ -148,6 +148,7 @@
static void dragIconToWorkspace(
LauncherInstrumentation launcher, Launchable launchable, Point dest,
String longPressIndicator) {
+ launcher.getTestInfo(TestProtocol.REQUEST_ENABLE_DEBUG_TRACING);
LauncherInstrumentation.log("dragIconToWorkspace: begin");
final Point launchableCenter = launchable.getObject().getVisibleCenter();
final long downTime = SystemClock.uptimeMillis();
@@ -162,6 +163,7 @@
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest);
LauncherInstrumentation.log("dragIconToWorkspace: end");
launcher.waitUntilGone("drop_target_bar");
+ launcher.getTestInfo(TestProtocol.REQUEST_DISABLE_DEBUG_TRACING);
}
/**