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

Commit 7b42c6ea authored by Josh Imbriani's avatar Josh Imbriani
Browse files

Adding new overloads for addEarcon and addSpeech that takes Uri

Bug: 139179420
Bug: 139180464
Test: Ran CTS test
Test: "run cts -m CtsSpeechTestCases"

Change-Id: Ie4cbd8aa91805804e099027b2404162e651323ca
parent 1cf41847
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42260,10 +42260,12 @@ package android.speech.tts {
    method public int addEarcon(String, String, @RawRes int);
    method @Deprecated public int addEarcon(String, String);
    method public int addEarcon(String, java.io.File);
    method public int addEarcon(@NonNull String, @NonNull android.net.Uri);
    method public int addSpeech(String, String, @RawRes int);
    method public int addSpeech(CharSequence, String, @RawRes int);
    method public int addSpeech(String, String);
    method public int addSpeech(CharSequence, java.io.File);
    method public int addSpeech(@NonNull CharSequence, @NonNull android.net.Uri);
    method @Deprecated public boolean areDefaultsEnforced();
    method public java.util.Set<java.util.Locale> getAvailableLanguages();
    method public String getDefaultEngine();
+44 −23
Original line number Diff line number Diff line
@@ -904,10 +904,7 @@ public class TextToSpeech {
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addSpeech(String text, String packagename, @RawRes int resourceId) {
        synchronized (mStartLock) {
            mUtterances.put(text, makeResourceUri(packagename, resourceId));
            return SUCCESS;
        }
        return addSpeech(text, makeResourceUri(packagename, resourceId));
    }

    /**
@@ -938,10 +935,7 @@ public class TextToSpeech {
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addSpeech(CharSequence text, String packagename, @RawRes int resourceId) {
        synchronized (mStartLock) {
            mUtterances.put(text, makeResourceUri(packagename, resourceId));
            return SUCCESS;
        }
        return addSpeech(text, makeResourceUri(packagename, resourceId));
    }

    /**
@@ -959,14 +953,11 @@ public class TextToSpeech {
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addSpeech(String text, String filename) {
        synchronized (mStartLock) {
            mUtterances.put(text, Uri.parse(filename));
            return SUCCESS;
        }
        return addSpeech(text, Uri.parse(filename));
    }

    /**
     * Adds a mapping between a CharSequence (may be spanned with TtsSpans and a sound file.
     * Adds a mapping between a CharSequence (may be spanned with TtsSpans) and a sound file.
     * Using this, it is possible to add custom pronounciations for a string of text. After a call
     * to this method, subsequent calls to {@link #speak(CharSequence, int, Bundle, String)}
     * will play the specified sound resource if it is available, or synthesize the text it is
@@ -980,8 +971,26 @@ public class TextToSpeech {
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addSpeech(CharSequence text, File file) {
        return addSpeech(text, Uri.fromFile(file));
    }

     /**
     * Adds a mapping between a CharSequence (may be spanned with TtsSpans) and a sound file.
     * Using this, it is possible to add custom pronounciations for a string of text. After a call
     * to this method, subsequent calls to {@link #speak(CharSequence, int, Bundle, String)}
     * will play the specified sound resource if it is available, or synthesize the text it is
     * missing.
     *
     * @param text
     *            The string of text. Example: <code>"south_south_east"</code>
     * @param uri
     *            Uri object pointing to the sound file.
     *
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addSpeech(@NonNull CharSequence text, @NonNull Uri uri) {
        synchronized (mStartLock) {
            mUtterances.put(text, Uri.fromFile(file));
            mUtterances.put(text, uri);
            return SUCCESS;
        }
    }
@@ -1012,10 +1021,7 @@ public class TextToSpeech {
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addEarcon(String earcon, String packagename, @RawRes int resourceId) {
        synchronized(mStartLock) {
            mEarcons.put(earcon, makeResourceUri(packagename, resourceId));
            return SUCCESS;
        }
        return addEarcon(earcon, makeResourceUri(packagename, resourceId));
    }

    /**
@@ -1038,10 +1044,7 @@ public class TextToSpeech {
     */
    @Deprecated
    public int addEarcon(String earcon, String filename) {
        synchronized(mStartLock) {
            mEarcons.put(earcon, Uri.parse(filename));
            return SUCCESS;
        }
        return addEarcon(earcon, Uri.parse(filename));
    }

    /**
@@ -1059,8 +1062,26 @@ public class TextToSpeech {
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addEarcon(String earcon, File file) {
        return addEarcon(earcon, Uri.fromFile(file));
    }

    /**
     * Adds a mapping between a string of text and a sound file.
     * Use this to add custom earcons.
     *
     * @see #playEarcon(String, int, HashMap)
     *
     * @param earcon
     *            The name of the earcon.
     *            Example: <code>"[tick]"</code>
     * @param uri
     *            Uri object pointing to the sound file.
     *
     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
     */
    public int addEarcon(@NonNull String earcon, @NonNull Uri uri) {
        synchronized(mStartLock) {
            mEarcons.put(earcon, Uri.fromFile(file));
            mEarcons.put(earcon, uri);
            return SUCCESS;
        }
    }