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

Commit 641fa065 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fix issue with delegate consumers being overwritten" into ub-launcher3-master

parents c84daaf7 a726df92
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -481,14 +481,14 @@ public class TouchInteractionService extends Service implements PluginListener<O
        }

        ActiveGestureLog.INSTANCE.addLog("onMotionEvent", event.getActionMasked());
        boolean cleanUpConsumer = (action == ACTION_UP || action == ACTION_CANCEL)
                && mConsumer != null
                && !mConsumer.getActiveConsumerInHierarchy().isConsumerDetachedFromGesture();
        mUncheckedConsumer.onMotionEvent(event);

        if (action == ACTION_UP || action == ACTION_CANCEL) {
            if (mConsumer != null && !mConsumer.isConsumerDetachedFromGesture()) {
                onConsumerInactive(mConsumer);
        if (cleanUpConsumer) {
            reset();
        }
        }

        TraceHelper.INSTANCE.endFlagsOverride(traceToken);
    }

@@ -686,14 +686,20 @@ public class TouchInteractionService extends Service implements PluginListener<O
    }

    /**
     * To be called by the consumer when it's no longer active.
     * To be called by the consumer when it's no longer active. This can be called by any consumer
     * in the hierarchy at any point during the gesture (ie. if a delegate consumer starts
     * intercepting touches, the base consumer can try to call this).
     */
    private void onConsumerInactive(InputConsumer caller) {
        if (mConsumer != null && mConsumer.isInConsumerHierarchy(caller)) {
        if (mConsumer != null && mConsumer.getActiveConsumerInHierarchy() == caller) {
            reset();
        }
    }

    private void reset() {
        mConsumer = mUncheckedConsumer = mResetGestureInputConsumer;
        mGestureState = new GestureState();
    }
    }

    private void preloadOverview(boolean fromInit) {
        if (!mDeviceState.isUserUnlocked()) {
+5 −7
Original line number Diff line number Diff line
@@ -25,13 +25,11 @@ public abstract class DelegateInputConsumer implements InputConsumer {
    }

    @Override
    public boolean isConsumerDetachedFromGesture() {
        return mDelegate.isConsumerDetachedFromGesture();
    public InputConsumer getActiveConsumerInHierarchy() {
        if (mState == STATE_ACTIVE) {
            return this;
        }

    @Override
    public boolean isInConsumerHierarchy(InputConsumer candidate) {
        return this == candidate || mDelegate.isInConsumerHierarchy(candidate);
        return mDelegate.getActiveConsumerInHierarchy();
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -70,10 +70,10 @@ public interface InputConsumer {
    }

    /**
     * Returns true if the given input consumer is in the hierarchy of this input consumer.
     * Returns the active input consumer is in the hierarchy of this input consumer.
     */
    default boolean isInConsumerHierarchy(InputConsumer candidate) {
        return this == candidate;
    default InputConsumer getActiveConsumerInHierarchy() {
        return this;
    }

    /**