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

Commit cafd1521 authored by Przemyslaw Szczepaniak's avatar Przemyslaw Szczepaniak
Browse files

Fix TTS regression, TTS#stop can result in #onDone callback.

Regressinon in the L, side effect of the rewrite. In pre-L android,
UtteranceProgressListener#onDone was called (but only if client
received UtteranceProgressListener#onStart for the utterance in progress)
after client called TextToSpeech#stop. This changeset reinstates
this behaviour.
+ Removed not used fallback callback

Bug: 16149006
Change-Id: I2eb5ede0abe6f5717b07f09adad861465575c238
parent c09a04da
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -42,13 +42,6 @@ oneway interface ITextToSpeechCallback {
     */
    void onStop(String utteranceId);

    /**
     * Tells the client that the synthesis failed, and fallback synthesis will be attempted.
     *
     * @param utteranceId Unique id identifying synthesis request.
     */
    void onFallback(String utteranceId);

    /**
     * Tells the client that the synthesis has failed.
     *
+4 −6
Original line number Diff line number Diff line
@@ -1945,13 +1945,11 @@ public class TextToSpeech {

        private final ITextToSpeechCallback.Stub mCallback = new ITextToSpeechCallback.Stub() {
            public void onStop(String utteranceId) throws RemoteException {
                // do nothing
            };

            @Override
            public void onFallback(String utteranceId) throws RemoteException {
                // do nothing
                UtteranceProgressListener listener = mUtteranceProgressListener;
                if (listener != null) {
                    listener.onDone(utteranceId);
                }
            };

            @Override
            public void onSuccess(String utteranceId) {
+0 −20
Original line number Diff line number Diff line
@@ -592,14 +592,12 @@ public abstract class TextToSpeechService extends Service {
    }

    interface UtteranceProgressDispatcher {
        public void dispatchOnFallback();
        public void dispatchOnStop();
        public void dispatchOnSuccess();
        public void dispatchOnStart();
        public void dispatchOnError(int errorCode);
    }


    /** Set of parameters affecting audio output. */
    static class AudioOutputParams {
        /**
@@ -769,14 +767,6 @@ public abstract class TextToSpeechService extends Service {
            }
        }

        @Override
        public void dispatchOnFallback() {
            final String utteranceId = getUtteranceId();
            if (utteranceId != null) {
                mCallbacks.dispatchOnFallback(getCallerIdentity(), utteranceId);
            }
        }

        @Override
        public void dispatchOnStart() {
            final String utteranceId = getUtteranceId();
@@ -1336,16 +1326,6 @@ public abstract class TextToSpeechService extends Service {
            }
        }

        public void dispatchOnFallback(Object callerIdentity, String utteranceId) {
            ITextToSpeechCallback cb = getCallbackFor(callerIdentity);
            if (cb == null) return;
            try {
                cb.onFallback(utteranceId);
            } catch (RemoteException e) {
                Log.e(TAG, "Callback onFallback failed: " + e);
            }
        }

        public void dispatchOnStop(Object callerIdentity, String utteranceId) {
            ITextToSpeechCallback cb = getCallbackFor(callerIdentity);
            if (cb == null) return;