Merge "Avoid NPE when sendMessage is called after disconnect." into mnc-dev

This commit is contained in:
Paul Jensen
2015-05-07 15:30:46 +00:00
committed by Android (Google) Code Review

View File

@@ -462,10 +462,8 @@ public class AsyncChannel {
} catch(Exception e) {
}
// Tell source we're disconnected.
if (mSrcHandler != null) {
replyDisconnected(STATUS_SUCCESSFUL);
mSrcHandler = null;
}
replyDisconnected(STATUS_SUCCESSFUL);
mSrcHandler = null;
// Unlink only when bindService isn't used
if (mConnection == null && mDstMessenger != null && mDeathMonitor!= null) {
mDstMessenger.getBinder().unlinkToDeath(mDeathMonitor, 0);
@@ -871,6 +869,8 @@ public class AsyncChannel {
* @param status to be stored in msg.arg1
*/
private void replyDisconnected(int status) {
// Can't reply if already disconnected. Avoid NullPointerException.
if (mSrcHandler == null) return;
Message msg = mSrcHandler.obtainMessage(CMD_CHANNEL_DISCONNECTED);
msg.arg1 = status;
msg.obj = this;