Remove precondition checks

Remove precondition checks when we can work around them.

Bug:16620302
Change-Id: Ideb70a35c08f2275361eebec2850f454cf0bec55
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index 20bf353..9d587ab 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -356,8 +356,6 @@
      * and instead keep the code resilient to unexpected state changes.
      */
     void setState(int newState) {
-        Preconditions.checkState(newState != CallState.DISCONNECTED ||
-                mDisconnectCause != DisconnectCause.NOT_VALID);
         if (mState != newState) {
             Log.v(this, "setState %s -> %s", mState, newState);
             mState = newState;
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index 5f01cb8..74b6e44 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -24,7 +24,6 @@
 import android.telecomm.PhoneAccountHandle;
 import android.telephony.DisconnectCause;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableList;
 
@@ -36,7 +35,7 @@
 /**
  * Singleton.
  *
- * NOTE(gilad): by design most APIs are package private, use the relevant adapter/s to allow
+ * NOTE: by design most APIs are package private, use the relevant adapter/s to allow
  * access from other packages specifically refraining from passing the CallsManager instance
  * beyond the com.android.telecomm package boundary.
  */
@@ -638,10 +637,11 @@
      * @param service The connection service that disconnected.
      */
     void handleConnectionServiceDeath(ConnectionServiceWrapper service) {
-        Preconditions.checkNotNull(service);
-        for (Call call : ImmutableList.copyOf(mCalls)) {
-            if (call.getConnectionService() == service) {
-                markCallAsDisconnected(call, DisconnectCause.ERROR_UNSPECIFIED, null);
+        if (service != null) {
+            for (Call call : ImmutableList.copyOf(mCalls)) {
+                if (call.getConnectionService() == service) {
+                    markCallAsDisconnected(call, DisconnectCause.ERROR_UNSPECIFIED, null);
+                }
             }
         }
     }
@@ -770,7 +770,9 @@
      * @param newState The new state of the call.
      */
     private void setCallState(Call call, int newState) {
-        Preconditions.checkNotNull(newState);
+        if (call == null) {
+            return;
+        }
         int oldState = call.getState();
         Log.i(this, "setCallState %s -> %s, call: %s", oldState, newState, call);
         if (newState != oldState) {
diff --git a/src/com/android/telecomm/DtmfLocalTonePlayer.java b/src/com/android/telecomm/DtmfLocalTonePlayer.java
index e18f59c..715b1e8 100644
--- a/src/com/android/telecomm/DtmfLocalTonePlayer.java
+++ b/src/com/android/telecomm/DtmfLocalTonePlayer.java
@@ -20,7 +20,6 @@
 import android.media.ToneGenerator;
 import android.provider.Settings;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 
 import java.util.Map;
@@ -57,13 +56,8 @@
     /** {@inheritDoc} */
     @Override
     public void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall) {
-        if (oldForegroundCall != null) {
-            endDtmfSession(oldForegroundCall);
-        }
-
-        if (newForegroundCall != null) {
-            startDtmfSession(newForegroundCall);
-        }
+        endDtmfSession(oldForegroundCall);
+        startDtmfSession(newForegroundCall);
     }
 
     /**
@@ -113,7 +107,9 @@
      * @param call The call associated with this dtmf session.
      */
     private void startDtmfSession(Call call) {
-        Preconditions.checkNotNull(call);
+        if (call == null) {
+            return;
+        }
         TelecommApp app = TelecommApp.getInstance();
 
         final boolean areLocalTonesEnabled;
@@ -144,8 +140,7 @@
      * @param call The call associated with the session to end.
      */
     private void endDtmfSession(Call call) {
-        Preconditions.checkNotNull(call);
-        if (mCall == call) {
+        if (call != null && mCall == call) {
             // Do a stopTone() in case the sessions ends before we are told to stop the tone.
             stopTone(call);