am 72079f7f: Merge "Make sure cancel is called on tear down." into lmp-dev
* commit '72079f7f9b644e57169e26597ec7c727786071a1': Make sure cancel is called on tear down.
This commit is contained in:
@@ -91,9 +91,20 @@ public abstract class RecognitionService extends Service {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void dispatchStartListening(Intent intent, IRecognitionListener listener) {
|
private void dispatchStartListening(Intent intent, final IRecognitionListener listener) {
|
||||||
if (mCurrentCallback == null) {
|
if (mCurrentCallback == null) {
|
||||||
if (DBG) Log.d(TAG, "created new mCurrentCallback, listener = " + listener.asBinder());
|
if (DBG) Log.d(TAG, "created new mCurrentCallback, listener = " + listener.asBinder());
|
||||||
|
try {
|
||||||
|
listener.asBinder().linkToDeath(new IBinder.DeathRecipient() {
|
||||||
|
@Override
|
||||||
|
public void binderDied() {
|
||||||
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_CANCEL, listener));
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
Log.e(TAG, "dead listener on startListening");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mCurrentCallback = new Callback(listener);
|
mCurrentCallback = new Callback(listener);
|
||||||
RecognitionService.this.onStartListening(intent, mCurrentCallback);
|
RecognitionService.this.onStartListening(intent, mCurrentCallback);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -396,6 +396,14 @@ public class SpeechRecognizer {
|
|||||||
* Destroys the {@code SpeechRecognizer} object.
|
* Destroys the {@code SpeechRecognizer} object.
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
if (mService != null) {
|
||||||
|
try {
|
||||||
|
mService.cancel(mListener);
|
||||||
|
} catch (final RemoteException e) {
|
||||||
|
// Not important
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mConnection != null) {
|
if (mConnection != null) {
|
||||||
mContext.unbindService(mConnection);
|
mContext.unbindService(mConnection);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user