Merge "Wiring HD audio call capability reporting. (2/2)" into lmp-dev
diff --git a/res/drawable/preference_background.xml b/res/drawable/preference_background.xml
new file mode 100644
index 0000000..19ca432
--- /dev/null
+++ b/res/drawable/preference_background.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+        android:insetLeft="0dip"
+        android:insetTop="0dip"
+        android:insetRight="0dip"
+        android:insetBottom="0dip">
+
+    <shape android:shape="rectangle">
+        <solid android:color="@*android:color/background_material_light" />
+    </shape>
+
+</inset>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 7eec223..30da2f7 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -49,4 +49,6 @@
             <enum name="not_reachable" value="3" />
         </attr>
     </declare-styleable>
+
+    <attr name="preferenceBackgroundColor" format="color" />
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 70dcfc2..c343deb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -134,6 +134,8 @@
     <string name="voicemail_abbreviated">VM:</string>
     <!-- Mobile network settings screen, setting option name -->
     <string name="networks">Network operators</string>
+    <!-- Cell Broadcast settings title.  [CHAR LIMIT=50] -->
+    <string name="cell_broadcast_settings">Emergency broadcasts</string>
     <!-- Call settings screen title -->
     <string name="call_settings">Call Settings</string>
     <!-- GSM Call settings screen, setting option name -->
@@ -369,6 +371,10 @@
         <item>"1"</item>
         <item>"0"</item>
     </string-array>
+    <!-- Cellular network 4G title [CHAR LIMIT=30] -->
+    <string name="enhanced_4g_lte_mode_title">Enhanced 4G LTE Mode</string>
+    <!-- Cellular network 4G summary [CHAR LIMIT=80] -->
+    <string name="enhanced_4g_lte_mode_summary">Use LTE services to improve voice and other communications (recommended)</string>
     <!-- Mobile network settings screen, data enabling checkbox name -->
     <string name="data_enabled">Data enabled</string>
     <!-- Mobile network settings screen, setting summary text when check box is not selected (explains what selecting it would do) [CHAR LIMITS=40] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 426de7f..3a025e2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -286,4 +286,9 @@
         <item name="android:windowIsFloating">true</item>
         <item name="android:backgroundDimEnabled">false</item>
     </style>
+
+    <style name="Theme.Material.Settings" parent="@android:style/Theme.Material.Settings">
+        <item name="@*android:actionBarSize">56dip</item>
+        <item name="preferenceBackgroundColor">@drawable/preference_background</item>
+    </style>
 </resources>
diff --git a/res/xml/network_setting.xml b/res/xml/network_setting.xml
index 00430e8..fcd4439 100644
--- a/res/xml/network_setting.xml
+++ b/res/xml/network_setting.xml
@@ -22,13 +22,7 @@
         android:title="@string/cdma_lte_data_service">
     </PreferenceScreen>
 
-    <CheckBoxPreference
-        android:key="button_data_enabled_key"
-        android:title="@string/data_enabled"
-        android:persistent="false"
-        android:summary="@string/data_enable_summary"/>
-
-    <CheckBoxPreference
+    <SwitchPreference
         android:key="button_roaming_key"
         android:title="@string/roaming"
         android:persistent="false"
@@ -51,4 +45,10 @@
         android:entryValues="@array/enabled_networks_values"
         android:dialogTitle="@string/preferred_network_mode_dialogtitle" />
 
+    <SwitchPreference
+        android:key="enhanced_4g_lte"
+        android:title="@string/enhanced_4g_lte_mode_title"
+        android:persistent="false"
+        android:summary="@string/enhanced_4g_lte_mode_summary"/>
+
 </PreferenceScreen>
diff --git a/src/com/android/phone/AudioRouter.java b/src/com/android/phone/AudioRouter.java
deleted file mode 100644
index 3c8e9d3..0000000
--- a/src/com/android/phone/AudioRouter.java
+++ /dev/null
@@ -1,395 +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;
-
-import com.google.common.collect.Lists;
-
-import android.content.Context;
-import android.os.SystemProperties;
-import android.provider.MediaStore.Audio;
-import android.util.Log;
-
-import com.android.internal.telephony.CallManager;
-import com.android.internal.telephony.PhoneConstants;
-import com.android.phone.BluetoothManager.BluetoothIndicatorListener;
-import com.android.phone.WiredHeadsetManager.WiredHeadsetListener;
-import com.android.services.telephony.common.AudioMode;
-
-import java.util.List;
-
-/**
- * Responsible for Routing in-call audio and maintaining routing state.
- */
-/* package */ class AudioRouter implements BluetoothIndicatorListener, WiredHeadsetListener {
-
-    private static String LOG_TAG = AudioRouter.class.getSimpleName();
-    private static final boolean DBG =
-            (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
-    private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
-
-    private static final boolean ON = true;
-    private static final boolean OFF = false;
-
-    private final Context mContext;
-    private final BluetoothManager mBluetoothManager;
-    private final WiredHeadsetManager mWiredHeadsetManager;
-    private final CallManager mCallManager;
-    private final List<AudioModeListener> mListeners = Lists.newArrayList();
-    private int mAudioMode = AudioMode.EARPIECE;
-    private int mPreviousMode = AudioMode.EARPIECE;
-    private int mSupportedModes = AudioMode.ALL_MODES;
-
-    public AudioRouter(Context context, BluetoothManager bluetoothManager,
-            WiredHeadsetManager wiredHeadsetManager, CallManager callManager) {
-        mContext = context;
-        mBluetoothManager = bluetoothManager;
-        mWiredHeadsetManager = wiredHeadsetManager;
-        mCallManager = callManager;
-
-        init();
-    }
-
-    /**
-     * Return the current audio mode.
-     */
-    public int getAudioMode() {
-        return mAudioMode;
-    }
-
-    /**
-     * Returns the currently supported audio modes.
-     */
-    public int getSupportedAudioModes() {
-        return mSupportedModes;
-    }
-
-    /**
-     * Returns the current mute state.
-     */
-    public boolean getMute() {
-        return PhoneUtils.getMute();
-    }
-
-    /**
-     * Add a listener to audio mode changes.
-     */
-    public void addAudioModeListener(AudioModeListener listener) {
-        if (!mListeners.contains(listener)) {
-            mListeners.add(listener);
-
-            // For first notification, mPreviousAudioMode doesn't make sense.
-            listener.onAudioModeChange(mAudioMode, getMute());
-            listener.onSupportedAudioModeChange(mSupportedModes);
-        }
-    }
-
-    /**
-     * Remove  listener.
-     */
-    public void removeAudioModeListener(AudioModeListener listener) {
-        if (mListeners.contains(listener)) {
-            mListeners.remove(listener);
-        }
-    }
-
-    /**
-     * Sets the audio mode to the mode that is passed in.
-     */
-    public void setAudioMode(int mode) {
-        logD("setAudioMode " + AudioMode.toString(mode));
-        boolean error = false;
-
-        // changes WIRED_OR_EARPIECE to appropriate single entry WIRED_HEADSET or EARPIECE
-        mode = selectWiredOrEarpiece(mode);
-
-        // If mode is unsupported, do nothing.
-        if ((calculateSupportedModes() | mode) == 0) {
-            Log.wtf(LOG_TAG, "Asking to set to a mode that is unsupported: " + mode);
-            return;
-        }
-
-        if (AudioMode.SPEAKER == mode) {
-            turnOnOffBluetooth(OFF);
-            turnOnOffSpeaker(ON);
-
-        } else if (AudioMode.BLUETOOTH == mode) {
-            if (mBluetoothManager.isBluetoothAvailable()) {
-                // Manually turn the speaker phone off, instead of allowing the
-                // Bluetooth audio routing to handle it, since there's other
-                // important state-updating that needs to happen in the
-                // PhoneUtils.turnOnSpeaker() method.
-                // (Similarly, whenever the user turns *on* the speaker, we
-                // manually disconnect the active bluetooth headset;
-                // see toggleSpeaker() and/or switchInCallAudio().)
-                turnOnOffSpeaker(OFF);
-                if (!turnOnOffBluetooth(ON)) {
-                    error = true;
-                }
-            } else {
-                Log.e(LOG_TAG, "Asking to turn on bluetooth when no bluetooth available. " +
-                        "supportedModes: " + AudioMode.toString(calculateSupportedModes()));
-                error = true;
-            }
-
-        // Wired headset and earpiece work the same way
-        } else if (AudioMode.EARPIECE == mode || AudioMode.WIRED_HEADSET == mode) {
-            turnOnOffBluetooth(OFF);
-            turnOnOffSpeaker(OFF);
-
-        } else {
-            error = true;
-        }
-
-        if (error) {
-            mode = calculateModeFromCurrentState();
-            Log.e(LOG_TAG, "There was an error in setting new audio mode. " +
-                    "Resetting mode to " + AudioMode.toString(mode) + ".");
-
-        }
-
-        updateAudioModeTo(mode);
-    }
-
-    /**
-     * Turns on speaker.
-     */
-    public void setSpeaker(boolean on) {
-        logD("setSpeaker " + on);
-
-        if (on) {
-            setAudioMode(AudioMode.SPEAKER);
-        } else {
-            setAudioMode(AudioMode.WIRED_OR_EARPIECE);
-        }
-    }
-
-    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.
-     */
-    @Override
-    public void onBluetoothIndicationChange(boolean isConnected, BluetoothManager btManager) {
-        logD("onBluetoothIndicationChange " + isConnected);
-
-        // this will read the new bluetooth mode appropriately
-        updateAudioModeTo(calculateModeFromCurrentState());
-    }
-
-    /**
-     * Called when the state of the wired headset changes.
-     */
-    @Override
-    public void onWiredHeadsetConnection(boolean pluggedIn) {
-        logD("onWireHeadsetConnection " + pluggedIn);
-
-        // Since the presence of a wired headset or bluetooth affects the
-        // speakerphone, update the "speaker" state.  We ONLY want to do
-        // this on the wired headset connect / disconnect events for now
-        // though.
-        final boolean isOffhook = (mCallManager.getState() == PhoneConstants.State.OFFHOOK);
-
-        int newMode = mAudioMode;
-
-        // Change state only if we are not using bluetooth
-        if (!mBluetoothManager.isBluetoothHeadsetAudioOn()) {
-
-            // Do special logic with speakerphone if we have an ongoing (offhook) call.
-            if (isOffhook) {
-                if (!pluggedIn) {
-                    // if the state is "not connected", restore the speaker state.
-                    PhoneUtils.restoreSpeakerMode(mContext);
-
-                    if (PhoneUtils.isSpeakerOn(mContext)) {
-                        newMode = AudioMode.SPEAKER;
-                    } else {
-                        newMode = AudioMode.EARPIECE;
-                    }
-                } else {
-                    // if the state is "connected", force the speaker off without
-                    // storing the state.
-                    PhoneUtils.turnOnSpeaker(mContext, false, false);
-
-                    newMode = AudioMode.WIRED_HEADSET;
-                }
-
-            // if we are outside of a phone call, the logic is simpler
-            } else {
-                newMode = pluggedIn ? AudioMode.WIRED_HEADSET : AudioMode.EARPIECE;
-            }
-        }
-
-        updateAudioModeTo(newMode);
-    }
-
-    /**
-     * Changes WIRED_OR_EARPIECE to appropriate single entry WIRED_HEADSET or EARPIECE.
-     * If mode passed it is not WIRED_OR_EARPIECE, this is a no-op and simply returns
-     * the unchanged mode parameter.
-     */
-    private int selectWiredOrEarpiece(int mode) {
-        // Since they are mutually exclusive and one is ALWAYS valid, we allow a special input of
-        // WIRED_OR_EARPIECE so that callers dont have to make a call to check which is supported
-        // before calling setAudioMode.
-        if (mode == AudioMode.WIRED_OR_EARPIECE) {
-            mode = AudioMode.WIRED_OR_EARPIECE & mSupportedModes;
-
-            if (mode == 0) {
-                Log.wtf(LOG_TAG, "One of wired headset or earpiece should always be valid.");
-                // assume earpiece in this case.
-                mode = AudioMode.EARPIECE;
-            }
-        }
-
-        return mode;
-    }
-
-    /**
-     * Turns on/off bluetooth.  If bluetooth is already in the correct mode, this does
-     * nothing.
-     */
-    private boolean turnOnOffBluetooth(boolean onOff) {
-        if (mBluetoothManager.isBluetoothAvailable()) {
-            final boolean isAlreadyOn = mBluetoothManager.isBluetoothAudioConnected();
-
-            if (onOff && !isAlreadyOn) {
-                mBluetoothManager.connectBluetoothAudio();
-            } else if (!onOff && isAlreadyOn) {
-                mBluetoothManager.disconnectBluetoothAudio();
-            }
-        } else if (onOff) {
-            Log.e(LOG_TAG, "Asking to turn on bluetooth, but there is no bluetooth availabled.");
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Turn on/off speaker.
-     */
-    private void turnOnOffSpeaker(boolean onOff) {
-        if (PhoneUtils.isSpeakerOn(mContext) != onOff) {
-            PhoneUtils.turnOnSpeaker(mContext, onOff, true /* storeState */);
-        }
-    }
-
-    private void init() {
-        mBluetoothManager.addBluetoothIndicatorListener(this);
-        mWiredHeadsetManager.addWiredHeadsetListener(this);
-    }
-
-    /**
-     * Reads the state of the world to determine Audio mode.
-     */
-    private int calculateModeFromCurrentState() {
-
-        int mode = AudioMode.EARPIECE;
-
-        // There is a very specific ordering here
-        if (mBluetoothManager.showBluetoothIndication()) {
-            mode = AudioMode.BLUETOOTH;
-        } else if (PhoneUtils.isSpeakerOn(mContext)) {
-            mode = AudioMode.SPEAKER;
-        } else if (mWiredHeadsetManager.isHeadsetPlugged()) {
-            mode = AudioMode.WIRED_HEADSET;
-        }
-
-        logD("calculateModeFromCurrentState " + AudioMode.toString(mode));
-
-        return mode;
-    }
-
-    /**
-     * Changes the audio mode to the mode in the parameter.
-     */
-    private void updateAudioModeTo(int mode) {
-        int oldSupportedModes = mSupportedModes;
-
-        mSupportedModes = calculateSupportedModes();
-
-        // This is a weird state that shouldn't happen, but we get called here
-        // once we've changed the audio layers so lets log the error, but assume
-        // that it went through. If it happens it is likely it is a race condition
-        // that will resolve itself when we get updates on the mode change.
-        if ((mSupportedModes & mode) == 0) {
-            Log.e(LOG_TAG, "Setting audio mode to an unsupported mode: " +
-                    AudioMode.toString(mode) + ", supported (" +
-                    AudioMode.toString(mSupportedModes) + ")");
-        }
-
-        boolean doNotify = oldSupportedModes != mSupportedModes;
-
-        // only update if it really changed.
-        if (mAudioMode != mode) {
-            Log.i(LOG_TAG, "Audio mode changing to " + AudioMode.toString(mode));
-            doNotify = true;
-        }
-
-        mPreviousMode = mAudioMode;
-        mAudioMode = mode;
-
-        if (doNotify) {
-            notifyListeners();
-        }
-    }
-
-    /**
-     * Gets the updates supported modes from the state of the audio systems.
-     */
-    private int calculateSupportedModes() {
-        // speaker phone always a supported state
-        int supportedModes = AudioMode.SPEAKER;
-
-        if (mWiredHeadsetManager.isHeadsetPlugged()) {
-            supportedModes |= AudioMode.WIRED_HEADSET;
-        } else {
-            supportedModes |= AudioMode.EARPIECE;
-        }
-
-        if (mBluetoothManager.isBluetoothAvailable()) {
-            supportedModes |= AudioMode.BLUETOOTH;
-        }
-
-        return supportedModes;
-    }
-
-    private void notifyListeners() {
-        logD("AudioMode: " + AudioMode.toString(mAudioMode));
-        logD("Supported AudioMode: " + AudioMode.toString(mSupportedModes));
-
-        for (int i = 0; i < mListeners.size(); i++) {
-            mListeners.get(i).onAudioModeChange(mAudioMode, getMute());
-            mListeners.get(i).onSupportedAudioModeChange(mSupportedModes);
-        }
-    }
-
-    public interface AudioModeListener {
-        void onAudioModeChange(int newMode, boolean muted);
-        void onSupportedAudioModeChange(int modeMask);
-    }
-
-    private void logD(String msg) {
-        if (DBG) {
-            Log.d(LOG_TAG, msg);
-        }
-    }
-}
diff --git a/src/com/android/phone/BluetoothPhoneService.java b/src/com/android/phone/BluetoothPhoneService.java
index a2e1288..87940a0 100644
--- a/src/com/android/phone/BluetoothPhoneService.java
+++ b/src/com/android/phone/BluetoothPhoneService.java
@@ -778,7 +778,6 @@
                     if (ringingCall.isRinging()) {
                         if (VDBG) log("CHLD:2 Callwaiting Answer call");
                         PhoneUtils.answerCall(ringingCall);
-                        PhoneUtils.setMute(false);
                         // Setting the second callers state flag to TRUE (i.e. active)
                         cdmaSetSecondCallState(true);
                         return true;
diff --git a/src/com/android/phone/CallController.java b/src/com/android/phone/CallController.java
index 1cb4c80..a42f57d 100644
--- a/src/com/android/phone/CallController.java
+++ b/src/com/android/phone/CallController.java
@@ -482,8 +482,6 @@
                     // Start the timer for 3 Way CallerInfo
                     if (mApp.cdmaPhoneCallState.getCurrentCallState()
                             == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE) {
-                        //Unmute for the second MO call
-                        PhoneUtils.setMute(false);
 
                         // This is a "CDMA 3-way call", which means that you're dialing a
                         // 2nd outgoing call while a previous call is already in progress.
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 1bab321..674f66d 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -352,10 +352,6 @@
                 // onRingbackTone((AsyncResult) msg.obj);
                 break;
 
-            case CallStateMonitor.PHONE_RESEND_MUTE:
-                onResendMute();
-                break;
-
             default:
                 // super.handleMessage(msg);
         }
@@ -1771,15 +1767,6 @@
         }
     }
 
-    /**
-     * Toggle mute and unmute requests while keeping the same mute state
-     */
-    private void onResendMute() {
-        boolean muteState = PhoneUtils.getMute();
-        PhoneUtils.setMute(!muteState);
-        PhoneUtils.setMute(muteState);
-    }
-
     private void log(String msg) {
         Log.d(LOG_TAG, msg);
     }
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 492ccc5..d077aa8 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -16,16 +16,22 @@
 
 package com.android.phone;
 
+import com.android.ims.ImsConfig;
+import com.android.ims.ImsManager;
+import com.android.ims.ImsException;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.TelephonyProperties;
 
+import java.util.Map;
+
 import android.app.ActionBar;
 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.net.Uri;
 import android.os.AsyncResult;
@@ -33,12 +39,15 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.SystemProperties;
+import android.os.UserHandle;
 import android.os.UserManager;
 import android.preference.CheckBoxPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
+import android.preference.SwitchPreference;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -63,14 +72,17 @@
     // debug data
     private static final String LOG_TAG = "NetworkSettings";
     private static final boolean DBG = true;
+    private static final String IMS_SHARED_PREFERENCES = "IMS_PREFERENCES";
+    private static final String KEY_IMS_ON = "IMS";
     public static final int REQUEST_CODE_EXIT_ECM = 17;
 
     //String keys for preference lookup
-    private static final String BUTTON_DATA_ENABLED_KEY = "button_data_enabled_key";
     private static final String BUTTON_PREFERED_NETWORK_MODE = "preferred_network_mode_key";
     private static final String BUTTON_ROAMING_KEY = "button_roaming_key";
     private static final String BUTTON_CDMA_LTE_DATA_SERVICE_KEY = "cdma_lte_data_service_key";
     private static final String BUTTON_ENABLED_NETWORKS_KEY = "enabled_networks_key";
+    private static final String BUTTON_4G_LTE_KEY = "enhanced_4g_lte";
+    private static final String BUTTON_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
 
     static final int preferredNetworkMode = Phone.PREFERRED_NT_MODE;
 
@@ -82,8 +94,8 @@
     //UI objects
     private ListPreference mButtonPreferredNetworkMode;
     private ListPreference mButtonEnabledNetworks;
-    private CheckBoxPreference mButtonDataRoam;
-    private CheckBoxPreference mButtonDataEnabled;
+    private SwitchPreference mButtonDataRoam;
+    private SwitchPreference mButton4glte;
     private Preference mLteDataServicePref;
 
     private static final String iface = "rmnet0"; //TODO: this will go away
@@ -114,6 +126,7 @@
         }
     }
 
+    @Override
     public void onDismiss(DialogInterface dialog) {
         // Assuming that onClick gets called first
         if (!mOkClicked) {
@@ -129,7 +142,9 @@
     @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
         /** TODO: Refactor and get rid of the if's using subclasses */
-        if (mGsmUmtsOptions != null &&
+        if (preference.getKey().equals(BUTTON_4G_LTE_KEY)) {
+            return true;
+        } else if (mGsmUmtsOptions != null &&
                 mGsmUmtsOptions.preferenceTreeClick(preference) == true) {
             return true;
         } else if (mCdmaOptions != null &&
@@ -152,30 +167,6 @@
                     preferredNetworkMode);
             mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
             return true;
-        } else if (preference == mButtonDataRoam) {
-            if (DBG) log("onPreferenceTreeClick: preference == mButtonDataRoam.");
-
-            //normally called on the toggle click
-            if (mButtonDataRoam.isChecked()) {
-                // First confirm with a warning dialog about charges
-                mOkClicked = false;
-                new AlertDialog.Builder(this).setMessage(
-                        getResources().getString(R.string.roaming_warning))
-                        .setTitle(android.R.string.dialog_alert_title)
-                        .setIconAttribute(android.R.attr.alertDialogIcon)
-                        .setPositiveButton(android.R.string.yes, this)
-                        .setNegativeButton(android.R.string.no, this)
-                        .show()
-                        .setOnDismissListener(this);
-            } else {
-                mPhone.setDataRoamingEnabled(false);
-            }
-            return true;
-        } else if (preference == mButtonDataEnabled) {
-            if (DBG) log("onPreferenceTreeClick: preference == mButtonDataEnabled.");
-
-            mPhone.setDataEnabled(mButtonDataEnabled.isChecked());
-            return true;
         } else if (preference == mLteDataServicePref) {
             String tmpl = android.provider.Settings.Global.getString(getContentResolver(),
                         android.provider.Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL);
@@ -210,8 +201,23 @@
         }
     }
 
+    public boolean isIMSOn() {
+        SharedPreferences imsPref =
+            getSharedPreferences(IMS_SHARED_PREFERENCES, Context.MODE_WORLD_READABLE);
+
+        return imsPref.getBoolean(KEY_IMS_ON, true);
+    }
+
+    private void setIMS(boolean turnOn) {
+        SharedPreferences imsPref =
+            getSharedPreferences(IMS_SHARED_PREFERENCES, Context.MODE_WORLD_READABLE);
+
+        imsPref.edit().putBoolean(KEY_IMS_ON, turnOn).commit();
+    }
+
     @Override
     protected void onCreate(Bundle icicle) {
+        setTheme(R.style.Theme_Material_Settings);
         super.onCreate(icicle);
 
         mPhone = PhoneGlobals.getPhone();
@@ -226,6 +232,11 @@
 
         addPreferencesFromResource(R.xml.network_setting);
 
+        mButton4glte = (SwitchPreference)findPreference(BUTTON_4G_LTE_KEY);
+
+        mButton4glte.setOnPreferenceChangeListener(this);
+        mButton4glte.setChecked(isIMSOn());
+
         try {
             Context con = createPackageContext("com.android.systemui", 0);
             int id = con.getResources().getIdentifier("config_show4GForLTE",
@@ -239,12 +250,12 @@
         //get UI object references
         PreferenceScreen prefSet = getPreferenceScreen();
 
-        mButtonDataEnabled = (CheckBoxPreference) prefSet.findPreference(BUTTON_DATA_ENABLED_KEY);
-        mButtonDataRoam = (CheckBoxPreference) prefSet.findPreference(BUTTON_ROAMING_KEY);
+        mButtonDataRoam = (SwitchPreference) prefSet.findPreference(BUTTON_ROAMING_KEY);
         mButtonPreferredNetworkMode = (ListPreference) prefSet.findPreference(
                 BUTTON_PREFERED_NETWORK_MODE);
         mButtonEnabledNetworks = (ListPreference) prefSet.findPreference(
                 BUTTON_ENABLED_NETWORKS_KEY);
+        mButtonDataRoam.setOnPreferenceChangeListener(this);
 
         mLteDataServicePref = prefSet.findPreference(BUTTON_CDMA_LTE_DATA_SERVICE_KEY);
 
@@ -337,6 +348,19 @@
             // android.R.id.home will be triggered in onOptionsItemSelected()
             actionBar.setDisplayHomeAsUpEnabled(true);
         }
+
+        final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
+        // Enable link to CMAS app settings depending on the value in config.xml.
+        final boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
+                com.android.internal.R.bool.config_cellBroadcastAppLinks);
+        if (isSecondaryUser || !isCellBroadcastAppLinkEnabled
+                || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) {
+            PreferenceScreen root = getPreferenceScreen();
+            Preference ps = findPreference(BUTTON_CELL_BROADCAST_SETTINGS);
+            if (ps != null) {
+                root.removePreference(ps);
+            }
+        }
     }
 
     @Override
@@ -351,8 +375,6 @@
         // preferences.
         getPreferenceScreen().setEnabled(true);
 
-        mButtonDataEnabled.setChecked(mPhone.getDataEnabled());
-
         // Set UI state in onResume because a user could go home, launch some
         // app to change this setting's backend, and re-launch this settings app
         // and the UI state would be inconsistent with actual state
@@ -462,6 +484,46 @@
                 mPhone.setPreferredNetworkType(modemNetworkMode, mHandler
                         .obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE));
             }
+        } else if (preference == mButton4glte) {
+            ImsManager imsMan = ImsManager.getInstance(getBaseContext(),
+                    SubscriptionManager.getDefaultVoiceSubId());
+            SwitchPreference ltePref = (SwitchPreference)preference;
+
+            if (imsMan != null) {
+                try {
+                    if (ltePref.isChecked()) {
+                        imsMan.turnOffIms();
+                    } else {
+                        imsMan.turnOnIms();
+                    }
+                } catch(ImsException ie) {
+                    ltePref.setChecked(ltePref.isChecked());
+                    return false;
+                }
+                ltePref.setChecked(!ltePref.isChecked());
+                setIMS(ltePref.isChecked());
+            } else {
+                ltePref.setChecked(false);
+            }
+        } else if (preference == mButtonDataRoam) {
+            if (DBG) log("onPreferenceTreeClick: preference == mButtonDataRoam.");
+
+            //normally called on the toggle click
+            if (!mButtonDataRoam.isChecked()) {
+                // First confirm with a warning dialog about charges
+                mOkClicked = false;
+                new AlertDialog.Builder(this).setMessage(
+                        getResources().getString(R.string.roaming_warning))
+                        .setTitle(android.R.string.dialog_alert_title)
+                        .setIconAttribute(android.R.attr.alertDialogIcon)
+                        .setPositiveButton(android.R.string.yes, this)
+                        .setNegativeButton(android.R.string.no, this)
+                        .show()
+                        .setOnDismissListener(this);
+            } else {
+                mPhone.setDataRoamingEnabled(false);
+            }
+            return true;
         }
 
         // always let the preference setting proceed.
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index df25684..f66ebce 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -60,7 +60,6 @@
 import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.TelephonyCapabilities;
 import com.android.internal.telephony.TelephonyIntents;
-import com.android.phone.WiredHeadsetManager.WiredHeadsetListener;
 import com.android.phone.common.CallLogAsync;
 import com.android.server.sip.SipService;
 
@@ -141,13 +140,11 @@
     Phone phone;
     PhoneInterfaceManager phoneMgr;
 
-    private AudioRouter audioRouter;
     private BluetoothManager bluetoothManager;
     private CallGatewayManager callGatewayManager;
     private CallStateMonitor callStateMonitor;
     private IBluetoothHeadsetPhone mBluetoothPhone;
     private Ringer ringer;
-    private WiredHeadsetManager wiredHeadsetManager;
 
     static int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
     static boolean sVoiceCapable = true;
@@ -298,10 +295,7 @@
 
                     phoneState = mCM.getState();
                     if (phoneState == PhoneConstants.State.OFFHOOK &&
-                            !wiredHeadsetManager.isHeadsetPlugged() &&
                             !bluetoothManager.isBluetoothHeadsetAudioOn()) {
-                        audioRouter.setSpeaker(inDockMode);
-
                         PhoneUtils.turnOnSpeaker(getApplicationContext(), inDockMode, true);
                     }
                     break;
@@ -406,17 +400,11 @@
             // Monitors call activity from the telephony layer
             callStateMonitor = new CallStateMonitor(mCM);
 
-            // Manages wired headset state
-            wiredHeadsetManager = new WiredHeadsetManager(this);
-
             // Bluetooth manager
             bluetoothManager = new BluetoothManager();
 
             ringer = Ringer.init(this, bluetoothManager);
 
-            // Audio router
-            audioRouter = new AudioRouter(this, bluetoothManager, wiredHeadsetManager, mCM);
-
             phoneMgr = PhoneInterfaceManager.init(this, phone);
 
             // Create the CallNotifer singleton, which handles
@@ -527,14 +515,6 @@
         return bluetoothManager;
     }
 
-    /* package */ WiredHeadsetManager getWiredHeadsetManager() {
-        return wiredHeadsetManager;
-    }
-
-    /* package */ AudioRouter getAudioRouter() {
-        return audioRouter;
-    }
-
     /* package */ CallManager getCallManager() {
         return mCM;
     }
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 06dacb8..bc9bf63 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -104,10 +104,6 @@
     /** Speaker state, persisting between wired headset connection events */
     private static boolean sIsSpeakerEnabled = false;
 
-    /** Hash table to store mute (Boolean) values based upon the connection.*/
-    private static Hashtable<Connection, Boolean> sConnectionMuteTable =
-        new Hashtable<Connection, Boolean>();
-
     /** Static handler for the connection/mute tracking */
     private static ConnectionHandler mConnectionHandler;
 
@@ -173,70 +169,6 @@
                         answerCall(frC.ringing);
                     }
                     break;
-                case PHONE_STATE_CHANGED:
-                    AsyncResult ar = (AsyncResult) msg.obj;
-                    if (DBG) log("ConnectionHandler: updating mute state for each connection");
-
-                    CallManager cm = (CallManager) ar.userObj;
-
-                    // update the foreground connections, if there are new connections.
-                    // Have to get all foreground calls instead of the active one
-                    // because there may two foreground calls co-exist in shore period
-                    // (a racing condition based on which phone changes firstly)
-                    // Otherwise the connection may get deleted.
-                    List<Connection> fgConnections = new ArrayList<Connection>();
-                    for (Call fgCall : cm.getForegroundCalls()) {
-                        if (!fgCall.isIdle()) {
-                            fgConnections.addAll(fgCall.getConnections());
-                        }
-                    }
-                    for (Connection cn : fgConnections) {
-                        if (sConnectionMuteTable.get(cn) == null) {
-                            sConnectionMuteTable.put(cn, Boolean.FALSE);
-                        }
-                    }
-
-                    // mute is connection based operation, we need loop over
-                    // all background calls instead of the first one to update
-                    // the background connections, if there are new connections.
-                    List<Connection> bgConnections = new ArrayList<Connection>();
-                    for (Call bgCall : cm.getBackgroundCalls()) {
-                        if (!bgCall.isIdle()) {
-                            bgConnections.addAll(bgCall.getConnections());
-                        }
-                    }
-                    for (Connection cn : bgConnections) {
-                        if (sConnectionMuteTable.get(cn) == null) {
-                          sConnectionMuteTable.put(cn, Boolean.FALSE);
-                        }
-                    }
-
-                    // Check to see if there are any lingering connections here
-                    // (disconnected connections), use old-school iterators to avoid
-                    // concurrent modification exceptions.
-                    Connection cn;
-                    for (Iterator<Connection> cnlist = sConnectionMuteTable.keySet().iterator();
-                            cnlist.hasNext();) {
-                        cn = cnlist.next();
-                        if (!fgConnections.contains(cn) && !bgConnections.contains(cn)) {
-                            if (DBG) log("connection '" + cn + "' not accounted for, removing.");
-                            cnlist.remove();
-                        }
-                    }
-
-                    // Restore the mute state of the foreground call if we're not IDLE,
-                    // otherwise just clear the mute state. This is really saying that
-                    // as long as there is one or more connections, we should update
-                    // the mute state with the earliest connection on the foreground
-                    // call, and that with no connections, we should be back to a
-                    // non-mute state.
-                    if (cm.getState() != PhoneConstants.State.IDLE) {
-                        restoreMuteState();
-                    } else {
-                        setMuteInternal(cm.getFgPhone(), false);
-                    }
-
-                    break;
             }
         }
     }
@@ -328,9 +260,6 @@
                 app.mCM.acceptCall(ringingCall);
                 answered = true;
 
-                // Always reset to "unmuted" for a freshly-answered call
-                setMute(false);
-
                 setAudioMode();
 
                 // Check is phone in any dock, and turn on speaker accordingly
@@ -769,11 +698,6 @@
 
             startGetCallerInfo(context, connection, null, null, gatewayInfo);
 
-            // Always set mute to off when we are dialing an emergency number
-            if (isEmergencyCall) {
-                setMute(false);
-            }
-
             setAudioMode();
 
             if (DBG) log("about to activate speaker");
@@ -882,49 +806,6 @@
         }
     }
 
-    /**
-     * Restore the mute setting from the earliest connection of the
-     * foreground call.
-     */
-    static Boolean restoreMuteState() {
-        Phone phone = PhoneGlobals.getInstance().mCM.getFgPhone();
-
-        //get the earliest connection
-        Connection c = phone.getForegroundCall().getEarliestConnection();
-
-        // only do this if connection is not null.
-        if (c != null) {
-
-            int phoneType = phone.getPhoneType();
-
-            // retrieve the mute value.
-            Boolean shouldMute = null;
-
-            // In CDMA, mute is not maintained per Connection. Single mute apply for
-            // a call where  call can have multiple connections such as
-            // Three way and Call Waiting.  Therefore retrieving Mute state for
-            // latest connection can apply for all connection in that call
-            if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
-                shouldMute = sConnectionMuteTable.get(
-                        phone.getForegroundCall().getLatestConnection());
-            } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
-                    || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
-                    || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
-                    || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
-                shouldMute = sConnectionMuteTable.get(c);
-            }
-            if (shouldMute == null) {
-                if (DBG) log("problem retrieving mute value for this connection.");
-                shouldMute = Boolean.FALSE;
-            }
-
-            // set the mute value and return the result.
-            setMute (shouldMute.booleanValue());
-            return shouldMute;
-        }
-        return Boolean.valueOf(getMute());
-    }
-
     static void mergeCalls() {
         mergeCalls(PhoneGlobals.getInstance().mCM);
     }
@@ -2034,49 +1915,6 @@
         }
     }
 
-    /**
-     *
-     * Mute / umute the foreground phone, which has the current foreground call
-     *
-     * All muting / unmuting from the in-call UI should go through this
-     * wrapper.
-     *
-     * Wrapper around Phone.setMute() and setMicrophoneMute().
-     * It also updates the connectionMuteTable and mute icon in the status bar.
-     *
-     */
-    static void setMute(boolean muted) {
-        CallManager cm = PhoneGlobals.getInstance().mCM;
-
-        // Emergency calls never get muted.
-        if (isInEmergencyCall(cm)) {
-            muted = false;
-        }
-
-        // make the call to mute the audio
-        setMuteInternal(cm.getFgPhone(), muted);
-
-        // update the foreground connections to match.  This includes
-        // all the connections on conference calls.
-        for (Connection cn : cm.getActiveFgCall().getConnections()) {
-            if (sConnectionMuteTable.get(cn) == null) {
-                if (DBG) log("problem retrieving mute value for this connection.");
-            }
-            sConnectionMuteTable.put(cn, Boolean.valueOf(muted));
-        }
-
-        // update the background connections to match.  This includes
-        // all the connections on conference calls.
-        if (cm.hasActiveBgCall()) {
-            for (Connection cn : cm.getFirstActiveBgCall().getConnections()) {
-                if (sConnectionMuteTable.get(cn) == null) {
-                    if (DBG) log("problem retrieving mute value for this connection.");
-                }
-                sConnectionMuteTable.put(cn, Boolean.valueOf(muted));
-            }
-        }
-    }
-
     static boolean isInEmergencyCall(CallManager cm) {
         for (Connection cn : cm.getActiveFgCall().getConnections()) {
             if (PhoneNumberUtils.isLocalEmergencyNumber(PhoneGlobals.getInstance(),
@@ -2088,172 +1926,20 @@
     }
 
     /**
-     * Internally used muting function.
-     */
-    private static void setMuteInternal(Phone phone, boolean muted) {
-        final PhoneGlobals app = PhoneGlobals.getInstance();
-        Context context = phone.getContext();
-        boolean routeToAudioManager =
-            context.getResources().getBoolean(R.bool.send_mic_mute_to_AudioManager);
-        if (routeToAudioManager) {
-            AudioManager audioManager =
-                (AudioManager) phone.getContext().getSystemService(Context.AUDIO_SERVICE);
-            if (DBG) log("setMuteInternal: using setMicrophoneMute(" + muted + ")...");
-            audioManager.setMicrophoneMute(muted);
-        } else {
-            if (DBG) log("setMuteInternal: using phone.setMute(" + muted + ")...");
-            phone.setMute(muted);
-        }
-        app.getAudioRouter().onMuteChange(muted);
-    }
-
-    /**
      * Get the mute state of foreground phone, which has the current
      * foreground call
      */
     static boolean getMute() {
-        final PhoneGlobals app = PhoneGlobals.getInstance();
-
-        boolean routeToAudioManager =
-            app.getResources().getBoolean(R.bool.send_mic_mute_to_AudioManager);
-        if (routeToAudioManager) {
-            AudioManager audioManager =
-                (AudioManager) app.getSystemService(Context.AUDIO_SERVICE);
-            return audioManager.isMicrophoneMute();
-        } else {
-            return app.mCM.getMute();
-        }
+        return false;
     }
 
     /* package */ static void setAudioMode() {
-        setAudioMode(PhoneGlobals.getInstance().mCM);
     }
 
     /**
      * Sets the audio mode per current phone state.
      */
     /* package */ static void setAudioMode(CallManager cm) {
-        if (DBG) Log.d(LOG_TAG, "setAudioMode()..." + cm.getState());
-
-        Context context = PhoneGlobals.getInstance();
-        AudioManager audioManager = (AudioManager)
-                context.getSystemService(Context.AUDIO_SERVICE);
-        int modeBefore = audioManager.getMode();
-        cm.setAudioMode();
-        int modeAfter = audioManager.getMode();
-
-        if (modeBefore != modeAfter) {
-            // Enable stack dump only when actively debugging ("new Throwable()" is expensive!)
-            if (DBG_SETAUDIOMODE_STACK) Log.d(LOG_TAG, "Stack:", new Throwable("stack dump"));
-        } else {
-            if (DBG) Log.d(LOG_TAG, "setAudioMode() no change: "
-                    + audioModeToString(modeBefore));
-        }
-    }
-    private static String audioModeToString(int mode) {
-        switch (mode) {
-            case AudioManager.MODE_INVALID: return "MODE_INVALID";
-            case AudioManager.MODE_CURRENT: return "MODE_CURRENT";
-            case AudioManager.MODE_NORMAL: return "MODE_NORMAL";
-            case AudioManager.MODE_RINGTONE: return "MODE_RINGTONE";
-            case AudioManager.MODE_IN_CALL: return "MODE_IN_CALL";
-            default: return String.valueOf(mode);
-        }
-    }
-
-    /**
-     * Handles the wired headset button while in-call.
-     *
-     * This is called from the PhoneApp, not from the InCallScreen,
-     * since the HEADSETHOOK button means "mute or unmute the current
-     * call" *any* time a call is active, even if the user isn't actually
-     * on the in-call screen.
-     *
-     * @return true if we consumed the event.
-     */
-    /* package */ static boolean handleHeadsetHook(Phone phone, KeyEvent event) {
-        if (DBG) log("handleHeadsetHook()..." + event.getAction() + " " + event.getRepeatCount());
-        final PhoneGlobals app = PhoneGlobals.getInstance();
-
-        // If the phone is totally idle, we ignore HEADSETHOOK events
-        // (and instead let them fall through to the media player.)
-        if (phone.getState() == PhoneConstants.State.IDLE) {
-            return false;
-        }
-
-        // Ok, the phone is in use.
-        // The headset button button means "Answer" if an incoming call is
-        // ringing.  If not, it toggles the mute / unmute state.
-        //
-        // And in any case we *always* consume this event; this means
-        // that the usual mediaplayer-related behavior of the headset
-        // button will NEVER happen while the user is on a call.
-
-        final boolean hasRingingCall = !phone.getRingingCall().isIdle();
-        final boolean hasActiveCall = !phone.getForegroundCall().isIdle();
-        final boolean hasHoldingCall = !phone.getBackgroundCall().isIdle();
-
-        if (hasRingingCall &&
-            event.getRepeatCount() == 0 &&
-            event.getAction() == KeyEvent.ACTION_UP) {
-            // If an incoming call is ringing, answer it (just like with the
-            // CALL button):
-            int phoneType = phone.getPhoneType();
-            if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
-                answerCall(phone.getRingingCall());
-            } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
-                    || (phoneType == PhoneConstants.PHONE_TYPE_SIP)
-                    || (phoneType == PhoneConstants.PHONE_TYPE_IMS)
-                    || (phoneType == PhoneConstants.PHONE_TYPE_THIRD_PARTY)) {
-                if (hasActiveCall && hasHoldingCall) {
-                    if (DBG) log("handleHeadsetHook: ringing (both lines in use) ==> answer!");
-                    answerAndEndActive(app.mCM, phone.getRingingCall());
-                } else {
-                    if (DBG) log("handleHeadsetHook: ringing ==> answer!");
-                    // answerCall() will automatically hold the current
-                    // active call, if there is one.
-                    answerCall(phone.getRingingCall());
-                }
-            } else {
-                throw new IllegalStateException("Unexpected phone type: " + phoneType);
-            }
-        } else {
-            // No incoming ringing call.
-            if (event.isLongPress()) {
-                if (DBG) log("handleHeadsetHook: longpress -> hangup");
-                hangup(app.mCM);
-            }
-            else if (event.getAction() == KeyEvent.ACTION_UP &&
-                     event.getRepeatCount() == 0) {
-                Connection c = phone.getForegroundCall().getLatestConnection();
-                // If it is NOT an emg #, toggle the mute state. Otherwise, ignore the hook.
-                if (c != null && !PhoneNumberUtils.isLocalEmergencyNumber(
-                        PhoneGlobals.getInstance(), c.getAddress())) {
-                    if (getMute()) {
-                        if (DBG) log("handleHeadsetHook: UNmuting...");
-                        setMute(false);
-                    } else {
-                        if (DBG) log("handleHeadsetHook: muting...");
-                        setMute(true);
-                    }
-                }
-            }
-        }
-
-        // Even if the InCallScreen is the current activity, there's no
-        // need to force it to update, because (1) if we answered a
-        // ringing call, the InCallScreen will imminently get a phone
-        // state change event (causing an update), and (2) if we muted or
-        // unmuted, the setMute() call automagically updates the status
-        // bar, and there's no "mute" indication in the InCallScreen
-        // itself (other than the menu item, which only ever stays
-        // onscreen for a second anyway.)
-        // TODO: (2) isn't entirely true anymore. Once we return our result
-        // to the PhoneApp, we ask InCallScreen to update its control widgets
-        // in case we changed mute or speaker state and phones with touch-
-        // screen [toggle] buttons need to update themselves.
-
-        return true;
     }
 
     /**
@@ -2561,13 +2247,13 @@
 
             // TODO: This function should move to AudioRouter
             final BluetoothManager btManager = app.getBluetoothManager();
-            final WiredHeadsetManager wiredHeadset = app.getWiredHeadsetManager();
-            final AudioRouter audioRouter = app.getAudioRouter();
+            //final WiredHeadsetManager wiredHeadset = app.getWiredHeadsetManager();
+            //final AudioRouter audioRouter = app.getAudioRouter();
 
-            if (!wiredHeadset.isHeadsetPlugged() && !btManager.isBluetoothHeadsetAudioOn()) {
-                audioRouter.setSpeaker(true);
+            /*if (!wiredHeadset.isHeadsetPlugged() && !btManager.isBluetoothHeadsetAudioOn()) {
+                //audioRouter.setSpeaker(true);
                 activated = true;
-            }
+            }*/
         }
         return activated;
     }
diff --git a/src/com/android/phone/WiredHeadsetManager.java b/src/com/android/phone/WiredHeadsetManager.java
deleted file mode 100644
index 4f09db6..0000000
--- a/src/com/android/phone/WiredHeadsetManager.java
+++ /dev/null
@@ -1,113 +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;
-
-import com.google.android.collect.Lists;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.SystemProperties;
-import android.util.Log;
-
-import java.util.List;
-
-/**
- * Listens for and caches headset state.  Used By the AudioRouter for maintaining
- * overall audio state for use in the UI layer. Also provides method for connecting the bluetooth
- * headset to the phone call.
- */
-public class WiredHeadsetManager {
-    private static final String LOG_TAG = WiredHeadsetManager.class.getSimpleName();
-    private static final boolean DBG =
-            (PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
-    private static final boolean VDBG = (PhoneGlobals.DBG_LEVEL >= 2);
-
-    // True if a wired headset is currently plugged in, based on the state
-    // from the latest Intent.ACTION_HEADSET_PLUG broadcast we received in
-    // mReceiver.onReceive().
-    private boolean mIsHeadsetPlugged = false;
-    private final WiredHeadsetBroadcastReceiver mReceiver;
-    private final List<WiredHeadsetListener> mListeners = Lists.newArrayList();
-
-    public WiredHeadsetManager(Context context) {
-        mReceiver = new WiredHeadsetBroadcastReceiver();
-
-        // Register for misc other intent broadcasts.
-        IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
-        context.registerReceiver(mReceiver, intentFilter);
-    }
-
-    /**
-     * Returns connection state of the wires headset.
-     */
-    public boolean isHeadsetPlugged() {
-        return mIsHeadsetPlugged;
-    }
-
-    /**
-     * Add a listener for wired headset connection status.
-     */
-    public void addWiredHeadsetListener(WiredHeadsetListener listener) {
-        if (!mListeners.contains(listener)) {
-            mListeners.add(listener);
-        }
-    }
-
-    /**
-     * Called when we get an event from the system for the headset connection state.
-     */
-    private void onHeadsetConnection(boolean pluggedIn) {
-        if (DBG) {
-            Log.d(LOG_TAG, "Wired headset connected: " +  pluggedIn);
-        }
-        mIsHeadsetPlugged = pluggedIn;
-
-        notifyListeners();
-    }
-
-    private void notifyListeners() {
-        for (int i = 0; i < mListeners.size(); i++) {
-            mListeners.get(i).onWiredHeadsetConnection(mIsHeadsetPlugged);
-        }
-    }
-
-    /**
-     * Receiver for misc intent broadcasts the BluetoothManager cares about.
-     */
-    private class WiredHeadsetBroadcastReceiver extends BroadcastReceiver {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            String action = intent.getAction();
-
-            if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
-                if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_HEADSET_PLUG");
-                if (VDBG) Log.d(LOG_TAG, "    state: " + intent.getIntExtra("state", 0));
-                if (VDBG) Log.d(LOG_TAG, "    name: " + intent.getStringExtra("name"));
-                onHeadsetConnection(intent.getIntExtra("state", 0) == 1);
-            }
-        }
-    }
-
-    /**
-     * Listeners for those that want to know about the headset state.
-     */
-    public interface WiredHeadsetListener {
-        void onWiredHeadsetConnection(boolean pluggedIn);
-    }
-}