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

Commit adeb6fa9 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Move some definitions into anonymous namespaces

To prevent ODR violations, move some of the definitions into anonymous
namespaces.
Specifically, this solves the issue of multiple definitions for
FakeWindowHandle, which was triggering the leak sanitizer check when
'sanitize: address' was set to true.

Bug: 284203306
Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests
Change-Id: I106b2b547cf465df15e317a9b7478dcc77467a46
parent 34ad3a3a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ using android::os::InputEventInjectionSync;

namespace android::inputdispatcher {

namespace {

// An arbitrary device id.
constexpr int32_t DEVICE_ID = 1;

@@ -348,6 +350,8 @@ static void benchmarkOnWindowInfosChanged(benchmark::State& state) {
    dispatcher.stop();
}

} // namespace

BENCHMARK(benchmarkNotifyMotion);
BENCHMARK(benchmarkInjectMotion);
BENCHMARK(benchmarkOnWindowInfosChanged);
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ using android::gui::WindowInfoHandle;

namespace android::inputdispatcher {

namespace {

class FakeWindowHandle : public WindowInfoHandle {
public:
    FakeWindowHandle(const std::string& name, const sp<IBinder>& token, bool focusable,
@@ -49,6 +51,8 @@ public:
    }
};

} // namespace

TEST(FocusResolverTest, SetFocusedWindow) {
    sp<IBinder> focusableWindowToken = sp<BBinder>::make();
    sp<IBinder> invisibleWindowToken = sp<BBinder>::make();
+4 −0
Original line number Diff line number Diff line
@@ -846,6 +846,8 @@ TEST_F(InputDispatcherTest, NotifySwitch_CallsPolicy) {
    mFakePolicy->assertNotifySwitchWasCalled(args);
}

namespace {

// --- InputDispatcherTest SetInputWindowTest ---
static constexpr std::chrono::duration INJECT_EVENT_TIMEOUT = 500ms;
// Default input dispatching timeout if there is no focused application or paused window
@@ -1592,6 +1594,8 @@ static NotifyPointerCaptureChangedArgs generatePointerCaptureChangedArgs(
    return NotifyPointerCaptureChangedArgs(/*id=*/0, systemTime(SYSTEM_TIME_MONOTONIC), request);
}

} // namespace

/**
 * When a window unexpectedly disposes of its input channel, policy should be notified about the
 * broken channel.