summaryrefslogtreecommitdiff
path: root/libs/input/rust
Commit message (Collapse)AuthorAgeFilesLines
* Replace use of deprecated function with_min_levelJeff Vander Stoep2024-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | This is needed to upgrade the android_logger crate from 0.12.0 to 0.13.3. with_max_level provides the same functionality as with_min_level. The renaming is admittedly confusing, but the new name is accurate and it makes sense that they deprecated and then removed the previously poorly named with_min_level. See crate documentation [1] and code [2]. [1]: https://docs.rs/android_logger/0.12.0/android_logger/struct.Config.html#method.with_min_level [2]: https://docs.rs/android_logger/0.12.0/src/android_logger/lib.rs.html#227 Bug: 322718401 Test: build and run CF with the change. Test: m aosp_cf_x86_64_phone Change-Id: I2e4ed99253f3b328a98d4bc5988beda7304612e6
* input_verifier: check the number of pointers for MOVE eventsSiarhei Vishniakou2023-12-071-0/+43
| | | | | | | | | | | | | Before this CL, the check for the existing pointers was not complete: there was a chance that the MOVE event contained less than the current number of pointers. Fix this by checking the number of pointers before comparing the sets of pointers. Bug: 312714754 Test: atest libinput_rust_test Change-Id: I4e6c00aec4247b6cb4c467ac5c2887ee3a90afba
* Update needed for Rust v1.73.0Charisee2023-11-171-12/+3
| | | | | | | https://rust-lang.github.io/rust-clippy/master/index.html#/unwrap_or_default bug: http://b/303252546 Change-Id: I1650c8109559c8818d796d01269b994802a1ed21
* input_verifier: Ensure bad event does not change verifier stateSiarhei Vishniakou2023-10-291-8/+57
| | | | | | | | | | | | | Before this CL, the verifier combined a check and a storage operation into a single action. After the check, a bad event would cause the verifier to return, but the state would have already be altered. In this CL, we ensure that the check happens first, so that a bad event does not modify the verifier state. Bug: 287342122 Test: atest inputflinger_tests Change-Id: Ib981231046faa062717a9d00856bf9551e510a33
* input_verifier: add isolated MotionEvent checksSiarhei Vishniakou2023-10-162-20/+66
| | | | | | | | | | | | | | | | | | | | Previously, we were checking the consistency of MotionEvents inside input_verifier in one large 'match' statement. However, the verifier should only be used to check whether a given MotionEvent makes sense in relation to all of the preceding motions. To improve the situation, in this CL some checks are moved into a separate function. Those checks allow us to test whether the event itself makes sense. If the event is bad, then no need to do the remaining checks in input_verifier. This CL makes the rust code a bit closer to the current checks implemented in the InputDispatcher. Bug: 211379801 Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: I60437797980f4f8f050023419a03d80e4ee4e1f1
* Allow values from SourceClass inside rust SourceSiarhei Vishniakou2023-10-041-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Inside ViewTest::testOnTouchEventScroll, some MotionEvents are created without a valid source. During injection, they get appended with SourceClass::Pointer. If these events are sent into the InputVerifier, it's basically being asked to convert 0x2 === AINPUT_SOURCE_CLASS_POINTER into rust's input::Source. This fails during unwrap: $ TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST [ RUN ] InputVerifierTest.BadSourceProcess thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', frameworks/native/libs/input/rust/lib.rs:84:35 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 Aborted To mitigate this, add the SourceClass definitions into Source, thus allowing such conversions. Bug: 303143553 Bug: 211379801 Test: TEST=libinput_rust_test; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Test: TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: I46415d88251937959104bb82a3976e72ffcfcaf9
* InputVerifier: only check pointer sourcesSiarhei Vishniakou2023-09-273-7/+130
| | | | | | | | | | | | | | Check for the source inside InputVerifier. Sources like MOUSE_RELATIVE could send ACTION_MOVE events without a prior DOWN event. Verifying such streams is tricky, so let's simply skip such events for now. Also in this CL, add some verifications to the number of pointers inside the event. Bug: 211379801 Test: enable event verification and run native tests Test: atest inputflinger_tests libinput_tests Change-Id: I3703ba57af7ede77712b91b7429ac46c0624a616
* Allow unsafe operations in unsafe functions in generated code.Andrew Walbran2023-08-031-0/+1
| | | | | | | | | This will soon be denied by default, but we trust that what cxx does is correct. Bug: 290018030 Test: m rust Change-Id: If38e434a5d9e3320cfa7e6f686a078f7ee764435
* Add flags to input_verifierSiarhei Vishniakou2023-07-192-4/+14
| | | | | | | | | | | | | These flags are currently not known by the verifier. As a result, this causes a panic when such events are trying to get converted to the rust object. Add the missing flags in this CL. Bug: 271455682 Test: manually enable event verification Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: I351b87c339c7efe8e6f3b14ad05e89d8a9e8c9e2
* Fix cancel flag checkSiarhei Vishniakou2023-07-051-2/+46
| | | | | | | | | The check inside the verifier for the presence of flag_canceled is incorrect. Fix it in this CL. Bug: 211379801 Test: TEST=libinput_rust_test; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: I6880922b21cc9cb629a98e0c8071f1c4d5130aa5
* Add hovering support to verifierSiarhei Vishniakou2023-07-042-4/+136
| | | | | | | | | | | In order to allow fuzzing of dispatcher, we need to be able to avoid incorrect hover sequences sent to the listener. Add hovering support for verifier in this CL. Bug: 211379801 Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: If7ee8ecb62044768915acc4657029366e193c6db
* Re-organize and export libinput_rust as a rust libraryPrabir Pradhan2023-06-234-0/+561
We export some definitions from libinput_rust as the "input" crate so they can be used directly by other rust libraries. Bug: 278783893 Test: atest libinput_rust_test Change-Id: Icba79b67103f710d8bb1cb8892016bbd4e3e6ff9