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

Commit 52ae8e84 authored by Alan Viverette's avatar Alan Viverette Committed by Android Git Automerger
Browse files

am a7fa0079: am 561dcc58: Merge "Avoid crash when TextToSpeech calls onInit()...

am a7fa0079: am 561dcc58: Merge "Avoid crash when TextToSpeech calls onInit() from the constructor." into jb-mr2-dev

* commit 'a7fa0079':
  Avoid crash when TextToSpeech calls onInit() from the constructor.
parents a5e5196b a7fa0079
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -647,6 +647,9 @@ class AccessibilityInjector {
    private static class TextToSpeechWrapper {
    private static class TextToSpeechWrapper {
        private static final String WRAP_TAG = TextToSpeechWrapper.class.getSimpleName();
        private static final String WRAP_TAG = TextToSpeechWrapper.class.getSimpleName();


        /** Lock used to control access to the TextToSpeech object. */
        private final Object mTtsLock = new Object();

        private final HashMap<String, String> mTtsParams;
        private final HashMap<String, String> mTtsParams;
        private final TextToSpeech mTextToSpeech;
        private final TextToSpeech mTextToSpeech;


@@ -684,7 +687,7 @@ class AccessibilityInjector {
        @JavascriptInterface
        @JavascriptInterface
        @SuppressWarnings("unused")
        @SuppressWarnings("unused")
        public boolean isSpeaking() {
        public boolean isSpeaking() {
            synchronized (mTextToSpeech) {
            synchronized (mTtsLock) {
                if (!mReady) {
                if (!mReady) {
                    return false;
                    return false;
                }
                }
@@ -696,7 +699,7 @@ class AccessibilityInjector {
        @JavascriptInterface
        @JavascriptInterface
        @SuppressWarnings("unused")
        @SuppressWarnings("unused")
        public int speak(String text, int queueMode, HashMap<String, String> params) {
        public int speak(String text, int queueMode, HashMap<String, String> params) {
            synchronized (mTextToSpeech) {
            synchronized (mTtsLock) {
                if (!mReady) {
                if (!mReady) {
                    if (DEBUG) {
                    if (DEBUG) {
                        Log.w(WRAP_TAG, "[" + hashCode() + "] Attempted to speak before TTS init");
                        Log.w(WRAP_TAG, "[" + hashCode() + "] Attempted to speak before TTS init");
@@ -715,7 +718,7 @@ class AccessibilityInjector {
        @JavascriptInterface
        @JavascriptInterface
        @SuppressWarnings("unused")
        @SuppressWarnings("unused")
        public int stop() {
        public int stop() {
            synchronized (mTextToSpeech) {
            synchronized (mTtsLock) {
                if (!mReady) {
                if (!mReady) {
                    if (DEBUG) {
                    if (DEBUG) {
                        Log.w(WRAP_TAG, "[" + hashCode() + "] Attempted to stop before initialize");
                        Log.w(WRAP_TAG, "[" + hashCode() + "] Attempted to stop before initialize");
@@ -733,7 +736,7 @@ class AccessibilityInjector {


        @SuppressWarnings("unused")
        @SuppressWarnings("unused")
        protected void shutdown() {
        protected void shutdown() {
            synchronized (mTextToSpeech) {
            synchronized (mTtsLock) {
                if (!mReady) {
                if (!mReady) {
                    if (DEBUG) {
                    if (DEBUG) {
                        Log.w(WRAP_TAG, "[" + hashCode() + "] Called shutdown before initialize");
                        Log.w(WRAP_TAG, "[" + hashCode() + "] Called shutdown before initialize");
@@ -753,7 +756,7 @@ class AccessibilityInjector {
        private final OnInitListener mInitListener = new OnInitListener() {
        private final OnInitListener mInitListener = new OnInitListener() {
            @Override
            @Override
            public void onInit(int status) {
            public void onInit(int status) {
                synchronized (mTextToSpeech) {
                synchronized (mTtsLock) {
                    if (!mShutdown && (status == TextToSpeech.SUCCESS)) {
                    if (!mShutdown && (status == TextToSpeech.SUCCESS)) {
                        if (DEBUG) {
                        if (DEBUG) {
                            Log.d(WRAP_TAG, "[" + TextToSpeechWrapper.this.hashCode()
                            Log.d(WRAP_TAG, "[" + TextToSpeechWrapper.this.hashCode()