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

Commit f509803c authored by Tyler Freeman's avatar Tyler Freeman
Browse files

fix(magnifier): avoid crash when smashing magnifier shortcut button repeatedly

This avoids a race condition where we start receiving events and
trying to send them to the input filter before it's been
installed.

Fix: 290271948
Test: manual:
1. Turn on magnification shortcut button
2. Tap it repeatedly quickly for like 30 seconds
3. Should not crash.

Change-Id: I24f0eafb2479ac7427ba28077e45ba26a9127cc8
parent 28d0aabf
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -388,11 +388,19 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
    @Override
    @Override
    public void onMotionEvent(MotionEvent transformedEvent, MotionEvent rawEvent,
    public void onMotionEvent(MotionEvent transformedEvent, MotionEvent rawEvent,
            int policyFlags) {
            int policyFlags) {
        if (!mInstalled) {
            Slog.w(TAG, "onMotionEvent called before input filter installed!");
            return;
        }
        sendInputEvent(transformedEvent, policyFlags);
        sendInputEvent(transformedEvent, policyFlags);
    }
    }


    @Override
    @Override
    public void onKeyEvent(KeyEvent event, int policyFlags) {
    public void onKeyEvent(KeyEvent event, int policyFlags) {
        if (!mInstalled) {
            Slog.w(TAG, "onKeyEvent called before input filter installed!");
            return;
        }
        sendInputEvent(event, policyFlags);
        sendInputEvent(event, policyFlags);
    }
    }