@@ -53,6 +53,7 @@ public class SpeechInputMethodService extends InputMethodService {
53
53
private static final String REWRITES_NAME_FREQUENT = "#f" ;
54
54
private static final String REWRITES_NAME_CLIP = "#c" ;
55
55
56
+ private boolean mFlagPersonalizedLearning = true ;
56
57
private InputMethodManager mInputMethodManager ;
57
58
private SpeechInputView mInputView ;
58
59
private CommandEditor mCommandEditor ;
@@ -123,6 +124,10 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
123
124
super .onStartInput (attribute , restarting );
124
125
String type = "UNKNOWN" ;
125
126
127
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
128
+ mFlagPersonalizedLearning = (attribute .imeOptions & EditorInfo .IME_FLAG_NO_PERSONALIZED_LEARNING ) != EditorInfo .IME_FLAG_NO_PERSONALIZED_LEARNING ;
129
+ }
130
+
126
131
switch (attribute .inputType & InputType .TYPE_MASK_CLASS ) {
127
132
case InputType .TYPE_CLASS_NUMBER :
128
133
type = "NUMBER" ;
@@ -163,7 +168,7 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
163
168
164
169
default :
165
170
}
166
- Log .i ("onStartInput: " + type + ", " + attribute .inputType + ", " + attribute .imeOptions + ", " + restarting );
171
+ Log .i ("onStartInput: " + type + ", " + attribute .inputType + ", " + attribute .imeOptions + ", " + restarting + ", learning: " + mFlagPersonalizedLearning );
167
172
}
168
173
169
174
/**
@@ -352,7 +357,7 @@ private void commitResults(List<String> results) {
352
357
if (editorResult != null && mInputView != null && editorResult .isCommand ()) {
353
358
mInputView .showMessage (editorResult .getRewrite ().ppCommand (), editorResult .isSuccess ());
354
359
}
355
- if (editorResult != null ) {
360
+ if (editorResult != null && mFlagPersonalizedLearning ) {
356
361
String rewritesRec = getRewrites (REWRITES_NAME_RECENT );
357
362
if (rewritesRec != null ) {
358
363
UtteranceRewriter ur = mRuleManager .addRecent (editorResult , rewritesRec );
0 commit comments