Use unordered_map for connections
Currently, keyedvector is used for keeping track of connections by file
descriptors. Instead, use supported api std::unordered_map.
Also, no longer remove raw indices into the map, because that's
implementation detail of map that should not be user-facing.
Bug: 70668286
Test: SANITIZE_TARGET=hwaddress atest libinput_tests inputflinger_tests
Change-Id: Id31b0002a7ff2310dcc506f834722b1e69a05571
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
index 92e1e5f..e35ba27 100644
--- a/services/inputflinger/InputDispatcher.h
+++ b/services/inputflinger/InputDispatcher.h
@@ -887,7 +887,7 @@
bool addOutsideTargets = false, bool addPortalWindows = false) REQUIRES(mLock);
// All registered connections mapped by channel file descriptor.
- KeyedVector<int, sp<Connection> > mConnectionsByFd GUARDED_BY(mLock);
+ std::unordered_map<int, sp<Connection>> mConnectionsByFd GUARDED_BY(mLock);
struct IBinderHash {
std::size_t operator()(const sp<IBinder>& b) const {
@@ -901,7 +901,7 @@
std::optional<int32_t> findGestureMonitorDisplayByTokenLocked(const sp<IBinder>& token)
REQUIRES(mLock);
- ssize_t getConnectionIndexLocked(const sp<InputChannel>& inputChannel) REQUIRES(mLock);
+ sp<Connection> getConnectionLocked(const sp<InputChannel>& inputChannel) REQUIRES(mLock);
// Input channels that will receive a copy of all input events sent to the provided display.
std::unordered_map<int32_t, std::vector<Monitor>> mGlobalMonitorsByDisplay