Loading core/java/android/speech/tts/TextToSpeech.java +20 −9 Original line number Diff line number Diff line Loading @@ -1282,6 +1282,7 @@ public class TextToSpeech { } }; @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.i(TAG, "Connected to " + name); synchronized(mStartLock) { Loading @@ -1305,6 +1306,7 @@ public class TextToSpeech { return mCallback; } @Override public void onServiceDisconnected(ComponentName name) { synchronized(mStartLock) { mService = null; Loading @@ -1317,17 +1319,25 @@ public class TextToSpeech { public void disconnect() { mContext.unbindService(this); synchronized (mStartLock) { mService = null; // If this is the active connection, clear it if (mServiceConnection == this) { mServiceConnection = null; } } } public <R> R runAction(Action<R> action, R errorResult, String method, boolean reconnect) { try { synchronized (mStartLock) { try { if (mService == null) { Log.w(TAG, method + " failed: not connected to TTS engine"); return errorResult; } return action.run(mService); } } catch (RemoteException ex) { Log.e(TAG, method + " failed", ex); if (reconnect) { Loading @@ -1338,6 +1348,7 @@ public class TextToSpeech { } } } } private interface Action<R> { R run(ITextToSpeechService service) throws RemoteException; Loading Loading
core/java/android/speech/tts/TextToSpeech.java +20 −9 Original line number Diff line number Diff line Loading @@ -1282,6 +1282,7 @@ public class TextToSpeech { } }; @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.i(TAG, "Connected to " + name); synchronized(mStartLock) { Loading @@ -1305,6 +1306,7 @@ public class TextToSpeech { return mCallback; } @Override public void onServiceDisconnected(ComponentName name) { synchronized(mStartLock) { mService = null; Loading @@ -1317,17 +1319,25 @@ public class TextToSpeech { public void disconnect() { mContext.unbindService(this); synchronized (mStartLock) { mService = null; // If this is the active connection, clear it if (mServiceConnection == this) { mServiceConnection = null; } } } public <R> R runAction(Action<R> action, R errorResult, String method, boolean reconnect) { try { synchronized (mStartLock) { try { if (mService == null) { Log.w(TAG, method + " failed: not connected to TTS engine"); return errorResult; } return action.run(mService); } } catch (RemoteException ex) { Log.e(TAG, method + " failed", ex); if (reconnect) { Loading @@ -1338,6 +1348,7 @@ public class TextToSpeech { } } } } private interface Action<R> { R run(ITextToSpeechService service) throws RemoteException; Loading