Loading core/java/android/speech/RecognitionManager.java +18 −9 Original line number Diff line number Diff line Loading @@ -216,7 +216,6 @@ public class RecognitionManager { throw new IllegalArgumentException("intent must not be null"); } checkIsCalledFromMainThread(); checkIsCommandAllowed(); if (mConnection == null) { // first time connection mConnection = new Connection(); if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), Loading @@ -243,7 +242,6 @@ public class RecognitionManager { */ public void stopListening() { checkIsCalledFromMainThread(); checkIsCommandAllowed(); putMessage(Message.obtain(mHandler, MSG_STOP)); } Loading @@ -254,7 +252,6 @@ public class RecognitionManager { */ public void cancel() { checkIsCalledFromMainThread(); checkIsCommandAllowed(); putMessage(Message.obtain(mHandler, MSG_CANCEL)); } Loading @@ -265,12 +262,6 @@ public class RecognitionManager { } } private void checkIsCommandAllowed() { if (mService == null && mPendingTasks.isEmpty()) { // setListener message must be there throw new IllegalStateException("Listener must be set before any command is called"); } } private void putMessage(Message msg) { if (mService == null) { mPendingTasks.offer(msg); Loading @@ -281,6 +272,9 @@ public class RecognitionManager { /** sends the actual message to the service */ private void handleStartListening(Intent recognizerIntent) { if (!checkOpenConnection()) { return; } try { mService.startListening(recognizerIntent, mListener); if (DBG) Log.d(TAG, "service start listening command succeded"); Loading @@ -292,6 +286,9 @@ public class RecognitionManager { /** sends the actual message to the service */ private void handleStopMessage() { if (!checkOpenConnection()) { return; } try { mService.stopListening(mListener); if (DBG) Log.d(TAG, "service stop listening command succeded"); Loading @@ -303,6 +300,9 @@ public class RecognitionManager { /** sends the actual message to the service */ private void handleCancelMessage() { if (!checkOpenConnection()) { return; } try { mService.cancel(mListener); if (DBG) Log.d(TAG, "service cancel command succeded"); Loading @@ -312,6 +312,15 @@ public class RecognitionManager { } } private boolean checkOpenConnection() { if (mService != null) { return true; } mListener.onError(ERROR_CLIENT); Log.e(TAG, "not connected to the recognition service"); return false; } /** changes the listener */ private void handleChangeListener(RecognitionListener listener) { if (DBG) Log.d(TAG, "handleChangeListener, listener=" + listener); Loading Loading
core/java/android/speech/RecognitionManager.java +18 −9 Original line number Diff line number Diff line Loading @@ -216,7 +216,6 @@ public class RecognitionManager { throw new IllegalArgumentException("intent must not be null"); } checkIsCalledFromMainThread(); checkIsCommandAllowed(); if (mConnection == null) { // first time connection mConnection = new Connection(); if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), Loading @@ -243,7 +242,6 @@ public class RecognitionManager { */ public void stopListening() { checkIsCalledFromMainThread(); checkIsCommandAllowed(); putMessage(Message.obtain(mHandler, MSG_STOP)); } Loading @@ -254,7 +252,6 @@ public class RecognitionManager { */ public void cancel() { checkIsCalledFromMainThread(); checkIsCommandAllowed(); putMessage(Message.obtain(mHandler, MSG_CANCEL)); } Loading @@ -265,12 +262,6 @@ public class RecognitionManager { } } private void checkIsCommandAllowed() { if (mService == null && mPendingTasks.isEmpty()) { // setListener message must be there throw new IllegalStateException("Listener must be set before any command is called"); } } private void putMessage(Message msg) { if (mService == null) { mPendingTasks.offer(msg); Loading @@ -281,6 +272,9 @@ public class RecognitionManager { /** sends the actual message to the service */ private void handleStartListening(Intent recognizerIntent) { if (!checkOpenConnection()) { return; } try { mService.startListening(recognizerIntent, mListener); if (DBG) Log.d(TAG, "service start listening command succeded"); Loading @@ -292,6 +286,9 @@ public class RecognitionManager { /** sends the actual message to the service */ private void handleStopMessage() { if (!checkOpenConnection()) { return; } try { mService.stopListening(mListener); if (DBG) Log.d(TAG, "service stop listening command succeded"); Loading @@ -303,6 +300,9 @@ public class RecognitionManager { /** sends the actual message to the service */ private void handleCancelMessage() { if (!checkOpenConnection()) { return; } try { mService.cancel(mListener); if (DBG) Log.d(TAG, "service cancel command succeded"); Loading @@ -312,6 +312,15 @@ public class RecognitionManager { } } private boolean checkOpenConnection() { if (mService != null) { return true; } mListener.onError(ERROR_CLIENT); Log.e(TAG, "not connected to the recognition service"); return false; } /** changes the listener */ private void handleChangeListener(RecognitionListener listener) { if (DBG) Log.d(TAG, "handleChangeListener, listener=" + listener); Loading