使用 Google 语音服务查询支持的语言不适用于 Android 13

dip*_*dip 5 android google-apps kotlin android-speech-api

我使用以下操作查询语音服务支持的语言RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS

val intent = Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS)
packageManager.queryBroadcastReceivers(intent, 0).map { resolveInfo ->
    sendOrderedBroadcast(
        intent.apply {
            component = ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name)
        },
        null,
        object : BroadcastReceiver() {
            override fun onReceive(context: Context?, intent: Intent?) {
                val extras = getResultExtras(true)
                val supportedLanguages = extras.getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)
                // supportedLanguages is empty on Android 13 for all services
            }
        },
        null, Activity.RESULT_OK, null, null
    )
}
Run Code Online (Sandbox Code Playgroud)

这在 Android 12 及更低版本上运行良好。但是,Android 13 上的列表为空。我正在使用 Google 语音服务/Google 应用程序。

经过一番挖掘后,似乎之前返回语言的广播接收器被简单地禁用了。来自Google App的反编译源:

values/bools.xml

<bool name="speech_services_enabled">true</bool>
Run Code Online (Sandbox Code Playgroud)

values-v33/bools.xml

<bool name="speech_services_enabled">false</bool>
Run Code Online (Sandbox Code Playgroud)

还有其他方法可以获取支持的语言列表吗?

编辑:我也尝试直接查询SpeechRecognizer

val speechRecognizer = SpeechRecognizer.createSpeechRecognizer(context)
speechRecognizer.checkRecognitionSupport(
    Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
    ...
)
Run Code Online (Sandbox Code Playgroud)

但这总是返回错误 14 ( ERROR_CANNOT_CHECK_SUPPORT)