This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Android] Fix a crash related to zeroed scanCode #35924
Merged
auto-submit
merged 1 commit into
flutter:main
from
NevercodeHQ:fix_android_crash_zeroed_scancode
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,7 @@ void updatePressingState(@NonNull Long physicalKey, @Nullable Long logicalKey) { | |
| // the current event in consideration. | ||
| // | ||
| // Events that should be synthesized before the main event are synthesized | ||
| // immediately, while events that should be syntehsized after the main event are appended to | ||
| // immediately, while events that should be synthesized after the main event are appended to | ||
| // `postSynchronize`. | ||
| // | ||
| // Although Android KeyEvent defined bitmasks for sided modifiers (SHIFT_LEFT_ON and | ||
|
|
@@ -133,6 +133,7 @@ void synchronizePressingKey( | |
| PressingGoal goal, | ||
| boolean truePressed, | ||
| long eventLogicalKey, | ||
| long eventPhysicalKey, | ||
| KeyEvent event, | ||
| ArrayList<Runnable> postSynchronize) { | ||
| // During an incoming event, there might be a synthesized Flutter event for each key of each | ||
|
|
@@ -151,8 +152,8 @@ void synchronizePressingKey( | |
| // 2. Derive the pre-event state of the event key (if applicable.) | ||
| for (int keyIdx = 0; keyIdx < goal.keys.length; keyIdx += 1) { | ||
| final KeyboardMap.KeyPair key = goal.keys[keyIdx]; | ||
| nowStates[keyIdx] = pressingRecords.containsKey(goal.keys[keyIdx].physicalKey); | ||
| if (goal.keys[keyIdx].logicalKey == eventLogicalKey) { | ||
| nowStates[keyIdx] = pressingRecords.containsKey(key.physicalKey); | ||
| if (key.logicalKey == eventLogicalKey) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm, are these two lines of change make any difference, or purely cosmetic? (I'm ok with either)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Purely cosmetic. The 'key' variable was already defined (before this PR) and It could be used on this two lines. |
||
| switch (getEventType(event)) { | ||
| case kDown: | ||
| preEventStates[keyIdx] = false; | ||
|
|
@@ -161,7 +162,7 @@ void synchronizePressingKey( | |
| postSynchronize.add( | ||
| () -> | ||
| synthesizeEvent( | ||
| false, key.logicalKey, key.physicalKey, event.getEventTime())); | ||
| false, key.logicalKey, eventPhysicalKey, event.getEventTime())); | ||
| } | ||
| break; | ||
| case kUp: | ||
|
|
@@ -273,7 +274,12 @@ private boolean handleEventImpl( | |
| final ArrayList<Runnable> postSynchronizeEvents = new ArrayList<>(); | ||
| for (final PressingGoal goal : KeyboardMap.pressingGoals) { | ||
| synchronizePressingKey( | ||
| goal, (event.getMetaState() & goal.mask) != 0, logicalKey, event, postSynchronizeEvents); | ||
| goal, | ||
| (event.getMetaState() & goal.mask) != 0, | ||
| logicalKey, | ||
| physicalKey, | ||
| event, | ||
| postSynchronizeEvents); | ||
| } | ||
|
|
||
| for (final TogglingGoal goal : togglingGoals.values()) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks for catching that! 😊