diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index e075d8b38cb44..cfa7ae772fce2 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2331,7 +2331,7 @@ public final class Settings { * preference, this rotation value will be used. Must be one of the * {@link android.view.Surface#ROTATION_0 Surface rotation constants}. * - * @see Display#getRotation + * @see android.view.Display#getRotation */ public static final String USER_ROTATION = "user_rotation"; @@ -2439,7 +2439,8 @@ public final class Settings { public static final String SHOW_TOUCHES = "show_touches"; /** - * Log raw orientation data from {@link WindowOrientationListener} for use with the + * Log raw orientation data from + * {@link com.android.internal.policy.impl.WindowOrientationListener} for use with the * orientationplot.py tool. * 0 = no * 1 = yes diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index cd3684b17769d..a173a5c1f8e7d 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -132,14 +132,33 @@ public class VoiceInteractionManagerService extends SystemService { public void initForUser(int userHandle) { if (DEBUG) Slog.i(TAG, "initForUser user=" + userHandle); - ComponentName curInteractor = getCurInteractor(userHandle); + String curInteractorStr = Settings.Secure.getStringForUser( + mContext.getContentResolver(), + Settings.Secure.VOICE_INTERACTION_SERVICE, userHandle); ComponentName curRecognizer = getCurRecognizer(userHandle); + VoiceInteractionServiceInfo curInteractorInfo = null; + if (curInteractorStr == null && curRecognizer != null) { + // If there is no interactor setting, that means we are upgrading + // from an older platform version. If the current recognizer is not + // set or matches the preferred recognizer, then we want to upgrade + // the user to have the default voice interaction service enabled. + curInteractorInfo = findAvailInteractor(userHandle, curRecognizer); + if (curInteractorInfo != null) { + // Looks good! We'll apply this one. To make it happen, we clear the + // recognizer so that we don't think we have anything set and will + // re-apply the settings. + curRecognizer = null; + } + } + if (curRecognizer != null) { // If we already have at least a recognizer, then we probably want to // leave things as they are... unless something has disappeared. IPackageManager pm = AppGlobals.getPackageManager(); ServiceInfo interactorInfo = null; ServiceInfo recognizerInfo = null; + ComponentName curInteractor = !TextUtils.isEmpty(curInteractorStr) + ? ComponentName.unflattenFromString(curInteractorStr) : null; try { recognizerInfo = pm.getServiceInfo(curRecognizer, 0, userHandle); if (curInteractor != null) { @@ -154,32 +173,27 @@ public class VoiceInteractionManagerService extends SystemService { } // Initializing settings, look for an interactor first. - curInteractor = findAvailInteractor(userHandle); - if (curInteractor != null) { - try { - VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo( - mContext.getPackageManager(), curInteractor, userHandle); - if (info.getParseError() == null) { - setCurInteractor(curInteractor, userHandle); - if (info.getRecognitionService() != null) { - // Eventually it will be an error to not specify this. - curRecognizer = new ComponentName(info.getServiceInfo().packageName, - info.getRecognitionService()); - setCurRecognizer(curRecognizer, userHandle); - return; - } - } else { - Slog.w(TAG, "Bad interaction service " + curInteractor + ": " - + info.getParseError()); - } - } catch (PackageManager.NameNotFoundException e) { - } catch (RemoteException e) { + if (curInteractorInfo == null) { + curInteractorInfo = findAvailInteractor(userHandle, null); + } + if (curInteractorInfo != null) { + // Eventually it will be an error to not specify this. + setCurInteractor(new ComponentName(curInteractorInfo.getServiceInfo().packageName, + curInteractorInfo.getServiceInfo().name), userHandle); + if (curInteractorInfo.getRecognitionService() != null) { + setCurRecognizer( + new ComponentName(curInteractorInfo.getServiceInfo().packageName, + curInteractorInfo.getRecognitionService()), userHandle); + return; } } // No voice interactor, we'll just set up a simple recognizer. curRecognizer = findAvailRecognizer(null, userHandle); if (curRecognizer != null) { + if (curInteractorInfo == null) { + setCurInteractor(null, userHandle); + } setCurRecognizer(curRecognizer, userHandle); } } @@ -234,7 +248,7 @@ public class VoiceInteractionManagerService extends SystemService { } } - ComponentName findAvailInteractor(int userHandle) { + VoiceInteractionServiceInfo findAvailInteractor(int userHandle, ComponentName recognizer) { List available = mContext.getPackageManager().queryIntentServicesAsUser( new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0, userHandle); @@ -246,23 +260,41 @@ public class VoiceInteractionManagerService extends SystemService { } else { // Find first system package. We never want to allow third party services to // be automatically selected, because those require approval of the user. - ServiceInfo serviceInfo = null; + VoiceInteractionServiceInfo foundInfo = null; for (int i=0; i