Metrics Collector: Prevent queuing interactions from ignored devices

We don't collect metrics for injected events. Since the interactions
queue is processed from the InputReader thread, if many interactions
are notified by InputDispatcher when the Reader thread is not active
(e.g. for interactions from injected events), it's possible for the
interactions queue to grow indefinitely.

To mitigate this:
- Do not queue interactions from ignored devices, such as those
  from injected events that use VIRTUAL_KEYBOARD_ID. This prevents
  the queue from growing in the first place due to injected events,
  which do not come from the Reader thread.
- Ensure the interactions queue is bounded so that it cannot grow
  indefinitely.

Bug: 287676652
Test: manual
Test: atest inputflinger_tests
Change-Id: I1ce27b1817704dd83307fab1917465dcb85ac31e
diff --git a/services/inputflinger/tests/SyncQueue_test.cpp b/services/inputflinger/tests/SyncQueue_test.cpp
index af2f961..b57ccc2 100644
--- a/services/inputflinger/tests/SyncQueue_test.cpp
+++ b/services/inputflinger/tests/SyncQueue_test.cpp
@@ -50,6 +50,18 @@
     }
 }
 
+// Make sure the queue has strict capacity limits.
+TEST(SyncQueueTest, QueueReachesCapacity) {
+    constexpr size_t capacity = 3;
+    SyncQueue<int> queue(capacity);
+
+    // First 3 elements should be added successfully
+    ASSERT_TRUE(queue.push(1));
+    ASSERT_TRUE(queue.push(2));
+    ASSERT_TRUE(queue.push(3));
+    ASSERT_FALSE(queue.push(4)) << "Queue should reach capacity at size " << capacity;
+}
+
 TEST(SyncQueueTest, AllowsMultipleThreads) {
     SyncQueue<int> queue;