blob: 64f8a09d6f435a780d966f8a7944699693f24e03 [file] [log] [blame]
Mike LeBeau92c33522010-01-25 18:18:45 -05001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070019import android.Manifest;
Mike LeBeau766a19b2010-02-11 22:57:12 -080020import android.content.ComponentName;
Mike LeBeau92c33522010-01-25 18:18:45 -050021import android.content.Intent;
22import android.content.pm.PackageManager;
Mike LeBeau766a19b2010-02-11 22:57:12 -080023import android.content.pm.ResolveInfo;
24import android.content.pm.ServiceInfo;
Dianne Hackborn0382a492010-03-04 11:44:09 -080025import android.content.pm.PackageManager.NameNotFoundException;
26import android.content.res.Resources;
Mike LeBeau766a19b2010-02-11 22:57:12 -080027import android.content.res.TypedArray;
28import android.content.res.XmlResourceParser;
Mike LeBeau766a19b2010-02-11 22:57:12 -080029import android.preference.ListPreference;
Mike LeBeau92c33522010-01-25 18:18:45 -050030import android.preference.Preference;
Mike LeBeau766a19b2010-02-11 22:57:12 -080031import android.preference.PreferenceCategory;
Mike LeBeau92c33522010-01-25 18:18:45 -050032import android.preference.PreferenceGroup;
Mike LeBeau766a19b2010-02-11 22:57:12 -080033import android.preference.PreferenceScreen;
34import android.preference.Preference.OnPreferenceChangeListener;
35import android.provider.Settings;
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070036import android.service.voice.VoiceInteractionService;
Mike LeBeau766a19b2010-02-11 22:57:12 -080037import android.speech.RecognitionService;
Narayan Kamathe247cb82011-10-05 12:26:31 +010038import android.speech.tts.TtsEngines;
Mike LeBeau766a19b2010-02-11 22:57:12 -080039import android.util.AttributeSet;
40import android.util.Log;
41import android.util.Xml;
Mike LeBeau92c33522010-01-25 18:18:45 -050042
Mike LeBeau766a19b2010-02-11 22:57:12 -080043import java.io.IOException;
44import java.util.HashMap;
Mike LeBeau92c33522010-01-25 18:18:45 -050045import java.util.List;
46
Amith Yamasanib44161f2010-12-10 13:17:34 -080047import org.xmlpull.v1.XmlPullParser;
48import org.xmlpull.v1.XmlPullParserException;
49
Mike LeBeau92c33522010-01-25 18:18:45 -050050/**
51 * Settings screen for voice input/output.
52 */
Amith Yamasanib44161f2010-12-10 13:17:34 -080053public class VoiceInputOutputSettings implements OnPreferenceChangeListener {
54
Mike LeBeau766a19b2010-02-11 22:57:12 -080055 private static final String TAG = "VoiceInputOutputSettings";
Amith Yamasanib44161f2010-12-10 13:17:34 -080056
Jean Chalard8ba5c422011-08-31 21:40:43 +090057 private static final String KEY_VOICE_CATEGORY = "voice_category";
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070058 private static final String KEY_VOICE_INTERACTOR = "voice_interactor";
59 private static final String KEY_VOICE_INTERACTOR_SETTINGS = "voice_interactor_settings";
Mike LeBeau766a19b2010-02-11 22:57:12 -080060 private static final String KEY_RECOGNIZER = "recognizer";
61 private static final String KEY_RECOGNIZER_SETTINGS = "recognizer_settings";
Narayan Kamathe247cb82011-10-05 12:26:31 +010062 private static final String KEY_TTS_SETTINGS = "tts_settings";
63
Mike LeBeau766a19b2010-02-11 22:57:12 -080064 private PreferenceGroup mParent;
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070065 private ListPreference mVoiceInteractionPref;
66 private PreferenceScreen mVoiceInteractionSettingsPref;
Jean Chalard8ba5c422011-08-31 21:40:43 +090067 private PreferenceCategory mVoiceCategory;
Mike LeBeau766a19b2010-02-11 22:57:12 -080068 private ListPreference mRecognizerPref;
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070069 private PreferenceScreen mRecognizerSettingsPref;
Narayan Kamathe247cb82011-10-05 12:26:31 +010070 private Preference mTtsSettingsPref;
Narayan Kamathe247cb82011-10-05 12:26:31 +010071 private final SettingsPreferenceFragment mFragment;
72 private final TtsEngines mTtsEngines;
Amith Yamasanib44161f2010-12-10 13:17:34 -080073
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070074 private HashMap<String, ResolveInfo> mAvailableVoiceInteractionsMap;
75
Mike LeBeau766a19b2010-02-11 22:57:12 -080076 private HashMap<String, ResolveInfo> mAvailableRecognizersMap;
Mike LeBeau92c33522010-01-25 18:18:45 -050077
Amith Yamasanib44161f2010-12-10 13:17:34 -080078 public VoiceInputOutputSettings(SettingsPreferenceFragment fragment) {
79 mFragment = fragment;
Narayan Kamathe247cb82011-10-05 12:26:31 +010080 mTtsEngines = new TtsEngines(fragment.getPreferenceScreen().getContext());
Amith Yamasanib44161f2010-12-10 13:17:34 -080081 }
Mike LeBeau766a19b2010-02-11 22:57:12 -080082
Amith Yamasanib44161f2010-12-10 13:17:34 -080083 public void onCreate() {
84
Narayan Kamathe247cb82011-10-05 12:26:31 +010085 mParent = mFragment.getPreferenceScreen();
Jean Chalard8ba5c422011-08-31 21:40:43 +090086 mVoiceCategory = (PreferenceCategory) mParent.findPreference(KEY_VOICE_CATEGORY);
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070087 mVoiceInteractionPref = (ListPreference) mVoiceCategory.findPreference(
88 KEY_VOICE_INTERACTOR);
89 mVoiceInteractionPref.setOnPreferenceChangeListener(this);
90 mVoiceInteractionSettingsPref = (PreferenceScreen)mVoiceCategory.findPreference(
91 KEY_VOICE_INTERACTOR_SETTINGS);
Jean Chalard8ba5c422011-08-31 21:40:43 +090092 mRecognizerPref = (ListPreference) mVoiceCategory.findPreference(KEY_RECOGNIZER);
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070093 mRecognizerSettingsPref = (PreferenceScreen)
Jean Chalard8ba5c422011-08-31 21:40:43 +090094 mVoiceCategory.findPreference(KEY_RECOGNIZER_SETTINGS);
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070095 mRecognizerPref.setOnPreferenceChangeListener(this);
96 mTtsSettingsPref = mVoiceCategory.findPreference(KEY_TTS_SETTINGS);
Amith Yamasanib44161f2010-12-10 13:17:34 -080097
Dianne Hackborndf7e99b2014-04-17 18:35:29 -070098 mAvailableVoiceInteractionsMap = new HashMap<String, ResolveInfo>();
Mike LeBeau766a19b2010-02-11 22:57:12 -080099 mAvailableRecognizersMap = new HashMap<String, ResolveInfo>();
Amith Yamasanib44161f2010-12-10 13:17:34 -0800100
Narayan Kamathe247cb82011-10-05 12:26:31 +0100101 populateOrRemovePreferences();
Mike LeBeau92c33522010-01-25 18:18:45 -0500102 }
Amith Yamasanib44161f2010-12-10 13:17:34 -0800103
Narayan Kamathe247cb82011-10-05 12:26:31 +0100104 private void populateOrRemovePreferences() {
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700105 boolean hasVoiceInteractionPrefs = populateOrRemoveVoiceInteractionPrefs();
Narayan Kamathe247cb82011-10-05 12:26:31 +0100106 boolean hasRecognizerPrefs = populateOrRemoveRecognizerPrefs();
107 boolean hasTtsPrefs = populateOrRemoveTtsPrefs();
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700108 if (!hasVoiceInteractionPrefs && !hasRecognizerPrefs && !hasTtsPrefs) {
Narayan Kamathe247cb82011-10-05 12:26:31 +0100109 // There were no TTS settings and no recognizer settings,
110 // so it should be safe to hide the preference category
111 // entirely.
112 mFragment.getPreferenceScreen().removePreference(mVoiceCategory);
113 }
114 }
115
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700116 private boolean populateOrRemoveVoiceInteractionPrefs() {
117 List<ResolveInfo> availableVoiceServices =
118 mFragment.getPackageManager().queryIntentServices(
119 new Intent(VoiceInteractionService.SERVICE_INTERFACE),
120 PackageManager.GET_META_DATA);
121 for (int i=0; i<availableVoiceServices.size(); i++) {
122 ResolveInfo ri = availableVoiceServices.get(i);
123 if (!Manifest.permission.BIND_VOICE_INTERACTION.equals(ri.serviceInfo.permission)) {
124 availableVoiceServices.remove(i);
125 }
126 }
127 int numAvailable = availableVoiceServices.size();
128
129 if (numAvailable == 0) {
130 mVoiceCategory.removePreference(mVoiceInteractionPref);
131 mVoiceCategory.removePreference(mVoiceInteractionSettingsPref);
132 return false;
133 }
134
135 populateVoiceInteractionPreference(availableVoiceServices);
136
137 // In this case, there was at least one available recognizer so
138 // we populated the settings.
139 return true;
140 }
141
Narayan Kamathe247cb82011-10-05 12:26:31 +0100142 private boolean populateOrRemoveRecognizerPrefs() {
Amith Yamasanib44161f2010-12-10 13:17:34 -0800143 List<ResolveInfo> availableRecognitionServices =
144 mFragment.getPackageManager().queryIntentServices(
Narayan Kamathe247cb82011-10-05 12:26:31 +0100145 new Intent(RecognitionService.SERVICE_INTERFACE),
146 PackageManager.GET_META_DATA);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800147 int numAvailable = availableRecognitionServices.size();
Narayan Kamathe247cb82011-10-05 12:26:31 +0100148
Mike LeBeau766a19b2010-02-11 22:57:12 -0800149 if (numAvailable == 0) {
Narayan Kamathe247cb82011-10-05 12:26:31 +0100150 mVoiceCategory.removePreference(mRecognizerPref);
151 mVoiceCategory.removePreference(mRecognizerSettingsPref);
152 return false;
153 }
154
155 if (numAvailable == 1) {
Mike LeBeau4c2ffc52010-02-12 14:47:48 -0800156 // Only one recognizer available, so don't show the list of choices, but do
157 // set up the link to settings for the available recognizer.
Jean Chalard8ba5c422011-08-31 21:40:43 +0900158 mVoiceCategory.removePreference(mRecognizerPref);
Amith Yamasanib44161f2010-12-10 13:17:34 -0800159
Mike LeBeau4c2ffc52010-02-12 14:47:48 -0800160 // But first set up the available recognizers map with just the one recognizer.
161 ResolveInfo resolveInfo = availableRecognitionServices.get(0);
162 String recognizerComponent =
Narayan Kamathe247cb82011-10-05 12:26:31 +0100163 new ComponentName(resolveInfo.serviceInfo.packageName,
164 resolveInfo.serviceInfo.name).flattenToShortString();
165
Mike LeBeau4c2ffc52010-02-12 14:47:48 -0800166 mAvailableRecognizersMap.put(recognizerComponent, resolveInfo);
Narayan Kamathe247cb82011-10-05 12:26:31 +0100167
Mike LeBeau4c2ffc52010-02-12 14:47:48 -0800168 String currentSetting = Settings.Secure.getString(
Amith Yamasanib44161f2010-12-10 13:17:34 -0800169 mFragment.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700170 updateRecognizerSettingsLink(currentSetting);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800171 } else {
172 // Multiple recognizers available, so show the full list of choices.
173 populateRecognizerPreference(availableRecognitionServices);
Mike LeBeau92c33522010-01-25 18:18:45 -0500174 }
Narayan Kamathe247cb82011-10-05 12:26:31 +0100175
176 // In this case, there was at least one available recognizer so
177 // we populated the settings.
178 return true;
179 }
180
181 private boolean populateOrRemoveTtsPrefs() {
182 if (mTtsEngines.getEngines().isEmpty()) {
183 mVoiceCategory.removePreference(mTtsSettingsPref);
184 return false;
185 }
186
187 return true;
Mike LeBeau766a19b2010-02-11 22:57:12 -0800188 }
Amith Yamasanib44161f2010-12-10 13:17:34 -0800189
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700190 private void populateVoiceInteractionPreference(List<ResolveInfo> voiceInteractors) {
191 int size = voiceInteractors.size();
192 CharSequence[] entries = new CharSequence[size+1];
193 CharSequence[] values = new CharSequence[size+1];
194
195 // Get the current value from the secure setting.
196 String currentSetting = Settings.Secure.getString(
197 mFragment.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE);
198
199 // Iterate through all the available recognizers and load up their info to show
200 // in the preference. Also build up a map of recognizer component names to their
201 // ResolveInfos - we'll need that a little later.
202 for (int i = 0; i < size; i++) {
203 ResolveInfo resolveInfo = voiceInteractors.get(i);
204 String recognizerComponent =
205 new ComponentName(resolveInfo.serviceInfo.packageName,
206 resolveInfo.serviceInfo.name).flattenToShortString();
207
208 mAvailableVoiceInteractionsMap.put(recognizerComponent, resolveInfo);
209
210 entries[i] = resolveInfo.loadLabel(mFragment.getPackageManager());
211 values[i] = recognizerComponent;
212 }
213
214 entries[size] = mFragment.getString(R.string.no_voice_interactor);
215 values[size] = "";
216
217 mVoiceInteractionPref.setEntries(entries);
218 mVoiceInteractionPref.setEntryValues(values);
219
220 mVoiceInteractionPref.setDefaultValue(currentSetting);
221 mVoiceInteractionPref.setValue(currentSetting);
222
223 updateVoiceInteractionSettingsLink(currentSetting);
224 }
225
226 private void updateVoiceInteractionSettingsLink(String currentSetting) {
227 ResolveInfo currentRecognizer = mAvailableVoiceInteractionsMap.get(currentSetting);
228 if (currentRecognizer == null) {
229 mVoiceInteractionPref.setSummary(mFragment.getString(R.string.no_voice_interactor));
230 mVoiceInteractionPref.setValue("");
231 return;
232 }
233
234 ServiceInfo si = currentRecognizer.serviceInfo;
235 XmlResourceParser parser = null;
236 String settingsActivity = null;
237 try {
238 parser = si.loadXmlMetaData(mFragment.getPackageManager(),
239 VoiceInteractionService.SERVICE_META_DATA);
240 if (parser == null) {
241 throw new XmlPullParserException("No " + VoiceInteractionService.SERVICE_META_DATA +
242 " meta-data for " + si.packageName);
243 }
244
245 Resources res = mFragment.getPackageManager().getResourcesForApplication(
246 si.applicationInfo);
247
248 AttributeSet attrs = Xml.asAttributeSet(parser);
249
250 int type;
251 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
252 && type != XmlPullParser.START_TAG) {
253 }
254
255 String nodeName = parser.getName();
256 if (!"voice-interaction-service".equals(nodeName)) {
257 throw new XmlPullParserException(
258 "Meta-data does not start with voice-interaction-service tag");
259 }
260
261 TypedArray array = res.obtainAttributes(attrs,
262 com.android.internal.R.styleable.VoiceInteractionService);
263 settingsActivity = array.getString(
264 com.android.internal.R.styleable.VoiceInteractionService_settingsActivity);
265 array.recycle();
266 } catch (XmlPullParserException e) {
267 Log.e(TAG, "error parsing recognition service meta-data", e);
268 } catch (IOException e) {
269 Log.e(TAG, "error parsing recognition service meta-data", e);
270 } catch (NameNotFoundException e) {
271 Log.e(TAG, "error parsing recognition service meta-data", e);
272 } finally {
273 if (parser != null) parser.close();
274 }
275
276 mVoiceInteractionPref.setSummary(currentRecognizer.loadLabel(
277 mFragment.getPackageManager()));
278 mVoiceInteractionPref.setValue(currentSetting);
279
280 if (settingsActivity == null) {
281 // No settings preference available - hide the preference.
282 Log.w(TAG, "no recognizer settings available for " + si.packageName);
283 } else {
284 Intent i = new Intent(Intent.ACTION_MAIN);
285 i.setComponent(new ComponentName(si.packageName, settingsActivity));
286 mVoiceInteractionSettingsPref.setIntent(i);
287 }
288 }
289
Mike LeBeau766a19b2010-02-11 22:57:12 -0800290 private void populateRecognizerPreference(List<ResolveInfo> recognizers) {
291 int size = recognizers.size();
292 CharSequence[] entries = new CharSequence[size];
293 CharSequence[] values = new CharSequence[size];
294
295 // Get the current value from the secure setting.
296 String currentSetting = Settings.Secure.getString(
Amith Yamasanib44161f2010-12-10 13:17:34 -0800297 mFragment.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800298
299 // Iterate through all the available recognizers and load up their info to show
300 // in the preference. Also build up a map of recognizer component names to their
301 // ResolveInfos - we'll need that a little later.
302 for (int i = 0; i < size; i++) {
303 ResolveInfo resolveInfo = recognizers.get(i);
304 String recognizerComponent =
305 new ComponentName(resolveInfo.serviceInfo.packageName,
Mike LeBeaueffc7542010-02-23 14:51:10 -0800306 resolveInfo.serviceInfo.name).flattenToShortString();
Mike LeBeau766a19b2010-02-11 22:57:12 -0800307
308 mAvailableRecognizersMap.put(recognizerComponent, resolveInfo);
Mike LeBeau92c33522010-01-25 18:18:45 -0500309
Amith Yamasanib44161f2010-12-10 13:17:34 -0800310 entries[i] = resolveInfo.loadLabel(mFragment.getPackageManager());
Mike LeBeau766a19b2010-02-11 22:57:12 -0800311 values[i] = recognizerComponent;
312 }
313
314 mRecognizerPref.setEntries(entries);
315 mRecognizerPref.setEntryValues(values);
316
317 mRecognizerPref.setDefaultValue(currentSetting);
318 mRecognizerPref.setValue(currentSetting);
319
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700320 updateRecognizerSettingsLink(currentSetting);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800321 }
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700322
323 private void updateRecognizerSettingsLink(String currentSetting) {
Mike LeBeau766a19b2010-02-11 22:57:12 -0800324 ResolveInfo currentRecognizer = mAvailableRecognizersMap.get(currentSetting);
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700325 if (currentRecognizer == null) return;
326
Mike LeBeau766a19b2010-02-11 22:57:12 -0800327 ServiceInfo si = currentRecognizer.serviceInfo;
328 XmlResourceParser parser = null;
329 String settingsActivity = null;
330 try {
Amith Yamasanib44161f2010-12-10 13:17:34 -0800331 parser = si.loadXmlMetaData(mFragment.getPackageManager(),
332 RecognitionService.SERVICE_META_DATA);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800333 if (parser == null) {
334 throw new XmlPullParserException("No " + RecognitionService.SERVICE_META_DATA +
335 " meta-data for " + si.packageName);
Mike LeBeau92c33522010-01-25 18:18:45 -0500336 }
Mike LeBeau766a19b2010-02-11 22:57:12 -0800337
Amith Yamasanib44161f2010-12-10 13:17:34 -0800338 Resources res = mFragment.getPackageManager().getResourcesForApplication(
Dianne Hackborn0382a492010-03-04 11:44:09 -0800339 si.applicationInfo);
340
Mike LeBeau766a19b2010-02-11 22:57:12 -0800341 AttributeSet attrs = Xml.asAttributeSet(parser);
342
343 int type;
344 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
345 && type != XmlPullParser.START_TAG) {
346 }
347
348 String nodeName = parser.getName();
349 if (!"recognition-service".equals(nodeName)) {
350 throw new XmlPullParserException(
351 "Meta-data does not start with recognition-service tag");
352 }
353
Dianne Hackborn0382a492010-03-04 11:44:09 -0800354 TypedArray array = res.obtainAttributes(attrs,
Mike LeBeau766a19b2010-02-11 22:57:12 -0800355 com.android.internal.R.styleable.RecognitionService);
356 settingsActivity = array.getString(
357 com.android.internal.R.styleable.RecognitionService_settingsActivity);
358 array.recycle();
359 } catch (XmlPullParserException e) {
360 Log.e(TAG, "error parsing recognition service meta-data", e);
361 } catch (IOException e) {
362 Log.e(TAG, "error parsing recognition service meta-data", e);
Dianne Hackborn0382a492010-03-04 11:44:09 -0800363 } catch (NameNotFoundException e) {
364 Log.e(TAG, "error parsing recognition service meta-data", e);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800365 } finally {
366 if (parser != null) parser.close();
Mike LeBeau92c33522010-01-25 18:18:45 -0500367 }
368
Mike LeBeau766a19b2010-02-11 22:57:12 -0800369 if (settingsActivity == null) {
370 // No settings preference available - hide the preference.
371 Log.w(TAG, "no recognizer settings available for " + si.packageName);
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700372 mRecognizerSettingsPref.setIntent(null);
373 mVoiceCategory.removePreference(mRecognizerSettingsPref);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800374 } else {
375 Intent i = new Intent(Intent.ACTION_MAIN);
376 i.setComponent(new ComponentName(si.packageName, settingsActivity));
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700377 mRecognizerSettingsPref.setIntent(i);
Amith Yamasanib44161f2010-12-10 13:17:34 -0800378 mRecognizerPref.setSummary(currentRecognizer.loadLabel(mFragment.getPackageManager()));
Mike LeBeau766a19b2010-02-11 22:57:12 -0800379 }
380 }
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700381
Mike LeBeau766a19b2010-02-11 22:57:12 -0800382 public boolean onPreferenceChange(Preference preference, Object newValue) {
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700383 if (preference == mVoiceInteractionPref) {
384 String setting = (String) newValue;
385
386 // Put the new value back into secure settings.
387 Settings.Secure.putString(mFragment.getContentResolver(),
388 Settings.Secure.VOICE_INTERACTION_SERVICE,
389 setting);
390
391 // Update the settings item so it points to the right settings.
392 updateVoiceInteractionSettingsLink(setting);
393
394 } else if (preference == mRecognizerPref) {
Mike LeBeau766a19b2010-02-11 22:57:12 -0800395 String setting = (String) newValue;
Amith Yamasanib44161f2010-12-10 13:17:34 -0800396
Mike LeBeau766a19b2010-02-11 22:57:12 -0800397 // Put the new value back into secure settings.
Amith Yamasanib44161f2010-12-10 13:17:34 -0800398 Settings.Secure.putString(mFragment.getContentResolver(),
Mike LeBeau766a19b2010-02-11 22:57:12 -0800399 Settings.Secure.VOICE_RECOGNITION_SERVICE,
400 setting);
Amith Yamasanib44161f2010-12-10 13:17:34 -0800401
Mike LeBeau766a19b2010-02-11 22:57:12 -0800402 // Update the settings item so it points to the right settings.
Dianne Hackborndf7e99b2014-04-17 18:35:29 -0700403 updateRecognizerSettingsLink(setting);
Mike LeBeau766a19b2010-02-11 22:57:12 -0800404 }
405 return true;
Mike LeBeau92c33522010-01-25 18:18:45 -0500406 }
407}