summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Derek Wu <derekwu@google.com> 2024-03-25 13:17:51 -0700
committer Derek Wu <derekwu@google.com> 2024-03-25 13:22:25 -0700
commitea36ee7cff42e98b31878f701dee4da3b2b4ecd7 (patch)
treeff242471ef07dc04a6ee5c8120b09a2c03d338c5
parentae9b557b8580fa5a50bf0d66ac2a141b977edc40 (diff)
Add fixed read only flag to enable jerk prediction pruning
For now this flag will simply allow all motion predictions (no-op). Test: atest libinput_tests Bug: 266747654 Change-Id: If54b924223255c068fff26f8b6f21cdd31799aea
-rw-r--r--libs/input/MotionPredictor.cpp13
-rw-r--r--libs/input/input_flags.aconfig9
2 files changed, 21 insertions, 1 deletions
diff --git a/libs/input/MotionPredictor.cpp b/libs/input/MotionPredictor.cpp
index c4e3ff6dee..1df88dd497 100644
--- a/libs/input/MotionPredictor.cpp
+++ b/libs/input/MotionPredictor.cpp
@@ -22,17 +22,21 @@
#include <cmath>
#include <cstddef>
#include <cstdint>
+#include <limits>
#include <string>
#include <vector>
#include <android-base/logging.h>
#include <android-base/strings.h>
#include <android/input.h>
+#include <com_android_input_flags.h>
#include <attestation/HmacKeyManager.h>
#include <ftl/enum.h>
#include <input/TfLiteMotionPredictor.h>
+namespace input_flags = com::android::input::flags;
+
namespace android {
namespace {
@@ -197,7 +201,14 @@ std::unique_ptr<MotionEvent> MotionPredictor::predict(nsecs_t timestamp) {
// device starts to speed up, but avoids producing noisy predictions as it slows down.
break;
}
- // TODO(b/266747654): Stop predictions if confidence is < some threshold.
+ if (input_flags::enable_prediction_pruning_via_jerk_thresholding()) {
+ // TODO(b/266747654): Stop predictions if confidence is < some threshold
+ // Arbitrarily high pruning index, will correct once jerk thresholding is implemented.
+ const size_t upperBoundPredictionIndex = std::numeric_limits<size_t>::max();
+ if (i > upperBoundPredictionIndex) {
+ break;
+ }
+ }
const TfLiteMotionPredictorSample::Point predictedPoint =
convertPrediction(axisFrom, axisTo, predictedR[i], predictedPhi[i]);
diff --git a/libs/input/input_flags.aconfig b/libs/input/input_flags.aconfig
index b48b0fb924..e041c51cc9 100644
--- a/libs/input/input_flags.aconfig
+++ b/libs/input/input_flags.aconfig
@@ -128,3 +128,12 @@ flag {
description: "Enable fling scrolling to be stopped by putting a finger on the touchpad again"
bug: "281106755"
}
+
+flag {
+ name: "enable_prediction_pruning_via_jerk_thresholding"
+ namespace: "input"
+ description: "Enable prediction pruning based on jerk thresholds."
+ bug: "266747654"
+ is_fixed_read_only: true
+
+}