Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d97b5bc0 authored by Felix Oghina's avatar Felix Oghina
Browse files

[speech] catch all exceptions and forward as client error

Sometimes we see non-RemoteException getting thrown here, let's catch it
and forward it to the client as well.

Bug: 301307379
Test: cts
Change-Id: I5f0c0dc1d6a221c5c52e4a14cc1e095cb50ab781
parent 55307861
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -758,7 +758,7 @@ public class SpeechRecognizer {
        try {
            mService.startListening(recognizerIntent, mListener, mContext.getAttributionSource());
            if (DBG) Log.d(TAG, "service start listening command succeeded");
        } catch (final RemoteException e) {
        } catch (final Exception e) {
            Log.e(TAG, "startListening() failed", e);
            mListener.onError(ERROR_CLIENT);
        }
@@ -772,7 +772,7 @@ public class SpeechRecognizer {
        try {
            mService.stopListening(mListener);
            if (DBG) Log.d(TAG, "service stop listening command succeeded");
        } catch (final RemoteException e) {
        } catch (final Exception e) {
            Log.e(TAG, "stopListening() failed", e);
            mListener.onError(ERROR_CLIENT);
        }
@@ -786,7 +786,7 @@ public class SpeechRecognizer {
        try {
            mService.cancel(mListener, /*isShutdown*/ false);
            if (DBG) Log.d(TAG, "service cancel command succeeded");
        } catch (final RemoteException e) {
        } catch (final Exception e) {
            Log.e(TAG, "cancel() failed", e);
            mListener.onError(ERROR_CLIENT);
        }
@@ -821,7 +821,7 @@ public class SpeechRecognizer {
                    mContext.getAttributionSource(),
                    new InternalSupportCallback(callbackExecutor, recognitionSupportCallback));
            if (DBG) Log.d(TAG, "service support command succeeded");
        } catch (final RemoteException e) {
        } catch (final Exception e) {
            Log.e(TAG, "checkRecognitionSupport() failed", e);
            callbackExecutor.execute(() -> recognitionSupportCallback.onError(ERROR_CLIENT));
        }
@@ -841,7 +841,7 @@ public class SpeechRecognizer {
                mService.triggerModelDownload(
                        recognizerIntent, mContext.getAttributionSource(), null);
                if (DBG) Log.d(TAG, "triggerModelDownload() without a listener");
            } catch (final RemoteException e) {
            } catch (final Exception e) {
                Log.e(TAG, "triggerModelDownload() without a listener failed", e);
                mListener.onError(ERROR_CLIENT);
            }
@@ -853,7 +853,7 @@ public class SpeechRecognizer {
                        recognizerIntent, mContext.getAttributionSource(),
                        new InternalModelDownloadListener(callbackExecutor, modelDownloadListener));
                if (DBG) Log.d(TAG, "triggerModelDownload() with a listener");
            } catch (final RemoteException e) {
            } catch (final Exception e) {
                Log.e(TAG, "triggerModelDownload() with a listener failed", e);
                callbackExecutor.execute(() -> modelDownloadListener.onError(ERROR_CLIENT));
            }
@@ -880,7 +880,7 @@ public class SpeechRecognizer {
        if (mService != null) {
            try {
                mService.cancel(mListener, /*isShutdown*/ true);
            } catch (final RemoteException e) {
            } catch (final Exception e) {
                // Not important
            }
        }