Reset InputClassifier HAL when system starts
Under normal operation, the system and the HAL will both start at the
same time, and will have initial state. However, since they are in
separate, and independent, processes, one can crash while another would
remain functional. For example, if the system crashes, the HAL may still
be operational.
To account for these situations, send a complete reset to the HAL when
the system loads. This would help ensure that HAL has consistent state
every time the system starts.
Test: none
Bug: 117935272
Change-Id: I90e53fd4205f018c87af8eb8ac16d54fe9a62011
diff --git a/services/inputflinger/InputClassifier.cpp b/services/inputflinger/InputClassifier.cpp
index 11427c3..7ade0d4 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputClassifier.cpp
@@ -505,6 +505,11 @@
// Set the thread name for debugging
pthread_setname_np(mHalThread.native_handle(), "InputClassifier");
#endif
+ // Under normal operation, we do not need to reset the HAL here. But in the case where system
+ // crashed, but HAL didn't, we may be connecting to an existing HAL process that might already
+ // have received events in the past. That means, that HAL could be in an inconsistent state
+ // once it receives events from the newly created MotionClassifier.
+ mEvents.push(ClassifierEvent::createHalResetEvent());
}
MotionClassifier::~MotionClassifier() {