From ba9d3c83b7c1a7cd6d48c1f49c7f3cfc418592fe Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Wed, 23 Jan 2019 15:14:20 -0800 Subject: [PATCH] Add reset to InputClassifier HAL The reset will be used to prevent an inconsistent stream of events to be sent to the HAL. Bug: 111480215 Test: make only Change-Id: I40c7d671f094065e3fcaff0d83e826c580dcae7a --- input/classifier/1.0/IInputClassifier.hal | 12 ++++++++++++ input/classifier/1.0/default/InputClassifier.cpp | 12 ++++++++++++ input/classifier/1.0/default/InputClassifier.h | 3 +++ 3 files changed, 27 insertions(+) diff --git a/input/classifier/1.0/IInputClassifier.hal b/input/classifier/1.0/IInputClassifier.hal index 5f8c2a564d..7397fea127 100644 --- a/input/classifier/1.0/IInputClassifier.hal +++ b/input/classifier/1.0/IInputClassifier.hal @@ -26,4 +26,16 @@ interface IInputClassifier { */ classify(MotionEvent event) generates (Classification classification); + /** + * Called by the framework to reset the HAL internal state. The reset may be called + * to prevent an inconsistent stream of events to be sent to the HAL. + */ + reset(); + + /** + * Called by the framework to reset the HAL internal state for a specific device. + * The reset may be called once device reset is received by the framework. + */ + resetDevice(int32_t deviceId); + }; diff --git a/input/classifier/1.0/default/InputClassifier.cpp b/input/classifier/1.0/default/InputClassifier.cpp index 7005e9d8b6..a78bbc5c94 100644 --- a/input/classifier/1.0/default/InputClassifier.cpp +++ b/input/classifier/1.0/default/InputClassifier.cpp @@ -57,6 +57,18 @@ Return InputClassifier::classify(const MotionEvent& event) { return Classification::NONE; } +Return InputClassifier::reset() { + // We don't have any internal state in this example implementation, + // so no work needed here. + return Void(); +} + +Return InputClassifier::resetDevice(int32_t /*deviceId*/) { + // We don't have any internal per-device state in this example implementation, + // so no work needed here. + return Void(); +} + } // namespace implementation } // namespace V1_0 } // namespace classifier diff --git a/input/classifier/1.0/default/InputClassifier.h b/input/classifier/1.0/default/InputClassifier.h index 39c4b17b38..eef370e706 100644 --- a/input/classifier/1.0/default/InputClassifier.h +++ b/input/classifier/1.0/default/InputClassifier.h @@ -34,6 +34,9 @@ struct InputClassifier : public IInputClassifier { Return classify( const android::hardware::input::common::V1_0::MotionEvent& event) override; + + Return reset() override; + Return resetDevice(int32_t deviceId) override; }; } // namespace implementation