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

Commit bf20e959 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

inputflinger: Remove anonymous namespaces from headers

Use an internal namespace instead of anonymous ones in headers
to avoid potential ODR violations, as per C++ guidelines.

Bug: 245989146
Change-Id: I0fbb3da5722738bb22b34591af4797a9fef185d4
Test: Build
Flag: TEST_ONLY
parent 4961d9bc
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -27,12 +27,8 @@

namespace android {

namespace {

using ::testing::Matcher;

} // namespace

/**
 * This file contains a copy of Matchers from .../inputflinger/tests/TestEventMatchers.h. Ideally,
 * implementations must not be duplicated.
+20 −15
Original line number Diff line number Diff line
@@ -32,7 +32,13 @@

namespace android {

namespace {
struct PointF {
    float x;
    float y;
    auto operator<=>(const PointF&) const = default;
};

namespace internal {

template <typename T>
static bool valuesMatch(T value1, T value2) {
@@ -43,17 +49,11 @@ static bool valuesMatch(T value1, T value2) {
    }
}

struct PointF {
    float x;
    float y;
    auto operator<=>(const PointF&) const = default;
};

inline std::string pointFToString(const PointF& p) {
    return std::string("(") + std::to_string(p.x) + ", " + std::to_string(p.y) + ")";
}

} // namespace
} // namespace internal

/// Source
class WithSourceMatcher {
@@ -453,8 +453,10 @@ public:
        }

        if (mPointers != actualPointers) {
            *os << "expected pointers " << dumpMap(mPointers, constToString, pointFToString)
                << ", but got " << dumpMap(actualPointers, constToString, pointFToString);
            *os << "expected pointers "
                << dumpMap(mPointers, constToString, internal::pointFToString)
                << ", but got "
                << dumpMap(actualPointers, constToString, internal::pointFToString);
            return false;
        }
        return true;
@@ -469,15 +471,17 @@ public:
        }

        if (mPointers != actualPointers) {
            *os << "expected pointers " << dumpMap(mPointers, constToString, pointFToString)
                << ", but got " << dumpMap(actualPointers, constToString, pointFToString);
            *os << "expected pointers "
                << dumpMap(mPointers, constToString, internal::pointFToString)
                << ", but got "
                << dumpMap(actualPointers, constToString, internal::pointFToString);
            return false;
        }
        return true;
    }

    void DescribeTo(std::ostream* os) const {
        *os << "with pointers " << dumpMap(mPointers, constToString, pointFToString);
        *os << "with pointers " << dumpMap(mPointers, constToString, internal::pointFToString);
    }

    void DescribeNegationTo(std::ostream* os) const { *os << "wrong pointers"; }
@@ -719,8 +723,9 @@ public:
        }

        const PointerCoords& coords = event.pointerCoords[mPointerIndex];
        bool matches = valuesMatch(mRelX, coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X)) &&
                valuesMatch(mRelY, coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y));
        bool matches =
            internal::valuesMatch(mRelX, coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X)) &&
                internal::valuesMatch(mRelY, coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y));
        if (!matches) {
            *os << "expected relative motion (" << mRelX << ", " << mRelY << ") at pointer index "
                << mPointerIndex << ", but got ("
+0 −2
Original line number Diff line number Diff line
@@ -18,10 +18,8 @@

namespace android {

namespace {
static constexpr int32_t MAX_RANDOM_POINTERS = 4;
static constexpr int32_t MAX_RANDOM_DEVICES = 4;
} // namespace

int getFuzzedMotionAction(FuzzedDataProvider& fdp) {
    int actionMasked = fdp.PickValueInArray<int>({