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

Commit 4e68fbfe authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Return early in doDispatchCycleFinishedLockedInterruptible

Reduce the identation of the entire method by returning early if entry
is null.

Bug: 70668286
Test: none
Change-Id: Ic9239c4f7e3566cd584a57973d9e8ed08d8c0287
parent 7e69851c
Loading
Loading
Loading
Loading
+42 −40
Original line number Original line Diff line number Diff line
@@ -4237,13 +4237,16 @@ void InputDispatcher::doOnPointerDownOutsideFocusLockedInterruptible(CommandEntr
void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
        CommandEntry* commandEntry) {
        CommandEntry* commandEntry) {
    sp<Connection> connection = commandEntry->connection;
    sp<Connection> connection = commandEntry->connection;
    nsecs_t finishTime = commandEntry->eventTime;
    const nsecs_t finishTime = commandEntry->eventTime;
    uint32_t seq = commandEntry->seq;
    uint32_t seq = commandEntry->seq;
    bool handled = commandEntry->handled;
    const bool handled = commandEntry->handled;


    // Handle post-event policy actions.
    // Handle post-event policy actions.
    DispatchEntry* dispatchEntry = connection->findWaitQueueEntry(seq);
    DispatchEntry* dispatchEntry = connection->findWaitQueueEntry(seq);
    if (dispatchEntry) {
    if (!dispatchEntry) {
        return;
    }

    nsecs_t eventDuration = finishTime - dispatchEntry->deliveryTime;
    nsecs_t eventDuration = finishTime - dispatchEntry->deliveryTime;
    if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) {
    if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) {
        std::string msg =
        std::string msg =
@@ -4256,12 +4259,12 @@ void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
    bool restartEvent;
    bool restartEvent;
    if (dispatchEntry->eventEntry->type == EventEntry::TYPE_KEY) {
    if (dispatchEntry->eventEntry->type == EventEntry::TYPE_KEY) {
        KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry);
        KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry);
            restartEvent = afterKeyEventLockedInterruptible(connection,
        restartEvent =
                    dispatchEntry, keyEntry, handled);
                afterKeyEventLockedInterruptible(connection, dispatchEntry, keyEntry, handled);
    } else if (dispatchEntry->eventEntry->type == EventEntry::TYPE_MOTION) {
    } else if (dispatchEntry->eventEntry->type == EventEntry::TYPE_MOTION) {
        MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry);
        MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry);
            restartEvent = afterMotionEventLockedInterruptible(connection,
        restartEvent = afterMotionEventLockedInterruptible(connection, dispatchEntry, motionEntry,
                    dispatchEntry, motionEntry, handled);
                                                           handled);
    } else {
    } else {
        restartEvent = false;
        restartEvent = false;
    }
    }
@@ -4284,7 +4287,6 @@ void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(
    // Start the next dispatch cycle for this connection.
    // Start the next dispatch cycle for this connection.
    startDispatchCycleLocked(now(), connection);
    startDispatchCycleLocked(now(), connection);
}
}
}


bool InputDispatcher::afterKeyEventLockedInterruptible(const sp<Connection>& connection,
bool InputDispatcher::afterKeyEventLockedInterruptible(const sp<Connection>& connection,
        DispatchEntry* dispatchEntry, KeyEntry* keyEntry, bool handled) {
        DispatchEntry* dispatchEntry, KeyEntry* keyEntry, bool handled) {