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

Commit 64c743b

Browse files
authored
Stop sending text to framework (#33892)
1 parent d7ef306 commit 64c743b

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

shell/platform/android/io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727
* <p>Once the spell check results are received by the {@link
2828
* io.flutter.plugin.editing.SpellCheckPlugin}, it will send back to the framework the {@code
2929
* ArrayList<String>} of encoded spell check results (see {@link
30-
* io.flutter.plugin.editing.SpellCheckPlugin#onGetSentenceSuggestions} for details) with the text
31-
* that these results correspond to appended to the front as an argument. For example, the argument
32-
* may look like: {@code {"Hello, wrold!", "7.11.world\nword\nold"}}. The {@link
30+
* io.flutter.plugin.editing.SpellCheckPlugin#onGetSentenceSuggestions} for details). For example,
31+
* the argument may look like: {@code {"7.11.world\nword\nold"}}. The {@link
3332
* io.flutter.plugin.editing.SpellCheckPlugin} only handles one request to fetch spell check results
3433
* at a time; see {@link io.flutter.plugin.editing.SpellCheckPlugin#initiateSpellCheck} for details.
3534
*

shell/platform/android/io/flutter/plugin/editing/SpellCheckPlugin.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import io.flutter.plugin.common.MethodChannel;
1616
import io.flutter.plugin.localization.LocalizationPlugin;
1717
import java.util.ArrayList;
18-
import java.util.Arrays;
1918
import java.util.Locale;
2019

2120
/**
@@ -36,7 +35,6 @@ public class SpellCheckPlugin
3635
private SpellCheckerSession mSpellCheckerSession;
3736

3837
@VisibleForTesting MethodChannel.Result pendingResult;
39-
@VisibleForTesting String pendingResultText;
4038

4139
// The maximum number of suggestions that the Android spell check service is allowed to provide
4240
// per word. Same number that is used by default for Android's TextViews.
@@ -80,7 +78,6 @@ public void initiateSpellCheck(
8078
}
8179

8280
pendingResult = result;
83-
pendingResultText = text;
8481

8582
performSpellCheck(locale, text);
8683
}
@@ -115,7 +112,7 @@ public void performSpellCheck(@NonNull String locale, @NonNull String text) {
115112
@Override
116113
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
117114
if (results.length == 0) {
118-
pendingResult.success(new ArrayList<>(Arrays.asList(pendingResultText, "")));
115+
pendingResult.success(new ArrayList<String>());
119116
pendingResult = null;
120117
return;
121118
}
@@ -146,7 +143,6 @@ public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
146143
spellCheckerSuggestionSpan.substring(0, spellCheckerSuggestionSpan.length() - 1));
147144
}
148145

149-
spellCheckerSuggestionSpans.add(0, pendingResultText);
150146
pendingResult.success(spellCheckerSuggestionSpans);
151147
pendingResult = null;
152148
}

shell/platform/android/test/io/flutter/plugin/editing/SpellCheckPluginTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ public void onGetSentenceSuggestionsResultsWithSuccessAndNoResultsProperly() {
182182
spy(new SpellCheckPlugin(fakeTextServicesManager, fakeSpellCheckChannel));
183183
MethodChannel.Result mockResult = mock(MethodChannel.Result.class);
184184
spellCheckPlugin.pendingResult = mockResult;
185-
spellCheckPlugin.pendingResultText = "Hello, world!";
186185

187186
spellCheckPlugin.onGetSentenceSuggestions(new SentenceSuggestionsInfo[] {});
188187

189-
verify(mockResult).success(new ArrayList<String>(Arrays.asList("Hello, world!", "")));
188+
verify(mockResult).success(new ArrayList<String>());
190189
}
191190

192191
@Test
@@ -197,7 +196,6 @@ public void onGetSentenceSuggestionsResultsWithSuccessAndResultsProperly() {
197196
spy(new SpellCheckPlugin(fakeTextServicesManager, fakeSpellCheckChannel));
198197
MethodChannel.Result mockResult = mock(MethodChannel.Result.class);
199198
spellCheckPlugin.pendingResult = mockResult;
200-
spellCheckPlugin.pendingResultText = "Hello, wrold!";
201199

202200
spellCheckPlugin.onGetSentenceSuggestions(
203201
new SentenceSuggestionsInfo[] {
@@ -211,7 +209,6 @@ public void onGetSentenceSuggestionsResultsWithSuccessAndResultsProperly() {
211209
new int[] {5})
212210
});
213211

214-
verify(mockResult)
215-
.success(new ArrayList<String>(Arrays.asList("Hello, wrold!", "7.11.world\nword\nold")));
212+
verify(mockResult).success(new ArrayList<String>(Arrays.asList("7.11.world\nword\nold")));
216213
}
217214
}

0 commit comments

Comments
 (0)