diff options
author | 2019-07-31 14:00:52 -0700 | |
---|---|---|
committer | 2019-07-31 14:14:01 -0700 | |
commit | 4e68fbfecc6ab41bfa3d6c06d4e04ff4b098eb00 (patch) | |
tree | 55c092181cfac12e83516dd83e3363cded21e1b8 | |
parent | 7e69851c9b1da8e52f9d539b5d15da4797cfdd8a (diff) |
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
-rw-r--r-- | services/inputflinger/InputDispatcher.cpp | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp index fc40eafd08..019815c2c5 100644 --- a/services/inputflinger/InputDispatcher.cpp +++ b/services/inputflinger/InputDispatcher.cpp @@ -4237,53 +4237,55 @@ void InputDispatcher::doOnPointerDownOutsideFocusLockedInterruptible(CommandEntr void InputDispatcher::doDispatchCycleFinishedLockedInterruptible( CommandEntry* commandEntry) { sp<Connection> connection = commandEntry->connection; - nsecs_t finishTime = commandEntry->eventTime; + const nsecs_t finishTime = commandEntry->eventTime; uint32_t seq = commandEntry->seq; - bool handled = commandEntry->handled; + const bool handled = commandEntry->handled; // Handle post-event policy actions. DispatchEntry* dispatchEntry = connection->findWaitQueueEntry(seq); - if (dispatchEntry) { - nsecs_t eventDuration = finishTime - dispatchEntry->deliveryTime; - if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) { - std::string msg = - StringPrintf("Window '%s' spent %0.1fms processing the last input event: ", - connection->getWindowName().c_str(), eventDuration * 0.000001f); - dispatchEntry->eventEntry->appendDescription(msg); - ALOGI("%s", msg.c_str()); - } - - bool restartEvent; - if (dispatchEntry->eventEntry->type == EventEntry::TYPE_KEY) { - KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry); - restartEvent = afterKeyEventLockedInterruptible(connection, - dispatchEntry, keyEntry, handled); - } else if (dispatchEntry->eventEntry->type == EventEntry::TYPE_MOTION) { - MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry); - restartEvent = afterMotionEventLockedInterruptible(connection, - dispatchEntry, motionEntry, handled); + if (!dispatchEntry) { + return; + } + + nsecs_t eventDuration = finishTime - dispatchEntry->deliveryTime; + if (eventDuration > SLOW_EVENT_PROCESSING_WARNING_TIMEOUT) { + std::string msg = + StringPrintf("Window '%s' spent %0.1fms processing the last input event: ", + connection->getWindowName().c_str(), eventDuration * 0.000001f); + dispatchEntry->eventEntry->appendDescription(msg); + ALOGI("%s", msg.c_str()); + } + + bool restartEvent; + if (dispatchEntry->eventEntry->type == EventEntry::TYPE_KEY) { + KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry); + restartEvent = + afterKeyEventLockedInterruptible(connection, dispatchEntry, keyEntry, handled); + } else if (dispatchEntry->eventEntry->type == EventEntry::TYPE_MOTION) { + MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry); + restartEvent = afterMotionEventLockedInterruptible(connection, dispatchEntry, motionEntry, + handled); + } else { + restartEvent = false; + } + + // Dequeue the event and start the next cycle. + // Note that because the lock might have been released, it is possible that the + // contents of the wait queue to have been drained, so we need to double-check + // a few things. + if (dispatchEntry == connection->findWaitQueueEntry(seq)) { + connection->waitQueue.dequeue(dispatchEntry); + traceWaitQueueLength(connection); + if (restartEvent && connection->status == Connection::STATUS_NORMAL) { + connection->outboundQueue.enqueueAtHead(dispatchEntry); + traceOutboundQueueLength(connection); } else { - restartEvent = false; - } - - // Dequeue the event and start the next cycle. - // Note that because the lock might have been released, it is possible that the - // contents of the wait queue to have been drained, so we need to double-check - // a few things. - if (dispatchEntry == connection->findWaitQueueEntry(seq)) { - connection->waitQueue.dequeue(dispatchEntry); - traceWaitQueueLength(connection); - if (restartEvent && connection->status == Connection::STATUS_NORMAL) { - connection->outboundQueue.enqueueAtHead(dispatchEntry); - traceOutboundQueueLength(connection); - } else { - releaseDispatchEntry(dispatchEntry); - } + releaseDispatchEntry(dispatchEntry); } - - // Start the next dispatch cycle for this connection. - startDispatchCycleLocked(now(), connection); } + + // Start the next dispatch cycle for this connection. + startDispatchCycleLocked(now(), connection); } bool InputDispatcher::afterKeyEventLockedInterruptible(const sp<Connection>& connection, |