From 317954397ef01099ed0afeb1fca1a3778d5fec87 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 7 Aug 2013 20:49:12 -0700 Subject: Fix race-condition case. Hitting a button when the call just disconnected can cause mCall = null. Protect against it instead of throwing exception. Change-Id: I529579b43746c7611bad1209fe4d19a355ae6203 --- InCallUI/src/com/android/incallui/AnswerPresenter.java | 14 +++++++++----- InCallUI/src/com/android/incallui/CallButtonPresenter.java | 10 ++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index c3a7c13ad..f899a566f 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -16,8 +16,6 @@ package com.android.incallui; -import com.google.common.base.Preconditions; - import com.android.incallui.InCallPresenter.InCallState; import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.services.telephony.common.Call; @@ -58,14 +56,20 @@ public class AnswerPresenter extends Presenter } public void onAnswer() { - Preconditions.checkNotNull(mCall); + if (mCall == null) { + return; + } + Logger.d(this, "onAnswer " + mCall.getCallId()); CallCommandClient.getInstance().answerCall(mCall.getCallId()); } public void onDecline() { - Preconditions.checkNotNull(mCall); + if (mCall == null) { + return; + } + Logger.d(this, "onDecline " + mCall.getCallId()); CallCommandClient.getInstance().rejectCall(mCall.getCallId(), false, null); @@ -89,4 +93,4 @@ public class AnswerPresenter extends Presenter public void dismissPopup(); public void configureMessageDialogue(ArrayList textResponses); } -} \ No newline at end of file +} diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 114685d33..12f27c81f 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -16,8 +16,6 @@ package com.android.incallui; -import com.google.common.base.Preconditions; - import android.media.AudioManager; import com.android.incallui.AudioModeProvider.AudioModeListener; @@ -122,7 +120,9 @@ public class CallButtonPresenter extends Presenter