diff options
| author | 2025-02-20 16:29:56 +0000 | |
|---|---|---|
| committer | 2025-02-20 16:29:56 +0000 | |
| commit | fa83e33649a0906cd8fd27c12305ada1197cfb81 (patch) | |
| tree | 8c191276777cd4bb918bf5b58a29ef97e15af3f2 | |
| parent | d442304ae59342d9e4f93608391950a7d9f709f0 (diff) | |
InputVerifier: add panic message for source conversion
We've seen a crash due to this failing, without many details on why, so
add an explicit check for the conversion with a more descriptive message
for next time.
Bug: 397706159
Test: modify InputVerifier.cpp to pass an invalid source, enable
verification, and check that any input event causes a panic with
the appropriate message:
$ adb shell 'stop && setprop log.tag.InputDispatcherVerifyEvents
DEBUG && start'
Flag: EXEMPT log only update
Change-Id: I0aa07cd14c8afdcd204daa0fb4660466e6c0be42
| -rw-r--r-- | libs/input/rust/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/input/rust/lib.rs b/libs/input/rust/lib.rs index 7638559553..ee999f7666 100644 --- a/libs/input/rust/lib.rs +++ b/libs/input/rust/lib.rs @@ -133,6 +133,12 @@ fn process_movement( flags: u32, button_state: u32, ) -> String { + let Some(converted_source) = Source::from_bits(source) else { + panic!( + "The conversion of source 0x{source:08x} failed, please check if some sources have not \ + been added to Source." + ); + }; let Some(motion_flags) = MotionFlags::from_bits(flags) else { panic!( "The conversion of flags 0x{:08x} failed, please check if some flags have not been \ @@ -167,7 +173,7 @@ fn process_movement( } let result = verifier.process_movement(NotifyMotionArgs { device_id: DeviceId(device_id), - source: Source::from_bits(source).unwrap(), + source: converted_source, action: motion_action, pointer_properties, flags: motion_flags, |