Merge changes from topics "default-reco", "default-reco-config" into sc-dev

* changes:
  VIMS: Use the new recognizer config resource for init.
  Introduce a default speech recognizer.
This commit is contained in:
Ahaan Ugale
2021-02-25 22:13:11 +00:00
committed by Android (Google) Code Review
4 changed files with 16 additions and 0 deletions

View File

@@ -353,6 +353,7 @@ package android {
field public static final int config_systemContacts = 17039403; // 0x104002b field public static final int config_systemContacts = 17039403; // 0x104002b
field public static final int config_systemGallery = 17039399; // 0x1040027 field public static final int config_systemGallery = 17039399; // 0x1040027
field public static final int config_systemShell = 17039402; // 0x104002a field public static final int config_systemShell = 17039402; // 0x104002a
field public static final int config_systemSpeechRecognizer = 17039406; // 0x104002e
} }
public static final class R.style { public static final class R.style {

View File

@@ -1953,6 +1953,8 @@
<string name="config_systemShell" translatable="false">com.android.shell</string> <string name="config_systemShell" translatable="false">com.android.shell</string>
<!-- The name of the package that will hold the system contacts role. --> <!-- The name of the package that will hold the system contacts role. -->
<string name="config_systemContacts" translatable="false">com.android.contacts</string> <string name="config_systemContacts" translatable="false">com.android.contacts</string>
<!-- The name of the package that will hold the speech recognizer role by default. -->
<string name="config_systemSpeechRecognizer" translatable="false"></string>
<!-- The name of the package that will be allowed to change its components' label/icon. --> <!-- The name of the package that will be allowed to change its components' label/icon. -->
<string name="config_overrideComponentUiPackage" translatable="false"></string> <string name="config_overrideComponentUiPackage" translatable="false"></string>

View File

@@ -3166,6 +3166,8 @@
<public name="config_customMediaKeyDispatcher" /> <public name="config_customMediaKeyDispatcher" />
<!-- @hide @SystemApi --> <!-- @hide @SystemApi -->
<public name="config_customMediaSessionPolicyProvider" /> <public name="config_customMediaSessionPolicyProvider" />
<!-- @hide @SystemApi -->
<public name="config_systemSpeechRecognizer" />
</public-group> </public-group>
<public-group type="id" first-id="0x01020055"> <public-group type="id" first-id="0x01020055">

View File

@@ -76,6 +76,7 @@ import android.util.ArraySet;
import android.util.Log; import android.util.Log;
import android.util.Slog; import android.util.Slog;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IHotwordRecognitionStatusCallback;
import com.android.internal.app.IVoiceActionCheckCallback; import com.android.internal.app.IVoiceActionCheckCallback;
@@ -643,6 +644,10 @@ public class VoiceInteractionManagerService extends SystemService {
} }
ComponentName findAvailRecognizer(String prefPackage, int userHandle) { ComponentName findAvailRecognizer(String prefPackage, int userHandle) {
if (prefPackage == null) {
prefPackage = getDefaultRecognizer();
}
List<ResolveInfo> available = List<ResolveInfo> available =
mContext.getPackageManager().queryIntentServicesAsUser( mContext.getPackageManager().queryIntentServicesAsUser(
new Intent(RecognitionService.SERVICE_INTERFACE), new Intent(RecognitionService.SERVICE_INTERFACE),
@@ -670,6 +675,12 @@ public class VoiceInteractionManagerService extends SystemService {
} }
} }
@Nullable
public String getDefaultRecognizer() {
String recognizer = mContext.getString(R.string.config_systemSpeechRecognizer);
return TextUtils.isEmpty(recognizer) ? null : recognizer;
}
ComponentName getCurRecognizer(int userHandle) { ComponentName getCurRecognizer(int userHandle) {
String curRecognizer = Settings.Secure.getStringForUser( String curRecognizer = Settings.Secure.getStringForUser(
mContext.getContentResolver(), mContext.getContentResolver(),