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

Commit 2bad713f authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 8860 into donut

* changes:
  Fix bug 2017664 Removed the TTS_ prefix in the TextToSpeech class to follow the standard naming convention. Moved the TTS-related intents from the Intent class to TextToSpeech and TextToSpeech.Engine. Renamed the TextToSpeech.Engine constants that are used as extras for the   ACTION_TTS_CHECK_TTS_DATA intent to prefix them with EXTRA_. Cleaned up the other TextToSpeech.Engine constant to remove superfluous mentions of   "TTS" in the name.
parents b307c894 ed06578e
Loading
Loading
Loading
Loading
+53 −53
Original line number Diff line number Diff line
@@ -32173,39 +32173,6 @@
 visibility="public"
>
</field>
<field name="ACTION_TTS_CHECK_TTS_DATA"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.intent.action.CHECK_TTS_DATA&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ACTION_TTS_INSTALL_TTS_DATA"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.intent.action.INSTALL_TTS_DATA&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ACTION_TTS_QUEUE_PROCESSING_COMPLETED"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.intent.action.TTS_QUEUE_PROCESSING_COMPLETED&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ACTION_UID_REMOVED"
 type="java.lang.String"
 transient="false"
@@ -111721,7 +111688,18 @@
<parameter name="filename" type="java.lang.String">
</parameter>
</method>
<field name="TTS_ERROR"
<field name="ACTION_TTS_QUEUE_PROCESSING_COMPLETED"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ERROR"
 type="int"
 transient="false"
 volatile="false"
@@ -111732,7 +111710,7 @@
 visibility="public"
>
</field>
<field name="TTS_LANG_AVAILABLE"
<field name="LANG_AVAILABLE"
 type="int"
 transient="false"
 volatile="false"
@@ -111743,7 +111721,7 @@
 visibility="public"
>
</field>
<field name="TTS_LANG_COUNTRY_AVAILABLE"
<field name="LANG_COUNTRY_AVAILABLE"
 type="int"
 transient="false"
 volatile="false"
@@ -111754,7 +111732,7 @@
 visibility="public"
>
</field>
<field name="TTS_LANG_COUNTRY_VAR_AVAILABLE"
<field name="LANG_COUNTRY_VAR_AVAILABLE"
 type="int"
 transient="false"
 volatile="false"
@@ -111765,7 +111743,7 @@
 visibility="public"
>
</field>
<field name="TTS_LANG_MISSING_DATA"
<field name="LANG_MISSING_DATA"
 type="int"
 transient="false"
 volatile="false"
@@ -111776,7 +111754,7 @@
 visibility="public"
>
</field>
<field name="TTS_LANG_NOT_SUPPORTED"
<field name="LANG_NOT_SUPPORTED"
 type="int"
 transient="false"
 volatile="false"
@@ -111787,7 +111765,7 @@
 visibility="public"
>
</field>
<field name="TTS_QUEUE_ADD"
<field name="QUEUE_ADD"
 type="int"
 transient="false"
 volatile="false"
@@ -111798,7 +111776,7 @@
 visibility="public"
>
</field>
<field name="TTS_QUEUE_FLUSH"
<field name="QUEUE_FLUSH"
 type="int"
 transient="false"
 volatile="false"
@@ -111809,7 +111787,7 @@
 visibility="public"
>
</field>
<field name="TTS_SUCCESS"
<field name="SUCCESS"
 type="int"
 transient="false"
 volatile="false"
@@ -111837,6 +111815,28 @@
 visibility="public"
>
</constructor>
<field name="ACTION_CHECK_TTS_DATA"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.speech.tts.engine.CHECK_TTS_DATA&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ACTION_INSTALL_TTS_DATA"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.speech.tts.engine.INSTALL_TTS_DATA&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHECK_VOICE_DATA_BAD_DATA"
 type="int"
 transient="false"
@@ -111892,7 +111892,7 @@
 visibility="public"
>
</field>
<field name="TTS_DEFAULT_STREAM"
<field name="DEFAULT_STREAM"
 type="int"
 transient="false"
 volatile="false"
@@ -111903,55 +111903,55 @@
 visibility="public"
>
</field>
<field name="TTS_KEY_PARAM_STREAM"
<field name="EXTRA_VOICE_DATA_FILES"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;streamType&quot;"
 value="&quot;dataFiles&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="TTS_KEY_PARAM_UTTERANCE_ID"
<field name="EXTRA_VOICE_DATA_FILES_INFO"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;utteranceId&quot;"
 value="&quot;dataFilesInfo&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="VOICE_DATA_FILES"
<field name="EXTRA_VOICE_DATA_ROOT_DIRECTORY"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;dataFiles&quot;"
 value="&quot;dataRoot&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="VOICE_DATA_FILES_INFO"
<field name="KEY_PARAM_STREAM"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;dataFilesInfo&quot;"
 value="&quot;streamType&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="VOICE_DATA_ROOT_DIRECTORY"
<field name="KEY_PARAM_UTTERANCE_ID"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;dataRoot&quot;"
 value="&quot;utteranceId&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
+0 −46
Original line number Diff line number Diff line
@@ -1683,53 +1683,7 @@ public class Intent implements Parcelable {
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_REBOOT =
            "android.intent.action.REBOOT";
    /**
     * Broadcast Action: Triggers the platform Text-To-Speech engine to
     * start the activity that installs the resource files on the device
     * that are required for TTS to be operational. Since the installation
     * of the data can be interrupted or declined by the user, the application
     * shouldn't expect successful installation upon return from that intent,
     * and if need be, should check installation status with 
     * {@link #ACTION_TTS_CHECK_TTS_DATA}.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_TTS_INSTALL_TTS_DATA =
            "android.intent.action.INSTALL_TTS_DATA";

    /**
     * Broadcast Action: Starts the activity from the platform Text-To-Speech
     * engine to verify the proper installation and availability of the
     * resource files on the system. Upon completion, the activity will
     * return one of the following codes: 
     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_PASS},
     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_FAIL},
     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_BAD_DATA},
     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_MISSING_DATA}, or
     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_MISSING_VOLUME}.
     * <p> Moreover, the data received in the activity result will contain the following
     * fields:
     * <ul>
     *   <li>{@link android.speech.tts.TextToSpeech.Engine#VOICE_DATA_ROOT_DIRECTORY} which
     *       indicates the path to the location of the resource files</li>,
     *   <li>{@link android.speech.tts.TextToSpeech.Engine#VOICE_DATA_FILES} which contains
     *       the list of all the resource files</li>,
     *   <li>and {@link android.speech.tts.TextToSpeech.Engine#VOICE_DATA_FILES_INFO} which
     *       contains, for each resource file, the description of the language covered by
     *       the file in the xxx-YYY format, where xxx is the 3-letter ISO language code,
     *       and YYY is the 3-letter ISO country code.</li>
     * </ul>
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_TTS_CHECK_TTS_DATA =
            "android.intent.action.CHECK_TTS_DATA";

    /**
     * Broadcast Action: The TextToSpeech synthesizer has completed processing 
     * all of the text in the speech queue.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_TTS_QUEUE_PROCESSING_COMPLETED =
            "android.intent.action.TTS_QUEUE_PROCESSING_COMPLETED";

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
+177 −126

File changed.

Preview size limit exceeded, changes collapsed.

+31 −31
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ public class TtsService extends Service implements OnCompletionListener {
    private boolean isDefaultEnforced() {
        return (android.provider.Settings.Secure.getInt(mResolver,
                    android.provider.Settings.Secure.TTS_USE_DEFAULTS,
                    TextToSpeech.Engine.FALLBACK_TTS_USE_DEFAULTS)
                    TextToSpeech.Engine.USE_DEFAULTS)
                == 1 );
    }

@@ -202,7 +202,7 @@ public class TtsService extends Service implements OnCompletionListener {
    private int getDefaultRate() {
        return android.provider.Settings.Secure.getInt(mResolver,
                android.provider.Settings.Secure.TTS_DEFAULT_RATE,
                TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_RATE);
                TextToSpeech.Engine.DEFAULT_RATE);
    }


@@ -346,7 +346,7 @@ public class TtsService extends Service implements OnCompletionListener {
     */
    private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) {
        Log.v("TtsService", "TTS service received " + text);
        if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
        if (queueMode == TextToSpeech.QUEUE_FLUSH) {
            stop(callingApp);
        } else if (queueMode == 2) {
            stopAll(callingApp);
@@ -355,7 +355,7 @@ public class TtsService extends Service implements OnCompletionListener {
        if (!mIsSpeaking) {
            processSpeechQueue();
        }
        return TextToSpeech.TTS_SUCCESS;
        return TextToSpeech.SUCCESS;
    }

    /**
@@ -372,7 +372,7 @@ public class TtsService extends Service implements OnCompletionListener {
     */
    private int playEarcon(String callingApp, String earcon, int queueMode,
            ArrayList<String> params) {
        if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
        if (queueMode == TextToSpeech.QUEUE_FLUSH) {
            stop(callingApp);
        } else if (queueMode == 2) {
            stopAll(callingApp);
@@ -381,14 +381,14 @@ public class TtsService extends Service implements OnCompletionListener {
        if (!mIsSpeaking) {
            processSpeechQueue();
        }
        return TextToSpeech.TTS_SUCCESS;
        return TextToSpeech.SUCCESS;
    }

    /**
     * Stops all speech output and removes any utterances still in the queue for the calling app.
     */
    private int stop(String callingApp) {
        int result = TextToSpeech.TTS_ERROR;
        int result = TextToSpeech.ERROR;
        boolean speechQueueAvailable = false;
        try{
            speechQueueAvailable =
@@ -414,7 +414,7 @@ public class TtsService extends Service implements OnCompletionListener {
                    mIsSpeaking = false;
                    mCurrentSpeechItem = null;
                } else {
                    result = TextToSpeech.TTS_SUCCESS;
                    result = TextToSpeech.SUCCESS;
                }
                Log.i("TtsService", "Stopped");
            }
@@ -437,7 +437,7 @@ public class TtsService extends Service implements OnCompletionListener {
     * Stops all speech output and removes any utterances still in the queue globally.
     */
    private int stopAll(String callingApp) {
        int result = TextToSpeech.TTS_ERROR;
        int result = TextToSpeech.ERROR;
        boolean speechQueueAvailable = false;
        try{
            speechQueueAvailable =
@@ -463,7 +463,7 @@ public class TtsService extends Service implements OnCompletionListener {
                    mIsSpeaking = false;
                    mCurrentSpeechItem = null;
                } else {
                    result = TextToSpeech.TTS_SUCCESS;
                    result = TextToSpeech.SUCCESS;
                }
                Log.i("TtsService", "Stopped all");
            }
@@ -487,7 +487,7 @@ public class TtsService extends Service implements OnCompletionListener {
        if (params != null){
            for (int i = 0; i < params.size() - 1; i = i + 2){
            String param = params.get(i);
                if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
                if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                    utteranceId = params.get(i+1);
                }
            }
@@ -500,14 +500,14 @@ public class TtsService extends Service implements OnCompletionListener {

    private int playSilence(String callingApp, long duration, int queueMode,
            ArrayList<String> params) {
        if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
        if (queueMode == TextToSpeech.QUEUE_FLUSH) {
            stop(callingApp);
        }
        mSpeechQueue.add(new SpeechItem(callingApp, duration, params));
        if (!mIsSpeaking) {
            processSpeechQueue();
        }
        return TextToSpeech.TTS_SUCCESS;
        return TextToSpeech.SUCCESS;
    }

    private void silence(final SpeechItem speechItem) {
@@ -517,7 +517,7 @@ public class TtsService extends Service implements OnCompletionListener {
                if (speechItem.mParams != null){
                    for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){
                        String param = speechItem.mParams.get(i);
                        if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
                        if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                            utteranceId = speechItem.mParams.get(i+1);
                        }
                    }
@@ -562,17 +562,17 @@ public class TtsService extends Service implements OnCompletionListener {
                        for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){
                            String param = speechItem.mParams.get(i);
                            if (param != null) {
                                if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)) {
                                if (param.equals(TextToSpeech.Engine.KEY_PARAM_RATE)) {
                                    speechRate = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_LANGUAGE)){
                                    language = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_COUNTRY)){
                                    country = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_VARIANT)){
                                    variant = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                                    utteranceId = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_STREAM)) {
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_STREAM)) {
                                    try {
                                        streamType
                                                = Integer.parseInt(speechItem.mParams.get(i + 1));
@@ -638,15 +638,15 @@ public class TtsService extends Service implements OnCompletionListener {
                        for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){
                            String param = speechItem.mParams.get(i);
                            if (param != null) {
                                if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)) {
                                if (param.equals(TextToSpeech.Engine.KEY_PARAM_RATE)) {
                                    speechRate = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_LANGUAGE)){
                                    language = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_COUNTRY)){
                                    country = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_VARIANT)){
                                    variant = speechItem.mParams.get(i+1);
                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                                    utteranceId = speechItem.mParams.get(i+1);
                                }
                            }
@@ -698,7 +698,7 @@ public class TtsService extends Service implements OnCompletionListener {
    }

    private void broadcastTtsQueueProcessingCompleted(){
        Intent i = new Intent(Intent.ACTION_TTS_QUEUE_PROCESSING_COMPLETED);
        Intent i = new Intent(TextToSpeech.ACTION_TTS_QUEUE_PROCESSING_COMPLETED);
        sendBroadcast(i);
    }

@@ -843,7 +843,7 @@ public class TtsService extends Service implements OnCompletionListener {
        }
        for (int i = 0; i < paramList.size() - 1; i = i + 2) {
            String param = paramList.get(i);
            if ((param != null) && (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_STREAM))) {
            if ((param != null) && (param.equals(TextToSpeech.Engine.KEY_PARAM_STREAM))) {
                try {
                    streamType = Integer.parseInt(paramList.get(i + 1));
                } catch (NumberFormatException e) {
@@ -910,18 +910,18 @@ public class TtsService extends Service implements OnCompletionListener {
            if (cb != null) {
                mCallbacks.register(cb);
                mCallbacksMap.put(packageName, cb);
                return TextToSpeech.TTS_SUCCESS;
                return TextToSpeech.SUCCESS;
            }
            return TextToSpeech.TTS_ERROR;
            return TextToSpeech.ERROR;
        }

        public int unregisterCallback(String packageName, ITtsCallback cb) {
            if (cb != null) {
                mCallbacksMap.remove(packageName);
                mCallbacks.unregister(cb);
                return TextToSpeech.TTS_SUCCESS;
                return TextToSpeech.SUCCESS;
            }
            return TextToSpeech.TTS_ERROR;
            return TextToSpeech.ERROR;
        }

        /**