Send mute state to UI.

Append to API to support deliver of mute status.
Have PhoneUtils.setMuteInternal notify the AudioRouter of the change.
AudioRouter then notifies CallHandlerServiceProxy.

Removed unused "previousstate" from the AudioRouter listener method;
replaced it with muted state.

bug:10395427
Change-Id: I0295e9d6b9af981c4911f2f5ba3abd65b748fd6e
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 3f38615..572bdae 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -155,7 +155,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?
@@ -170,13 +170,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/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);
     }
 
     /**