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

Commit ea2a13a0 authored by Pat Manning's avatar Pat Manning
Browse files

Do not process stashed taskbar hover actions when taskbar is not present.

Fix: 306745595
Test: Manual.
Flag: ACONFIG com.android.launcher3.enable_cursor_hover_states NEXTFOOD.

Change-Id: I419e4dcbea6f615b0bf9521fb34c9c5df65df8ef
parent 8379c985
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ import androidx.annotation.UiThread;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ConstantItem;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.EncryptionType;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
@@ -725,8 +724,7 @@ public class TouchInteractionService extends Service {
        final int action = event.getActionMasked();
        // Note this will create a new consumer every mouse click, as after ACTION_UP from the click
        // an ACTION_HOVER_ENTER will fire as well.
        boolean isHoverActionWithoutConsumer =
                event.isHoverEvent() && (mUncheckedConsumer.getType() & TYPE_CURSOR_HOVER) == 0;
        boolean isHoverActionWithoutConsumer = isHoverActionWithoutConsumer(event);
        CompoundString reasonString = action == ACTION_DOWN
                ? new CompoundString("onMotionEvent: ") : CompoundString.NO_OP;
        if (action == ACTION_DOWN || isHoverActionWithoutConsumer) {
@@ -846,6 +844,15 @@ public class TouchInteractionService extends Service {
        traceToken.close();
    }

    private boolean isHoverActionWithoutConsumer(MotionEvent event) {
        // Only process these events when taskbar is present.
        TaskbarActivityContext tac = mTaskbarManager.getCurrentActivityContext();
        boolean isTaskbarPresent = tac != null && tac.getDeviceProfile().isTaskbarPresent
                && !tac.isPhoneMode();
        return event.isHoverEvent() && (mUncheckedConsumer.getType() & TYPE_CURSOR_HOVER) == 0
                && isTaskbarPresent;
    }

    // Talkback generates hover events on touch, which we do not want to consume.
    private boolean isCursorHoverEvent(MotionEvent event) {
        return event.isHoverEvent() && event.getSource() == InputDevice.SOURCE_MOUSE;