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

Commit 33476239 authored by Harry Cutts's avatar Harry Cutts
Browse files

inputflinger: make parameter comment style consistent

The Google C++ style guide [0] suggests that parameter name comments
should be of the form `/*paramName=*/value`. This potentially allows
tooling to check that the parameter names are correct, too.

[0]: https://google.github.io/styleguide/cppguide.html#Function_Argument_Comments

Bug: none
Test: host-side inputflinger_tests
Change-Id: I89625844bcd19d27c43b4f14f1f207ade39a4718
parent dd6b1f1d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ void InputProcessor::setMotionClassifierEnabled(bool enabled) {
            { // acquire lock
                std::scoped_lock threadLock(mLock);
                mHalDeathRecipient =
                        std::make_unique<ScopedDeathRecipient>(onBinderDied, this /*cookie*/);
                        std::make_unique<ScopedDeathRecipient>(onBinderDied, /*cookie=*/this);
                mHalDeathRecipient->linkToDeath(service->asBinder().get());
                setMotionClassifierLocked(MotionClassifier::create(std::move(service)));
            } // release lock
+4 −4
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ public:
                ALOGE("Waited too long for consumer to produce an event, giving up");
                break;
            }
            result = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq,
            result = mConsumer->consume(&mEventFactory, /*consumeBatches=*/true, -1, &consumeSeq,
                                        &event);
        }
        if (result != OK) {
@@ -308,13 +308,13 @@ static void benchmarkInjectMotion(benchmark::State& state) {
    for (auto _ : state) {
        MotionEvent event = generateMotionEvent();
        // Send ACTION_DOWN
        dispatcher.injectInputEvent(&event, {} /*targetUid*/, InputEventInjectionSync::NONE,
        dispatcher.injectInputEvent(&event, /*targetUid=*/{}, InputEventInjectionSync::NONE,
                                    INJECT_EVENT_TIMEOUT,
                                    POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER);

        // Send ACTION_UP
        event.setAction(AMOTION_EVENT_ACTION_UP);
        dispatcher.injectInputEvent(&event, {} /*targetUid*/, InputEventInjectionSync::NONE,
        dispatcher.injectInputEvent(&event, /*targetUid=*/{}, InputEventInjectionSync::NONE,
                                    INJECT_EVENT_TIMEOUT,
                                    POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER);

@@ -344,7 +344,7 @@ static void benchmarkOnWindowInfosChanged(benchmark::State& state) {

    for (auto _ : state) {
        dispatcher.onWindowInfosChanged(windowInfos, displayInfos);
        dispatcher.onWindowInfosChanged({} /*windowInfos*/, {} /*displayInfos*/);
        dispatcher.onWindowInfosChanged(/*windowInfos=*/{}, /*displayInfos=*/{});
    }
    dispatcher.stop();
}
+16 −18
Original line number Diff line number Diff line
@@ -670,8 +670,7 @@ InputDispatcher::~InputDispatcher() {

    while (!mConnectionsByToken.empty()) {
        sp<Connection> connection = mConnectionsByToken.begin()->second;
        removeInputChannelLocked(connection->inputChannel->getConnectionToken(),
                                 false /* notify */);
        removeInputChannelLocked(connection->inputChannel->getConnectionToken(), /*notify=*/false);
    }
}

@@ -1023,7 +1022,7 @@ bool InputDispatcher::shouldPruneInboundQueueLocked(const MotionEntry& motionEnt
    if (isPointerDownEvent && mAwaitedFocusedApplication != nullptr) {
        const int32_t displayId = motionEntry.displayId;
        const auto [x, y] = resolveTouchedPosition(motionEntry);
        const bool isStylus = isPointerFromStylus(motionEntry, 0 /*pointerIndex*/);
        const bool isStylus = isPointerFromStylus(motionEntry, /*pointerIndex=*/0);

        auto [touchedWindowHandle, _] = findTouchedWindowAtLocked(displayId, x, y, isStylus);
        if (touchedWindowHandle != nullptr &&
@@ -2372,7 +2371,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
        if (maskedAction == AMOTION_EVENT_ACTION_MOVE && entry.pointerCount == 1 &&
            tempTouchState.isSlippery()) {
            const auto [x, y] = resolveTouchedPosition(entry);
            const bool isStylus = isPointerFromStylus(entry, 0 /*pointerIndex*/);
            const bool isStylus = isPointerFromStylus(entry, /*pointerIndex=*/0);
            sp<WindowInfoHandle> oldTouchedWindowHandle =
                    tempTouchState.getFirstForegroundWindowHandle();
            auto [newTouchedWindowHandle, _] = findTouchedWindowAtLocked(displayId, x, y, isStylus);
@@ -2609,7 +2608,7 @@ void InputDispatcher::finishDragAndDrop(int32_t displayId, float x, float y) {
    constexpr bool isStylus = false;

    auto [dropWindow, _] =
            findTouchedWindowAtLocked(displayId, x, y, isStylus, true /*ignoreDragWindow*/);
            findTouchedWindowAtLocked(displayId, x, y, isStylus, /*ignoreDragWindow=*/true);
    if (dropWindow) {
        vec2 local = dropWindow->getInfo()->transform.transform(x, y);
        sendDropWindowCommandLocked(dropWindow->getToken(), local.x, local.y);
@@ -2666,19 +2665,19 @@ void InputDispatcher::addDragEventLocked(const MotionEntry& entry) {
            constexpr bool isStylus = false;

            auto [hoverWindowHandle, _] = findTouchedWindowAtLocked(entry.displayId, x, y, isStylus,
                                                                    true /*ignoreDragWindow*/);
                                                                    /*ignoreDragWindow=*/true);
            // enqueue drag exit if needed.
            if (hoverWindowHandle != mDragState->dragHoverWindowHandle &&
                !haveSameToken(hoverWindowHandle, mDragState->dragHoverWindowHandle)) {
                if (mDragState->dragHoverWindowHandle != nullptr) {
                    enqueueDragEventLocked(mDragState->dragHoverWindowHandle, true /*isExiting*/, x,
                    enqueueDragEventLocked(mDragState->dragHoverWindowHandle, /*isExiting=*/true, x,
                                           y);
                }
                mDragState->dragHoverWindowHandle = hoverWindowHandle;
            }
            // enqueue drag location if needed.
            if (hoverWindowHandle != nullptr) {
                enqueueDragEventLocked(hoverWindowHandle, false /*isExiting*/, x, y);
                enqueueDragEventLocked(hoverWindowHandle, /*isExiting=*/false, x, y);
            }
            break;
        }
@@ -3356,8 +3355,7 @@ status_t InputDispatcher::publishMotionEvent(Connection& connection,
                // Don't apply window scale here since we don't want scale to affect raw
                // coordinates. The scale will be sent back to the client and applied
                // later when requesting relative coordinates.
                scaledCoords[i].scale(globalScaleFactor, 1 /* windowXScale */,
                                      1 /* windowYScale */);
                scaledCoords[i].scale(globalScaleFactor, /*windowXScale=*/1, /*windowYScale=*/1);
            }
            usingCoords = scaledCoords;
        }
@@ -3493,7 +3491,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
                          "event to it, status=%s(%d)",
                          connection->getInputChannelName().c_str(), statusToString(status).c_str(),
                          status);
                    abortBrokenDispatchCycleLocked(currentTime, connection, true /*notify*/);
                    abortBrokenDispatchCycleLocked(currentTime, connection, /*notify=*/true);
                } else {
                    // Pipe is full and we are waiting for the app to finish process some events
                    // before sending more events to it.
@@ -3508,7 +3506,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
                      "status=%s(%d)",
                      connection->getInputChannelName().c_str(), statusToString(status).c_str(),
                      status);
                abortBrokenDispatchCycleLocked(currentTime, connection, true /*notify*/);
                abortBrokenDispatchCycleLocked(currentTime, connection, /*notify=*/true);
            }
            return;
        }
@@ -4245,7 +4243,7 @@ void InputDispatcher::notifySensor(const NotifySensorArgs* args) {
        // Just enqueue a new sensor event.
        std::unique_ptr<SensorEntry> newEntry =
                std::make_unique<SensorEntry>(args->id, args->eventTime, args->deviceId,
                                              args->source, 0 /* policyFlags*/, args->hwTimestamp,
                                              args->source, /* policyFlags=*/0, args->hwTimestamp,
                                              args->sensorType, args->accuracy,
                                              args->accuracyChanged, args->values);

@@ -5639,7 +5637,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputChannel(const
        const sp<IBinder>& token = serverChannel->getConnectionToken();
        int fd = serverChannel->getFd();
        sp<Connection> connection =
                sp<Connection>::make(std::move(serverChannel), false /*monitor*/, mIdGenerator);
                sp<Connection>::make(std::move(serverChannel), /*monitor=*/false, mIdGenerator);

        if (mConnectionsByToken.find(token) != mConnectionsByToken.end()) {
            ALOGE("Created a new connection, but the token %p is already known", token.get());
@@ -5677,7 +5675,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(int32_
        }

        sp<Connection> connection =
                sp<Connection>::make(serverChannel, true /*monitor*/, mIdGenerator);
                sp<Connection>::make(serverChannel, /*monitor=*/true, mIdGenerator);
        const sp<IBinder>& token = serverChannel->getConnectionToken();
        const int fd = serverChannel->getFd();

@@ -5703,7 +5701,7 @@ status_t InputDispatcher::removeInputChannel(const sp<IBinder>& connectionToken)
    { // acquire lock
        std::scoped_lock _l(mLock);

        status_t status = removeInputChannelLocked(connectionToken, false /*notify*/);
        status_t status = removeInputChannelLocked(connectionToken, /*notify=*/false);
        if (status) {
            return status;
        }
@@ -6411,11 +6409,11 @@ void InputDispatcher::onFocusChangedLocked(const FocusResolver::FocusChanges& ch
            CancelationOptions options(CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS,
                                       "focus left window");
            synthesizeCancelationEventsForInputChannelLocked(focusedInputChannel, options);
            enqueueFocusEventLocked(changes.oldFocus, false /*hasFocus*/, changes.reason);
            enqueueFocusEventLocked(changes.oldFocus, /*hasFocus=*/false, changes.reason);
        }
    }
    if (changes.newFocus) {
        enqueueFocusEventLocked(changes.newFocus, true /*hasFocus*/, changes.reason);
        enqueueFocusEventLocked(changes.newFocus, /*hasFocus=*/true, changes.reason);
    }

    // If a window has pointer capture, then it must have focus. We need to ensure that this
+17 −17
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t f
    switch (actionMasked) {
        case AMOTION_EVENT_ACTION_UP:
        case AMOTION_EVENT_ACTION_CANCEL: {
            ssize_t index = findMotionMemento(entry, false /*hovering*/);
            ssize_t index = findMotionMemento(entry, /*hovering=*/false);
            if (index >= 0) {
                mMotionMementos.erase(mMotionMementos.begin() + index);
                return true;
@@ -111,11 +111,11 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t f
        }

        case AMOTION_EVENT_ACTION_DOWN: {
            ssize_t index = findMotionMemento(entry, false /*hovering*/);
            ssize_t index = findMotionMemento(entry, /*hovering=*/false);
            if (index >= 0) {
                mMotionMementos.erase(mMotionMementos.begin() + index);
            }
            addMotionMemento(entry, flags, false /*hovering*/);
            addMotionMemento(entry, flags, /*hovering=*/false);
            return true;
        }

@@ -129,7 +129,7 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t f
                return true;
            }

            ssize_t index = findMotionMemento(entry, false /*hovering*/);
            ssize_t index = findMotionMemento(entry, /*hovering=*/false);

            if (entry.source & AINPUT_SOURCE_CLASS_JOYSTICK) {
                // Joysticks can send MOVE events without a corresponding DOWN or UP. Since all
@@ -145,7 +145,7 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t f
                        memento.setPointers(entry);
                    }
                } else if (!entry.pointerCoords[0].isEmpty()) {
                    addMotionMemento(entry, flags, false /*hovering*/);
                    addMotionMemento(entry, flags, /*hovering=*/false);
                }

                // Joysticks and trackballs can send MOVE events without corresponding DOWN or UP.
@@ -168,7 +168,7 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t f
        }

        case AMOTION_EVENT_ACTION_HOVER_EXIT: {
            ssize_t index = findMotionMemento(entry, true /*hovering*/);
            ssize_t index = findMotionMemento(entry, /*hovering=*/true);
            if (index >= 0) {
                mMotionMementos.erase(mMotionMementos.begin() + index);
                return true;
@@ -183,11 +183,11 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t action, int32_t f

        case AMOTION_EVENT_ACTION_HOVER_ENTER:
        case AMOTION_EVENT_ACTION_HOVER_MOVE: {
            ssize_t index = findMotionMemento(entry, true /*hovering*/);
            ssize_t index = findMotionMemento(entry, /*hovering=*/true);
            if (index >= 0) {
                mMotionMementos.erase(mMotionMementos.begin() + index);
            }
            addMotionMemento(entry, flags, true /*hovering*/);
            addMotionMemento(entry, flags, /*hovering=*/true);
            return true;
        }

@@ -280,7 +280,7 @@ std::vector<std::unique_ptr<EventEntry>> InputState::synthesizeCancelationEvents
                                               memento.policyFlags, AKEY_EVENT_ACTION_UP,
                                               memento.flags | AKEY_EVENT_FLAG_CANCELED,
                                               memento.keyCode, memento.scanCode, memento.metaState,
                                               0 /*repeatCount*/, memento.downTime));
                                               /*repeatCount=*/0, memento.downTime));
        }
    }

@@ -297,8 +297,8 @@ std::vector<std::unique_ptr<EventEntry>> InputState::synthesizeCancelationEvents
                        std::make_unique<MotionEntry>(mIdGenerator.nextId(), currentTime,
                                                      memento.deviceId, memento.source,
                                                      memento.displayId, memento.policyFlags,
                                                      action, 0 /*actionButton*/, flags, AMETA_NONE,
                                                      0 /*buttonState*/, MotionClassification::NONE,
                                                      action, /*actionButton=*/0, flags, AMETA_NONE,
                                                      /*buttonState=*/0, MotionClassification::NONE,
                                                      AMOTION_EVENT_EDGE_FLAG_NONE,
                                                      memento.xPrecision, memento.yPrecision,
                                                      memento.xCursorPosition,
@@ -359,8 +359,8 @@ std::vector<std::unique_ptr<EventEntry>> InputState::synthesizePointerDownEvents
                    std::make_unique<MotionEntry>(mIdGenerator.nextId(), currentTime,
                                                  memento.deviceId, memento.source,
                                                  memento.displayId, memento.policyFlags, action,
                                                  0 /*actionButton*/, memento.flags, AMETA_NONE,
                                                  0 /*buttonState*/, MotionClassification::NONE,
                                                  /*actionButton=*/0, memento.flags, AMETA_NONE,
                                                  /*buttonState=*/0, MotionClassification::NONE,
                                                  AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
                                                  memento.yPrecision, memento.xCursorPosition,
                                                  memento.yCursorPosition, memento.downTime,
@@ -398,8 +398,8 @@ std::vector<std::unique_ptr<MotionEntry>> InputState::synthesizeCancelationEvent
        events.push_back(
                std::make_unique<MotionEntry>(mIdGenerator.nextId(), currentTime, memento.deviceId,
                                              memento.source, memento.displayId,
                                              memento.policyFlags, action, 0 /*actionButton*/,
                                              flags, AMETA_NONE, 0 /*buttonState*/,
                                              memento.policyFlags, action, /*actionButton=*/0,
                                              flags, AMETA_NONE, /*buttonState=*/0,
                                              MotionClassification::NONE,
                                              AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
                                              memento.yPrecision, memento.xCursorPosition,
@@ -425,9 +425,9 @@ std::vector<std::unique_ptr<MotionEntry>> InputState::synthesizeCancelationEvent
                    std::make_unique<MotionEntry>(mIdGenerator.nextId(), currentTime,
                                                  memento.deviceId, memento.source,
                                                  memento.displayId, memento.policyFlags, action,
                                                  0 /*actionButton*/,
                                                  /*actionButton=*/0,
                                                  memento.flags | AMOTION_EVENT_FLAG_CANCELED,
                                                  AMETA_NONE, 0 /*buttonState*/,
                                                  AMETA_NONE, /*buttonState=*/0,
                                                  MotionClassification::NONE,
                                                  AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
                                                  memento.yPrecision, memento.xCursorPosition,
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ void LatencyTracker::trackGraphicsLatency(
void LatencyTracker::reportAndPruneMatureRecords(nsecs_t newEventTime) {
    while (!mEventTimes.empty()) {
        const auto& [oldestEventTime, oldestInputEventId] = *mEventTimes.begin();
        if (isMatureEvent(oldestEventTime, newEventTime /*now*/)) {
        if (isMatureEvent(oldestEventTime, /*now=*/newEventTime)) {
            // Report and drop this event
            const auto it = mTimelines.find(oldestInputEventId);
            LOG_ALWAYS_FATAL_IF(it == mTimelines.end(),
Loading