Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Implement delayed event synthesis key event handling for Android #19024

Merged
merged 7 commits into from
Jul 17, 2020

Conversation

gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Jun 12, 2020

@gspencergoog gspencergoog changed the title [WIP] Implement synchronous key event handling for Android Implement synchronous key event handling for Android Jun 13, 2020
@gspencergoog gspencergoog marked this pull request as ready for review June 13, 2020 00:43
@auto-assign auto-assign bot requested a review from jason-simmons June 13, 2020 00:43
@gspencergoog gspencergoog removed the request for review from jason-simmons June 18, 2020 22:43
@gspencergoog gspencergoog marked this pull request as draft June 18, 2020 22:43
@gspencergoog gspencergoog added the Work in progress (WIP) Not ready (yet) for review! label Jun 18, 2020
@gspencergoog gspencergoog force-pushed the synchronous_keys branch 3 times, most recently from 0a760f3 to 0613773 Compare June 22, 2020 22:04
@gspencergoog gspencergoog changed the title Implement synchronous key event handling for Android Implement pseudo-synchronous key event handling for Android Jun 22, 2020
@gspencergoog gspencergoog changed the title Implement pseudo-synchronous key event handling for Android Implement delayed event synthesis key event handling for Android Jun 22, 2020
@gspencergoog gspencergoog removed the Work in progress (WIP) Not ready (yet) for review! label Jun 23, 2020
@gspencergoog gspencergoog marked this pull request as ready for review June 23, 2020 17:05
@flutter flutter deleted a comment from fluttergithubbot Jun 23, 2020
@auto-assign auto-assign bot requested a review from cbracken June 23, 2020 17:08
@gspencergoog gspencergoog requested review from dkwingsmt and chinmaygarde and removed request for cbracken June 23, 2020 18:16
Copy link
Contributor

@dkwingsmt dkwingsmt left a 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.

@gspencergoog gspencergoog force-pushed the synchronous_keys branch 2 times, most recently from 9eb47be to 1c5cf60 Compare June 26, 2020 02:30
@gspencergoog
Copy link
Contributor Author

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.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 20, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 20, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 20, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 20, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 21, 2020
gspencergoog added a commit to gspencergoog/engine that referenced this pull request Jul 22, 2020
…oid (flutter#19024)"

This reverts commit 8825f91 because it breaks flutter_gallery__back_button_memory and a customer test.
gspencergoog added a commit that referenced this pull request Jul 22, 2020
…oid (#19024)" (#19956)

This reverts commit 8825f91 because it breaks flutter_gallery__back_button_memory and a customer test.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 23, 2020
gspencergoog added a commit to gspencergoog/engine that referenced this pull request Aug 24, 2020
gspencergoog added a commit that referenced this pull request Aug 28, 2020
…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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants