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
Restart all modern Samsung keyboard IMM #12780
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
665d969
Restart all modern samsung keyboard IMM
GaryQian fc1e164
Check default keyboard to determine if fix should be applied.
GaryQian 8f9fc09
Change test name
GaryQian a8008d6
VTOL
GaryQian 5a695e1
Fix tests
GaryQian f186de1
Imports
GaryQian 582bfc9
putString
GaryQian 2ce3a69
Short circuit to skip keyboard lookup on non-samsung devices
GaryQian ff6ba89
Remove redundant test, add sdk=27
GaryQian bf11a2a
Fix test
GaryQian 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
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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package io.flutter.plugin.editing; | ||
|
|
||
| import android.content.Context; | ||
| import android.provider.Settings; | ||
| import android.util.SparseIntArray; | ||
| import android.view.View; | ||
| import android.view.inputmethod.InputMethodManager; | ||
|
|
@@ -24,7 +25,7 @@ | |
| import static org.junit.Assert.assertEquals; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| @Config(manifest = Config.NONE, shadows = TextInputPluginTest.TestImm.class) | ||
| @Config(manifest = Config.NONE, shadows = TextInputPluginTest.TestImm.class, sdk = 27) | ||
| @RunWith(RobolectricTestRunner.class) | ||
| public class TextInputPluginTest { | ||
| @Test | ||
|
|
@@ -47,12 +48,15 @@ public void setTextInputEditingState_doesNotRestartWhenTextIsIdentical() { | |
| assertEquals(1, testImm.getRestartCount(testView)); | ||
| } | ||
|
|
||
| // See https://github.com/flutter/flutter/issues/29341 | ||
| // See https://github.com/flutter/flutter/issues/29341 and https://github.com/flutter/flutter/issues/31512 | ||
| // All modern Samsung keybords are affected including non-korean languages and thus | ||
| // need the restart. | ||
| @Test | ||
| public void setTextInputEditingState_alwaysRestartsOnAffectedDevices() { | ||
| public void setTextInputEditingState_alwaysRestartsOnAffectedDevices2() { | ||
|
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. The tests are failing because they're running on On a second look, I'd also just replace the existing |
||
| // Initialize a TextInputPlugin that needs to be always restarted. | ||
| ShadowBuild.setManufacturer("samsung"); | ||
| InputMethodSubtype inputMethodSubtype = new InputMethodSubtype(0, 0, /*locale=*/"ko", "", "", false, false); | ||
| InputMethodSubtype inputMethodSubtype = new InputMethodSubtype(0, 0, /*locale=*/"en", "", "", false, false); | ||
| Settings.Secure.putString(RuntimeEnvironment.application.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD, "com.sec.android.inputmethod/.SamsungKeypad"); | ||
| TestImm testImm = Shadow.extract(RuntimeEnvironment.application.getSystemService(Context.INPUT_METHOD_SERVICE)); | ||
| testImm.setCurrentInputMethodSubtype(inputMethodSubtype); | ||
| View testView = new View(RuntimeEnvironment.application); | ||
|
|
@@ -69,6 +73,28 @@ public void setTextInputEditingState_alwaysRestartsOnAffectedDevices() { | |
| assertEquals(2, testImm.getRestartCount(testView)); | ||
| } | ||
|
|
||
| @Test | ||
| public void setTextInputEditingState_doesNotRestartOnUnaffectedDevices() { | ||
| // Initialize a TextInputPlugin that needs to be always restarted. | ||
| ShadowBuild.setManufacturer("samsung"); | ||
| InputMethodSubtype inputMethodSubtype = new InputMethodSubtype(0, 0, /*locale=*/"en", "", "", false, false); | ||
| Settings.Secure.putString(RuntimeEnvironment.application.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD, "com.fake.test.blah/.NotTheRightKeyboard"); | ||
| TestImm testImm = Shadow.extract(RuntimeEnvironment.application.getSystemService(Context.INPUT_METHOD_SERVICE)); | ||
| testImm.setCurrentInputMethodSubtype(inputMethodSubtype); | ||
| View testView = new View(RuntimeEnvironment.application); | ||
| TextInputPlugin textInputPlugin = new TextInputPlugin(testView, mock(DartExecutor.class), mock(PlatformViewsController.class)); | ||
| textInputPlugin.setTextInputClient(0, new TextInputChannel.Configuration(false, false, TextInputChannel.TextCapitalization.NONE, null, null, null)); | ||
| // There's a pending restart since we initialized the text input client. Flush that now. | ||
| textInputPlugin.setTextInputEditingState(testView, new TextInputChannel.TextEditState("", 0, 0)); | ||
|
|
||
| // Move the cursor. | ||
| assertEquals(1, testImm.getRestartCount(testView)); | ||
| textInputPlugin.setTextInputEditingState(testView, new TextInputChannel.TextEditState("", 0, 0)); | ||
|
|
||
| // Verify that we've restarted the input. | ||
| assertEquals(1, testImm.getRestartCount(testView)); | ||
| } | ||
|
|
||
| @Test | ||
| public void setTextInputEditingState_nullInputMethodSubtype() { | ||
| TestImm testImm = Shadow.extract(RuntimeEnvironment.application.getSystemService(Context.INPUT_METHOD_SERVICE)); | ||
|
|
||
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.
Does this API call read from disk? I thought this API was slow because it ended up doing I/O, but I could be mistaken here.
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.
Let me look it up
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.
There seems to be no mention of it storing it on disk, which I would imagine if it were stored on disk, would at least be mentioned a few times.
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.
It reads from something called sNameValueCache, which I am assuming reads from disk at some point but the values should be cached when we use it here.
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.
In any case, I added short circuiting to prevent non-samsung devices from performing the lookup.
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 looking into it, this LGTM.