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

Commit 9213590a authored by Asmita Poddar's avatar Asmita Poddar
Browse files

Cache flag value to prevent performance regressions

Cache the value of the enable_per_device_input_latency_metrics flag
to prevent performace regressions.

Bug: 369812450
Test: atest inputflinger_tests
Flag: com.android.input.flags.enable_per_device_input_latency_metrics
Change-Id: I7afc2eb5ce25ae4be12bcb836f8645f1168b9e94
parent 26e74e58
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1029,7 +1029,7 @@ void InputDispatcher::dispatchOnce() {
        const nsecs_t nextAnrCheck = processAnrsLocked();
        nextWakeupTime = std::min(nextWakeupTime, nextAnrCheck);

        if (input_flags::enable_per_device_input_latency_metrics()) {
        if (mPerDeviceInputLatencyMetricsFlag) {
            const nsecs_t nextStatisticsPush = processLatencyStatisticsLocked();
            nextWakeupTime = std::min(nextWakeupTime, nextStatisticsPush);
        }
@@ -4548,7 +4548,7 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs& args) {
            newEntry->traceTracker = mTracer->traceInboundEvent(*newEntry);
        }

        if (input_flags::enable_per_device_input_latency_metrics()) {
        if (mPerDeviceInputLatencyMetricsFlag) {
            if (args.id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID &&
                IdGenerator::getSource(args.id) == IdGenerator::Source::INPUT_READER &&
                !mInputFilterEnabled) {
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#pragma once

#include <com_android_input_flags.h>

#include "AnrTracker.h"
#include "CancelationOptions.h"
#include "DragState.h"
@@ -741,6 +743,10 @@ private:

    sp<android::gui::WindowInfoHandle> findWallpaperWindowBelow(
            const sp<android::gui::WindowInfoHandle>& windowHandle) const REQUIRES(mLock);

    /** Stores the value of the input flag for per device input latency metrics. */
    const bool mPerDeviceInputLatencyMetricsFlag =
            com::android::input::flags::enable_per_device_input_latency_metrics();
};

} // namespace android::inputdispatcher