summaryrefslogtreecommitdiffstats
path: root/services/voiceinteraction
diff options
context:
space:
mode:
authorCedric Ho <cedricho@google.com>2015-05-19 15:44:31 -0700
committerCedric Ho <cedricho@google.com>2015-05-20 13:50:22 -0700
commit80cf2210226bc652181abafe606b69ebce63af78 (patch)
treee58d00e82437d0f0d9185190b27aaf63bdcf4f41 /services/voiceinteraction
parent627f26817f752e0e1beb4185e778edc4501b4aa6 (diff)
downloadframeworks_base-80cf2210226bc652181abafe606b69ebce63af78.zip
frameworks_base-80cf2210226bc652181abafe606b69ebce63af78.tar.gz
frameworks_base-80cf2210226bc652181abafe606b69ebce63af78.tar.bz2
Add config_forceVoiceInteractionServicePackage to allow a device to config its VoiceInteractionService package and ignore the regular setting.
Change-Id: Ic40d90f1a7a9942f5e82080668552239bbed9b03
Diffstat (limited to 'services/voiceinteraction')
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index e8cdc55..2fe3670 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -28,7 +28,6 @@ import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
@@ -150,7 +149,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
@@ -159,6 +158,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) {
@@ -218,8 +229,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) {
@@ -272,7 +289,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);
@@ -293,8 +310,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 {