Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 119604e7 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Per-display verifiers for InputDispatcherFuzzer

Before this CL, a single verifier was used inside InputDispatcherFuzzer,
which isn't correct. The event sequences are supposed to be per-display.
Therefore, we should have a verifier for each display.

Bug: 287342122
Test: FUZZER=inputflinger_input_dispatcher_fuzzer; m $FUZZER && ASAN_OPTIONS=detect_odr_violation=0 $ANDROID_HOST_OUT/fuzz/x86_64/$FUZZER/$FUZZER
Change-Id: Id58da6ccedca4cdb5d221bbc4f1d64e069b86689
parent e67646ed
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -41,12 +41,14 @@ static constexpr int32_t MAX_RANDOM_WINDOWS = 4;
class NotifyStreamProvider {
public:
    NotifyStreamProvider(FuzzedDataProvider& fdp)
          : mFdp(fdp), mIdGenerator(IdGenerator::Source::OTHER), mVerifier("Fuzz verifier") {}
          : mFdp(fdp), mIdGenerator(IdGenerator::Source::OTHER) {}

    std::optional<NotifyMotionArgs> nextMotion() {
        NotifyMotionArgs args = generateFuzzedMotionArgs(mIdGenerator, mFdp, MAX_RANDOM_DISPLAYS);
        auto [it, _] = mVerifiers.emplace(args.displayId, "Fuzz Verifier");
        InputVerifier& verifier = it->second;
        const Result<void> result =
                mVerifier.processMovement(args.deviceId, args.source, args.action,
                verifier.processMovement(args.deviceId, args.source, args.action,
                                         args.getPointerCount(), args.pointerProperties.data(),
                                         args.pointerCoords.data(), args.flags);
        if (result.ok()) {
@@ -60,7 +62,7 @@ private:

    IdGenerator mIdGenerator;

    InputVerifier mVerifier;
    std::map<int32_t /*displayId*/, InputVerifier> mVerifiers;
};

} // namespace