Use std::set instead of SortedVector
We only care whether a certain input device is present in a list or not.
For that, we can just use an std::set and not have to use custom
SortedVector data structure. This makes it easier for someone already
familiar with c++ but not necessarily Android to follow the code. It
also ensures that the data structure is properly maintained going
forward.
Bug: 137212522
Test: atest libinput_tests inputflinger_tests
Change-Id: I7808b41524ae0b87dbf1aaf7a49afa64b14b3eb9
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index eee49d5..2de5ffa 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -1094,8 +1094,8 @@
}
if (!changes || (changes & InputReaderConfiguration::CHANGE_ENABLED_STATE)) {
- ssize_t index = config->disabledDevices.indexOf(mId);
- bool enabled = index < 0;
+ auto it = config->disabledDevices.find(mId);
+ bool enabled = it == config->disabledDevices.end();
setEnabled(enabled, when);
}