summaryrefslogtreecommitdiff
path: root/include/input/InputVerifier.h
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2023-05-15 15:45:02 -0700
committer Siarhei Vishniakou <svv@google.com> 2023-06-14 22:57:42 +0000
commit5c02a719954b4e2c3221aefe75a7b151bbf91c01 (patch)
tree1e175cb7e82b423ce09046a066b612755d1d70d5 /include/input/InputVerifier.h
parent6778bd40c51ffa583f0533d00d2c7230a630b20c (diff)
Convert InputVerifier to rust
To establish some basic rust infrastructure for input code, convert the InputVerifier into rust. Currently, we use bindgen for interfacing between cpp and rust. In a future CL, this may be changed to an aidl interface instead. The logs and verifications can be enabled via: adb shell setprop log.tag.InputTransportVerifyEvents DEBUG adb shell setprop log.tag.InputVerifierLogEvents DEBUG adb shell setprop log.tag.InputDispatcherVerifyEvents DEBUG Bug: 271455682 Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests Change-Id: I607fed9f6fc9c38e2c8392f59e9c4facdaf6c68a
Diffstat (limited to 'include/input/InputVerifier.h')
-rw-r--r--include/input/InputVerifier.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/include/input/InputVerifier.h b/include/input/InputVerifier.h
index d4589f53b5..3715408388 100644
--- a/include/input/InputVerifier.h
+++ b/include/input/InputVerifier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,25 @@
#pragma once
+#include <android-base/result.h>
#include <input/Input.h>
-#include <map>
+#include "rust/cxx.h"
namespace android {
+namespace input {
+namespace verifier {
+struct InputVerifier;
+}
+} // namespace input
+
/*
* Crash if the provided touch stream is inconsistent.
+ * This class is a pass-through to the rust implementation of InputVerifier.
+ * The rust class could also be used directly, but it would be less convenient.
+ * We can't directly invoke the rust methods on a rust object. So, there's no way to do:
+ * mVerifier.process_movement(...).
+ * This C++ class makes it a bit easier to use.
*
* TODO(b/211379801): Add support for hover events:
* - No hover move without enter
@@ -34,16 +46,13 @@ class InputVerifier {
public:
InputVerifier(const std::string& name);
- void processMovement(int32_t deviceId, int32_t action, uint32_t pointerCount,
- const PointerProperties* pointerProperties,
- const PointerCoords* pointerCoords, int32_t flags);
+ android::base::Result<void> processMovement(int32_t deviceId, int32_t action,
+ uint32_t pointerCount,
+ const PointerProperties* pointerProperties,
+ const PointerCoords* pointerCoords, int32_t flags);
private:
- const std::string mName;
- std::map<int32_t /*deviceId*/, std::bitset<MAX_POINTER_ID + 1>> mTouchingPointerIdsByDevice;
- void ensureTouchingPointersMatch(int32_t deviceId, uint32_t pointerCount,
- const PointerProperties* pointerProperties,
- const char* action) const;
+ rust::Box<android::input::verifier::InputVerifier> mVerifier;
};
} // namespace android