diff options
author | 2023-07-18 18:30:32 -0700 | |
---|---|---|
committer | 2023-07-19 13:51:52 +0000 | |
commit | 227a7f8fd9cbc8e4105bfb8d0688aa5f37c0d9a7 (patch) | |
tree | 3353a38367c8ceb932a0ec44bcca604b4eeee524 | |
parent | 25537f8503565a35062ffe01a83914abb96a2db2 (diff) |
Add flags to input_verifier
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
-rw-r--r-- | libs/input/Android.bp | 4 | ||||
-rw-r--r-- | libs/input/InputVerifier.cpp | 2 | ||||
-rw-r--r-- | libs/input/rust/input.rs | 14 | ||||
-rw-r--r-- | libs/input/rust/lib.rs | 4 |
4 files changed, 19 insertions, 5 deletions
diff --git a/libs/input/Android.bp b/libs/input/Android.bp index 769677c6ff..757cde2074 100644 --- a/libs/input/Android.bp +++ b/libs/input/Android.bp @@ -65,6 +65,10 @@ rust_bindgen { bindgen_flags: [ "--verbose", "--allowlist-var=AMOTION_EVENT_FLAG_CANCELED", + "--allowlist-var=AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED", + "--allowlist-var=AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED", + "--allowlist-var=AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT", + "--allowlist-var=AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE", "--allowlist-var=AMOTION_EVENT_ACTION_CANCEL", "--allowlist-var=AMOTION_EVENT_ACTION_UP", "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_DOWN", diff --git a/libs/input/InputVerifier.cpp b/libs/input/InputVerifier.cpp index 851babfb54..341eb6f920 100644 --- a/libs/input/InputVerifier.cpp +++ b/libs/input/InputVerifier.cpp @@ -44,7 +44,7 @@ Result<void> InputVerifier::processMovement(DeviceId deviceId, int32_t action, rust::Slice<const RustPointerProperties> properties{rpp.data(), rpp.size()}; rust::String errorMessage = android::input::verifier::process_movement(*mVerifier, deviceId, action, properties, - flags); + static_cast<uint32_t>(flags)); if (errorMessage.empty()) { return {}; } else { diff --git a/libs/input/rust/input.rs b/libs/input/rust/input.rs index a308c26b2e..9d3b38693a 100644 --- a/libs/input/rust/input.rs +++ b/libs/input/rust/input.rs @@ -119,8 +119,18 @@ impl MotionAction { bitflags! { /// MotionEvent flags. - pub struct MotionFlags: i32 { + pub struct MotionFlags: u32 { /// FLAG_CANCELED - const CANCELED = input_bindgen::AMOTION_EVENT_FLAG_CANCELED; + const CANCELED = input_bindgen::AMOTION_EVENT_FLAG_CANCELED as u32; + /// FLAG_WINDOW_IS_OBSCURED + const WINDOW_IS_OBSCURED = input_bindgen::AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED; + /// FLAG_WINDOW_IS_PARTIALLY_OBSCURED + const WINDOW_IS_PARTIALLY_OBSCURED = + input_bindgen::AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED; + /// FLAG_IS_ACCESSIBILITY_EVENT + const IS_ACCESSIBILITY_EVENT = + input_bindgen::AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; + /// FLAG_NO_FOCUS_CHANGE + const NO_FOCUS_CHANGE = input_bindgen::AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE; } } diff --git a/libs/input/rust/lib.rs b/libs/input/rust/lib.rs index 892f558da6..688d941bf6 100644 --- a/libs/input/rust/lib.rs +++ b/libs/input/rust/lib.rs @@ -52,7 +52,7 @@ mod ffi { device_id: i32, action: u32, pointer_properties: &[RustPointerProperties], - flags: i32, + flags: u32, ) -> String; fn reset_device(verifier: &mut InputVerifier, device_id: i32); } @@ -74,7 +74,7 @@ fn process_movement( device_id: i32, action: u32, pointer_properties: &[RustPointerProperties], - flags: i32, + flags: u32, ) -> String { let result = verifier.process_movement( DeviceId(device_id), |