summaryrefslogtreecommitdiff
path: root/libs/input/InputConsumerNoResampling.cpp
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-12 19:32:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-11-12 19:32:24 +0000
commitbad8a9ea9bf30ab33ba7e940a36fa1054f3d2e3e (patch)
tree2473cebfa02d16acb84a3efb58b928b9058c8bb7 /libs/input/InputConsumerNoResampling.cpp
parent2eb60a80e9c63aa7f47ac58d88944b6f86fb8adb (diff)
parent362fa2273d66fae4af1ec38cac32c0ad22e1acf5 (diff)
Merge "Remove callback at the end of consumer destructor" into main
Diffstat (limited to 'libs/input/InputConsumerNoResampling.cpp')
-rw-r--r--libs/input/InputConsumerNoResampling.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/libs/input/InputConsumerNoResampling.cpp b/libs/input/InputConsumerNoResampling.cpp
index d3653cfc45..2c0f77a814 100644
--- a/libs/input/InputConsumerNoResampling.cpp
+++ b/libs/input/InputConsumerNoResampling.cpp
@@ -193,13 +193,6 @@ InputConsumerNoResampling::InputConsumerNoResampling(
InputConsumerNoResampling::~InputConsumerNoResampling() {
ensureCalledOnLooperThread(__func__);
- while (!mOutboundQueue.empty()) {
- processOutboundEvents();
- // This is our last chance to ack the events. If we don't ack them here, we will get an ANR,
- // so keep trying to send the events as long as they are present in the queue.
- }
-
- setFdEvents(0);
// If there are any remaining unread batches, send an ack for them and don't deliver
// them to callbacks.
for (auto& [_, batches] : mBatches) {
@@ -208,6 +201,12 @@ InputConsumerNoResampling::~InputConsumerNoResampling() {
batches.pop();
}
}
+
+ while (!mOutboundQueue.empty()) {
+ processOutboundEvents();
+ // This is our last chance to ack the events. If we don't ack them here, we will get an ANR,
+ // so keep trying to send the events as long as they are present in the queue.
+ }
// However, it is still up to the app to finish any events that have already been delivered
// to the callbacks. If we wanted to change that behaviour and auto-finish all unfinished events
// that were already sent to callbacks, we could potentially loop through "mConsumeTimes"
@@ -216,6 +215,10 @@ InputConsumerNoResampling::~InputConsumerNoResampling() {
const size_t unfinishedEvents = mConsumeTimes.size();
LOG_IF(INFO, unfinishedEvents != 0)
<< getName() << " has " << unfinishedEvents << " unfinished event(s)";
+ // Remove the fd from epoll, so that Looper does not call 'handleReceiveCallback' anymore.
+ // This must be done at the end of the destructor; otherwise, some of the other functions may
+ // call 'setFdEvents' as a side-effect, thus adding the fd back to the epoll set of the looper.
+ setFdEvents(0);
}
int InputConsumerNoResampling::handleReceiveCallback(int events) {