Merge "Remove device state when device is reset" into rvc-dev am: 104600438d
Change-Id: Idb212ed32d62234a794f66456a43a54057f3b260
diff --git a/services/inputflinger/BlockingQueue.h b/services/inputflinger/BlockingQueue.h
index db9f26e..b612ca7 100644
--- a/services/inputflinger/BlockingQueue.h
+++ b/services/inputflinger/BlockingQueue.h
@@ -45,10 +45,7 @@
T pop() {
std::unique_lock lock(mLock);
android::base::ScopedLockAssertion assumeLock(mLock);
- mHasElements.wait(lock, [this]{
- android::base::ScopedLockAssertion assumeLock(mLock);
- return !this->mQueue.empty();
- });
+ mHasElements.wait(lock, [this]() REQUIRES(mLock) { return !this->mQueue.empty(); });
T t = std::move(mQueue.front());
mQueue.erase(mQueue.begin());
return t;
diff --git a/services/inputflinger/InputClassifier.cpp b/services/inputflinger/InputClassifier.cpp
index ae9a348..e5e83d7 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputClassifier.cpp
@@ -250,7 +250,7 @@
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: {
@@ -321,6 +321,12 @@
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);
@@ -455,6 +461,7 @@
void InputClassifier::dump(std::string& dump) {
std::scoped_lock lock(mLock);
dump += "Input Classifier State:\n";
+ dump += StringPrintf(INDENT1 "Deep press: %s\n", deepPressEnabled() ? "enabled" : "disabled");
dump += INDENT1 "Motion Classifier:\n";
if (mMotionClassifier) {
diff --git a/services/inputflinger/InputClassifier.h b/services/inputflinger/InputClassifier.h
index 47e20db..9692352 100644
--- a/services/inputflinger/InputClassifier.h
+++ b/services/inputflinger/InputClassifier.h
@@ -212,6 +212,8 @@
void updateLastDownTime(int32_t deviceId, nsecs_t downTime);
+ void clearDeviceState(int32_t deviceId);
+
/**
* Exit the InputClassifier HAL thread.
* Useful for tests to ensure proper cleanup.