Skip to content

Commit fa83e33

Browse files
committed
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
1 parent d442304 commit fa83e33

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

libs/input/rust/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ fn process_movement(
133133
flags: u32,
134134
button_state: u32,
135135
) -> String {
136+
let Some(converted_source) = Source::from_bits(source) else {
137+
panic!(
138+
"The conversion of source 0x{source:08x} failed, please check if some sources have not \
139+
been added to Source."
140+
);
141+
};
136142
let Some(motion_flags) = MotionFlags::from_bits(flags) else {
137143
panic!(
138144
"The conversion of flags 0x{:08x} failed, please check if some flags have not been \
@@ -167,7 +173,7 @@ fn process_movement(
167173
}
168174
let result = verifier.process_movement(NotifyMotionArgs {
169175
device_id: DeviceId(device_id),
170-
source: Source::from_bits(source).unwrap(),
176+
source: converted_source,
171177
action: motion_action,
172178
pointer_properties,
173179
flags: motion_flags,

0 commit comments

Comments
 (0)