diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ede5e2deb25..e9f39a574a5 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2004,18 +2004,6 @@
-
-
-
-
-
-
-
-
-
-
-
profiles = cachedDevice.getConnectableProfiles();
- for (LocalBluetoothProfile profile : profiles) {
- if (profile.getPreferred(device) == BluetoothProfile.PRIORITY_AUTO_CONNECT) {
- cachedDevice.connect(false);
- return;
- }
- }
- }
-
- private synchronized void applyBtSettings(BluetoothDevice device, int startId) {
- if (device == null || mProfiles == null || mCheckedItems == null
- || mLocalAdapter == null) {
- return;
- }
-
- // Turn on BT if something is enabled
- for (boolean enable : mCheckedItems) {
- if (enable) {
- int btState = mLocalAdapter.getBluetoothState();
- if (DEBUG) {
- Log.d(TAG, "BtState = " + btState);
- }
- // May have race condition as the phone comes in and out and in the dock.
- // Always turn on BT
- mLocalAdapter.enable();
-
- // if adapter was previously OFF, TURNING_OFF, or TURNING_ON
- if (btState != BluetoothAdapter.STATE_ON) {
- if (mPendingDevice != null && mPendingDevice.equals(mDevice)) {
- return;
- }
-
- mPendingDevice = device;
- mPendingStartId = startId;
- if (btState != BluetoothAdapter.STATE_TURNING_ON) {
- getPrefs().edit().putBoolean(
- KEY_DISABLE_BT_WHEN_UNDOCKED, true).apply();
- }
- return;
- }
- }
- }
-
- mPendingDevice = null;
-
- boolean callConnect = false;
- CachedBluetoothDevice cachedDevice = getCachedBluetoothDevice(
- device);
- for (int i = 0; i < mProfiles.length; i++) {
- LocalBluetoothProfile profile = mProfiles[i];
- if (DEBUG) Log.d(TAG, profile.toString() + " = " + mCheckedItems[i]);
-
- if (mCheckedItems[i]) {
- // Checked but not connected
- callConnect = true;
- } else if (!mCheckedItems[i]) {
- // Unchecked, may or may not be connected.
- int status = profile.getConnectionStatus(cachedDevice.getDevice());
- if (status == BluetoothProfile.STATE_CONNECTED) {
- if (DEBUG) Log.d(TAG, "applyBtSettings - Disconnecting");
- cachedDevice.disconnect(mProfiles[i]);
- }
- }
- profile.setPreferred(device, mCheckedItems[i]);
- if (DEBUG) {
- if (mCheckedItems[i] != profile.isPreferred(device)) {
- Log.e(TAG, "Can't save preferred value");
- }
- }
- }
-
- if (callConnect) {
- if (DEBUG) Log.d(TAG, "applyBtSettings - Connecting");
- cachedDevice.connect(false);
- }
- }
-
- private synchronized void handleDocked(BluetoothDevice device, int state,
- int startId) {
- if (device != null &&
- LocalBluetoothPreferences.getDockAutoConnectSetting(this, device.getAddress())) {
- // Setting == auto connect
- initBtSettings(device, state, false);
- applyBtSettings(mDevice, startId);
- } else {
- createDialog(device, state, startId);
- }
- }
-
- private synchronized void handleUndocked(BluetoothDevice device) {
- mRunnable = null;
- mProfileManager.removeServiceListener(this);
- if (mDialog != null) {
- mDialog.dismiss();
- mDialog = null;
- }
- mDevice = null;
- mPendingDevice = null;
- if (device != null) {
- CachedBluetoothDevice cachedDevice = getCachedBluetoothDevice(device);
- cachedDevice.disconnect();
- }
- }
-
- private CachedBluetoothDevice getCachedBluetoothDevice(BluetoothDevice device) {
- CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
- if (cachedDevice == null) {
- cachedDevice = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, device);
- }
- return cachedDevice;
- }
-
- public synchronized void onServiceConnected() {
- if (mRunnable != null) {
- mRunnable.run();
- mRunnable = null;
- mProfileManager.removeServiceListener(this);
- }
- }
-
- public void onServiceDisconnected() {
- // FIXME: shouldn't I do something on service disconnected too?
- }
-
- public static class DockBluetoothCallback implements BluetoothCallback {
- private final Context mContext;
-
- public DockBluetoothCallback(Context context) {
- mContext = context;
- }
-
- public void onBluetoothStateChanged(int bluetoothState) { }
- public void onDeviceAdded(CachedBluetoothDevice cachedDevice) { }
- public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) { }
- public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { }
- public void onScanningStateChanged(boolean started) { }
-
- @Override
- public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
- BluetoothDevice device = cachedDevice.getDevice();
- if (bondState == BluetoothDevice.BOND_NONE) {
- if (device.isBluetoothDock()) {
- // After a dock is unpaired, we will forget the settings
- LocalBluetoothPreferences
- .removeDockAutoConnectSetting(mContext, device.getAddress());
-
- // if the device is undocked, remove it from the list as well
- if (!device.getAddress().equals(getDockedDeviceAddress(mContext))) {
- cachedDevice.setVisible(false);
- }
- }
- }
- }
-
- // This can't be called from a broadcast receiver where the filter is set in the Manifest.
- private static String getDockedDeviceAddress(Context context) {
- // This works only because these broadcast intents are "sticky"
- Intent i = context.registerReceiver(null, new IntentFilter(Intent.ACTION_DOCK_EVENT));
- if (i != null) {
- int state = i.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED);
- if (state != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
- BluetoothDevice device = i.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if (device != null) {
- return device.getAddress();
- }
- }
- }
- return null;
- }
- }
-}
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
index 6a0bdcf4b21..19eb2005f1c 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
@@ -44,8 +44,6 @@ final class LocalBluetoothPreferences {
private static final String KEY_LAST_SELECTED_DEVICE_TIME = "last_selected_device_time";
- private static final String KEY_DOCK_AUTO_CONNECT = "auto_connect_to_dock";
-
private static final String KEY_DISCOVERABLE_END_TIMESTAMP = "discoverable_end_timestamp";
private LocalBluetoothPreferences() {
@@ -147,25 +145,4 @@ final class LocalBluetoothPreferences {
editor.putLong(KEY_DISCOVERABLE_END_TIMESTAMP, endTimestamp);
editor.apply();
}
-
- static boolean hasDockAutoConnectSetting(Context context, String addr) {
- return getSharedPreferences(context).contains(KEY_DOCK_AUTO_CONNECT + addr);
- }
-
- static boolean getDockAutoConnectSetting(Context context, String addr) {
- return getSharedPreferences(context).getBoolean(KEY_DOCK_AUTO_CONNECT + addr,
- false);
- }
-
- static void saveDockAutoConnectSetting(Context context, String addr, boolean autoConnect) {
- SharedPreferences.Editor editor = getSharedPreferences(context).edit();
- editor.putBoolean(KEY_DOCK_AUTO_CONNECT + addr, autoConnect);
- editor.apply();
- }
-
- static void removeDockAutoConnectSetting(Context context, String addr) {
- SharedPreferences.Editor editor = getSharedPreferences(context).edit();
- editor.remove(KEY_DOCK_AUTO_CONNECT + addr);
- editor.apply();
- }
}
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index b6928521e23..4fa44b44549 100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -24,7 +24,6 @@ import android.content.DialogInterface;
import android.widget.Toast;
import com.android.settings.R;
-import com.android.settings.bluetooth.DockService.DockBluetoothCallback;
import com.android.settings.search.Index;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -85,11 +84,6 @@ public final class Utils {
// TODO: wire this up to show connection errors...
static void showConnectingError(Context context, String name) {
- // if (!mIsConnectingErrorPossible) {
- // return;
- // }
- // mIsConnectingErrorPossible = false;
-
showError(context, name, R.string.bluetooth_connecting_error_message);
}
@@ -147,8 +141,6 @@ public final class Utils {
@Override
public void onBluetoothManagerInitialized(Context appContext,
LocalBluetoothManager bluetoothManager) {
- bluetoothManager.getEventManager().registerCallback(
- new DockBluetoothCallback(appContext));
com.android.settingslib.bluetooth.Utils.setErrorListener(mErrorListener);
}
};