Rename InputClassifier to InputProcessor
The InputClassifier stage now calls a HAL that was renamed to
IInputProcessor. Let's rename the input stage accordingly.
Bug: 210158587
Test: atest inputflinger_tests
Change-Id: Id1a4f01b07b404064917acd0beb04b839abb2929
diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp
index 554514d..d62f4aa 100644
--- a/services/inputflinger/Android.bp
+++ b/services/inputflinger/Android.bp
@@ -56,7 +56,7 @@
filegroup {
name: "libinputflinger_sources",
srcs: [
- "InputClassifier.cpp",
+ "InputProcessor.cpp",
"InputCommonConverter.cpp",
"PreferStylusOverTouchBlocker.cpp",
"UnwantedInteractionBlocker.cpp",
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index 9767cd9..9182503 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -55,14 +55,14 @@
/**
* The event flow is via the "InputListener" interface, as follows:
- * InputReader -> UnwantedInteractionBlocker -> InputClassifier -> InputDispatcher
+ * InputReader -> UnwantedInteractionBlocker -> InputProcessor -> InputDispatcher
*/
InputManager::InputManager(
const sp<InputReaderPolicyInterface>& readerPolicy,
const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
mDispatcher = createInputDispatcher(dispatcherPolicy);
- mClassifier = std::make_unique<InputClassifier>(*mDispatcher);
- mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mClassifier);
+ mProcessor = std::make_unique<InputProcessor>(*mDispatcher);
+ mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mProcessor);
mReader = createInputReader(readerPolicy, *mBlocker);
}
@@ -110,12 +110,12 @@
return *mReader;
}
-UnwantedInteractionBlockerInterface& InputManager::getUnwantedInteractionBlocker() {
+UnwantedInteractionBlockerInterface& InputManager::getBlocker() {
return *mBlocker;
}
-InputClassifierInterface& InputManager::getClassifier() {
- return *mClassifier;
+InputProcessorInterface& InputManager::getProcessor() {
+ return *mProcessor;
}
InputDispatcherInterface& InputManager::getDispatcher() {
@@ -125,7 +125,7 @@
void InputManager::monitor() {
mReader->monitor();
mBlocker->monitor();
- mClassifier->monitor();
+ mProcessor->monitor();
mDispatcher->monitor();
}
diff --git a/services/inputflinger/InputManager.h b/services/inputflinger/InputManager.h
index 8aad35b..b40ab7f 100644
--- a/services/inputflinger/InputManager.h
+++ b/services/inputflinger/InputManager.h
@@ -21,7 +21,7 @@
* Native input manager.
*/
-#include "InputClassifier.h"
+#include "InputProcessor.h"
#include "InputReaderBase.h"
#include "include/UnwantedInteractionBlockerInterface.h"
@@ -52,10 +52,11 @@
* this could be a palm on the screen. This stage would alter the event stream to remove either
* partially (some of the pointers) or fully (all touches) the unwanted interaction. The events
* are processed on the InputReader thread, without any additional queue. The events are then
- * posted to the queue managed by the InputClassifier.
- * 3. The InputClassifier class starts a thread to communicate with the device-specific
- * classifiers. It then waits on the queue of events from UnwantedInteractionBlocker, applies
- * a classification to them, and queues them for the InputDispatcher.
+ * posted to the queue managed by the InputProcessor.
+ * 3. The InputProcessor class starts a thread to communicate with the device-specific
+ * IInputProcessor HAL. It then waits on the queue of events from UnwantedInteractionBlocker,
+ * processes the events (for example, applies a classification to the events), and queues them
+ * for the InputDispatcher.
* 4. The InputDispatcher class starts a thread that waits for new events on the
* previous queue and asynchronously dispatches them to applications.
*
@@ -83,10 +84,10 @@
virtual InputReaderInterface& getReader() = 0;
/* Gets the unwanted interaction blocker. */
- virtual UnwantedInteractionBlockerInterface& getUnwantedInteractionBlocker() = 0;
+ virtual UnwantedInteractionBlockerInterface& getBlocker() = 0;
- /* Gets the input classifier */
- virtual InputClassifierInterface& getClassifier() = 0;
+ /* Gets the input processor */
+ virtual InputProcessorInterface& getProcessor() = 0;
/* Gets the input dispatcher. */
virtual InputDispatcherInterface& getDispatcher() = 0;
@@ -108,8 +109,8 @@
status_t stop() override;
InputReaderInterface& getReader() override;
- UnwantedInteractionBlockerInterface& getUnwantedInteractionBlocker() override;
- InputClassifierInterface& getClassifier() override;
+ UnwantedInteractionBlockerInterface& getBlocker() override;
+ InputProcessorInterface& getProcessor() override;
InputDispatcherInterface& getDispatcher() override;
void monitor() override;
@@ -123,7 +124,7 @@
std::unique_ptr<UnwantedInteractionBlockerInterface> mBlocker;
- std::unique_ptr<InputClassifierInterface> mClassifier;
+ std::unique_ptr<InputProcessorInterface> mProcessor;
std::unique_ptr<InputDispatcherInterface> mDispatcher;
};
diff --git a/services/inputflinger/InputClassifier.cpp b/services/inputflinger/InputProcessor.cpp
similarity index 85%
rename from services/inputflinger/InputClassifier.cpp
rename to services/inputflinger/InputProcessor.cpp
index 21695c3..0749441 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputProcessor.cpp
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#define LOG_TAG "InputClassifier"
+#define LOG_TAG "InputProcessor"
-#include "InputClassifier.h"
+#include "InputProcessor.h"
#include "InputCommonConverter.h"
#include <android-base/stringprintf.h>
@@ -27,7 +27,7 @@
#include <algorithm>
#include <cmath>
#if defined(__linux__)
- #include <pthread.h>
+#include <pthread.h>
#endif
#include <unordered_set>
@@ -44,10 +44,10 @@
namespace android {
-//Max number of elements to store in mEvents.
+// Max number of elements to store in mEvents.
static constexpr size_t MAX_EVENTS = 5;
-template<class K, class V>
+template <class K, class V>
static V getValueForKey(const std::unordered_map<K, V>& map, K key, V defaultValue) {
auto it = map.find(key);
if (it == map.end()) {
@@ -123,15 +123,15 @@
// --- ClassifierEvent ---
-ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyMotionArgs> args) :
- type(ClassifierEventType::MOTION), args(std::move(args)) { };
-ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyDeviceResetArgs> args) :
- type(ClassifierEventType::DEVICE_RESET), args(std::move(args)) { };
-ClassifierEvent::ClassifierEvent(ClassifierEventType type, std::unique_ptr<NotifyArgs> args) :
- type(type), args(std::move(args)) { };
+ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyMotionArgs> args)
+ : type(ClassifierEventType::MOTION), args(std::move(args)){};
+ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyDeviceResetArgs> args)
+ : type(ClassifierEventType::DEVICE_RESET), args(std::move(args)){};
+ClassifierEvent::ClassifierEvent(ClassifierEventType type, std::unique_ptr<NotifyArgs> args)
+ : type(type), args(std::move(args)){};
-ClassifierEvent::ClassifierEvent(ClassifierEvent&& other) :
- type(other.type), args(std::move(other.args)) { };
+ClassifierEvent::ClassifierEvent(ClassifierEvent&& other)
+ : type(other.type), args(std::move(other.args)){};
ClassifierEvent& ClassifierEvent::operator=(ClassifierEvent&& other) {
type = other.type;
@@ -180,7 +180,7 @@
mHalThread = std::thread(&MotionClassifier::processEvents, this);
#if defined(__linux__)
// Set the thread name for debugging
- pthread_setname_np(mHalThread.native_handle(), "InputClassifier");
+ pthread_setname_np(mHalThread.native_handle(), "InputProcessor");
#endif
}
@@ -198,7 +198,7 @@
/**
* Obtain the classification from the HAL for a given MotionEvent.
- * Should only be called from the InputClassifier thread (mHalThread).
+ * Should only be called from the InputProcessor thread (mHalThread).
* Should not be called from the thread that notifyMotion runs on.
*
* There is no way to provide a timeout for a HAL call. So if the HAL takes too long
@@ -239,8 +239,8 @@
}
}
if (!halResponseOk) {
- ALOGE("Error communicating with InputClassifier HAL. "
- "Exiting MotionClassifier HAL thread");
+ ALOGE("Error communicating with InputProcessor HAL. "
+ "Exiting MotionClassifier HAL thread");
clearClassifications();
return;
}
@@ -262,14 +262,14 @@
}
void MotionClassifier::updateClassification(int32_t deviceId, nsecs_t eventTime,
- MotionClassification classification) {
+ MotionClassification classification) {
std::scoped_lock lock(mLock);
const nsecs_t lastDownTime = getValueForKey(mLastDownTimes, deviceId, static_cast<nsecs_t>(0));
if (eventTime < lastDownTime) {
// HAL just finished processing an event that belonged to an earlier gesture,
// but new gesture is already in progress. Drop this classification.
ALOGW("Received late classification. Late by at least %" PRId64 " ms.",
- nanoseconds_to_milliseconds(lastDownTime - eventTime));
+ nanoseconds_to_milliseconds(lastDownTime - eventTime));
return;
}
mClassifications[deviceId] = classification;
@@ -319,14 +319,14 @@
/**
* Per-device reset. Clear the outstanding events that are going to be sent to HAL.
- * Request InputClassifier thread to call resetDevice for this particular device.
+ * Request InputProcessor thread to call resetDevice for this particular device.
*/
void MotionClassifier::reset(const NotifyDeviceResetArgs& args) {
int32_t deviceId = args.deviceId;
// Clear the pending events right away, to avoid unnecessary work done by the HAL.
mEvents.erase([deviceId](const ClassifierEvent& event) {
- std::optional<int32_t> eventDeviceId = event.getDeviceId();
- return eventDeviceId && (*eventDeviceId == deviceId);
+ std::optional<int32_t> eventDeviceId = event.getDeviceId();
+ return eventDeviceId && (*eventDeviceId == deviceId);
});
enqueueEvent(std::make_unique<NotifyDeviceResetArgs>(args));
}
@@ -334,23 +334,22 @@
void MotionClassifier::dump(std::string& dump) {
std::scoped_lock lock(mLock);
dump += StringPrintf(INDENT2 "mService connected: %s\n", mService ? "true" : "false");
- dump += StringPrintf(INDENT2 "mEvents: %zu element(s) (max=%zu)\n",
- mEvents.size(), MAX_EVENTS);
+ dump += StringPrintf(INDENT2 "mEvents: %zu element(s) (max=%zu)\n", mEvents.size(), MAX_EVENTS);
dump += INDENT2 "mClassifications, mLastDownTimes:\n";
dump += INDENT3 "Device Id\tClassification\tLast down time";
// Combine mClassifications and mLastDownTimes into a single table.
// Create a superset of device ids.
std::unordered_set<int32_t> deviceIds;
std::for_each(mClassifications.begin(), mClassifications.end(),
- [&deviceIds](auto pair){ deviceIds.insert(pair.first); });
+ [&deviceIds](auto pair) { deviceIds.insert(pair.first); });
std::for_each(mLastDownTimes.begin(), mLastDownTimes.end(),
- [&deviceIds](auto pair){ deviceIds.insert(pair.first); });
- for(int32_t deviceId : deviceIds) {
+ [&deviceIds](auto pair) { deviceIds.insert(pair.first); });
+ for (int32_t deviceId : deviceIds) {
const MotionClassification classification =
getValueForKey(mClassifications, deviceId, MotionClassification::NONE);
const nsecs_t downTime = getValueForKey(mLastDownTimes, deviceId, static_cast<nsecs_t>(0));
- dump += StringPrintf("\n" INDENT4 "%" PRId32 "\t%s\t%" PRId64,
- deviceId, motionClassificationToString(classification), downTime);
+ dump += StringPrintf("\n" INDENT4 "%" PRId32 "\t%s\t%" PRId64, deviceId,
+ motionClassificationToString(classification), downTime);
}
}
@@ -366,20 +365,20 @@
}
}
-// --- InputClassifier ---
+// --- InputProcessor ---
-InputClassifier::InputClassifier(InputListenerInterface& listener) : mQueuedListener(listener) {}
+InputProcessor::InputProcessor(InputListenerInterface& listener) : mQueuedListener(listener) {}
-void InputClassifier::onBinderDied(void* cookie) {
- InputClassifier* classifier = static_cast<InputClassifier*>(cookie);
- if (classifier == nullptr) {
+void InputProcessor::onBinderDied(void* cookie) {
+ InputProcessor* processor = static_cast<InputProcessor*>(cookie);
+ if (processor == nullptr) {
LOG_ALWAYS_FATAL("Cookie is not valid");
return;
}
- classifier->setMotionClassifierEnabled(false);
+ processor->setMotionClassifierEnabled(false);
}
-void InputClassifier::setMotionClassifierEnabled(bool enabled) {
+void InputProcessor::setMotionClassifierEnabled(bool enabled) {
std::scoped_lock lock(mLock);
if (enabled) {
ALOGI("Enabling motion classifier");
@@ -392,7 +391,7 @@
* and we can't continue because 'mInitializeMotionClassifier' will block in its
* destructor.
*/
- LOG_ALWAYS_FATAL("The thread to load IInputClassifier is stuck!");
+ LOG_ALWAYS_FATAL("The thread to load IInputProcessor is stuck!");
}
}
mInitializeMotionClassifier = std::async(std::launch::async, [this] {
@@ -416,19 +415,19 @@
}
}
-void InputClassifier::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
+void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
// pass through
mQueuedListener.notifyConfigurationChanged(args);
mQueuedListener.flush();
}
-void InputClassifier::notifyKey(const NotifyKeyArgs* args) {
+void InputProcessor::notifyKey(const NotifyKeyArgs* args) {
// pass through
mQueuedListener.notifyKey(args);
mQueuedListener.flush();
}
-void InputClassifier::notifyMotion(const NotifyMotionArgs* args) {
+void InputProcessor::notifyMotion(const NotifyMotionArgs* args) {
{ // acquire lock
std::scoped_lock lock(mLock);
// MotionClassifier is only used for touch events, for now
@@ -444,25 +443,25 @@
mQueuedListener.flush();
}
-void InputClassifier::notifySensor(const NotifySensorArgs* args) {
+void InputProcessor::notifySensor(const NotifySensorArgs* args) {
// pass through
mQueuedListener.notifySensor(args);
mQueuedListener.flush();
}
-void InputClassifier::notifyVibratorState(const NotifyVibratorStateArgs* args) {
+void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs* args) {
// pass through
mQueuedListener.notifyVibratorState(args);
mQueuedListener.flush();
}
-void InputClassifier::notifySwitch(const NotifySwitchArgs* args) {
+void InputProcessor::notifySwitch(const NotifySwitchArgs* args) {
// pass through
mQueuedListener.notifySwitch(args);
mQueuedListener.flush();
}
-void InputClassifier::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
{ // acquire lock
std::scoped_lock lock(mLock);
if (mMotionClassifier) {
@@ -475,13 +474,13 @@
mQueuedListener.flush();
}
-void InputClassifier::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
+void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
// pass through
mQueuedListener.notifyPointerCaptureChanged(args);
mQueuedListener.flush();
}
-void InputClassifier::setMotionClassifierLocked(
+void InputProcessor::setMotionClassifierLocked(
std::unique_ptr<MotionClassifierInterface> motionClassifier) REQUIRES(mLock) {
if (motionClassifier == nullptr) {
// Destroy the ScopedDeathRecipient object, which will cause it to unlinkToDeath.
@@ -491,9 +490,9 @@
mMotionClassifier = std::move(motionClassifier);
}
-void InputClassifier::dump(std::string& dump) {
+void InputProcessor::dump(std::string& dump) {
std::scoped_lock lock(mLock);
- dump += "Input Classifier State:\n";
+ dump += "Input Processor State:\n";
dump += INDENT1 "Motion Classifier:\n";
if (mMotionClassifier) {
mMotionClassifier->dump(dump);
@@ -503,12 +502,11 @@
dump += "\n";
}
-void InputClassifier::monitor() {
+void InputProcessor::monitor() {
std::scoped_lock lock(mLock);
if (mMotionClassifier) mMotionClassifier->monitor();
}
-InputClassifier::~InputClassifier() {
-}
+InputProcessor::~InputProcessor() {}
} // namespace android
diff --git a/services/inputflinger/InputClassifier.h b/services/inputflinger/InputProcessor.h
similarity index 90%
rename from services/inputflinger/InputClassifier.h
rename to services/inputflinger/InputProcessor.h
index 9b31a3c..261e012 100644
--- a/services/inputflinger/InputClassifier.h
+++ b/services/inputflinger/InputProcessor.h
@@ -61,8 +61,8 @@
*/
class MotionClassifierInterface {
public:
- MotionClassifierInterface() { }
- virtual ~MotionClassifierInterface() { }
+ MotionClassifierInterface() {}
+ virtual ~MotionClassifierInterface() {}
/**
* Based on the motion event described by NotifyMotionArgs,
* provide a MotionClassification for the current gesture.
@@ -92,7 +92,7 @@
* Base interface for an InputListener stage.
* Provides classification to events.
*/
-class InputClassifierInterface : public InputListenerInterface {
+class InputProcessorInterface : public InputListenerInterface {
public:
virtual void setMotionClassifierEnabled(bool enabled) = 0;
/**
@@ -104,8 +104,8 @@
/** Called by the heartbeat to ensure that the classifier has not deadlocked. */
virtual void monitor() = 0;
- InputClassifierInterface() { }
- virtual ~InputClassifierInterface() { }
+ InputProcessorInterface() {}
+ virtual ~InputProcessorInterface() {}
};
// --- Implementations ---
@@ -124,10 +124,10 @@
};
/**
- * Implementation of MotionClassifierInterface that calls the InputClassifier HAL
+ * Implementation of MotionClassifierInterface that calls the InputProcessor HAL
* in order to determine the classification for the current gesture.
*
- * The InputClassifier HAL may keep track of the entire gesture in order to determine
+ * The InputProcessor HAL may keep track of the entire gesture in order to determine
* the classification, and may be hardware-specific. It may use the data in
* NotifyMotionArgs::videoFrames field to drive the classification decisions.
* The HAL is called from a separate thread.
@@ -174,20 +174,20 @@
*/
void enqueueEvent(ClassifierEvent&& event);
/**
- * Thread that will communicate with InputClassifier HAL.
- * This should be the only thread that communicates with InputClassifier HAL,
+ * Thread that will communicate with InputProcessor HAL.
+ * This should be the only thread that communicates with InputProcessor HAL,
* because this thread is allowed to block on the HAL calls.
*/
std::thread mHalThread;
/**
- * Process events and call the InputClassifier HAL
+ * Process events and call the InputProcessor HAL
*/
void processEvents();
/**
* Access to the InputProcessor HAL. May be null if init() hasn't completed yet.
* When init() successfully completes, mService is guaranteed to remain non-null and to not
* change its value until MotionClassifier is destroyed.
- * This variable is *not* guarded by mLock in the InputClassifier thread, because
+ * This variable is *not* guarded by mLock in the InputProcessor thread, because
* that thread knows exactly when this variable is initialized.
* When accessed in any other thread, mService is checked for nullness with a lock.
*/
@@ -197,8 +197,8 @@
* Per-device input classifications. Should only be accessed using the
* getClassification / setClassification methods.
*/
- std::unordered_map<int32_t /*deviceId*/, MotionClassification>
- mClassifications GUARDED_BY(mLock);
+ std::unordered_map<int32_t /*deviceId*/, MotionClassification> mClassifications
+ GUARDED_BY(mLock);
/**
* Set the current classification for a given device.
*/
@@ -208,7 +208,7 @@
*/
MotionClassification getClassification(int32_t deviceId);
void updateClassification(int32_t deviceId, nsecs_t eventTime,
- MotionClassification classification);
+ MotionClassification classification);
/**
* Clear all current classifications
*/
@@ -217,7 +217,7 @@
* Per-device times when the last ACTION_DOWN was received.
* Used to reject late classifications that do not belong to the current gesture.
*
- * Accessed indirectly by both InputClassifier thread and the thread that receives notifyMotion.
+ * Accessed indirectly by both InputProcessor thread and the thread that receives notifyMotion.
*/
std::unordered_map<int32_t /*deviceId*/, nsecs_t /*downTime*/> mLastDownTimes GUARDED_BY(mLock);
@@ -226,7 +226,7 @@
void clearDeviceState(int32_t deviceId);
/**
- * Exit the InputClassifier HAL thread.
+ * Exit the InputProcessor HAL thread.
* Useful for tests to ensure proper cleanup.
*/
void requestExit();
@@ -237,14 +237,14 @@
};
/**
- * Implementation of the InputClassifierInterface.
+ * Implementation of the InputProcessorInterface.
* Represents a separate stage of input processing. All of the input events go through this stage.
* Acts as a passthrough for all input events except for motion events.
* The events of motion type are sent to MotionClassifier.
*/
-class InputClassifier : public InputClassifierInterface {
+class InputProcessor : public InputProcessorInterface {
public:
- explicit InputClassifier(InputListenerInterface& listener);
+ explicit InputProcessor(InputListenerInterface& listener);
void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
void notifyKey(const NotifyKeyArgs* args) override;
@@ -258,7 +258,7 @@
void dump(std::string& dump) override;
void monitor() override;
- ~InputClassifier();
+ ~InputProcessor();
// Called from InputManager
void setMotionClassifierEnabled(bool enabled) override;
diff --git a/services/inputflinger/tests/Android.bp b/services/inputflinger/tests/Android.bp
index 76a7c19..6da2145 100644
--- a/services/inputflinger/tests/Android.bp
+++ b/services/inputflinger/tests/Android.bp
@@ -41,8 +41,8 @@
"EventHub_test.cpp",
"FocusResolver_test.cpp",
"IInputFlingerQuery.aidl",
- "InputClassifier_test.cpp",
- "InputClassifierConverter_test.cpp",
+ "InputProcessor_test.cpp",
+ "InputProcessorConverter_test.cpp",
"InputDispatcher_test.cpp",
"InputReader_test.cpp",
"InputFlingerService_test.cpp",
diff --git a/services/inputflinger/tests/InputClassifierConverter_test.cpp b/services/inputflinger/tests/InputProcessorConverter_test.cpp
similarity index 93%
rename from services/inputflinger/tests/InputClassifierConverter_test.cpp
rename to services/inputflinger/tests/InputProcessorConverter_test.cpp
index 81ef9b9..040c8da 100644
--- a/services/inputflinger/tests/InputClassifierConverter_test.cpp
+++ b/services/inputflinger/tests/InputProcessorConverter_test.cpp
@@ -24,7 +24,7 @@
namespace android {
-// --- InputClassifierConverterTest ---
+// --- InputProcessorConverterTest ---
static NotifyMotionArgs generateBasicMotionArgs() {
// Create a basic motion event for testing
@@ -52,7 +52,7 @@
static float getMotionEventAxis(common::PointerCoords coords, common::Axis axis) {
uint32_t index = BitSet64::getIndexOfBit(static_cast<uint64_t>(coords.bits),
- static_cast<uint64_t>(axis));
+ static_cast<uint64_t>(axis));
return coords.values[index];
}
@@ -60,7 +60,7 @@
* Check that coordinates get converted properly from the framework's PointerCoords
* to the hidl PointerCoords in input::common.
*/
-TEST(InputClassifierConverterTest, PointerCoordsAxes) {
+TEST(InputProcessorConverterTest, PointerCoordsAxes) {
const NotifyMotionArgs motionArgs = generateBasicMotionArgs();
ASSERT_EQ(1, motionArgs.pointerCoords[0].getX());
ASSERT_EQ(2, motionArgs.pointerCoords[0].getY());
@@ -76,7 +76,7 @@
ASSERT_EQ(getMotionEventAxis(motionEvent.pointerCoords[0], common::Axis::SIZE),
motionArgs.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_SIZE));
ASSERT_EQ(BitSet64::count(motionArgs.pointerCoords[0].bits),
- BitSet64::count(motionEvent.pointerCoords[0].bits));
+ BitSet64::count(motionEvent.pointerCoords[0].bits));
}
} // namespace android
diff --git a/services/inputflinger/tests/InputClassifier_test.cpp b/services/inputflinger/tests/InputProcessor_test.cpp
similarity index 75%
rename from services/inputflinger/tests/InputClassifier_test.cpp
rename to services/inputflinger/tests/InputProcessor_test.cpp
index 3a77127..380001c 100644
--- a/services/inputflinger/tests/InputClassifier_test.cpp
+++ b/services/inputflinger/tests/InputProcessor_test.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "../InputClassifier.h"
+#include "../InputProcessor.h"
#include <gtest/gtest.h>
#include <gui/constants.h>
@@ -31,7 +31,7 @@
namespace android {
-// --- InputClassifierTest ---
+// --- InputProcessorTest ---
static NotifyMotionArgs generateBasicMotionArgs() {
// Create a basic motion event for testing
@@ -56,105 +56,104 @@
return motionArgs;
}
-class InputClassifierTest : public testing::Test {
+class InputProcessorTest : public testing::Test {
protected:
TestInputListener mTestListener;
- std::unique_ptr<InputClassifierInterface> mClassifier;
+ std::unique_ptr<InputProcessorInterface> mProcessor;
- void SetUp() override { mClassifier = std::make_unique<InputClassifier>(mTestListener); }
+ void SetUp() override { mProcessor = std::make_unique<InputProcessor>(mTestListener); }
};
/**
- * Create a basic configuration change and send it to input classifier.
+ * Create a basic configuration change and send it to input processor.
* Expect that the event is received by the next input stage, unmodified.
*/
-TEST_F(InputClassifierTest, SendToNextStage_NotifyConfigurationChangedArgs) {
- // Create a basic configuration change and send to classifier
- NotifyConfigurationChangedArgs args(1/*sequenceNum*/, 2/*eventTime*/);
+TEST_F(InputProcessorTest, SendToNextStage_NotifyConfigurationChangedArgs) {
+ // Create a basic configuration change and send to processor
+ NotifyConfigurationChangedArgs args(1 /*sequenceNum*/, 2 /*eventTime*/);
- mClassifier->notifyConfigurationChanged(&args);
+ mProcessor->notifyConfigurationChanged(&args);
NotifyConfigurationChangedArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyConfigurationChangedWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
}
-TEST_F(InputClassifierTest, SendToNextStage_NotifyKeyArgs) {
- // Create a basic key event and send to classifier
+TEST_F(InputProcessorTest, SendToNextStage_NotifyKeyArgs) {
+ // Create a basic key event and send to processor
NotifyKeyArgs args(1 /*sequenceNum*/, 2 /*eventTime*/, 21 /*readTime*/, 3 /*deviceId*/,
AINPUT_SOURCE_KEYBOARD, ADISPLAY_ID_DEFAULT, 0 /*policyFlags*/,
AKEY_EVENT_ACTION_DOWN, 4 /*flags*/, AKEYCODE_HOME, 5 /*scanCode*/,
AMETA_NONE, 6 /*downTime*/);
- mClassifier->notifyKey(&args);
+ mProcessor->notifyKey(&args);
NotifyKeyArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyKeyWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
}
-
/**
- * Create a basic motion event and send it to input classifier.
+ * Create a basic motion event and send it to input processor.
* Expect that the event is received by the next input stage, unmodified.
*/
-TEST_F(InputClassifierTest, SendToNextStage_NotifyMotionArgs) {
+TEST_F(InputProcessorTest, SendToNextStage_NotifyMotionArgs) {
NotifyMotionArgs motionArgs = generateBasicMotionArgs();
- mClassifier->notifyMotion(&motionArgs);
+ mProcessor->notifyMotion(&motionArgs);
NotifyMotionArgs args;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyMotionWasCalled(&args));
ASSERT_EQ(motionArgs, args);
}
/**
- * Create a basic switch event and send it to input classifier.
+ * Create a basic switch event and send it to input processor.
* Expect that the event is received by the next input stage, unmodified.
*/
-TEST_F(InputClassifierTest, SendToNextStage_NotifySwitchArgs) {
- NotifySwitchArgs args(1/*sequenceNum*/, 2/*eventTime*/, 3/*policyFlags*/, 4/*switchValues*/,
- 5/*switchMask*/);
+TEST_F(InputProcessorTest, SendToNextStage_NotifySwitchArgs) {
+ NotifySwitchArgs args(1 /*sequenceNum*/, 2 /*eventTime*/, 3 /*policyFlags*/, 4 /*switchValues*/,
+ 5 /*switchMask*/);
- mClassifier->notifySwitch(&args);
+ mProcessor->notifySwitch(&args);
NotifySwitchArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifySwitchWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
}
/**
- * Create a basic device reset event and send it to input classifier.
+ * Create a basic device reset event and send it to input processor.
* Expect that the event is received by the next input stage, unmodified.
*/
-TEST_F(InputClassifierTest, SendToNextStage_NotifyDeviceResetArgs) {
- NotifyDeviceResetArgs args(1/*sequenceNum*/, 2/*eventTime*/, 3/*deviceId*/);
+TEST_F(InputProcessorTest, SendToNextStage_NotifyDeviceResetArgs) {
+ NotifyDeviceResetArgs args(1 /*sequenceNum*/, 2 /*eventTime*/, 3 /*deviceId*/);
- mClassifier->notifyDeviceReset(&args);
+ mProcessor->notifyDeviceReset(&args);
NotifyDeviceResetArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyDeviceResetWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
}
-TEST_F(InputClassifierTest, SetMotionClassifier_Enabled) {
- mClassifier->setMotionClassifierEnabled(true);
+TEST_F(InputProcessorTest, SetMotionClassifier_Enabled) {
+ mProcessor->setMotionClassifierEnabled(true);
}
-TEST_F(InputClassifierTest, SetMotionClassifier_Disabled) {
- mClassifier->setMotionClassifierEnabled(false);
+TEST_F(InputProcessorTest, SetMotionClassifier_Disabled) {
+ mProcessor->setMotionClassifierEnabled(false);
}
/**
* Try to break it by calling setMotionClassifierEnabled multiple times.
*/
-TEST_F(InputClassifierTest, SetMotionClassifier_Multiple) {
- mClassifier->setMotionClassifierEnabled(true);
- mClassifier->setMotionClassifierEnabled(true);
- mClassifier->setMotionClassifierEnabled(true);
- mClassifier->setMotionClassifierEnabled(false);
- mClassifier->setMotionClassifierEnabled(false);
- mClassifier->setMotionClassifierEnabled(true);
- mClassifier->setMotionClassifierEnabled(true);
- mClassifier->setMotionClassifierEnabled(true);
+TEST_F(InputProcessorTest, SetMotionClassifier_Multiple) {
+ mProcessor->setMotionClassifierEnabled(true);
+ mProcessor->setMotionClassifierEnabled(true);
+ mProcessor->setMotionClassifierEnabled(true);
+ mProcessor->setMotionClassifierEnabled(false);
+ mProcessor->setMotionClassifierEnabled(false);
+ mProcessor->setMotionClassifierEnabled(true);
+ mProcessor->setMotionClassifierEnabled(true);
+ mProcessor->setMotionClassifierEnabled(true);
}
/**
- * A minimal implementation of IInputClassifier.
+ * A minimal implementation of IInputProcessor.
*/
class TestHal : public aidl::android::hardware::input::processor::BnInputProcessor {
::ndk::ScopedAStatus classify(
@@ -212,7 +211,7 @@
NotifyMotionArgs motionArgs = generateBasicMotionArgs();
std::vector<int16_t> videoData = {1, 2, 3, 4};
- timeval timestamp = { 1, 1};
+ timeval timestamp = {1, 1};
TouchVideoFrame frame(2, 2, std::move(videoData), timestamp);
motionArgs.videoFrames = {frame};
@@ -228,11 +227,11 @@
NotifyMotionArgs motionArgs = generateBasicMotionArgs();
std::vector<int16_t> videoData1 = {1, 2, 3, 4};
- timeval timestamp1 = { 1, 1};
+ timeval timestamp1 = {1, 1};
TouchVideoFrame frame1(2, 2, std::move(videoData1), timestamp1);
std::vector<int16_t> videoData2 = {6, 6, 6, 6};
- timeval timestamp2 = { 1, 2};
+ timeval timestamp2 = {1, 2};
TouchVideoFrame frame2(2, 2, std::move(videoData2), timestamp2);
motionArgs.videoFrames = {frame1, frame2};
@@ -253,7 +252,7 @@
* Make sure MotionClassifier does not crash when a device is reset.
*/
TEST_F(MotionClassifierTest, DeviceReset_DoesNotCrash) {
- NotifyDeviceResetArgs args(1/*sequenceNum*/, 2/*eventTime*/, 3/*deviceId*/);
+ NotifyDeviceResetArgs args(1 /*sequenceNum*/, 2 /*eventTime*/, 3 /*deviceId*/);
ASSERT_NO_FATAL_FAILURE(mMotionClassifier->reset(args));
}
diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
index 8af3871..f2a3964 100644
--- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
+++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
@@ -405,11 +405,11 @@
};
/**
- * Create a basic configuration change and send it to input classifier.
+ * Create a basic configuration change and send it to input processor.
* Expect that the event is received by the next input stage, unmodified.
*/
TEST_F(UnwantedInteractionBlockerTest, ConfigurationChangedIsPassedToNextListener) {
- // Create a basic configuration change and send to classifier
+ // Create a basic configuration change and send to blocker
NotifyConfigurationChangedArgs args(1 /*sequenceNum*/, 2 /*eventTime*/);
mBlocker->notifyConfigurationChanged(&args);
@@ -423,7 +423,7 @@
* to next stage unmodified.
*/
TEST_F(UnwantedInteractionBlockerTest, KeyIsPassedToNextListener) {
- // Create a basic key event and send to classifier
+ // Create a basic key event and send to blocker
NotifyKeyArgs args(1 /*sequenceNum*/, 2 /*eventTime*/, 21 /*readTime*/, 3 /*deviceId*/,
AINPUT_SOURCE_KEYBOARD, ADISPLAY_ID_DEFAULT, 0 /*policyFlags*/,
AKEY_EVENT_ACTION_DOWN, 4 /*flags*/, AKEYCODE_HOME, 5 /*scanCode*/,