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

Commit 5e46f072 authored by vadimt's avatar vadimt Committed by Winson Chung
Browse files

Fixing TouchInteractionService referring destroyed activity

Bug: 139137636
Change-Id: I2d36bcd9478e070e21cb6c8e2cde617807af8dd1
parent 0465b4d7
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@
 */
package com.android.quickstep;

import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;

import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -435,7 +437,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
                TraceHelper.FLAG_ALLOW_BINDER_TRACKING);
        mDeviceState.setOrientationTransformIfNeeded(event);

        if (event.getAction() == ACTION_DOWN) {
        final int action = event.getAction();
        if (action == ACTION_DOWN) {
            GestureState newGestureState = new GestureState(mOverviewComponentObserver,
                    ActiveGestureLog.INSTANCE.generateAndSetLogId());
            newGestureState.updateRunningTask(TraceHelper.whitelistIpcs("getRunningTask.0",
@@ -468,6 +471,13 @@ public class TouchInteractionService extends Service implements PluginListener<O

        ActiveGestureLog.INSTANCE.addLog("onMotionEvent", event.getActionMasked());
        mUncheckedConsumer.onMotionEvent(event);

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

        TraceHelper.INSTANCE.endFlagsOverride(traceToken);
    }

@@ -661,8 +671,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
     */
    private void onConsumerInactive(InputConsumer caller) {
        if (mConsumer == caller) {
            mConsumer = mResetGestureInputConsumer;
            mUncheckedConsumer = mConsumer;
            mConsumer = mUncheckedConsumer = mResetGestureInputConsumer;
            mGestureState = new GestureState();
        }
    }

+5 −0
Original line number Diff line number Diff line
@@ -24,6 +24,11 @@ public abstract class DelegateInputConsumer implements InputConsumer {
        mState = STATE_INACTIVE;
    }

    @Override
    public boolean isConsumerDetachedFromGesture() {
        return mDelegate.isConsumerDetachedFromGesture();
    }

    @Override
    public boolean allowInterceptByParent() {
        return mDelegate.allowInterceptByParent() && mState != STATE_ACTIVE;
+5 −0
Original line number Diff line number Diff line
@@ -160,6 +160,11 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        return TYPE_OTHER_ACTIVITY;
    }

    @Override
    public boolean isConsumerDetachedFromGesture() {
        return true;
    }

    private void forceCancelGesture(MotionEvent ev) {
        int action = ev.getAction();
        ev.setAction(ACTION_CANCEL);
+10 −0
Original line number Diff line number Diff line
@@ -59,6 +59,16 @@ public interface InputConsumer {
        return true;
    }

    /**
     * Returns true if the lifecycle of this input consumer is detached from the normal gesture
     * down/up flow. If so, it is the responsibility of the input consumer to call back to
     * {@link TouchInteractionService#onConsumerInactive(InputConsumer)} after the consumer is
     * finished.
     */
    default boolean isConsumerDetachedFromGesture() {
        return false;
    }

    /**
     * Called by the event queue when the consumer is about to be switched to a new consumer.
     * Consumers should update the state accordingly here before the state is passed to the new