Offset 2, 62 lines modifiedOffset 2, 45 lines modified
2 package·com.android.textclassifier;2 package·com.android.textclassifier;
  
3 import·com.android.textclassifier.utils.IndentingPrintWriter;3 import·com.android.textclassifier.utils.IndentingPrintWriter;
4 import·com.google.common.base.Splitter;4 import·com.google.common.base.Splitter;
5 import·java.util.Collections;5 import·java.util.Collections;
6 import·java.util.Arrays;6 import·java.util.Arrays;
7 import·java.util.List;7 import·java.util.List;
 8 import·android.provider.DeviceConfig;
8 import·com.google.common.collect.ImmutableList;9 import·com.google.common.collect.ImmutableList;
  
9 public·final·class·TextClassifierSettings10 public·final·class·TextClassifierSettings
10 {11 {
11 ····static·final·String·ACTIONS_SUGGESTIONS_URL_PREFIX·=·"actions_suggestions_url_prefix"; 
12 ····static·final·String·ANNOTATOR_URL_PREFIX·=·"annotator_url_prefix"; 
13 ····private·static·final·ImmutableList·CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES;12 ····private·static·final·ImmutableList·CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES;
14 ····private·static·final·TextClassifierSettings$IDeviceConfig·DEFAULT_DEVICE_CONFIG; 
15 ····static·final·String·ENTITY_LIST_DEFAULT·=·"entity_list_default";13 ····static·final·String·ENTITY_LIST_DEFAULT·=·"entity_list_default";
16 ····private·static·final·ImmutableList·ENTITY_LIST_DEFAULT_VALUE;14 ····private·static·final·ImmutableList·ENTITY_LIST_DEFAULT_VALUE;
17 ····static·final·String·LANG_ID_CONTEXT_SETTINGS·=·"lang_id_context_settings";15 ····static·final·String·LANG_ID_CONTEXT_SETTINGS·=·"lang_id_context_settings";
18 ····private·static·final·float[]·LANG_ID_CONTEXT_SETTINGS_DEFAULT;16 ····private·static·final·float[]·LANG_ID_CONTEXT_SETTINGS_DEFAULT;
19 ····static·final·String·LANG_ID_THRESHOLD_OVERRIDE·=·"lang_id_threshold_override";17 ····static·final·String·LANG_ID_THRESHOLD_OVERRIDE·=·"lang_id_threshold_override";
20 ····static·final·String·LANG_ID_URL_PREFIX·=·"lang_id_url_prefix"; 
21 ····static·final·String·MODEL_DOWNLOAD_MANAGER_ENABLED·=·"model_download_manager_enabled"; 
22 ····static·final·String·PRIMARY_ACTIONS_SUGGESTIONS_URL_SUFFIX·=·"primary_actions_suggestions_url_suffix"; 
23 ····static·final·String·PRIMARY_ANNOTATOR_URL_SUFFIX·=·"primary_annotator_url_suffix"; 
24 ····static·final·String·PRIMARY_LANG_ID_URL_SUFFIX·=·"primary_lang_id_url_suffix"; 
25 ····static·final·String·SUGGEST_SELECTION_MAX_RANGE_LENGTH·=·"suggest_selection_max_range_length";18 ····static·final·String·SUGGEST_SELECTION_MAX_RANGE_LENGTH·=·"suggest_selection_max_range_length";
26 ····static·final·String·TEMPLATE_INTENT_FACTORY_ENABLED·=·"template_intent_factory_enabled";19 ····static·final·String·TEMPLATE_INTENT_FACTORY_ENABLED·=·"template_intent_factory_enabled";
27 ····private·final·TextClassifierSettings$IDeviceConfig·deviceConfig; 
28 ····20 ····
29 ····static·{21 ····static·{
30 ········ENTITY_LIST_DEFAULT_VALUE·=·ImmutableList.of((Object)"address",·(Object)"email",·(Object)"phone",·(Object)"url",·(Object)"date",·(Object)"datetime",·(Object)"flight");22 ········ENTITY_LIST_DEFAULT_VALUE·=·ImmutableList.of((Object)"address",·(Object)"email",·(Object)"phone",·(Object)"url",·(Object)"date",·(Object)"datetime",·(Object)"flight");
31 ········CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES·=·ImmutableList.of((Object)"text_reply",·(Object)"create_reminder",·(Object)"call_phone",·(Object)"open_url",·(Object)"send_email",·(Object)"send_sms",·(Object)"track_flight",·(Object)"view_calendar",·(Object)"view_map",·(Object)"add_contact",·(Object)"copy");23 ········CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES·=·ImmutableList.of((Object)"text_reply",·(Object)"create_reminder",·(Object)"call_phone",·(Object)"open_url",·(Object)"send_email",·(Object)"send_sms",·(Object)"track_flight",·(Object)"view_calendar",·(Object)"view_map",·(Object)"add_contact",·(Object)"copy");
32 ········final·float[]·array;24 ········final·float[]·array;
33 ········final·float[]·lang_ID_CONTEXT_SETTINGS_DEFAULT·=·array·=·new·float[3];25 ········final·float[]·lang_ID_CONTEXT_SETTINGS_DEFAULT·=·array·=·new·float[3];
34 ········array[0]·=·20.0f;26 ········array[0]·=·20.0f;
35 ········array[1]·=·1.0f;27 ········array[1]·=·1.0f;
36 ········array[2]·=·0.4f;28 ········array[2]·=·0.4f;
37 ········LANG_ID_CONTEXT_SETTINGS_DEFAULT·=·lang_ID_CONTEXT_SETTINGS_DEFAULT;29 ········LANG_ID_CONTEXT_SETTINGS_DEFAULT·=·lang_ID_CONTEXT_SETTINGS_DEFAULT;
38 ········DEFAULT_DEVICE_CONFIG·=·(TextClassifierSettings$IDeviceConfig)new·TextClassifierSettings$1(); 
39 ····}30 ····}
40 ····31 ····
41 ····public·TextClassifierSettings()·{32 ····private·static·float[]·getDeviceConfigFloatArray(final·String·s,·final·float[]·array)·{
42 ········this(TextClassifierSettings.DEFAULT_DEVICE_CONFIG);33 ········return·parse(DeviceConfig.getString("textclassifier",·s,·(String)null),·array);
43 ····}34 ····}
44 ····35 ····
45 ····TextClassifierSettings(final·TextClassifierSettings$IDeviceConfig·deviceConfig)·{36 ····private·static·List·getDeviceConfigStringList(final·String·s,·final·List·list)·{
46 ········this.deviceConfig·=·deviceConfig;37 ········return·parse(DeviceConfig.getString("textclassifier",·s,·(String)null),·list);
47 ····} 
48 ···· 
49 ····private·float[]·getDeviceConfigFloatArray(final·String·s,·final·float[]·array)·{ 
50 ········return·parse(this.deviceConfig.getString("textclassifier",·s,·(String)null),·array); 
51 ····} 
52 ···· 
53 ····private·List·getDeviceConfigStringList(final·String·s,·final·List·list)·{ 
54 ········return·parse(this.deviceConfig.getString("textclassifier",·s,·(String)null),·list); 
55 ····}38 ····}
56 ····39 ····
57 ····private·static·List·parse(final·String·s,·final·List·list)·{40 ····private·static·List·parse(final·String·s,·final·List·list)·{
58 ········if·(s·!=·null)·{41 ········if·(s·!=·null)·{
59 ············return·Collections.unmodifiableList((List<?>)Arrays.asList((T[])s.split(":")));42 ············return·Collections.unmodifiableList((List<?>)Arrays.asList((T[])s.split(":")));
60 ········}43 ········}
61 ········return·list;44 ········return·list;
Offset 110, 170 lines modifiedOffset 93, 74 lines modified
110 ········indentingPrintWriter.printPair("lang_id_threshold_override",·(Object)this.getLangIdThresholdOverride());93 ········indentingPrintWriter.printPair("lang_id_threshold_override",·(Object)this.getLangIdThresholdOverride());
111 ········indentingPrintWriter.printPair("translate_action_threshold",·(Object)this.getTranslateActionThreshold());94 ········indentingPrintWriter.printPair("translate_action_threshold",·(Object)this.getTranslateActionThreshold());
112 ········indentingPrintWriter.printPair("notification_conversation_action_types_default",·(Object)this.getNotificationConversationActionTypes());95 ········indentingPrintWriter.printPair("notification_conversation_action_types_default",·(Object)this.getNotificationConversationActionTypes());
113 ········indentingPrintWriter.printPair("suggest_selection_max_range_length",·(Object)this.getSuggestSelectionMaxRangeLength());96 ········indentingPrintWriter.printPair("suggest_selection_max_range_length",·(Object)this.getSuggestSelectionMaxRangeLength());
114 ········indentingPrintWriter.printPair("user_language_profile_enabled",·(Object)this.isUserLanguageProfileEnabled());97 ········indentingPrintWriter.printPair("user_language_profile_enabled",·(Object)this.isUserLanguageProfileEnabled());
115 ········indentingPrintWriter.printPair("template_intent_factory_enabled",·(Object)this.isTemplateIntentFactoryEnabled());98 ········indentingPrintWriter.printPair("template_intent_factory_enabled",·(Object)this.isTemplateIntentFactoryEnabled());
116 ········indentingPrintWriter.printPair("translate_in_classification_enabled",·(Object)this.isTranslateInClassificationEnabled());99 ········indentingPrintWriter.printPair("translate_in_classification_enabled",·(Object)this.isTranslateInClassificationEnabled());
117 ········indentingPrintWriter.printPair("model_download_manager_enabled",·(Object)this.isModelDownloadManagerEnabled()); 
118 ········final·String·s·=·"annotator"; 
119 ········indentingPrintWriter.printPair("annotator_url_prefix",·(Object)this.getModelURLPrefix(s)); 
120 ········final·String·s2·=·"lang_id"; 
121 ········indentingPrintWriter.printPair("lang_id_url_prefix",·(Object)this.getModelURLPrefix(s2)); 
122 ········final·String·s3·=·"actions_suggestions"; 
123 ········indentingPrintWriter.printPair("actions_suggestions_url_prefix",·(Object)this.getModelURLPrefix(s3)); 
124 ········indentingPrintWriter.decreaseIndent(); 
125 ········indentingPrintWriter.printPair("primary_annotator_url_suffix",·(Object)this.getPrimaryModelURLSuffix(s)); 
126 ········indentingPrintWriter.printPair("primary_lang_id_url_suffix",·(Object)this.getPrimaryModelURLSuffix(s2)); 
127 ········indentingPrintWriter.printPair("primary_actions_suggestions_url_suffix",·(Object)this.getPrimaryModelURLSuffix(s3)); 
128 ········indentingPrintWriter.decreaseIndent();100 ········indentingPrintWriter.decreaseIndent();
129 ····}101 ····}
130 ····102 ····
131 ····public·int·getClassifyTextMaxRangeLength()·{103 ····public·int·getClassifyTextMaxRangeLength()·{
132 ········return·this.deviceConfig.getInt("textclassifier",·"classify_text_max_range_length",·10000);104 ········return·DeviceConfig.getInt("textclassifier",·"classify_text_max_range_length",·10000);
133 ····}105 ····}
134 ····106 ····
135 ····public·List·getEntityListDefault()·{107 ····public·List·getEntityListDefault()·{
136 ········return·this.getDeviceConfigStringList("entity_list_default",·(List)TextClassifierSettings.ENTITY_LIST_DEFAULT_VALUE);108 ········return·getDeviceConfigStringList("entity_list_default",·(List)TextClassifierSettings.ENTITY_LIST_DEFAULT_VALUE);
137 ····}109 ····}
138 ····110 ····
139 ····public·List·getEntityListEditable()·{111 ····public·List·getEntityListEditable()·{
140 ········return·this.getDeviceConfigStringList("entity_list_editable",·(List)TextClassifierSettings.ENTITY_LIST_DEFAULT_VALUE);112 ········return·getDeviceConfigStringList("entity_list_editable",·(List)TextClassifierSettings.ENTITY_LIST_DEFAULT_VALUE);
141 ····}113 ····}
142 ····114 ····
143 ····public·List·getEntityListNotEditable()·{115 ····public·List·getEntityListNotEditable()·{
144 ········return·this.getDeviceConfigStringList("entity_list_not_editable",·(List)TextClassifierSettings.ENTITY_LIST_DEFAULT_VALUE);116 ········return·getDeviceConfigStringList("entity_list_not_editable",·(List)TextClassifierSettings.ENTITY_LIST_DEFAULT_VALUE);
145 ····}117 ····}
146 ····118 ····
147 ····public·int·getGenerateLinksLogSampleRate()·{119 ····public·int·getGenerateLinksLogSampleRate()·{
148 ········return·this.deviceConfig.getInt("textclassifier",·"generate_links_log_sample_rate",·100);120 ········return·DeviceConfig.getInt("textclassifier",·"generate_links_log_sample_rate",·100);
149 ····}121 ····}
150 ····122 ····
151 ····public·int·getGenerateLinksMaxTextLength()·{123 ····public·int·getGenerateLinksMaxTextLength()·{
152 ········return·this.deviceConfig.getInt("textclassifier",·"generate_links_max_text_length",·100000);124 ········return·DeviceConfig.getInt("textclassifier",·"generate_links_max_text_length",·100000);
153 ····}125 ····}
154 ····126 ····
155 ····public·List·getInAppConversationActionTypes()·{127 ····public·List·getInAppConversationActionTypes()·{
156 ········return·this.getDeviceConfigStringList("in_app_conversation_action_types_default",·(List)TextClassifierSettings.CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES);128 ········return·getDeviceConfigStringList("in_app_conversation_action_types_default",·(List)TextClassifierSettings.CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES);
157 ····}129 ····}
158 ····130 ····
159 ····public·float[]·getLangIdContextSettings()·{131 ····public·float[]·getLangIdContextSettings()·{
160 ········return·this.getDeviceConfigFloatArray("lang_id_context_settings",·TextClassifierSettings.LANG_ID_CONTEXT_SETTINGS_DEFAULT);132 ········return·getDeviceConfigFloatArray("lang_id_context_settings",·TextClassifierSettings.LANG_ID_CONTEXT_SETTINGS_DEFAULT);
161 ····}133 ····}
162 ····134 ····
163 ····public·float·getLangIdThresholdOverride()·{135 ····public·float·getLangIdThresholdOverride()·{
164 ········return·this.deviceConfig.getFloat("textclassifier",·"lang_id_threshold_override",·-1.0f);136 ········return·DeviceConfig.getFloat("textclassifier",·"lang_id_threshold_override",·-1.0f);
165 ····} 
166 ···· 
167 ····public·String·getModelURLPrefix(final·String·s)·{ 
168 ········final·int·hashCode·=·s.hashCode(); 
169 ········final·int·n·=·-1408005459; 
170 ········final·int·n2·=·2; 
171 ········final·boolean·b·=·true; 
172 ········int·n3·=·0; 
173 ········Label_0120:·{ 
174 ············if·(hashCode·!=·n)·{ 
175 ················if·(hashCode·!=·-52072180)·{ 
176 ····················if·(hashCode·==·1335310812)·{ 
177 ························if·(s.equals("annotator"))·{ 
178 ····························n3·=·0; 
179 ····························break·Label_0120; 
180 ························} 
181 ····················} 
182 ················} 
183 ················else·if·(s.equals("lang_id"))·{ 
184 ····················n3·=·(b·?·1·:·0); 
185 ····················break·Label_0120; 
186 ················} 
187 ············} 
188 ············else·if·(s.equals("actions_suggestions"))·{ 
189 ················n3·=·n2; 
190 ················break·Label_0120; 
191 ············} 
192 ············n3·=·-1; 
193 ········} 
194 ········final·String·s2·=·"textclassifier"; 
195 ········if·(n3·==·0)·{ 
196 ············return·this.deviceConfig.getString(s2,·"annotator_url_prefix",·"https://www.gstatic.com/android/text_classifier/"); 
197 ········} 
198 ········if·(n3·==·(b·?·1·:·0))·{ 
199 ············return·this.deviceConfig.getString(s2,·"lang_id_url_prefix",·"https://www.gstatic.com/android/text_classifier/langid/"); 
200 ········} 
201 ········if·(n3·!=·n2)·{ 
202 ············return·""; 
203 ········} 
204 ········return·this.deviceConfig.getString(s2,·"actions_suggestions_url_prefix",·"https://www.gstatic.com/android/text_classifier/actions/"); 
205 ····}137 ····}
206 ····138 ····
207 ····public·List·getNotificationConversationActionTypes()·{139 ····public·List·getNotificationConversationActionTypes()·{
208 ········return·this.getDeviceConfigStringList("notification_conversation_action_types_default",·(List)TextClassifierSettings.CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES);140 ········return·getDeviceConfigStringList("notification_conversation_action_types_default",·(List)TextClassifierSettings.CONVERSATION_ACTIONS_TYPES_DEFAULT_VALUES);
209 ····} 
210 ···· 
211 ····public·String·getPrimaryModelURLSuffix(final·String·s)·{ 
212 ········final·int·hashCode·=·s.hashCode(); 
213 ········final·int·n·=·-1408005459; 
214 ········final·int·n2·=·2; 
215 ········final·boolean·b·=·true; 
216 ········int·n3·=·0; 
217 ········Label_0120:·{ 
218 ············if·(hashCode·!=·n)·{ 
219 ················if·(hashCode·!=·-52072180)·{ 
220 ····················if·(hashCode·==·1335310812)·{ 
221 ························if·(s.equals("annotator"))·{ 
222 ····························n3·=·0; 
223 ····························break·Label_0120; 
224 ························} 
225 ····················} 
226 ················} 
227 ················else·if·(s.equals("lang_id"))·{ 
228 ····················n3·=·(b·?·1·:·0); 
229 ····················break·Label_0120; 
230 ················} 
231 ············} 
232 ············else·if·(s.equals("actions_suggestions"))·{ 
233 ················n3·=·n2; 
234 ················break·Label_0120; 
235 ············} 
236 ············n3·=·-1; 
237 ········} 
238 ········final·String·s2·=·"textclassifier"; 
239 ········final·String·s3·=·""; 
240 ········if·(n3·==·0)·{ 
241 ············return·this.deviceConfig.getString(s2,·"primary_annotator_url_suffix",·s3); 
242 ········} 
243 ········if·(n3·==·(b·?·1·:·0))·{ 
244 ············return·this.deviceConfig.getString(s2,·"primary_lang_id_url_suffix",·s3); 
245 ········} 
246 ········if·(n3·!=·n2)·{ 
247 ············return·s3; 
248 ········} 
249 ········return·this.deviceConfig.getString(s2,·"primary_actions_suggestions_url_suffix",·s3); 
250 ····}141 ····}
251 ····142 ····
252 ····public·int·getSuggestSelectionMaxRangeLength()·{143 ····public·int·getSuggestSelectionMaxRangeLength()·{
253 ········return·this.deviceConfig.getInt("textclassifier",·"suggest_selection_max_range_length",·10000);144 ········return·DeviceConfig.getInt("textclassifier",·"suggest_selection_max_range_length",·10000);
254 ····}145 ····}
255 ····146 ····
256 ····public·float·getTranslateActionThreshold()·{147 ····public·float·getTranslateActionThreshold()·{
257 ········return·this.deviceConfig.getFloat("textclassifier",·"translate_action_threshold",·0.5f);148 ········return·DeviceConfig.getFloat("textclassifier",·"translate_action_threshold",·0.5f);
258 ····}149 ····}
259 ····150 ····
260 ····public·boolean·isDetectLanguagesFromTextEnabled()·{151 ····public·boolean·isDetectLanguagesFromTextEnabled()·{
261 ········return·this.deviceConfig.getBoolean("textclassifier",·"detect_languages_from_text_enabled",·true);152 ········return·DeviceConfig.getBoolean("textclassifier",·"detect_languages_from_text_enabled",·true);
262 ····} 
263 ···· 
264 ····public·boolean·isModelDownloadManagerEnabled()·{ 
265 ········return·this.deviceConfig.getBoolean("textclassifier",·"model_download_manager_enabled",·false); 
266 ····}153 ····}
267 ····154 ····
268 ····public·boolean·isTemplateIntentFactoryEnabled()·{155 ····public·boolean·isTemplateIntentFactoryEnabled()·{
269 ········return·this.deviceConfig.getBoolean("textclassifier",·"template_intent_factory_enabled",·true);156 ········return·DeviceConfig.getBoolean("textclassifier",·"template_intent_factory_enabled",·true);
270 ····}157 ····}
271 ····158 ····
272 ····public·boolean·isTranslateInClassificationEnabled()·{159 ····public·boolean·isTranslateInClassificationEnabled()·{
273 ········return·this.deviceConfig.getBoolean("textclassifier",·"translate_in_classification_enabled",·true);160 ········return·DeviceConfig.getBoolean("textclassifier",·"translate_in_classification_enabled",·true);
274 ····}161 ····}
275 ····162 ····
276 ····public·boolean·isUserLanguageProfileEnabled()·{163 ····public·boolean·isUserLanguageProfileEnabled()·{
277 ········return·this.deviceConfig.getBoolean("textclassifier",·"user_language_profile_enabled",·true);164 ········return·DeviceConfig.getBoolean("textclassifier",·"user_language_profile_enabled",·true);
278 ····}165 ····}
279 }166 }