Revert "Use Result<InputPublisher::Finished> instead of callback"
Revert submission 13780058-receiveFinishedSignal
Reason for revert:
Caused severe delay in back navigation on IME-focusable window.
Reverted Changes:
I301c6e9c3:Use Result<InputPublisher::Finished> instead of ca...
I43a0f2d31:Update the usage of receiveFinishedSignal
Bug: 167947340
Fix: 182514338
Test: Manually verified as follows:
1. Set up the device as "Set up offline" mode.
2. adb shell am start -n com.google.android.dialer/.extensions.GoogleDialtactsActivity
3. On one terminal, run adb logcat -s InputMethodManager:*
4. On another terminal, run adb shell input keyevent 4
5. Make sure that the following message is not shown.
"Timeout waiting for IME to handle input event after 2500 ms"
Change-Id: I1e71010f5f4ae268dfcbc3bde50881c2fa3d51d5
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 3183a98..6d9190c 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -80,7 +80,6 @@
#define INDENT4 " "
using android::base::HwTimeoutMultiplier;
-using android::base::Result;
using android::base::StringPrintf;
using android::os::BlockUntrustedTouchesMode;
using android::os::IInputConstants;
@@ -3194,17 +3193,17 @@
nsecs_t currentTime = now();
bool gotOne = false;
- status_t status = OK;
+ status_t status;
for (;;) {
- Result<InputPublisher::Finished> result =
- connection->inputPublisher.receiveFinishedSignal();
- if (!result.ok()) {
- status = result.error().code();
+ std::function<void(uint32_t seq, bool handled, nsecs_t consumeTime)> callback =
+ std::bind(&InputDispatcher::finishDispatchCycleLocked, d, currentTime,
+ connection, std::placeholders::_1, std::placeholders::_2,
+ std::placeholders::_3);
+
+ status = connection->inputPublisher.receiveFinishedSignal(callback);
+ if (status) {
break;
}
- const InputPublisher::Finished& finished = *result;
- d->finishDispatchCycleLocked(currentTime, connection, finished.seq,
- finished.handled, finished.consumeTime);
gotOne = true;
}
if (gotOne) {
@@ -4892,7 +4891,8 @@
}
}
-Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputChannel(const std::string& name) {
+base::Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputChannel(
+ const std::string& name) {
#if DEBUG_CHANNEL_CREATION
ALOGD("channel '%s' ~ createInputChannel", name.c_str());
#endif
@@ -4921,10 +4921,8 @@
return clientChannel;
}
-Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(int32_t displayId,
- bool isGestureMonitor,
- const std::string& name,
- int32_t pid) {
+base::Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(
+ int32_t displayId, bool isGestureMonitor, const std::string& name, int32_t pid) {
std::shared_ptr<InputChannel> serverChannel;
std::unique_ptr<InputChannel> clientChannel;
status_t result = openInputChannelPair(name, serverChannel, clientChannel);