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

Commit 09afc2b3 authored by Harry Cutts's avatar Harry Cutts
Browse files

Touchpad debug view: fix crash when disabling using touchpad

When using the touchpad to toggle the "Show touchpad input" developer
option off, the hideDebugView method (which sets mTouchpadDebugView to
null) was running in between the mTouchpadDebugView.post call and the
posted action actually running, so we need another null check within the
action.

Bug: 376018148
Test: with the developer option enabled, click its toggle using the
      touchpad that's currently being visualized
Flag: com.android.hardware.input.touchpad_visualizer
Change-Id: I8e2be39c05c9cab2d51b98acabf95b399d0a00a5
parent 49e9bfc3
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -163,9 +163,15 @@ public class TouchpadDebugViewController implements InputManager.InputDeviceList
                                            int deviceId) {
        mHandler.post(() -> {
            if (mTouchpadDebugView != null) {
                mTouchpadDebugView.post(
                        () -> mTouchpadDebugView.updateHardwareState(touchpadHardwareState,
                                deviceId));
                mTouchpadDebugView.post(() -> {
                    // hideDebugView might have been called since we posted the action (e.g. if the
                    // developer option toggle is clicked using the same touchpad currently being
                    // visualized, b/376018148), so we need to check for null again.
                    if (mTouchpadDebugView != null) {
                        mTouchpadDebugView.updateHardwareState(touchpadHardwareState,
                                deviceId);
                    }
                });
            }
        });
    }
@@ -177,8 +183,14 @@ public class TouchpadDebugViewController implements InputManager.InputDeviceList
    public void updateTouchpadGestureInfo(int gestureType, int deviceId) {
        mHandler.post(() -> {
            if (mTouchpadDebugView != null) {
                mTouchpadDebugView.post(
                        () -> mTouchpadDebugView.updateGestureInfo(gestureType, deviceId));
                mTouchpadDebugView.post(() -> {
                    // hideDebugView might have been called since we posted the action (e.g. if the
                    // developer option toggle is clicked using the same touchpad currently being
                    // visualized, b/376018148), so we need to check for null again.
                    if (mTouchpadDebugView != null) {
                        mTouchpadDebugView.updateGestureInfo(gestureType, deviceId);
                    }
                });
            }
        });
    }