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

Commit 44de9caa authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Send ACTION_CANCEL motion event to TIS instead of finishing the recents animation on screen off

Finishing the recents animation on screen off callback did not necessarily stop touch tracking, which would allow the user to double press the power button, but create a broken experience.

Sending ACTION_DOWN instead stops touch tracking and runs the proper clean up methods.

Flag: not needed
Fixes: 299235099
Test: single-pressed and double-pressed the power button mid-gesture
Change-Id: I2608053460f43703613bd6caead91ccb4ce08ceb
parent a1a5e087
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchControlle
import com.android.launcher3.uioverrides.touchcontrollers.TransposedQuickSwitchTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.TwoButtonNavbarTouchController;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.BackPressHandler;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.IntSet;
@@ -738,15 +737,6 @@ public class QuickstepLauncher extends Launcher {
                () -> ActivityManagerWrapper.getInstance().invalidateHomeTaskSnapshot(this));
    }

    @Override
    protected void onScreenOnChanged(boolean isOn) {
        super.onScreenOnChanged(isOn);
        if (!isOn) {
            RecentsView recentsView = getOverviewPanel();
            recentsView.finishRecentsAnimation(true /* toRecents */, null);
        }
    }

    @Override
    public void onAllAppsTransition(float progress) {
        super.onAllAppsTransition(progress);
+23 −5
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.LockedUserState;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.ScreenOnTracker;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
import com.android.quickstep.inputconsumers.AssistantInputConsumer;
@@ -449,6 +450,8 @@ public class TouchInteractionService extends Service {
    private final AbsSwipeUpHandler.Factory mFallbackSwipeHandlerFactory =
            this::createFallbackSwipeHandler;

    private final ScreenOnTracker.ScreenOnListener mScreenOnListener = this::onScreenOnChanged;

    private ActivityManagerWrapper mAM;
    private OverviewCommandHelper mOverviewCommandHelper;
    private OverviewComponentObserver mOverviewComponentObserver;
@@ -485,6 +488,8 @@ public class TouchInteractionService extends Service {
        LockedUserState.get(this).runOnUserUnlocked(mTaskbarManager::onUserUnlocked);
        mDeviceState.addNavigationModeChangedCallback(this::onNavigationModeChanged);
        sConnected = true;

        ScreenOnTracker.INSTANCE.get(this).addListener(mScreenOnListener);
    }

    private void disposeEventHandlers(String reason) {
@@ -657,6 +662,8 @@ public class TouchInteractionService extends Service {

        mTaskbarManager.destroy();
        sConnected = false;

        ScreenOnTracker.INSTANCE.get(this).removeListener(mScreenOnListener);
        super.onDestroy();
    }

@@ -666,6 +673,17 @@ public class TouchInteractionService extends Service {
        return mTISBinder;
    }

    protected void onScreenOnChanged(boolean isOn) {
        if (isOn) {
            return;
        }
        long currentTime = SystemClock.uptimeMillis();
        MotionEvent cancelEvent = MotionEvent.obtain(
                currentTime, currentTime, ACTION_CANCEL, 0f, 0f, 0);
        onInputEvent(cancelEvent);
        cancelEvent.recycle();
    }

    private void onInputEvent(InputEvent ev) {
        if (!(ev instanceof MotionEvent)) {
            Log.e(TAG, "Unknown event " + ev);
@@ -729,7 +747,7 @@ public class TouchInteractionService extends Service {
        }

        if (mUncheckedConsumer != InputConsumer.NO_OP) {
            switch (event.getActionMasked()) {
            switch (action) {
                case ACTION_DOWN:
                    // fall through
                case ACTION_UP:
@@ -739,18 +757,18 @@ public class TouchInteractionService extends Service {
                                    .append(", ")
                                    .append((int) event.getRawY())
                                    .append("): ")
                                    .append(MotionEvent.actionToString(event.getActionMasked()))
                                    .append(MotionEvent.actionToString(action))
                                    .append(", ")
                                    .append(MotionEvent.classificationToString(
                                            event.getClassification())),
                            /* gestureEvent= */ event.getActionMasked() == ACTION_DOWN
                            /* gestureEvent= */ action == ACTION_DOWN
                                    ? MOTION_DOWN
                                    : MOTION_UP);
                    break;
                case ACTION_MOVE:
                    ActiveGestureLog.INSTANCE.addLog(
                            new CompoundString("onMotionEvent: ")
                                    .append(MotionEvent.actionToString(event.getActionMasked()))
                                    .append(MotionEvent.actionToString(action))
                                    .append(",")
                                    .append(MotionEvent.classificationToString(
                                            event.getClassification()))
@@ -761,7 +779,7 @@ public class TouchInteractionService extends Service {
                default: {
                    ActiveGestureLog.INSTANCE.addLog(
                            new CompoundString("onMotionEvent: ")
                                    .append(MotionEvent.actionToString(event.getActionMasked()))
                                    .append(MotionEvent.actionToString(action))
                                    .append(",")
                                    .append(MotionEvent.classificationToString(
                                            event.getClassification())));