inputflinger fuzzers: remove FuzzContainer.getPolicyConfig
Because FuzzInputReaderPolicy::getReaderConfiguration does nothing, any
calls to getPolicyConfig can be replaced with default
InputReaderConfiguration structs. This makes it clearer where where a
fuzzer is getting its configuration from, and therefore makes it easier
to understand the fuzzer without having to dig into FuzzContainer and
FuzzInputReaderPolicy.
InputReaderPolicyInterface::getReaderConfiguration is not called by any
of the code being fuzzed, so it's unlikely that
FuzzInputReaderPolicy::getReaderConfiguration will need to be modified
to return a non-default InputReaderConfiguration in future.
Bug: 245989146
Test: build and briefly run all modified fuzzers
$ SANITIZE_TARGET=hwaddress make ${FUZZER_NAME}
$ cd $ANDROID_PRODUCT_OUT
$ adb root
$ adb sync data
$ adb shell /data/fuzz/$(get_build_var TARGET_ARCH)/${FUZZER_NAME}/${FUZZER_NAME}
Change-Id: If933e1ce81439831b24c61dde1c2d24ed1a00942
diff --git a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
index 993f6a8..e93b592 100644
--- a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
@@ -16,6 +16,7 @@
#include <CursorInputMapper.h>
#include <FuzzContainer.h>
+#include <InputReaderBase.h>
#include <MapperHelpers.h>
namespace android {
@@ -39,7 +40,7 @@
std::make_shared<ThreadSafeFuzzedDataProvider>(data, size);
FuzzContainer fuzzer(fdp);
- auto policyConfig = fuzzer.getPolicyConfig();
+ InputReaderConfiguration policyConfig;
CursorInputMapper& mapper = fuzzer.getMapper<CursorInputMapper>(policyConfig);
// Loop through mapper operations until randomness is exhausted.
diff --git a/services/inputflinger/tests/fuzzers/FuzzContainer.h b/services/inputflinger/tests/fuzzers/FuzzContainer.h
index 0869b9f..ade5328 100644
--- a/services/inputflinger/tests/fuzzers/FuzzContainer.h
+++ b/services/inputflinger/tests/fuzzers/FuzzContainer.h
@@ -25,11 +25,9 @@
class FuzzContainer {
std::shared_ptr<FuzzEventHub> mFuzzEventHub;
- sp<FuzzInputReaderPolicy> mFuzzPolicy;
FuzzInputListener mFuzzListener;
std::unique_ptr<FuzzInputReaderContext> mFuzzContext;
std::unique_ptr<InputDevice> mFuzzDevice;
- InputReaderConfiguration mPolicyConfig;
std::shared_ptr<ThreadSafeFuzzedDataProvider> mFdp;
public:
@@ -42,8 +40,8 @@
// Create mocked objects.
mFuzzEventHub = std::make_shared<FuzzEventHub>(mFdp);
- mFuzzPolicy = sp<FuzzInputReaderPolicy>::make(mFdp);
- mFuzzContext = std::make_unique<FuzzInputReaderContext>(mFuzzEventHub, mFuzzPolicy,
+ sp<FuzzInputReaderPolicy> policy = sp<FuzzInputReaderPolicy>::make(mFdp);
+ mFuzzContext = std::make_unique<FuzzInputReaderContext>(mFuzzEventHub, policy,
mFuzzListener, mFdp);
InputDeviceIdentifier identifier;
@@ -51,7 +49,6 @@
identifier.location = deviceLocation;
mFuzzDevice = std::make_unique<InputDevice>(mFuzzContext.get(), deviceID, deviceGeneration,
identifier);
- mFuzzPolicy->getReaderConfiguration(&mPolicyConfig);
}
~FuzzContainer() {}
@@ -59,7 +56,7 @@
void configureDevice() {
nsecs_t arbitraryTime = mFdp->ConsumeIntegral<nsecs_t>();
std::list<NotifyArgs> out;
- out += mFuzzDevice->configure(arbitraryTime, mPolicyConfig, /*changes=*/{});
+ out += mFuzzDevice->configure(arbitraryTime, /*readerConfig=*/{}, /*changes=*/{});
out += mFuzzDevice->reset(arbitraryTime);
for (const NotifyArgs& args : out) {
mFuzzListener.notify(args);
@@ -71,8 +68,6 @@
configureDevice();
}
- InputReaderConfiguration& getPolicyConfig() { return mPolicyConfig; }
-
void setAbsoluteAxisInfo(int axis, const RawAbsoluteAxisInfo& axisInfo) {
mFuzzEventHub->setAbsoluteAxisInfo(mFuzzDevice->getId(), axis, axisInfo);
}
diff --git a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
index d11e8ae..54977df 100644
--- a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
@@ -15,6 +15,7 @@
*/
#include <FuzzContainer.h>
+#include <InputReaderBase.h>
#include <KeyboardInputMapper.h>
#include <MapperHelpers.h>
@@ -45,9 +46,9 @@
std::make_shared<ThreadSafeFuzzedDataProvider>(data, size);
FuzzContainer fuzzer(fdp);
- auto policyConfig = fuzzer.getPolicyConfig();
KeyboardInputMapper& mapper =
- fuzzer.getMapper<KeyboardInputMapper>(policyConfig, fdp->ConsumeIntegral<uint32_t>(),
+ fuzzer.getMapper<KeyboardInputMapper>(InputReaderConfiguration{},
+ fdp->ConsumeIntegral<uint32_t>(),
fdp->ConsumeIntegral<int32_t>());
// Loop through mapper operations until randomness is exhausted.
@@ -65,7 +66,7 @@
[&]() -> void { mapper.getSources(); },
[&]() -> void {
std::list<NotifyArgs> unused =
- mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), policyConfig,
+ mapper.reconfigure(fdp->ConsumeIntegral<nsecs_t>(), /*readerConfig=*/{},
InputReaderConfiguration::Change(
fdp->ConsumeIntegral<uint32_t>()));
},
diff --git a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
index 494b0ef..569767f 100644
--- a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
@@ -15,6 +15,7 @@
*/
#include <FuzzContainer.h>
+#include <InputReaderBase.h>
#include <MapperHelpers.h>
#include <MultiTouchInputMapper.h>
@@ -62,7 +63,7 @@
std::make_shared<ThreadSafeFuzzedDataProvider>(data, size);
FuzzContainer fuzzer(fdp);
- auto policyConfig = fuzzer.getPolicyConfig();
+ InputReaderConfiguration policyConfig;
MultiTouchInputMapper& mapper = fuzzer.getMapper<MultiTouchInputMapper>(policyConfig);
// Loop through mapper operations until randomness is exhausted.
diff --git a/services/inputflinger/tests/fuzzers/SwitchInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/SwitchInputFuzzer.cpp
index 381e7b5..80eebd5 100644
--- a/services/inputflinger/tests/fuzzers/SwitchInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/SwitchInputFuzzer.cpp
@@ -15,6 +15,7 @@
*/
#include <FuzzContainer.h>
+#include <InputReaderBase.h>
#include <MapperHelpers.h>
#include <SwitchInputMapper.h>
@@ -25,8 +26,7 @@
std::make_shared<ThreadSafeFuzzedDataProvider>(data, size);
FuzzContainer fuzzer(fdp);
- auto policyConfig = fuzzer.getPolicyConfig();
- SwitchInputMapper& mapper = fuzzer.getMapper<SwitchInputMapper>(policyConfig);
+ SwitchInputMapper& mapper = fuzzer.getMapper<SwitchInputMapper>(InputReaderConfiguration{});
// Loop through mapper operations until randomness is exhausted.
while (fdp->remaining_bytes() > 0) {
diff --git a/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp
index ef9663a..796178a 100644
--- a/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp
@@ -21,6 +21,7 @@
#include <linux/input-event-codes.h>
#include <FuzzContainer.h>
+#include <InputReaderBase.h>
#include <MapperHelpers.h>
#include <TouchpadInputMapper.h>
@@ -133,7 +134,7 @@
setAxisInfos(*fdp, fuzzer);
setDeviceSpecificConfig(*fdp, fuzzer);
- auto policyConfig = fuzzer.getPolicyConfig();
+ InputReaderConfiguration policyConfig;
// Some settings are fuzzed here, as well as in the main loop, to provide randomized data to the
// TouchpadInputMapper constructor.
setTouchpadSettings(*fdp, policyConfig);