Merge changes I0295e9d6,Ib0bb7ab2 into klp-dev

* changes:
  Send mute state to UI.
  Stop overwriting CALL_WAITING with INCOMING
diff --git a/common/src/com/android/services/telephony/common/Call.java b/common/src/com/android/services/telephony/common/Call.java
index f397f62..debad61 100644
--- a/common/src/com/android/services/telephony/common/Call.java
+++ b/common/src/com/android/services/telephony/common/Call.java
@@ -372,7 +372,7 @@
     public String toString() {
         return Objects.toStringHelper(this)
                 .add("mCallId", mCallId)
-                .add("mState", mState)
+                .add("mState", STATE_MAP.get(mState))
                 .add("mDisconnectCause", mDisconnectCause)
                 .add("mCapabilities", mCapabilities)
                 .add("mConnectTime", mConnectTime)
diff --git a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
index ccf30b0..5eddb0e 100644
--- a/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
+++ b/common/src/com/android/services/telephony/common/ICallHandlerService.aidl
@@ -55,7 +55,7 @@
      * Called when the audio mode changes.
      * {@see AudioMode}
      */
-    void onAudioModeChange(in int mode);
+    void onAudioModeChange(in int mode, in boolean muted);
 
     /**
      * Called when the supported audio modes change.
diff --git a/src/com/android/phone/AudioRouter.java b/src/com/android/phone/AudioRouter.java
index 517f777..00fc131 100644
--- a/src/com/android/phone/AudioRouter.java
+++ b/src/com/android/phone/AudioRouter.java
@@ -75,6 +75,13 @@
     }
 
     /**
+     * Returns the current mute state.
+     */
+    public boolean getMute() {
+        return PhoneUtils.getMute();
+    }
+
+    /**
      * Add a listener to audio mode changes.
      */
     public void addAudioModeListener(AudioModeListener listener) {
@@ -82,7 +89,7 @@
             mListeners.add(listener);
 
             // For first notification, mPreviousAudioMode doesn't make sense.
-            listener.onAudioModeChange(mAudioMode, mAudioMode);
+            listener.onAudioModeChange(mAudioMode, getMute());
             listener.onSupportedAudioModeChange(mSupportedModes);
         }
     }
@@ -187,6 +194,11 @@
         }
     }
 
+    public void onMuteChange(boolean muted) {
+        logD("onMuteChange: " + muted);
+        notifyListeners();
+    }
+
     /**
      * Called when the bluetooth connection changes.
      * We adjust the audio mode according to the state we receive.
@@ -323,13 +335,13 @@
         logD("Supported AudioMode: " + AudioMode.toString(mSupportedModes));
 
         for (int i = 0; i < mListeners.size(); i++) {
-            mListeners.get(i).onAudioModeChange(mPreviousMode, mAudioMode);
+            mListeners.get(i).onAudioModeChange(mAudioMode, getMute());
             mListeners.get(i).onSupportedAudioModeChange(mSupportedModes);
         }
     }
 
     public interface AudioModeListener {
-        void onAudioModeChange(int previousMode, int newMode);
+        void onAudioModeChange(int newMode, boolean muted);
         void onSupportedAudioModeChange(int modeMask);
     }
 
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index b1a3345..553deec 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -158,7 +158,7 @@
     }
 
     @Override
-    public void onAudioModeChange(int previousMode, int newMode) {
+    public void onAudioModeChange(int newMode, boolean muted) {
         try {
             synchronized (mServiceAndQueueLock) {
                 // TODO(klp): does this need to be enqueued?
@@ -173,13 +173,13 @@
 
             // Just do a simple log for now.
             Log.i(TAG, "Updating with new audio mode: " + AudioMode.toString(newMode) +
-                    " from " + AudioMode.toString(previousMode));
+                    " with mute " + muted);
 
             if (DBG) {
                 Log.d(TAG, "onSupportAudioModeChange");
             }
 
-            mCallHandlerServiceGuarded.onAudioModeChange(newMode);
+            mCallHandlerServiceGuarded.onAudioModeChange(newMode, muted);
         } catch (Exception e) {
             Log.e(TAG, "Remote exception handling onAudioModeChange", e);
         }
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index 6b7a137..393e054 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -199,7 +199,6 @@
         final Call call = getCallFromMap(mCallMap, conn, true);
 
         updateCallFromConnection(call, conn, false);
-        call.setState(Call.State.INCOMING);
 
         for (int i = 0; i < mListeners.size(); ++i) {
             if (call != null) {
@@ -217,7 +216,6 @@
             final boolean wasConferenced = call.getState() == State.CONFERENCED;
 
             updateCallFromConnection(call, conn, false);
-            call.setState(Call.State.DISCONNECTED);
 
             for (int i = 0; i < mListeners.size(); ++i) {
                 mListeners.get(i).onDisconnect(call);
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 6b96737..586cf88 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -1971,6 +1971,7 @@
             phone.setMute(muted);
         }
         app.notificationMgr.updateMuteNotification();
+        app.getAudioRouter().onMuteChange(muted);
     }
 
     /**