Adding new BluetoothManager class

Previously, the UI-heavy InCallScreen handled all the bluetooth code.
This code does not add very much logic at all...it's mostly copying from
InCallScreen and whatever Bluetooth code existed in PhoneGlobals.

Changes of note:
- New BluetoothManager class from InCallScreen bluetooth code
- I removed the REQUEST_BLUETOOTH... code from InCallScreen since it was
  there to "update" the UI, which no longer runs.
- Added a Listener to the BluetoothManager for anyone that wants to
  listen in on changes.  This helped remove PhoneGlobals references from
  BluetoothManager code.  Currently PhoneGlobals is the only listener
  (for some proximity sensor-related code) but in the next CL there will
  be an AudioRouter class that will also listen to those changes.
- Previous callers of InCallScreen->whateverBluetooth has been updated
  to use BluetoothManager, or the code was commented because it was
  primarily UI code which is being replaced.

Change-Id: I6f86d16c8bd9cd1da2156c1f3743886f32e84c25
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index a64a205..f243123 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -288,6 +288,8 @@
                 // Check is phone in any dock, and turn on speaker accordingly
                 final boolean speakerActivated = activateSpeakerIfDocked(phone);
 
+                final BluetoothManager btManager = app.getBluetoothManager();
+
                 // When answering a phone call, the user will move the phone near to her/his ear
                 // and start conversation, without checking its speaker status. If some other
                 // application turned on the speaker mode before the call and didn't turn it off,
@@ -297,7 +299,7 @@
                 // - we did not activate speaker by ourselves during the process above, and
                 // - Bluetooth headset is not in use.
                 if (isRealIncomingCall && !speakerActivated && isSpeakerOn(app)
-                        && !app.isBluetoothHeadsetAudioOn()) {
+                        && !btManager.isBluetoothHeadsetAudioOn()) {
                     // This is not an error but might cause users' confusion. Add log just in case.
                     Log.i(LOG_TAG, "Forcing speaker off due to new incoming call...");
                     turnOnSpeaker(app, false, true);
@@ -711,9 +713,11 @@
             // Check is phone in any dock, and turn on speaker accordingly
             final boolean speakerActivated = activateSpeakerIfDocked(phone);
 
+            final BluetoothManager btManager = app.getBluetoothManager();
+
             // See also similar logic in answerCall().
             if (initiallyIdle && !speakerActivated && isSpeakerOn(app)
-                    && !app.isBluetoothHeadsetAudioOn()) {
+                    && !btManager.isBluetoothHeadsetAudioOn()) {
                 // This is not an error but might cause users' confusion. Add log just in case.
                 Log.i(LOG_TAG, "Forcing speaker off when initiating a new outgoing call...");
                 PhoneUtils.turnOnSpeaker(app, false, true);
@@ -2457,8 +2461,9 @@
         if (PhoneGlobals.mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
             if (DBG) log("activateSpeakerIfDocked(): In a dock -> may need to turn on speaker.");
             PhoneGlobals app = PhoneGlobals.getInstance();
+            final BluetoothManager btManager = app.getBluetoothManager();
 
-            if (!app.isHeadsetPlugged() && !app.isBluetoothHeadsetAudioOn()) {
+            if (!app.isHeadsetPlugged() && !btManager.isBluetoothHeadsetAudioOn()) {
                 turnOnSpeaker(phone.getContext(), true, true);
                 activated = true;
             }