diff options
author | Cedric Ho <cedricho@google.com> | 2015-05-20 22:22:23 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-05-20 22:22:23 +0000 |
commit | d9b0c913f7dd1508b8d4b97d8b82ea23a5a9ca40 (patch) | |
tree | 7593f2b6dbca667f5ee9bed9b1a082e0fff593b4 /services/voiceinteraction | |
parent | d3f216d921b44990066d83a3379ee2dcf39fda81 (diff) | |
parent | 782def772adacaf029d7d9850605923066665424 (diff) | |
download | frameworks_base-d9b0c913f7dd1508b8d4b97d8b82ea23a5a9ca40.zip frameworks_base-d9b0c913f7dd1508b8d4b97d8b82ea23a5a9ca40.tar.gz frameworks_base-d9b0c913f7dd1508b8d4b97d8b82ea23a5a9ca40.tar.bz2 |
am 782def77: am 80cf2210: Add config_forceVoiceInteractionServicePackage to allow a device to config its VoiceInteractionService package and ignore the regular setting.
* commit '782def772adacaf029d7d9850605923066665424':
Add config_forceVoiceInteractionServicePackage to allow a device to config its VoiceInteractionService package and ignore the regular setting.
Diffstat (limited to 'services/voiceinteraction')
-rw-r--r-- | services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index fcdb6d6..35bdceb 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -151,7 +151,7 @@ public class VoiceInteractionManagerService extends SystemService { // the user to have the default voice interaction service enabled. // Note that we don't do this for low-RAM devices, since we aren't // supporting voice interaction services there. - curInteractorInfo = findAvailInteractor(userHandle, curRecognizer); + curInteractorInfo = findAvailInteractor(userHandle, curRecognizer.getPackageName()); 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 @@ -162,6 +162,18 @@ public class VoiceInteractionManagerService extends SystemService { } } + // If forceInteractorPackage exists, try to apply the interactor from this package if + // possible and ignore the regular interactor setting. + String forceInteractorPackage = + getForceVoiceInteractionServicePackage(mContext.getResources()); + if (forceInteractorPackage != null) { + curInteractorInfo = findAvailInteractor(userHandle, forceInteractorPackage); + if (curInteractorInfo != null) { + // We'll apply this one. Clear the recognizer and re-apply the settings. + curRecognizer = null; + } + } + // If we are on a svelte device, make sure an interactor is not currently // enabled; if it is, turn it off. if (!mEnableService && curInteractorStr != null) { @@ -225,8 +237,14 @@ public class VoiceInteractionManagerService extends SystemService { private boolean shouldEnableService(Resources res) { // VoiceInteractionService should not be enabled on low ram devices unless it has the config flag. - return !ActivityManager.isLowRamDeviceStatic() - || res.getBoolean(com.android.internal.R.bool.config_forceEnableVoiceInteractionService); + return !ActivityManager.isLowRamDeviceStatic() || + getForceVoiceInteractionServicePackage(res) != null; + } + + private String getForceVoiceInteractionServicePackage(Resources res) { + String interactorPackage = + res.getString(com.android.internal.R.string.config_forceVoiceInteractionServicePackage); + return TextUtils.isEmpty(interactorPackage) ? null : interactorPackage; } public void systemRunning(boolean safeMode) { @@ -279,7 +297,7 @@ public class VoiceInteractionManagerService extends SystemService { } } - VoiceInteractionServiceInfo findAvailInteractor(int userHandle, ComponentName recognizer) { + VoiceInteractionServiceInfo findAvailInteractor(int userHandle, String packageName) { List<ResolveInfo> available = mContext.getPackageManager().queryIntentServicesAsUser( new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0, userHandle); @@ -300,8 +318,8 @@ public class VoiceInteractionManagerService extends SystemService { VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo( mContext.getPackageManager(), comp, userHandle); if (info.getParseError() == null) { - if (recognizer == null || info.getServiceInfo().packageName.equals( - recognizer.getPackageName())) { + if (packageName == null || info.getServiceInfo().packageName.equals( + packageName)) { if (foundInfo == null) { foundInfo = info; } else { |