Fix possible crash in scale-invariant error calculation
The logic for the scale-invariant calculation was quite complex
in the existing code, and depended on some tricky chains of logical
dependence between scale-invariant errors and general errors.
This change firstly eliminates unnecessary nesting by pulling the
scale-invariant error calculation out of the loop – the full calculation
only occurs once per computeAtomFields call, within its own loop.
Secondly, instead of crashing under certain conditions when the
scale-invariant error count is zero, this changes the code to simply not
compute the error in this case. (The complex chain of logic I had
followed to initially add the fatal crash turned out to be fallacious.)
Finally, this adds a testcase that fails without the changes to the
MetricsManager implementation (see ag/26418604). This added testcase
represents skipped/dropped input events, or an input interval greater
than the prediction interval.
Test: atest frameworks/native/libs/input/tests/MotionPredictorMetricsManager_test.cpp
Test: the above test fails without the changes to MotionPredictionMetricsManager.cpp
Test: `statsd_testdrive 718`, then draw with stylus → reported metrics are reasonable
Bug: 325711945
Change-Id: Ic56c0f0c810ec1b85b1906e16a8640824187d1fb
2 files changed