Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.speech.RecognitionService SecurityException with some 3rd-party speech recognizers

We created an Android app which uses Google speech recognizer and we choose first ,in program, Google speech recognizer to use. Most devices work fine, and only few devices(MEIZU_M5, U78-E, Apollo Lite etc.) report below exceptions. It seems some conflicts with Mediatek's voicecommand? We found some other Mediatek's devices work fine. it's confusing.

java.lang.SecurityException: Not allowed to bind to service Intent { act=android.speech.RecognitionService cmp=com.mediatek.voicecommand/.service.VoiceWakeupRecognitionService }
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1421)
at android.app.ContextImpl.bindService(ContextImpl.java:1385)
at android.content.ContextWrapper.bindService(ContextWrapper.java:604)
at android.speech.SpeechRecognizer.startListening(SpeechRecognizer.java:287)

To trace into the codes, the source codes only show up to ContextWrapper.java. How to let it show up to ContextImpl.java:1421?

By firebase log, we find it happens at many 3rd-party speech recognizers:

com.mediatek.voicecommand
com.htc.android.voicedictation
com.vlingo.midas
com.iflytek.speechcloud
com.iflytek.speechsuite
...

We've also tested some other 3rd-party speech recognizers working well. Are those speech recognizers,which caused exception, just used for system voice commands and not accessible to apps?

Any idea or experience is welcome.

like image 638
Fisher Avatar asked Oct 29 '22 21:10

Fisher


1 Answers

At last, we found the root cause from some information in Android Developers Services overview:

However, you can declare the service as private in the manifest file and block access from other applications.

These 3rd-party SpeechRecognizer services are private and can not be called by other apps. So, we just try-catch this exception and inform users to install Google App(Voice typing). Or you can exclude these unexpected SpeechRecognizer by just skipping them.

like image 143
Fisher Avatar answered Nov 11 '22 12:11

Fisher