Fix a anr bug caused by sendFinishedSignal logical error
Because of eliminate multiple benign overflow conditions see:
https://android-review.googlesource.com/#/c/172237/
Changed the do while loop resulting in a logical difference.
When the chainIndex-- to 0, the loop is not run.
It is the most important cycle, it will push head seq to mSeqChains.
If not run, will lead to a batch of seq can not corrected finish.
Eventually leading to the occurrence of anr.
Signed-off-by: gaoshang <gaoshang@xiaomi.com>
Test: Input dispatche process
Bug: 38366215
Change-Id: I87e609dfcb00ac7b8e82c6de789df094e7c25efd
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index af1c0af..293bc25 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -842,15 +842,14 @@
}
if (status) {
// An error occurred so at least one signal was not sent, reconstruct the chain.
- do {
+ for (;;) {
SeqChain seqChain;
seqChain.seq = chainIndex != 0 ? chainSeqs[chainIndex - 1] : seq;
seqChain.chain = chainSeqs[chainIndex];
mSeqChains.push(seqChain);
- if (chainIndex != 0) {
- chainIndex--;
- }
- } while (chainIndex > 0);
+ if (!chainIndex) break;
+ chainIndex--;
+ }
return status;
}
}