diff options
| author | 2024-05-01 22:48:16 +0000 | |
|---|---|---|
| committer | 2024-05-01 16:06:04 -0700 | |
| commit | 8c5f7bec585e734ab466f0b8a2a5bfb5914973e3 (patch) | |
| tree | 17fa4d703ce54a0d09830f4354fad0a8335ff9fe | |
| parent | 99a0f11460077e2f773a23792d18f7f76b9a31f9 (diff) | |
Move BlockingQueue.h to libinput
This is already useful in several places, and it's going to be also
useful in the future when InputConsumer is refactored.
So let's move it to include/input.
Bug: 311142655
Test: m inputflinger_blocking_queue_fuzzer
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3782af62ea590e8945f2175a90aa2b6f4995814d)
Merged-In: Idfc492c6bfc3cccab7e0b0d12b21a41a954cc44b
Change-Id: Ie662961b77d331cd62b529bae0fd66e56a69bd19
| -rw-r--r-- | include/input/BlockingQueue.h (renamed from services/inputflinger/BlockingQueue.h) | 0 | ||||
| -rw-r--r-- | libs/input/tests/Android.bp | 1 | ||||
| -rw-r--r-- | libs/input/tests/BlockingQueue_test.cpp (renamed from services/inputflinger/tests/BlockingQueue_test.cpp) | 7 | ||||
| -rw-r--r-- | services/inputflinger/InputProcessor.h | 2 | ||||
| -rw-r--r-- | services/inputflinger/tests/Android.bp | 1 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputDispatcher_test.cpp | 2 | ||||
| -rw-r--r-- | services/inputflinger/tests/fuzzers/BlockingQueueFuzzer.cpp | 2 |
7 files changed, 7 insertions, 8 deletions
diff --git a/services/inputflinger/BlockingQueue.h b/include/input/BlockingQueue.h index f848c82c42..f848c82c42 100644 --- a/services/inputflinger/BlockingQueue.h +++ b/include/input/BlockingQueue.h diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp index 13cfb491b5..9137a3468f 100644 --- a/libs/input/tests/Android.bp +++ b/libs/input/tests/Android.bp @@ -13,6 +13,7 @@ cc_test { cpp_std: "c++20", host_supported: true, srcs: [ + "BlockingQueue_test.cpp", "IdGenerator_test.cpp", "InputChannel_test.cpp", "InputDevice_test.cpp", diff --git a/services/inputflinger/tests/BlockingQueue_test.cpp b/libs/input/tests/BlockingQueue_test.cpp index 754a5c451e..924b937080 100644 --- a/services/inputflinger/tests/BlockingQueue_test.cpp +++ b/libs/input/tests/BlockingQueue_test.cpp @@ -14,8 +14,7 @@ * limitations under the License. */ -#include "../BlockingQueue.h" - +#include <input/BlockingQueue.h> #include <gtest/gtest.h> #include <thread> @@ -109,7 +108,7 @@ TEST(BlockingQueueTest, Queue_AllowsMultipleThreads) { BlockingQueue<int> queue(capacity); // Fill queue from a different thread - std::thread fillQueue([&queue](){ + std::thread fillQueue([&queue]() { for (size_t i = 0; i < capacity; i++) { ASSERT_TRUE(queue.push(static_cast<int>(i))); } @@ -136,7 +135,7 @@ TEST(BlockingQueueTest, Queue_BlocksWhileWaitingForElements) { std::atomic_bool hasReceivedElement = false; // fill queue from a different thread - std::thread waitUntilHasElements([&queue, &hasReceivedElement](){ + std::thread waitUntilHasElements([&queue, &hasReceivedElement]() { queue.pop(); // This should block until an element has been added hasReceivedElement = true; }); diff --git a/services/inputflinger/InputProcessor.h b/services/inputflinger/InputProcessor.h index dcbfebc62f..7a00a2dae8 100644 --- a/services/inputflinger/InputProcessor.h +++ b/services/inputflinger/InputProcessor.h @@ -22,7 +22,7 @@ #include <unordered_map> #include <aidl/android/hardware/input/processor/IInputProcessor.h> -#include "BlockingQueue.h" +#include <input/BlockingQueue.h> #include "InputListener.h" namespace android { diff --git a/services/inputflinger/tests/Android.bp b/services/inputflinger/tests/Android.bp index 2a03ecc62b..9c9f643656 100644 --- a/services/inputflinger/tests/Android.bp +++ b/services/inputflinger/tests/Android.bp @@ -39,7 +39,6 @@ cc_test { ], srcs: [ "AnrTracker_test.cpp", - "BlockingQueue_test.cpp", "CapturedTouchpadEventConverter_test.cpp", "CursorInputMapper_test.cpp", "EventHub_test.cpp", diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp index 5002391f61..c2e67fa788 100644 --- a/services/inputflinger/tests/InputDispatcher_test.cpp +++ b/services/inputflinger/tests/InputDispatcher_test.cpp @@ -15,7 +15,6 @@ */ #include "../dispatcher/InputDispatcher.h" -#include "../BlockingQueue.h" #include "FakeApplicationHandle.h" #include "TestEventMatchers.h" @@ -31,6 +30,7 @@ #include <flag_macros.h> #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <input/BlockingQueue.h> #include <input/Input.h> #include <input/PrintTools.h> #include <linux/input.h> diff --git a/services/inputflinger/tests/fuzzers/BlockingQueueFuzzer.cpp b/services/inputflinger/tests/fuzzers/BlockingQueueFuzzer.cpp index 219b662ffb..863d0a165e 100644 --- a/services/inputflinger/tests/fuzzers/BlockingQueueFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/BlockingQueueFuzzer.cpp @@ -15,8 +15,8 @@ */ #include <fuzzer/FuzzedDataProvider.h> +#include <input/BlockingQueue.h> #include <thread> -#include "BlockingQueue.h" // Chosen to be a number large enough for variation in fuzzer runs, but not consume too much memory. static constexpr size_t MAX_CAPACITY = 1024; |