Snap for 5342135 from 57920a8087 to qt-release

Change-Id: Ie81274ec8abecf589aa94371510ac59247d9ef8a
This commit is contained in:
android-build-team Robot
2019-02-28 04:08:27 +00:00
9 changed files with 91 additions and 56 deletions
Binary file not shown.
@@ -17,15 +17,13 @@ package com.android.quickstep;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import java.util.function.Consumer;
@TargetApi(Build.VERSION_CODES.O)
@FunctionalInterface
public interface TouchConsumer extends Consumer<MotionEvent> {
TouchConsumer NO_OP = (ev) -> {};
public interface InputConsumer {
InputConsumer NO_OP = new InputConsumer() { };
default boolean isActive() {
return false;
@@ -35,4 +33,16 @@ public interface TouchConsumer extends Consumer<MotionEvent> {
* Called by the event queue when the consumer is about to be switched to a new consumer.
*/
default void onConsumerAboutToBeSwitched() { }
default void onMotionEvent(MotionEvent ev) { }
default void onKeyEvent(KeyEvent ev) { }
default void onInputEvent(InputEvent ev) {
if (ev instanceof MotionEvent) {
onMotionEvent((MotionEvent) ev);
} else {
onKeyEvent((KeyEvent) ev);
}
}
}
@@ -62,13 +62,13 @@ import com.android.systemui.shared.system.WindowManagerWrapper;
import java.util.function.Consumer;
/**
* Touch consumer for handling events originating from an activity other than Launcher
* Input consumer for handling events originating from an activity other than Launcher
*/
@TargetApi(Build.VERSION_CODES.P)
public class OtherActivityTouchConsumer extends ContextWrapper implements TouchConsumer {
public class OtherActivityInputConsumer extends ContextWrapper implements InputConsumer {
public static final String DOWN_EVT = "OtherActivityTouchConsumer.DOWN";
private static final String UP_EVT = "OtherActivityTouchConsumer.UP";
public static final String DOWN_EVT = "OtherActivityInputConsumer.DOWN";
private static final String UP_EVT = "OtherActivityInputConsumer.UP";
private final CachedEventDispatcher mRecentsViewDispatcher = new CachedEventDispatcher();
private final RunningTaskInfo mRunningTask;
@@ -83,7 +83,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
private final int mDisplayRotation;
private final Rect mStableInsets = new Rect();
private final Consumer<OtherActivityTouchConsumer> mOnCompleteCallback;
private final Consumer<OtherActivityInputConsumer> mOnCompleteCallback;
private final MotionPauseDetector mMotionPauseDetector;
private VelocityTracker mVelocityTracker;
@@ -105,11 +105,11 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
// TODO: Start displacement should have both x and y
private float mStartDisplacement;
public OtherActivityTouchConsumer(Context base, RunningTaskInfo runningTaskInfo,
public OtherActivityInputConsumer(Context base, RunningTaskInfo runningTaskInfo,
RecentsModel recentsModel, Intent homeIntent, ActivityControlHelper activityControl,
boolean isDeferredDownTarget, OverviewCallbacks overviewCallbacks,
TaskOverlayFactory taskOverlayFactory, InputConsumerController inputConsumer,
Consumer<OtherActivityTouchConsumer> onCompleteCallback,
Consumer<OtherActivityInputConsumer> onCompleteCallback,
SwipeSharedState swipeSharedState) {
super(base);
@@ -139,7 +139,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
}
@Override
public void accept(MotionEvent ev) {
public void onMotionEvent(MotionEvent ev) {
if (mVelocityTracker == null) {
return;
}
@@ -20,10 +20,12 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
import android.graphics.PointF;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
@@ -33,10 +35,10 @@ import com.android.quickstep.util.CachedEventDispatcher;
import com.android.systemui.shared.system.ActivityManagerWrapper;
/**
* Touch consumer for handling touch on the recents/Launcher activity.
* Input consumer for handling touch on the recents/Launcher activity.
*/
public class OverviewTouchConsumer<T extends BaseDraggingActivity>
implements TouchConsumer {
public class OverviewInputConsumer<T extends BaseDraggingActivity>
implements InputConsumer {
private final CachedEventDispatcher mCachedEventDispatcher = new CachedEventDispatcher();
private final T mActivity;
@@ -50,7 +52,7 @@ public class OverviewTouchConsumer<T extends BaseDraggingActivity>
private boolean mTrackingStarted = false;
private boolean mInvalidated = false;
OverviewTouchConsumer(T activity, boolean startingInActivityBounds) {
OverviewInputConsumer(T activity, boolean startingInActivityBounds) {
mActivity = activity;
mTarget = activity.getDragLayer();
mTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
@@ -58,7 +60,7 @@ public class OverviewTouchConsumer<T extends BaseDraggingActivity>
}
@Override
public void accept(MotionEvent ev) {
public void onMotionEvent(MotionEvent ev) {
if (mInvalidated) {
return;
}
@@ -96,11 +98,18 @@ public class OverviewTouchConsumer<T extends BaseDraggingActivity>
// Set an empty consumer to that all the cached events are cleared
if (!mCachedEventDispatcher.hasConsumer()) {
mCachedEventDispatcher.setConsumer(NO_OP);
mCachedEventDispatcher.setConsumer(motionEvent -> { });
}
}
}
@Override
public void onKeyEvent(KeyEvent ev) {
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
mActivity.dispatchKeyEvent(ev);
}
}
private void startTouchTracking(MotionEvent ev, boolean updateLocationOffset,
boolean closeActiveWindows) {
if (updateLocationOffset) {
@@ -135,12 +144,12 @@ public class OverviewTouchConsumer<T extends BaseDraggingActivity>
ev.setEdgeFlags(flags);
}
public static TouchConsumer newInstance(ActivityControlHelper activityHelper,
public static InputConsumer newInstance(ActivityControlHelper activityHelper,
boolean startingInActivityBounds) {
BaseDraggingActivity activity = activityHelper.getCreatedActivity();
if (activity == null) {
return TouchConsumer.NO_OP;
return InputConsumer.NO_OP;
}
return new OverviewTouchConsumer(activity, startingInActivityBounds);
return new OverviewInputConsumer(activity, startingInActivityBounds);
}
}
@@ -19,6 +19,8 @@ import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import com.android.launcher3.util.Preconditions;
@@ -43,18 +45,18 @@ public class RecentsAnimationWrapper {
private boolean mWindowThresholdCrossed = false;
private final InputConsumerController mInputConsumer;
private final Supplier<TouchConsumer> mTouchProxySupplier;
private final InputConsumerController mInputConsumerController;
private final Supplier<InputConsumer> mInputProxySupplier;
private TouchConsumer mTouchConsumer;
private InputConsumer mInputConsumer;
private boolean mTouchInProgress;
private boolean mFinishPending;
public RecentsAnimationWrapper(InputConsumerController inputConsumer,
Supplier<TouchConsumer> touchProxySupplier) {
mInputConsumer = inputConsumer;
mTouchProxySupplier = touchProxySupplier;
public RecentsAnimationWrapper(InputConsumerController inputConsumerController,
Supplier<InputConsumer> inputProxySupplier) {
mInputConsumerController = inputConsumerController;
mInputProxySupplier = inputProxySupplier;
}
@UiThread
@@ -132,15 +134,30 @@ public class RecentsAnimationWrapper {
}
}
public void enableTouchProxy() {
mInputConsumer.setTouchListener(this::onInputConsumerTouch);
public void enableInputProxy() {
mInputConsumerController.setInputListener(this::onInputConsumerEvent);
}
private boolean onInputConsumerTouch(MotionEvent ev) {
private boolean onInputConsumerEvent(InputEvent ev) {
if (ev instanceof MotionEvent) {
onInputConsumerMotionEvent((MotionEvent) ev);
} else if (ev instanceof KeyEvent) {
if (mInputConsumer == null) {
mInputConsumer = mInputProxySupplier.get();
}
mInputConsumer.onKeyEvent((KeyEvent) ev);
return true;
}
return false;
}
private boolean onInputConsumerMotionEvent(MotionEvent ev) {
int action = ev.getAction();
if (action == ACTION_DOWN) {
mTouchInProgress = true;
mTouchConsumer = mTouchProxySupplier.get();
if (mInputConsumer == null) {
mInputConsumer = mInputProxySupplier.get();
}
} else if (action == ACTION_CANCEL || action == ACTION_UP) {
// Finish any pending actions
mTouchInProgress = false;
@@ -149,8 +166,8 @@ public class RecentsAnimationWrapper {
finishAndClear(true /* toRecents */, null);
}
}
if (mTouchConsumer != null) {
mTouchConsumer.accept(ev);
if (mInputConsumer != null) {
mInputConsumer.onMotionEvent(ev);
}
return true;
@@ -42,7 +42,7 @@ public class TouchInteractionLog {
getCurrentLog().add("[" + mDateFormat.format(mCalendar.getTime()) + "]");
}
public void setTouchConsumer(TouchConsumer consumer) {
public void setInputConsumer(InputConsumer consumer) {
getCurrentLog().add("tc=" + consumer.getClass().getSimpleName());
}
@@ -159,7 +159,7 @@ public class TouchInteractionService extends Service {
private InputConsumerController mInputConsumer;
private SwipeSharedState mSwipeSharedState;
private TouchConsumer mConsumer = TouchConsumer.NO_OP;
private InputConsumer mConsumer = InputConsumer.NO_OP;
private Choreographer mMainChoreographer;
private InputEventReceiver mInputEventReceiver;
@@ -226,34 +226,34 @@ public class TouchInteractionService extends Service {
boolean useSharedState = mConsumer.isActive();
mConsumer.onConsumerAboutToBeSwitched();
mConsumer = newConsumer(useSharedState, event);
TOUCH_INTERACTION_LOG.setTouchConsumer(mConsumer);
TOUCH_INTERACTION_LOG.setInputConsumer(mConsumer);
}
TOUCH_INTERACTION_LOG.addMotionEvent(event);
mConsumer.accept(event);
mConsumer.onMotionEvent(event);
}
private TouchConsumer newConsumer(boolean useSharedState, MotionEvent event) {
private InputConsumer newConsumer(boolean useSharedState, MotionEvent event) {
RunningTaskInfo runningTaskInfo = mAM.getRunningTask(0);
if (!useSharedState) {
mSwipeSharedState.clearAllState();
}
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher) {
return TouchConsumer.NO_OP;
return InputConsumer.NO_OP;
} else if (mSwipeSharedState.goingToLauncher ||
mOverviewComponentObserver.getActivityControlHelper().isResumed()) {
return OverviewTouchConsumer.newInstance(
return OverviewInputConsumer.newInstance(
mOverviewComponentObserver.getActivityControlHelper(), false);
} else if (ENABLE_QUICKSTEP_LIVE_TILE.get() &&
mOverviewComponentObserver.getActivityControlHelper().isInLiveTileMode()) {
return OverviewTouchConsumer.newInstance(
return OverviewInputConsumer.newInstance(
mOverviewComponentObserver.getActivityControlHelper(), false);
} else {
ActivityControlHelper activityControl =
mOverviewComponentObserver.getActivityControlHelper();
boolean shouldDefer = activityControl.deferStartingActivity(mActiveNavBarRegion, event);
return new OtherActivityTouchConsumer(this, runningTaskInfo, mRecentsModel,
return new OtherActivityInputConsumer(this, runningTaskInfo, mRecentsModel,
mOverviewComponentObserver.getOverviewIntent(), activityControl,
shouldDefer, mOverviewCallbacks, mTaskOverlayFactory, mInputConsumer,
this::onConsumerInactive, mSwipeSharedState);
@@ -263,9 +263,9 @@ public class TouchInteractionService extends Service {
/**
* To be called by the consumer when it's no longer active.
*/
private void onConsumerInactive(TouchConsumer caller) {
private void onConsumerInactive(InputConsumer caller) {
if (mConsumer == caller) {
mConsumer = TouchConsumer.NO_OP;
mConsumer = InputConsumer.NO_OP;
}
}
@@ -56,7 +56,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
@@ -274,7 +273,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
.createActivityInitListener(this::onActivityInit);
mContinuingLastGesture = continuingLastGesture;
mRecentsAnimationWrapper = new RecentsAnimationWrapper(inputConsumer,
this::createNewTouchProxyHandler);
this::createNewInputProxyHandler);
mClipAnimationHelper = new ClipAnimationHelper(context);
mTransformParams = new ClipAnimationHelper.TransformParams();
@@ -719,7 +718,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
}
@UiThread
private TouchConsumer createNewTouchProxyHandler() {
private InputConsumer createNewInputProxyHandler() {
mCurrentShift.finishAnimation();
if (mLauncherTransitionController != null) {
mLauncherTransitionController.getAnimationPlayer().end();
@@ -729,7 +728,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
setTargetAlphaProvider(WindowTransformSwipeHandler::getHiddenTargetAlpha);
}
return OverviewTouchConsumer.newInstance(mActivityControlHelper, true);
return OverviewInputConsumer.newInstance(mActivityControlHelper, true);
}
@UiThread
@@ -823,7 +822,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
setShelfState(ShelfAnimState.CANCEL, LINEAR, 0);
duration = Math.max(MIN_OVERSHOOT_DURATION, duration);
} else if (endTarget == RECENTS) {
mRecentsAnimationWrapper.enableTouchProxy();
mRecentsAnimationWrapper.enableInputProxy();
if (mRecentsView != null) {
duration = Math.max(duration, mRecentsView.getScroller().getDuration());
}
@@ -63,11 +63,11 @@ public class StartLauncherViaGestureTests extends AbstractQuickStepTest {
public void testPressHome() {
runTest(enterEvt(Launcher.ON_CREATE_EVT),
exitEvt(Launcher.ON_CREATE_EVT),
enterEvt(OtherActivityTouchConsumer.DOWN_EVT),
exitEvt(OtherActivityTouchConsumer.DOWN_EVT));
enterEvt(OtherActivityInputConsumer.DOWN_EVT),
exitEvt(OtherActivityInputConsumer.DOWN_EVT));
runTest(enterEvt(OtherActivityTouchConsumer.DOWN_EVT),
exitEvt(OtherActivityTouchConsumer.DOWN_EVT),
runTest(enterEvt(OtherActivityInputConsumer.DOWN_EVT),
exitEvt(OtherActivityInputConsumer.DOWN_EVT),
enterEvt(Launcher.ON_CREATE_EVT),
exitEvt(Launcher.ON_CREATE_EVT));
}