diff options
| author | Jeff Brown <jeffbrown@google.com> | 2012-02-13 14:02:51 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-13 14:02:51 -0800 |
| commit | a17032eeb91f709360b6271b71b85e67f729bcc1 (patch) | |
| tree | 98cc862fc7d3633f93b942630776e9802452f212 /libs/ui/InputTransport.cpp | |
| parent | 7a29d84f0150b49215726d08a69d343df74e02bc (diff) | |
| parent | 2d34e0cfe7e2586b75a6f2c6646dd2e1e52c973f (diff) | |
| download | frameworks_base-a17032eeb91f709360b6271b71b85e67f729bcc1.zip frameworks_base-a17032eeb91f709360b6271b71b85e67f729bcc1.tar.gz frameworks_base-a17032eeb91f709360b6271b71b85e67f729bcc1.tar.bz2 | |
Merge "Accurately track the sequence numbers of batched events."
Diffstat (limited to 'libs/ui/InputTransport.cpp')
| -rw-r--r-- | libs/ui/InputTransport.cpp | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp index 44cb6db..ecb3fb5 100644 --- a/libs/ui/InputTransport.cpp +++ b/libs/ui/InputTransport.cpp @@ -401,17 +401,16 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, if (batchIndex >= 0) { Batch& batch = mBatches.editItemAt(batchIndex); if (canAppendSamples(&batch.event, &mMsg)) { - // Send finished message for the earlier part of the batch. - // Claim that we handled the event. (The dispatcher doesn't care either - // way at the moment.) - status_t status = sendFinishedSignal(batch.seq, true); - if (status) { - return status; - } - // Append to the batch and save the new sequence number for the tail end. + uint32_t chain = batch.seq; appendSamples(&batch.event, &mMsg); batch.seq = mMsg.body.motion.seq; + + // Update the sequence number chain. + SeqChain seqChain; + seqChain.seq = batch.seq; + seqChain.chain = chain; + mSeqChains.push(seqChain); #if DEBUG_TRANSPORT_ACTIONS ALOGD("channel '%s' consumer ~ appended to batch event", mChannel->getName().string()); @@ -486,6 +485,41 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { return BAD_VALUE; } + // Send finished signals for the batch sequence chain first. + size_t seqChainCount = mSeqChains.size(); + if (seqChainCount) { + uint32_t currentSeq = seq; + uint32_t chainSeqs[seqChainCount]; + size_t chainIndex = 0; + for (size_t i = seqChainCount; i-- > 0; ) { + const SeqChain& seqChain = mSeqChains.itemAt(i); + if (seqChain.seq == currentSeq) { + currentSeq = seqChain.chain; + chainSeqs[chainIndex++] = currentSeq; + mSeqChains.removeAt(i); + } + } + status_t status = OK; + while (!status && chainIndex-- > 0) { + status = sendUnchainedFinishedSignal(chainSeqs[chainIndex], handled); + } + if (status) { + // An error occurred so at least one signal was not sent, reconstruct the chain. + do { + SeqChain seqChain; + seqChain.seq = chainIndex != 0 ? chainSeqs[chainIndex - 1] : seq; + seqChain.chain = chainSeqs[chainIndex]; + mSeqChains.push(seqChain); + } while (chainIndex-- > 0); + return status; + } + } + + // Send finished signal for the last message in the batch. + return sendUnchainedFinishedSignal(seq, handled); +} + +status_t InputConsumer::sendUnchainedFinishedSignal(uint32_t seq, bool handled) { InputMessage msg; msg.header.type = InputMessage::TYPE_FINISHED; msg.body.finished.seq = seq; |
