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

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

Merge "Fixing TouchInteractionService referring destroyed activity" into ub-launcher3-master

parents 20035f18 5e46f072
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -15,7 +15,9 @@
 */
 */
package com.android.quickstep;
package com.android.quickstep;


import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
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.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
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);
                TraceHelper.FLAG_ALLOW_BINDER_TRACKING);
        mDeviceState.setOrientationTransformIfNeeded(event);
        mDeviceState.setOrientationTransformIfNeeded(event);


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


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

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

        TraceHelper.INSTANCE.endFlagsOverride(traceToken);
        TraceHelper.INSTANCE.endFlagsOverride(traceToken);
    }
    }


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


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


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

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


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

    private void forceCancelGesture(MotionEvent ev) {
    private void forceCancelGesture(MotionEvent ev) {
        int action = ev.getAction();
        int action = ev.getAction();
        ev.setAction(ACTION_CANCEL);
        ev.setAction(ACTION_CANCEL);
+10 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,16 @@ public interface InputConsumer {
        return true;
        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.
     * 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
     * Consumers should update the state accordingly here before the state is passed to the new