new class AudioRouter manages audio routing for the phone call

This CL only has support between bluetooth/earpiece

Of Note:
- New shared class AudioMode defines different modes for audio routing
- New class AudioRouter manages between EARPIECE and Bluetooth modes.
- Add function in CallCommandService and CallHandlerService for audio
  mode

Change-Id: I52ff70e53868c45e5202b757cc80a13af3abe5f8
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index b134310..2762c98 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -28,6 +28,8 @@
 import android.os.SystemProperties;
 import android.util.Log;
 
+import com.android.phone.AudioRouter.AudioModeListener;
+import com.android.services.telephony.common.AudioMode;
 import com.android.services.telephony.common.Call;
 import com.android.services.telephony.common.ICallHandlerService;
 import com.android.services.telephony.common.ICallCommandService;
@@ -37,7 +39,8 @@
 /**
  * This class is responsible for passing through call state changes to the CallHandlerService.
  */
-public class CallHandlerServiceProxy extends Handler implements CallModeler.Listener {
+public class CallHandlerServiceProxy extends Handler implements CallModeler.Listener,
+        AudioModeListener {
 
     private static final String TAG = CallHandlerServiceProxy.class.getSimpleName();
     private static final boolean DBG =
@@ -85,6 +88,21 @@
         }
     }
 
+    @Override
+    public void onAudioModeChange(int previousMode, int newMode) {
+        // Just do a simple log for now.
+        Log.i(TAG, "Updating with new audio mode: " + AudioMode.toString(newMode) +
+                " from " + AudioMode.toString(previousMode));
+
+        if (mCallHandlerService != null) {
+            try {
+                mCallHandlerService.onAudioModeChange(newMode);
+            } catch (RemoteException e) {
+                Log.e(TAG, "Remote exception handling onAudioModeChange", e);
+            }
+        }
+    }
+
     /**
      * Sets up the connection with ICallHandlerService
      */