Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58bd4390 authored by Winson Chung's avatar Winson Chung
Browse files

Fix issue with quick switch animation not running.

- We were intercepting touch before the quickscrub controller had a chance
  to handle the touch, which meant that we canceled the recents animation
  before passing the quick switch event to launcher.  Instead, just move
  the cancel recents animation logic to the key button view (before
  handling up) and ensure that we intercept from the button only in the
  cases we desire (a quick switch/scrub, recents animation start, or if
  it's a dock drag (not currently enabled).

Test: Fling on the nav button to quickswitch, ensure recents animation
      runs

Change-Id: Id89fda56f2996a38a9aea99179b5e2870b531003
parent 73ccb72d
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -36,25 +36,25 @@ oneway interface IOverviewProxy {

    /**
     * Sent when a user has quickly flinged on the nav bar to switch tasks. Once this event is sent
     * the caller will stop sending any motion events.
     * the caller will stop sending any motion events and will no longer preemptively cancel any
     * recents animations started as a part of the motion event handling.
     */
    void onQuickSwitch();

    /**
     * Sent when the user starts to actively scrub the nav bar to switch tasks. Once this event is
     * sent the caller will stop sending any motion events.
     * sent the caller will stop sending any motion events and will no longer preemptively cancel
     * any recents animations started as a part of the motion event handling.
     */
    void onQuickScrubStart();

    /**
     * Sent when the user stops actively scrubbing the nav bar to switch tasks. Once this event is
     * sent the caller will stop sending any motion events.
     * Sent when the user stops actively scrubbing the nav bar to switch tasks.
     */
    void onQuickScrubEnd();

    /**
     * Sent for each movement over the nav bar while the user is scrubbing it to switch tasks. Once
     * this event is sent the caller will stop sending any motion events.
     * Sent for each movement over the nav bar while the user is scrubbing it to switch tasks.
     */
    void onQuickScrubProgress(float progress);
}
+1 −3
Original line number Diff line number Diff line
@@ -99,9 +99,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        public void onRecentsAnimationStarted() {
            long token = Binder.clearCallingIdentity();
            try {
                mHandler.post(() -> {
                    notifyRecentsAnimationStarted();
                });
                mHandler.post(OverviewProxyService.this::notifyRecentsAnimationStarted);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
+12 −18
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
import android.view.MotionEvent;
@@ -159,25 +158,19 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture
                mRecentsAnimationStarted = false;
                break;
            }
            case MotionEvent.ACTION_UP: {
                // If the overview proxy service has not started the recents animation then clean up
                // after it to ensure that the nav bar buttons still work
                if (mOverviewProxyService.getProxy() != null && !mRecentsAnimationStarted) {
                    try {
                        ActivityManager.getService().cancelRecentsAnimation();
                    } catch (RemoteException e) {
                        Log.e(TAG, "Could not cancel recents animation", e);
                    }
                }
                break;
        }
        }
        if (mStatusBar.isPresenterFullyCollapsed()
                && !mQuickScrubController.onInterceptTouchEvent(event)) {
        boolean handledByQuickscrub = mQuickScrubController.onInterceptTouchEvent(event);
        if (mStatusBar.isPresenterFullyCollapsed() && !handledByQuickscrub) {
            // Proxy motion events until we start intercepting for quickscrub
            proxyMotionEvents(event);
            return false;
        }
        return (mDockWindowEnabled && interceptDockWindowEvent(event)) || mRecentsAnimationStarted;

        boolean result = handledByQuickscrub;
        result |= mRecentsAnimationStarted;
        if (mDockWindowEnabled) {
            result |= interceptDockWindowEvent(event);
        }
        return result;
    }

    public boolean onTouchEvent(MotionEvent event) {
@@ -188,10 +181,11 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture
                && (mQuickScrubController.onTouchEvent(event)
                || ignoreProxyDownEvent
                || proxyMotionEvents(event));
        result |= mRecentsAnimationStarted;
        if (mDockWindowEnabled) {
            result |= handleDockWindowEvent(event);
        }
        return result || mRecentsAnimationStarted;
        return result;
    }

    public void onDraw(Canvas canvas) {
+10 −0
Original line number Diff line number Diff line
@@ -27,10 +27,12 @@ import android.media.AudioManager;
import android.metrics.LogMaker;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
@@ -55,6 +57,7 @@ import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK;

public class KeyButtonView extends ImageView implements ButtonInterface {
    private static final String TAG = KeyButtonView.class.getSimpleName();

    private final boolean mPlaySounds;
    private int mContentDescriptionRes;
@@ -264,6 +267,13 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
                }
                if (mCode != 0) {
                    if (doIt) {
                        // If there was a pending remote recents animation, then we need to
                        // cancel the animation now before we handle the button itself
                        try {
                            ActivityManager.getService().cancelRecentsAnimation();
                        } catch (RemoteException e) {
                            Log.e(TAG, "Could not cancel recents animation", e);
                        }
                        sendEvent(KeyEvent.ACTION_UP, 0);
                        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
                    } else {