Remove BluetoothManager.

Bug: 25851538
Change-Id: I40cbd1fc5c26fb61bdf815a5ecc044197d887a0e
diff --git a/src/com/android/phone/BluetoothManager.java b/src/com/android/phone/BluetoothManager.java
deleted file mode 100644
index 3f0ce6f..0000000
--- a/src/com/android/phone/BluetoothManager.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone;
-
-public class BluetoothManager {
-    public BluetoothManager() {
-    }
-
-    /* package */ boolean isBluetoothHeadsetAudioOn() {
-        return false;
-    }
-
-    /* package */ boolean isBluetoothAvailable() {
-        return false;
-    }
-
-    /* package */ boolean isBluetoothAudioConnected() {
-        return false;
-    }
-
-    /* package */ boolean isBluetoothAudioConnectedOrPending() {
-        return false;
-    }
-
-    /* package */ boolean showBluetoothIndication() {
-        return false;
-    }
-
-    /* package */ void updateBluetoothIndication() {
-    }
-
-    public void addBluetoothIndicatorListener(BluetoothIndicatorListener listener) {
-    }
-
-    public void removeBluetoothIndicatorListener(BluetoothIndicatorListener listener) {
-    }
-
-    /* package */ void connectBluetoothAudio() {
-    }
-
-    /* package */ void disconnectBluetoothAudio() {
-    }
-
-    /* package */ interface BluetoothIndicatorListener {
-        public void onBluetoothIndicationChange(boolean isConnected, BluetoothManager manager);
-    }
-}
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 2b7d2ff..fc583c4 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -114,7 +114,6 @@
 
     // Cached AudioManager
     private AudioManager mAudioManager;
-    private final BluetoothManager mBluetoothManager;
     private SubscriptionManager mSubscriptionManager;
     private TelephonyManager mTelephonyManager;
 
@@ -125,11 +124,10 @@
     /* package */ static CallNotifier init(
             PhoneGlobals app,
             CallLogger callLogger,
-            CallStateMonitor callStateMonitor,
-            BluetoothManager bluetoothManager) {
+            CallStateMonitor callStateMonitor) {
         synchronized (CallNotifier.class) {
             if (sInstance == null) {
-                sInstance = new CallNotifier(app, callLogger, callStateMonitor, bluetoothManager);
+                sInstance = new CallNotifier(app, callLogger, callStateMonitor);
             } else {
                 Log.wtf(LOG_TAG, "init() called multiple times!  sInstance = " + sInstance);
             }
@@ -141,12 +139,10 @@
     private CallNotifier(
             PhoneGlobals app,
             CallLogger callLogger,
-            CallStateMonitor callStateMonitor,
-            BluetoothManager bluetoothManager) {
+            CallStateMonitor callStateMonitor) {
         mApplication = app;
         mCM = app.mCM;
         mCallLogger = callLogger;
-        mBluetoothManager = bluetoothManager;
 
         mAudioManager = (AudioManager) mApplication.getSystemService(Context.AUDIO_SERVICE);
         mTelephonyManager =
@@ -458,13 +454,6 @@
             mPreviousCdmaCallState = fgPhone.getForegroundCall().getState();
         }
 
-        // Have the PhoneApp recompute its mShowBluetoothIndication
-        // flag based on the (new) telephony state.
-        // There's no need to force a UI update since we update the
-        // in-call notification ourselves (below), and the InCallScreen
-        // listens for phone state changes itself.
-        mBluetoothManager.updateBluetoothIndication();
-
         // Update the phone state and other sensor/lock.
         mApplication.updatePhoneState(state);
 
diff --git a/src/com/android/phone/OtaUtils.java b/src/com/android/phone/OtaUtils.java
index c4b0d19..775b253 100644
--- a/src/com/android/phone/OtaUtils.java
+++ b/src/com/android/phone/OtaUtils.java
@@ -162,9 +162,6 @@
     // an InCallScreen or CallCard or any OTASP UI elements at all.
     private boolean mInteractive = true;
 
-    // used when setting speakerphone
-    private final BluetoothManager mBluetoothManager;
-
     /**
      * OtaWidgetData class represent all OTA UI elements
      *
@@ -209,12 +206,11 @@
      * Note if interactive is true, you must also call updateUiWidgets() as soon
      * as the InCallScreen instance is ready.
      */
-    public OtaUtils(Context context, boolean interactive, BluetoothManager bluetoothManager) {
+    public OtaUtils(Context context, boolean interactive) {
         if (DBG) log("OtaUtils constructor...");
         mApplication = PhoneGlobals.getInstance();
         mContext = context;
         mInteractive = interactive;
-        mBluetoothManager = bluetoothManager;
     }
 
     /**
@@ -385,8 +381,7 @@
         }
 
         // Create the OtaUtils instance.
-        app.otaUtils = new OtaUtils(context, false /* non-interactive mode */,
-                app.getBluetoothManager());
+        app.otaUtils = new OtaUtils(context, false /* non-interactive mode */);
         if (DBG) log("- created OtaUtils: " + app.otaUtils);
 
         // ... and kick off the OTASP call.
@@ -501,8 +496,7 @@
         }
 
         // Create the OtaUtils instance.
-        app.otaUtils = new OtaUtils(app.getApplicationContext(), true /* interactive */,
-                app.getBluetoothManager());
+        app.otaUtils = new OtaUtils(app.getApplicationContext(), true /* interactive */);
         if (DBG) log("- created OtaUtils: " + app.otaUtils);
 
         // NOTE we still need to call OtaUtils.updateUiWidgets() once the
@@ -560,10 +554,6 @@
             return;
         }
 
-        if (state && mBluetoothManager.isBluetoothAvailable()
-                && mBluetoothManager.isBluetoothAudioConnected()) {
-            mBluetoothManager.disconnectBluetoothAudio();
-        }
         PhoneUtils.turnOnSpeaker(mContext, state, true);
     }
 
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index fc08c5f..c6081b1 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -109,8 +109,7 @@
     private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
     private static final int EVENT_DATA_ROAMING_OK = 11;
     private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
-    private static final int EVENT_DOCK_STATE_CHANGED = 13;
-    private static final int EVENT_START_SIP_SERVICE = 14;
+    private static final int EVENT_START_SIP_SERVICE = 13;
 
     // The MMI codes are also used by the InCallScreen.
     public static final int MMI_INITIATE = 51;
@@ -152,11 +151,9 @@
     public SimActivationManager simActivationManager;
     CarrierConfigLoader configLoader;
 
-    private BluetoothManager bluetoothManager;
     private CallGatewayManager callGatewayManager;
     private CallStateMonitor callStateMonitor;
 
-    static int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
     static boolean sVoiceCapable = true;
 
     // TODO: Remove, no longer used.
@@ -292,23 +289,6 @@
                 case EVENT_UNSOL_CDMA_INFO_RECORD:
                     //TODO: handle message here;
                     break;
-
-                case EVENT_DOCK_STATE_CHANGED:
-                    // If the phone is docked/undocked during a call, and no wired or BT headset
-                    // is connected: turn on/off the speaker accordingly.
-                    boolean inDockMode = false;
-                    if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
-                        inDockMode = true;
-                    }
-                    if (VDBG) Log.d(LOG_TAG, "received EVENT_DOCK_STATE_CHANGED. Phone inDock = "
-                            + inDockMode);
-
-                    phoneState = mCM.getState();
-                    if (phoneState == PhoneConstants.State.OFFHOOK &&
-                            !bluetoothManager.isBluetoothHeadsetAudioOn()) {
-                        PhoneUtils.turnOnSpeaker(getApplicationContext(), inDockMode, true);
-                    }
-                    break;
             }
         }
     };
@@ -394,9 +374,6 @@
             // Monitors call activity from the telephony layer
             callStateMonitor = new CallStateMonitor(mCM);
 
-            // Bluetooth manager
-            bluetoothManager = new BluetoothManager();
-
             phoneMgr = PhoneInterfaceManager.init(this, PhoneFactory.getDefaultPhone());
 
             configLoader = CarrierConfigLoader.init(this);
@@ -405,7 +382,7 @@
             // asynchronous events from the telephony layer (like
             // launching the incoming-call UI when an incoming call comes
             // in.)
-            notifier = CallNotifier.init(this, callLogger, callStateMonitor, bluetoothManager);
+            notifier = CallNotifier.init(this, callLogger, callStateMonitor);
 
             PhoneUtils.registerIccStatus(mHandler, EVENT_SIM_NETWORK_LOCKED);
 
@@ -419,7 +396,6 @@
             IntentFilter intentFilter =
                     new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
             intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
-            intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
             intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
             intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
             intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
@@ -497,10 +473,6 @@
         return PhoneFactory.getPhone(SubscriptionManager.getPhoneId(subId));
     }
 
-    /* package */ BluetoothManager getBluetoothManager() {
-        return bluetoothManager;
-    }
-
     /* package */ CallManager getCallManager() {
         return mCM;
     }
@@ -863,11 +835,6 @@
                             + "but ECM isn't supported for phone: "
                             + mCM.getFgPhone().getPhoneName());
                 }
-            } else if (action.equals(Intent.ACTION_DOCK_EVENT)) {
-                mDockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE,
-                        Intent.EXTRA_DOCK_STATE_UNDOCKED);
-                if (VDBG) Log.d(LOG_TAG, "ACTION_DOCK_EVENT -> mDockState = " + mDockState);
-                mHandler.sendMessage(mHandler.obtainMessage(EVENT_DOCK_STATE_CHANGED, 0));
             }
         }
     }
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 1fa886c..0ab0cd2 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -252,26 +252,6 @@
                 answered = true;
 
                 setAudioMode();
-
-                // 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,
-                // Phone app would need to be responsible for the speaker phone.
-                // Here, we turn off the speaker if
-                // - the phone call is the first in-coming call,
-                // - we did not activate speaker by ourselves during the process above, and
-                // - Bluetooth headset is not in use.
-                if (isRealIncomingCall && !speakerActivated && isSpeakerOn(app)
-                        && !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);
-                }
             } catch (CallStateException ex) {
                 Log.w(LOG_TAG, "answerCall: caught " + ex, ex);
 
@@ -669,20 +649,6 @@
             startGetCallerInfo(context, connection, null, null, gatewayInfo);
 
             setAudioMode();
-
-            if (DBG) log("about to activate speaker");
-            // 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)
-                    && !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);
-            }
         }
 
         return status;
@@ -2196,35 +2162,6 @@
         return PhoneNumberUtils.isGlobalPhoneNumber(number);
     }
 
-   /**
-    * This function is called when phone answers or places a call.
-    * Check if the phone is in a car dock or desk dock.
-    * If yes, turn on the speaker, when no wired or BT headsets are connected.
-    * Otherwise do nothing.
-    * @return true if activated
-    */
-    private static boolean activateSpeakerIfDocked(Phone phone) {
-        if (DBG) log("activateSpeakerIfDocked()...");
-
-        boolean activated = false;
-        if (PhoneGlobals.mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
-            if (DBG) log("activateSpeakerIfDocked(): In a dock -> may need to turn on speaker.");
-            final PhoneGlobals app = PhoneGlobals.getInstance();
-
-            // TODO: This function should move to AudioRouter
-            final BluetoothManager btManager = app.getBluetoothManager();
-            //final WiredHeadsetManager wiredHeadset = app.getWiredHeadsetManager();
-            //final AudioRouter audioRouter = app.getAudioRouter();
-
-            /*if (!wiredHeadset.isHeadsetPlugged() && !btManager.isBluetoothHeadsetAudioOn()) {
-                //audioRouter.setSpeaker(true);
-                activated = true;
-            }*/
-        }
-        return activated;
-    }
-
-
     /**
      * Returns whether the phone is in ECM ("Emergency Callback Mode") or not.
      */