Merge "Avoid NPE when sendMessage is called after disconnect." into mnc-dev
This commit is contained in:
@@ -462,10 +462,8 @@ public class AsyncChannel {
|
|||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
}
|
}
|
||||||
// Tell source we're disconnected.
|
// Tell source we're disconnected.
|
||||||
if (mSrcHandler != null) {
|
replyDisconnected(STATUS_SUCCESSFUL);
|
||||||
replyDisconnected(STATUS_SUCCESSFUL);
|
mSrcHandler = null;
|
||||||
mSrcHandler = null;
|
|
||||||
}
|
|
||||||
// Unlink only when bindService isn't used
|
// Unlink only when bindService isn't used
|
||||||
if (mConnection == null && mDstMessenger != null && mDeathMonitor!= null) {
|
if (mConnection == null && mDstMessenger != null && mDeathMonitor!= null) {
|
||||||
mDstMessenger.getBinder().unlinkToDeath(mDeathMonitor, 0);
|
mDstMessenger.getBinder().unlinkToDeath(mDeathMonitor, 0);
|
||||||
@@ -871,6 +869,8 @@ public class AsyncChannel {
|
|||||||
* @param status to be stored in msg.arg1
|
* @param status to be stored in msg.arg1
|
||||||
*/
|
*/
|
||||||
private void replyDisconnected(int status) {
|
private void replyDisconnected(int status) {
|
||||||
|
// Can't reply if already disconnected. Avoid NullPointerException.
|
||||||
|
if (mSrcHandler == null) return;
|
||||||
Message msg = mSrcHandler.obtainMessage(CMD_CHANNEL_DISCONNECTED);
|
Message msg = mSrcHandler.obtainMessage(CMD_CHANNEL_DISCONNECTED);
|
||||||
msg.arg1 = status;
|
msg.arg1 = status;
|
||||||
msg.obj = this;
|
msg.obj = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user