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

Commit 25fc537f authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Making it possible to determine which TTS engine is currently set as...

Merge "Making it possible to determine which TTS engine is currently set as the default by the user."
parents bf4650ca 56ccaa08
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -62,4 +62,6 @@ interface ITts {
    int playSilence(in String callingApp, in long duration, in int queueMode, in String[] params);

    int setEngineByPackageName(in String enginePackageName);

    String getDefaultEngine();
}
+39 −0
Original line number Diff line number Diff line
@@ -1340,4 +1340,43 @@ public class TextToSpeech {
        }
    }


    /**
     * Gets the packagename of the default speech synthesis engine.
     *
     * @return Packagename of the TTS engine that the user has chosen as their default.
     *
     * @hide
     */
    public String getDefaultEngine() {
        synchronized (mStartLock) {
            String engineName = "";
            if (!mStarted) {
                return engineName;
            }
            try {
                engineName = mITts.getDefaultEngine();
            } catch (RemoteException e) {
                // TTS died; restart it.
                Log.e("TextToSpeech.java - setEngineByPackageName", "RemoteException");
                e.printStackTrace();
                mStarted = false;
                initTts();
            } catch (NullPointerException e) {
                // TTS died; restart it.
                Log.e("TextToSpeech.java - setEngineByPackageName", "NullPointerException");
                e.printStackTrace();
                mStarted = false;
                initTts();
            } catch (IllegalStateException e) {
                // TTS died; restart it.
                Log.e("TextToSpeech.java - setEngineByPackageName", "IllegalStateException");
                e.printStackTrace();
                mStarted = false;
                initTts();
            } finally {
                return engineName;
            }
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -1436,6 +1436,15 @@ public class TtsService extends Service implements OnCompletionListener {
            return mSelf.setEngine(packageName);
        }

        /**
         * Returns the packagename of the default speech synthesis engine.
         *
         * @return Packagename of the TTS engine that the user has chosen as their default.
         */
        public String getDefaultEngine() {
            return mSelf.getDefaultEngine();
        }

    };

}