Add audio mode and audio focus support to Telecomm

This CL adds support for:
  - audio focus
  - switching to speaker phone
  - mute
  - wired headset

Bluetooth support is coming in a different CL.

Change-Id: Iaf4013ea747548451cff45b48bcbb5b1dd1b8498
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index 0bfe30d..5c3e3e6 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -22,6 +22,7 @@
 import android.content.ServiceConnection;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.telecomm.CallAudioState;
 import android.telecomm.CallInfo;
 import android.telecomm.CallState;
 
@@ -138,6 +139,19 @@
         }
     }
 
+    @Override
+    public void onAudioStateChanged(CallAudioState oldAudioState, CallAudioState newAudioState) {
+        if (mInCallService != null) {
+            Log.i(this, "Calling onAudioStateChanged, audioState: %s -> %s", oldAudioState,
+                    newAudioState);
+            try {
+                mInCallService.onAudioStateChanged(newAudioState);
+            } catch (RemoteException e) {
+                Log.e(this, e, "Exception attempting to update audio state.");
+            }
+        }
+    }
+
     /**
      * Unbinds an existing bound connection to the in-call app.
      */
@@ -198,6 +212,7 @@
             for (Call call : calls) {
                 onCallAdded(call);
             }
+            onAudioStateChanged(null, CallsManager.getInstance().getAudioState());
         } else {
             unbind();
         }