summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2023-04-05 23:51:23 +0000
committer Prabir Pradhan <prabirmsp@google.com> 2023-04-13 21:24:04 +0000
commite3da4bbc9c7e0f07a7241ee937c39f1007a9a449 (patch)
treeb3fb06f8647f8d06df3f97fe8928a0ab63fd84f6
parent71660f18f6312ce8fe2962e116d6a0533491c06f (diff)
Notify InputListener when there an changes to input devices
There are now more than one input listener stages that need to know when the devices change. Notify listeners directly instead of routing it through the policy. Bug: 275726706 Test: atest inputflinger_tests Change-Id: I37019f8069bad3bbc585805f792beb514faa8cb1
-rw-r--r--services/inputflinger/InputListener.cpp7
-rw-r--r--services/inputflinger/InputProcessor.cpp6
-rw-r--r--services/inputflinger/InputProcessor.h1
-rw-r--r--services/inputflinger/NotifyArgs.cpp7
-rw-r--r--services/inputflinger/UnwantedInteractionBlocker.cpp7
-rw-r--r--services/inputflinger/UnwantedInteractionBlocker.h4
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.h1
-rw-r--r--services/inputflinger/include/InputListener.h2
-rw-r--r--services/inputflinger/include/NotifyArgs.h22
-rw-r--r--services/inputflinger/include/UnwantedInteractionBlockerInterface.h12
-rw-r--r--services/inputflinger/reader/InputReader.cpp2
-rw-r--r--services/inputflinger/tests/InputReader_test.cpp2
-rw-r--r--services/inputflinger/tests/TestInputListener.cpp12
-rw-r--r--services/inputflinger/tests/TestInputListener.h8
-rw-r--r--services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp30
-rw-r--r--services/inputflinger/tests/fuzzers/MapperHelpers.h1
16 files changed, 91 insertions, 33 deletions
diff --git a/services/inputflinger/InputListener.cpp b/services/inputflinger/InputListener.cpp
index d33b29888f..1bc1adf154 100644
--- a/services/inputflinger/InputListener.cpp
+++ b/services/inputflinger/InputListener.cpp
@@ -24,7 +24,6 @@
#include <android-base/stringprintf.h>
#include <android/log.h>
-#include <math.h>
#include <utils/Trace.h>
using android::base::StringPrintf;
@@ -47,6 +46,7 @@ Visitor(V...) -> Visitor<V...>;
void InputListenerInterface::notify(const NotifyArgs& generalArgs) {
Visitor v{
+ [&](const NotifyInputDevicesChangedArgs& args) { notifyInputDevicesChanged(args); },
[&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(&args); },
[&](const NotifyKeyArgs& args) { notifyKey(&args); },
[&](const NotifyMotionArgs& args) { notifyMotion(&args); },
@@ -73,6 +73,11 @@ static inline void traceEvent(const char* functionName, int32_t id) {
QueuedInputListener::QueuedInputListener(InputListenerInterface& innerListener)
: mInnerListener(innerListener) {}
+void QueuedInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
+}
+
void QueuedInputListener::notifyConfigurationChanged(
const NotifyConfigurationChangedArgs* args) {
traceEvent(__func__, args->id);
diff --git a/services/inputflinger/InputProcessor.cpp b/services/inputflinger/InputProcessor.cpp
index a98b383037..6c0bcffd6b 100644
--- a/services/inputflinger/InputProcessor.cpp
+++ b/services/inputflinger/InputProcessor.cpp
@@ -413,6 +413,12 @@ void InputProcessor::setMotionClassifierEnabled(bool enabled) {
}
}
+void InputProcessor::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
+ // pass through
+ mQueuedListener.notify(args);
+ mQueuedListener.flush();
+}
+
void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
// pass through
mQueuedListener.notifyConfigurationChanged(args);
diff --git a/services/inputflinger/InputProcessor.h b/services/inputflinger/InputProcessor.h
index f4d02b6f30..01795a8983 100644
--- a/services/inputflinger/InputProcessor.h
+++ b/services/inputflinger/InputProcessor.h
@@ -245,6 +245,7 @@ class InputProcessor : public InputProcessorInterface {
public:
explicit InputProcessor(InputListenerInterface& listener);
+ void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
void notifyKey(const NotifyKeyArgs* args) override;
void notifyMotion(const NotifyMotionArgs* args) override;
diff --git a/services/inputflinger/NotifyArgs.cpp b/services/inputflinger/NotifyArgs.cpp
index 5f2a22f467..408fbed99e 100644
--- a/services/inputflinger/NotifyArgs.cpp
+++ b/services/inputflinger/NotifyArgs.cpp
@@ -29,6 +29,12 @@ using android::base::StringPrintf;
namespace android {
+// --- NotifyInputDevicesChangedArgs ---
+
+NotifyInputDevicesChangedArgs::NotifyInputDevicesChangedArgs(int32_t id,
+ std::vector<InputDeviceInfo> infos)
+ : id(id), inputDeviceInfos(std::move(infos)) {}
+
// --- NotifyConfigurationChangedArgs ---
NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(int32_t id, nsecs_t eventTime)
@@ -234,6 +240,7 @@ Visitor(V...) -> Visitor<V...>;
const char* toString(const NotifyArgs& args) {
Visitor toStringVisitor{
+ [&](const NotifyInputDevicesChangedArgs&) { return "NotifyInputDevicesChangedArgs"; },
[&](const NotifyConfigurationChangedArgs&) { return "NotifyConfigurationChangedArgs"; },
[&](const NotifyKeyArgs&) { return "NotifyKeyArgs"; },
[&](const NotifyMotionArgs&) { return "NotifyMotionArgs"; },
diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp
index ae20f862dc..6d43e8d009 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.cpp
+++ b/services/inputflinger/UnwantedInteractionBlocker.cpp
@@ -411,6 +411,13 @@ void UnwantedInteractionBlocker::notifyPointerCaptureChanged(
}
void UnwantedInteractionBlocker::notifyInputDevicesChanged(
+ const NotifyInputDevicesChangedArgs& args) {
+ onInputDevicesChanged(args.inputDeviceInfos);
+ mQueuedListener.notify(args);
+ mQueuedListener.flush();
+}
+
+void UnwantedInteractionBlocker::onInputDevicesChanged(
const std::vector<InputDeviceInfo>& inputDevices) {
std::scoped_lock lock(mLock);
if (!mEnablePalmRejection) {
diff --git a/services/inputflinger/UnwantedInteractionBlocker.h b/services/inputflinger/UnwantedInteractionBlocker.h
index 5d0dde8e64..3bc5240eb6 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.h
+++ b/services/inputflinger/UnwantedInteractionBlocker.h
@@ -90,6 +90,7 @@ public:
explicit UnwantedInteractionBlocker(InputListenerInterface& listener);
explicit UnwantedInteractionBlocker(InputListenerInterface& listener, bool enablePalmRejection);
+ void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
void notifyKey(const NotifyKeyArgs* args) override;
void notifyMotion(const NotifyMotionArgs* args) override;
@@ -99,7 +100,6 @@ public:
void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override;
- void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) override;
void dump(std::string& dump) override;
void monitor() override;
@@ -123,6 +123,8 @@ private:
// Call this function for outbound events so that they can be logged when logging is enabled.
void enqueueOutboundMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
+
+ void onInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices);
};
class SlotState {
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 2246d47e48..aaf12146af 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -93,6 +93,7 @@ public:
status_t start() override;
status_t stop() override;
+ void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override{};
void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
void notifyKey(const NotifyKeyArgs* args) override;
void notifyMotion(const NotifyMotionArgs* args) override;
diff --git a/services/inputflinger/include/InputListener.h b/services/inputflinger/include/InputListener.h
index 1bb19686e7..d1b86c8cc4 100644
--- a/services/inputflinger/include/InputListener.h
+++ b/services/inputflinger/include/InputListener.h
@@ -37,6 +37,7 @@ public:
InputListenerInterface& operator=(const InputListenerInterface&) = delete;
virtual ~InputListenerInterface() { }
+ virtual void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) = 0;
virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) = 0;
virtual void notifyKey(const NotifyKeyArgs* args) = 0;
virtual void notifyMotion(const NotifyMotionArgs* args) = 0;
@@ -58,6 +59,7 @@ class QueuedInputListener : public InputListenerInterface {
public:
explicit QueuedInputListener(InputListenerInterface& innerListener);
+ virtual void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
virtual void notifyKey(const NotifyKeyArgs* args) override;
virtual void notifyMotion(const NotifyMotionArgs* args) override;
diff --git a/services/inputflinger/include/NotifyArgs.h b/services/inputflinger/include/NotifyArgs.h
index c46f90501f..f12482b1b2 100644
--- a/services/inputflinger/include/NotifyArgs.h
+++ b/services/inputflinger/include/NotifyArgs.h
@@ -24,6 +24,20 @@
namespace android {
+/* Describes a change in any of the connected input devices. */
+struct NotifyInputDevicesChangedArgs {
+ int32_t id;
+ std::vector<InputDeviceInfo> inputDeviceInfos;
+
+ inline NotifyInputDevicesChangedArgs() {}
+
+ NotifyInputDevicesChangedArgs(int32_t id, std::vector<InputDeviceInfo> infos);
+
+ bool operator==(const NotifyInputDevicesChangedArgs& rhs) const = default;
+
+ NotifyInputDevicesChangedArgs(const NotifyInputDevicesChangedArgs& other) = default;
+};
+
/* Describes a configuration change event. */
struct NotifyConfigurationChangedArgs {
int32_t id;
@@ -183,7 +197,6 @@ struct NotifyDeviceResetArgs {
/* Describes a change in the state of Pointer Capture. */
struct NotifyPointerCaptureChangedArgs {
- // The sequence number of the Pointer Capture request, if enabled.
int32_t id;
nsecs_t eventTime;
@@ -211,9 +224,10 @@ struct NotifyVibratorStateArgs {
NotifyVibratorStateArgs(const NotifyVibratorStateArgs& other) = default;
};
-using NotifyArgs = std::variant<NotifyConfigurationChangedArgs, NotifyKeyArgs, NotifyMotionArgs,
- NotifySensorArgs, NotifySwitchArgs, NotifyDeviceResetArgs,
- NotifyPointerCaptureChangedArgs, NotifyVibratorStateArgs>;
+using NotifyArgs =
+ std::variant<NotifyInputDevicesChangedArgs, NotifyConfigurationChangedArgs, NotifyKeyArgs,
+ NotifyMotionArgs, NotifySensorArgs, NotifySwitchArgs, NotifyDeviceResetArgs,
+ NotifyPointerCaptureChangedArgs, NotifyVibratorStateArgs>;
const char* toString(const NotifyArgs& args);
diff --git a/services/inputflinger/include/UnwantedInteractionBlockerInterface.h b/services/inputflinger/include/UnwantedInteractionBlockerInterface.h
index 1a6f8472a5..64c6114ceb 100644
--- a/services/inputflinger/include/UnwantedInteractionBlockerInterface.h
+++ b/services/inputflinger/include/UnwantedInteractionBlockerInterface.h
@@ -27,23 +27,13 @@ namespace android {
*/
class UnwantedInteractionBlockerInterface : public InputListenerInterface {
public:
- /* Notifies the input reader policy that some input devices have changed
- * and provides information about all current input devices.
- * Important! This call should happen on the same thread as the calls to the
- * InputListenerInterface methods.
- * That is, same thread should call 'notifyMotion' and 'notifyInputDevicesChanged' and
- * 'notifyDeviceReset'. If this architecture changes, we will need to make the implementation
- * of this interface thread-safe.
- */
- virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;
-
/**
* Dump the state of the interaction blocker.
* This method may be called on any thread (usually by the input manager on a binder thread).
*/
virtual void dump(std::string& dump) = 0;
- /* Called by the heatbeat to ensures that the blocker has not deadlocked. */
+ /* Called by the heartbeat to ensures that the blocker has not deadlocked. */
virtual void monitor() = 0;
UnwantedInteractionBlockerInterface() {}
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index 81ac03b7b3..02d79b08ea 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -157,6 +157,8 @@ void InputReader::loopOnce() {
if (oldGeneration != mGeneration) {
inputDevicesChanged = true;
inputDevices = getInputDevicesLocked();
+ notifyArgs.emplace_back(
+ NotifyInputDevicesChangedArgs{mContext.getNextId(), inputDevices});
}
} // release lock
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index fb082da8e1..2b8b70b54c 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -603,6 +603,7 @@ protected:
mReader->loopOnce();
mReader->loopOnce();
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyInputDevicesChangedWasCalled());
ASSERT_NO_FATAL_FAILURE(mFakeEventHub->assertQueueIsEmpty());
}
@@ -1324,6 +1325,7 @@ protected:
// to the test device will show up in mReader. We wait for those input devices to
// show up before beginning the tests.
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged());
+ ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyInputDevicesChangedWasCalled());
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyConfigurationChangedWasCalled());
}
diff --git a/services/inputflinger/tests/TestInputListener.cpp b/services/inputflinger/tests/TestInputListener.cpp
index 2801072b6a..ac1dc05f6d 100644
--- a/services/inputflinger/tests/TestInputListener.cpp
+++ b/services/inputflinger/tests/TestInputListener.cpp
@@ -29,6 +29,14 @@ TestInputListener::TestInputListener(std::chrono::milliseconds eventHappenedTime
TestInputListener::~TestInputListener() {}
+void TestInputListener::assertNotifyInputDevicesChangedWasCalled(
+ NotifyInputDevicesChangedArgs* outEventArgs) {
+ ASSERT_NO_FATAL_FAILURE(
+ assertCalled<NotifyInputDevicesChangedArgs>(outEventArgs,
+ "Expected notifyInputDevicesChanged() "
+ "to have been called."));
+}
+
void TestInputListener::assertNotifyConfigurationChangedWasCalled(
NotifyConfigurationChangedArgs* outEventArgs) {
ASSERT_NO_FATAL_FAILURE(
@@ -168,6 +176,10 @@ void TestInputListener::addToQueue(const NotifyArgsType* args) {
mCondition.notify_all();
}
+void TestInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
+ addToQueue<NotifyInputDevicesChangedArgs>(&args);
+}
+
void TestInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
addToQueue<NotifyConfigurationChangedArgs>(args);
}
diff --git a/services/inputflinger/tests/TestInputListener.h b/services/inputflinger/tests/TestInputListener.h
index 9665f702a1..da2cab3351 100644
--- a/services/inputflinger/tests/TestInputListener.h
+++ b/services/inputflinger/tests/TestInputListener.h
@@ -35,6 +35,9 @@ public:
using TimePoint = std::chrono::time_point<std::chrono::system_clock>;
+ void assertNotifyInputDevicesChangedWasCalled(
+ NotifyInputDevicesChangedArgs* outEventArgs = nullptr);
+
void assertNotifyConfigurationChangedWasCalled(
NotifyConfigurationChangedArgs* outEventArgs = nullptr);
@@ -76,6 +79,8 @@ private:
template <class NotifyArgsType>
void addToQueue(const NotifyArgsType* args);
+ virtual void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
+
virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
@@ -97,7 +102,8 @@ private:
const std::chrono::milliseconds mEventHappenedTimeout;
const std::chrono::milliseconds mEventDidNotHappenTimeout;
- std::tuple<std::vector<NotifyConfigurationChangedArgs>, //
+ std::tuple<std::vector<NotifyInputDevicesChangedArgs>, //
+ std::vector<NotifyConfigurationChangedArgs>, //
std::vector<NotifyDeviceResetArgs>, //
std::vector<NotifyKeyArgs>, //
std::vector<NotifyMotionArgs>, //
diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
index 2a9ace00c5..be731b1a2f 100644
--- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
+++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
@@ -492,7 +492,7 @@ TEST_F(UnwantedInteractionBlockerTest, DeviceResetIsPassedToNextListener) {
*/
TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenResetHappens) {
NotifyMotionArgs args;
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
mBlocker->notifyMotion(
&(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}})));
mBlocker->notifyMotion(
@@ -505,7 +505,7 @@ TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenResetHappens) {
}
TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenStylusSourceWithFingerToolIsReceived) {
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
NotifyMotionArgs args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}});
args.pointerProperties[0].toolType = ToolType::FINGER;
args.source = AINPUT_SOURCE_STYLUS;
@@ -518,14 +518,14 @@ TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenStylusSourceWithFingerToolIsRe
*/
TEST_F(UnwantedInteractionBlockerTest, NoResetIfDeviceInfoChanges) {
NotifyMotionArgs args;
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
mBlocker->notifyMotion(
&(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}})));
mBlocker->notifyMotion(
&(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}})));
// Now pretend the device changed, even though nothing is different for DEVICE_ID in practice.
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
// The MOVE event continues the gesture that started before 'devices changed', so it should not
// cause a crash.
@@ -538,7 +538,7 @@ TEST_F(UnwantedInteractionBlockerTest, NoResetIfDeviceInfoChanges) {
*/
TEST_F(UnwantedInteractionBlockerTest, StylusAfterTouchWorks) {
NotifyMotionArgs args;
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
mBlocker->notifyMotion(&args);
args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{4, 5, 6}});
@@ -568,7 +568,7 @@ TEST_F(UnwantedInteractionBlockerTest, StylusAfterTouchWorks) {
* options
*/
TEST_F(UnwantedInteractionBlockerTest, DumpCanBeAccessedOnAnotherThread) {
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
mBlocker->notifyMotion(&args1);
std::thread dumpThread([this]() {
@@ -587,7 +587,7 @@ TEST_F(UnwantedInteractionBlockerTest, DumpCanBeAccessedOnAnotherThread) {
* of the touch is large. This is an integration test that checks that this filter kicks in.
*/
TEST_F(UnwantedInteractionBlockerTest, HeuristicFilterWorks) {
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
// Small touch down
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
mBlocker->notifyMotion(&args1);
@@ -613,9 +613,9 @@ TEST_F(UnwantedInteractionBlockerTest, HeuristicFilterWorks) {
* This is similar to `HeuristicFilterWorks` test, but for stylus tool.
*/
TEST_F(UnwantedInteractionBlockerTest, StylusIsNotBlocked) {
- InputDeviceInfo info = generateTestDeviceInfo();
- info.addSource(AINPUT_SOURCE_STYLUS);
- mBlocker->notifyInputDevicesChanged({info});
+ NotifyInputDevicesChangedArgs deviceChangedArgs = {/*id=*/0, {generateTestDeviceInfo()}};
+ deviceChangedArgs.inputDeviceInfos[0].addSource(AINPUT_SOURCE_STYLUS);
+ mBlocker->notifyInputDevicesChanged(deviceChangedArgs);
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
args1.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args1);
@@ -643,9 +643,9 @@ TEST_F(UnwantedInteractionBlockerTest, StylusIsNotBlocked) {
* Stylus event should continue to work even after touch is detected as a palm.
*/
TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) {
- InputDeviceInfo info = generateTestDeviceInfo();
- info.addSource(AINPUT_SOURCE_STYLUS);
- mBlocker->notifyInputDevicesChanged({info});
+ NotifyInputDevicesChangedArgs deviceChangedArgs = {/*id=*/0, {generateTestDeviceInfo()}};
+ deviceChangedArgs.inputDeviceInfos[0].addSource(AINPUT_SOURCE_STYLUS);
+ mBlocker->notifyInputDevicesChanged(deviceChangedArgs);
// Touch down
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
@@ -699,7 +699,7 @@ using UnwantedInteractionBlockerTestDeathTest = UnwantedInteractionBlockerTest;
TEST_F(UnwantedInteractionBlockerTestDeathTest, InconsistentEventAfterResetCausesACrash) {
ScopedSilentDeath _silentDeath;
NotifyMotionArgs args;
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
mBlocker->notifyMotion(
&(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}})));
mBlocker->notifyMotion(
@@ -721,7 +721,7 @@ TEST_F(UnwantedInteractionBlockerTestDeathTest, InconsistentEventAfterResetCause
TEST_F(UnwantedInteractionBlockerTestDeathTest, WhenMoveWithoutDownCausesACrash) {
ScopedSilentDeath _silentDeath;
NotifyMotionArgs args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{1, 2, 3}});
- mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
+ mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
ASSERT_DEATH({ mBlocker->notifyMotion(&args); }, "Could not find slot");
}
diff --git a/services/inputflinger/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h
index 9f4aa5cd5e..0dc627a8f7 100644
--- a/services/inputflinger/tests/fuzzers/MapperHelpers.h
+++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h
@@ -293,6 +293,7 @@ public:
class FuzzInputListener : public virtual InputListenerInterface {
public:
+ void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override {}
void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override {}
void notifyKey(const NotifyKeyArgs* args) override {}
void notifyMotion(const NotifyMotionArgs* args) override {}