summaryrefslogtreecommitdiff
path: root/services/inputflinger/InputClassifier.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2020-09-10 17:22:18 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2020-09-10 17:22:18 +0000
commitcdb6b16dec3a541b455be99d075004cb2f0a0cd7 (patch)
treef7110d50445c67a337105034b1f2db3946a88fef /services/inputflinger/InputClassifier.cpp
parent171cac1b603e4bb83412eb596d05a500af5d7a76 (diff)
parentac07d0f5ab16bb9e8bbbabb589d1c7d36817baa9 (diff)
Merge "Merge Android R"
Diffstat (limited to 'services/inputflinger/InputClassifier.cpp')
-rw-r--r--services/inputflinger/InputClassifier.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/services/inputflinger/InputClassifier.cpp b/services/inputflinger/InputClassifier.cpp
index cda0e0cdcb..77a0716269 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputClassifier.cpp
@@ -191,7 +191,7 @@ void MotionClassifier::processEvents() {
case ClassifierEventType::DEVICE_RESET: {
const int32_t deviceId = *(event.getDeviceId());
halResponseOk = mService->resetDevice(deviceId).isOk();
- setClassification(deviceId, MotionClassification::NONE);
+ clearDeviceState(deviceId);
break;
}
case ClassifierEventType::HAL_RESET: {
@@ -217,7 +217,7 @@ void MotionClassifier::enqueueEvent(ClassifierEvent&& event) {
bool eventAdded = mEvents.push(std::move(event));
if (!eventAdded) {
// If the queue is full, suspect the HAL is slow in processing the events.
- ALOGE("Dropped event with eventTime %" PRId64, event.args->eventTime);
+ ALOGE("Could not add the event to the queue. Resetting");
reset();
}
}
@@ -262,6 +262,12 @@ void MotionClassifier::updateLastDownTime(int32_t deviceId, nsecs_t downTime) {
mClassifications[deviceId] = MotionClassification::NONE;
}
+void MotionClassifier::clearDeviceState(int32_t deviceId) {
+ std::scoped_lock lock(mLock);
+ mClassifications.erase(deviceId);
+ mLastDownTimes.erase(deviceId);
+}
+
MotionClassification MotionClassifier::classify(const NotifyMotionArgs& args) {
if ((args.action & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_DOWN) {
updateLastDownTime(args.deviceId, args.downTime);
@@ -408,7 +414,6 @@ void InputClassifier::setMotionClassifier(
void InputClassifier::dump(std::string& dump) {
std::scoped_lock lock(mLock);
dump += "Input Classifier State:\n";
-
dump += INDENT1 "Motion Classifier:\n";
if (mMotionClassifier) {
mMotionClassifier->dump(dump);