summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-08-07 20:49:12 -0700
committerSantos Cordon <santoscordon@google.com>2013-08-08 06:35:58 +0000
commit317954397ef01099ed0afeb1fca1a3778d5fec87 (patch)
tree089ffb86ab034343f0ea11465f0f45ba7dfdbc4a
parentda7c1570893e81e3d83d72e71f38b20a8fbd0383 (diff)
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
-rw-r--r--InCallUI/src/com/android/incallui/AnswerPresenter.java14
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonPresenter.java10
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<AnswerPresenter.AnswerUi>
}
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<AnswerPresenter.AnswerUi>
public void dismissPopup();
public void configureMessageDialogue(ArrayList<String> 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<CallButtonPresenter.CallButto
}
public void endCallClicked() {
- Preconditions.checkNotNull(mCall);
+ if (mCall == null) {
+ return;
+ }
// TODO(klp): hook up call id.
CallCommandClient.getInstance().disconnectCall(mCall.getCallId());
@@ -136,7 +136,9 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
}
public void holdClicked(boolean checked) {
- Preconditions.checkNotNull(mCall);
+ if (mCall == null) {
+ return;
+ }
Logger.d(this, "holding: " + mCall.getCallId());