-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Implement delayed event synthesis key event handling for Android #19024
Conversation
3eb72ea
to
579dee8
Compare
0a760f3
to
0613773
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks good, but I think better documentation is necessary for a complex mechanism like this, so that future maintainers can understand the code without reading the design doc. Also tests should be limited to public features unless absolutely necessary, so that we can change implementations without invalidating the tests.
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/engine/systemchannels/KeyEventChannel.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
Show resolved
Hide resolved
9eb47be
to
1c5cf60
Compare
I just switched the Context argument for the AndroidKeyProcessor to be a View, and instead of searching for the Activity in the Context hierarchy, I'm sending the synthesized key directly to the View instead. I think this is the right thing, since the next thing in the focus chain will get the event when we return false from onKeyDown/onKeyUp, but it occurred to me that in the middle of the async round trip, the focus chain could change, and instead of the old "next" thing getting the event, it'll be the "new" next thing that gets it. In practice, I don't think this is a huge problem, but if it were a problem, I'm not quite sure how it would manifest itself. |
1c5cf60
to
b382916
Compare
…oid (flutter#19024)" This reverts commit 8825f91 because it breaks flutter_gallery__back_button_memory and a customer test.
…for Android (flutter#19024)"" This reverts commit 27cc8d6.
…oid (#20736) This re-lands the key event synthesis implementation for Android (Original PR: #19024, Revert PR: #19956). The only difference is sending the synthesized key events to the root view instead of the current view. Without sending it to the root view, the system doesn't have any chance of handling keys like the back button. The event will still not be sent to the framework twice, since we turn off event propagation while re-dispatching the event.
Description
This implements the design in https://flutter.dev/go/handling-synchronous-keyboard-events for Android.
I started with Android, but this will be used for all platforms as we add them.
The related framework PR is: flutter/flutter#59358
Related Issues