diff --git a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java index 17e5105a409..db3ccf827d3 100644 --- a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java +++ b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java @@ -55,8 +55,8 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (BluetoothIntent.SCAN_MODE_CHANGED_ACTION.equals(intent.getAction())) { - int mode = intent.getIntExtra(BluetoothIntent.SCAN_MODE, BluetoothError.ERROR); + if (BluetoothAdapter.ACTION_SCAN_MODE_CHANGED.equals(intent.getAction())) { + int mode = intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothError.ERROR); if (mode != BluetoothError.ERROR) { handleModeChanged(mode); } @@ -89,7 +89,7 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan return; } - IntentFilter filter = new IntentFilter(BluetoothIntent.SCAN_MODE_CHANGED_ACTION); + IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED); mContext.registerReceiver(mReceiver, filter); mCheckBoxPreference.setOnPreferenceChangeListener(this); diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java index 2808ce3f46d..355ea1393ac 100644 --- a/src/com/android/settings/bluetooth/BluetoothEnabler.java +++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java @@ -49,7 +49,7 @@ public class BluetoothEnabler implements Preference.OnPreferenceChangeListener { private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - int state = intent.getIntExtra(BluetoothIntent.BLUETOOTH_STATE, + int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothError.ERROR); handleStateChanged(state); } @@ -76,13 +76,13 @@ public class BluetoothEnabler implements Preference.OnPreferenceChangeListener { int state = mLocalManager.getBluetoothState(); // This is the widget enabled state, not the preference toggled state - mCheckBoxPreference.setEnabled(state == BluetoothAdapter.BLUETOOTH_STATE_ON || - state == BluetoothAdapter.BLUETOOTH_STATE_OFF); + mCheckBoxPreference.setEnabled(state == BluetoothAdapter.STATE_ON || + state == BluetoothAdapter.STATE_OFF); // BT state is not a sticky broadcast, so set it manually handleStateChanged(state); mContext.registerReceiver(mReceiver, - new IntentFilter(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION)); + new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); mCheckBoxPreference.setOnPreferenceChangeListener(this); } @@ -112,18 +112,18 @@ public class BluetoothEnabler implements Preference.OnPreferenceChangeListener { private void handleStateChanged(int state) { - if (state == BluetoothAdapter.BLUETOOTH_STATE_OFF || - state == BluetoothAdapter.BLUETOOTH_STATE_ON) { - mCheckBoxPreference.setChecked(state == BluetoothAdapter.BLUETOOTH_STATE_ON); - mCheckBoxPreference.setSummary(state == BluetoothAdapter.BLUETOOTH_STATE_OFF ? + if (state == BluetoothAdapter.STATE_OFF || + state == BluetoothAdapter.STATE_ON) { + mCheckBoxPreference.setChecked(state == BluetoothAdapter.STATE_ON); + mCheckBoxPreference.setSummary(state == BluetoothAdapter.STATE_OFF ? mOriginalSummary : null); mCheckBoxPreference.setEnabled(isEnabledByDependency()); - } else if (state == BluetoothAdapter.BLUETOOTH_STATE_TURNING_ON || - state == BluetoothAdapter.BLUETOOTH_STATE_TURNING_OFF) { - mCheckBoxPreference.setSummary(state == BluetoothAdapter.BLUETOOTH_STATE_TURNING_ON + } else if (state == BluetoothAdapter.STATE_TURNING_ON || + state == BluetoothAdapter.STATE_TURNING_OFF) { + mCheckBoxPreference.setSummary(state == BluetoothAdapter.STATE_TURNING_ON ? R.string.wifi_starting : R.string.wifi_stopping); diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java index fdc217a9f5f..01d61bb7c45 100644 --- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java +++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java @@ -17,6 +17,7 @@ package com.android.settings.bluetooth; import android.bluetooth.BluetoothA2dp; +import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothError; @@ -51,8 +52,8 @@ public class BluetoothEventRedirector { String action = intent.getAction(); BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE); - if (action.equals(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION)) { - int state = intent.getIntExtra(BluetoothIntent.BLUETOOTH_STATE, + if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { + int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothError.ERROR); mManager.setBluetoothStateInt(state); } else if (action.equals(BluetoothIntent.DISCOVERY_STARTED_ACTION)) { @@ -123,7 +124,7 @@ public class BluetoothEventRedirector { IntentFilter filter = new IntentFilter(); // Bluetooth on/off broadcasts - filter.addAction(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION); + filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); // Discovery broadcasts filter.addAction(BluetoothIntent.DISCOVERY_STARTED_ACTION); diff --git a/src/com/android/settings/bluetooth/BluetoothNamePreference.java b/src/com/android/settings/bluetooth/BluetoothNamePreference.java index 1e79704d369..c956f5a19e6 100644 --- a/src/com/android/settings/bluetooth/BluetoothNamePreference.java +++ b/src/com/android/settings/bluetooth/BluetoothNamePreference.java @@ -49,9 +49,9 @@ public class BluetoothNamePreference extends EditTextPreference implements TextW String action = intent.getAction(); if (action.equals(BluetoothIntent.NAME_CHANGED_ACTION)) { setSummaryToName(); - } else if (action.equals(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION) && - (intent.getIntExtra(BluetoothIntent.BLUETOOTH_STATE, - BluetoothError.ERROR) == BluetoothAdapter.BLUETOOTH_STATE_ON)) { + } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) && + (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, + BluetoothError.ERROR) == BluetoothAdapter.STATE_ON)) { setSummaryToName(); } } @@ -67,7 +67,7 @@ public class BluetoothNamePreference extends EditTextPreference implements TextW public void resume() { IntentFilter filter = new IntentFilter(); - filter.addAction(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION); + filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothIntent.NAME_CHANGED_ACTION); getContext().registerReceiver(mReceiver, filter); diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 0525ec7cab0..810e07b8c3b 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -87,7 +87,7 @@ public class BluetoothSettings extends PreferenceActivity public void onReceive(Context context, Intent intent) { // TODO: put this in callback instead of receiving - if (intent.getAction().equals(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION)) { + if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { onBluetoothStateChanged(mLocalManager.getBluetoothState()); } else if (intent.getAction().equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION) && mScreenType == SCREEN_TYPE_DEVICEPICKER) { @@ -175,7 +175,7 @@ public class BluetoothSettings extends PreferenceActivity mLocalManager.startScanning(false); IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION); + intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION); registerReceiver(mReceiver, intentFilter); mLocalManager.setForegroundActivity(this); @@ -339,9 +339,9 @@ public class BluetoothSettings extends PreferenceActivity private void onBluetoothStateChanged(int bluetoothState) { // When bluetooth is enabled (and we are in the activity, which we are), // we should start a scan - if (bluetoothState == BluetoothAdapter.BLUETOOTH_STATE_ON) { + if (bluetoothState == BluetoothAdapter.STATE_ON) { mLocalManager.startScanning(false); - } else if (bluetoothState == BluetoothAdapter.BLUETOOTH_STATE_OFF) { + } else if (bluetoothState == BluetoothAdapter.STATE_OFF) { mDeviceList.setProgress(false); } } diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index d13f77c03d0..65f4645d7db 100644 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -20,6 +20,7 @@ import android.app.AlertDialog; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothError; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -322,7 +323,7 @@ public class CachedBluetoothDevice implements Comparable int status = profileManager.getConnectionStatus(cachedDevice.mDevice); if (SettingsBtStatus.isConnectionStatusConnected(status)) { if (profileManager.disconnect(cachedDevice.mDevice) == - BluetoothAdapter.RESULT_SUCCESS) { + BluetoothError.SUCCESS) { return true; } } @@ -407,7 +408,7 @@ public class CachedBluetoothDevice implements Comparable LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile); int status = profileManager.getConnectionStatus(cachedDevice.mDevice); if (!SettingsBtStatus.isConnectionStatusConnected(status)) { - if (profileManager.connect(cachedDevice.mDevice) == BluetoothAdapter.RESULT_SUCCESS) { + if (profileManager.connect(cachedDevice.mDevice) == BluetoothError.SUCCESS) { return true; } Log.i(TAG, "Failed to connect " + profile.toString() + " to " + cachedDevice.mName); @@ -690,7 +691,7 @@ public class CachedBluetoothDevice implements Comparable public void onCreateContextMenu(ContextMenu menu) { // No context menu if it is busy (none of these items are applicable if busy) - if (mLocalManager.getBluetoothState() != BluetoothAdapter.BLUETOOTH_STATE_ON || isBusy()) { + if (mLocalManager.getBluetoothState() != BluetoothAdapter.STATE_ON || isBusy()) { return; } diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java index d4b55c13e29..77e16f57030 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java @@ -196,10 +196,10 @@ public class LocalBluetoothManager { void setBluetoothStateInt(int state) { mState = state; - if (state == BluetoothAdapter.BLUETOOTH_STATE_ON || - state == BluetoothAdapter.BLUETOOTH_STATE_OFF) { + if (state == BluetoothAdapter.STATE_ON || + state == BluetoothAdapter.STATE_OFF) { mCachedDeviceManager.onBluetoothStateChanged(state == - BluetoothAdapter.BLUETOOTH_STATE_ON); + BluetoothAdapter.STATE_ON); } } @@ -208,8 +208,8 @@ public class LocalBluetoothManager { if (mAdapter != null) { bluetoothState = mAdapter.isEnabled() - ? BluetoothAdapter.BLUETOOTH_STATE_ON - : BluetoothAdapter.BLUETOOTH_STATE_OFF; + ? BluetoothAdapter.STATE_ON + : BluetoothAdapter.STATE_OFF; } else { bluetoothState = BluetoothError.ERROR; } @@ -224,8 +224,8 @@ public class LocalBluetoothManager { if (wasSetStateSuccessful) { setBluetoothStateInt(enabled - ? BluetoothAdapter.BLUETOOTH_STATE_TURNING_ON - : BluetoothAdapter.BLUETOOTH_STATE_TURNING_OFF); + ? BluetoothAdapter.STATE_TURNING_ON + : BluetoothAdapter.STATE_TURNING_OFF); } else { if (V) { Log.v(TAG, diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java index 2e3f305af02..eddeb634b5f 100644 --- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java +++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java @@ -379,9 +379,9 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider { } } int state = mLocalBluetoothManager.getBluetoothState(); - if (state == BluetoothAdapter.BLUETOOTH_STATE_OFF) { + if (state == BluetoothAdapter.STATE_OFF) { return STATE_DISABLED; - } else if (state == BluetoothAdapter.BLUETOOTH_STATE_ON) { + } else if (state == BluetoothAdapter.STATE_ON) { return STATE_ENABLED; } else { return STATE_INTERMEDIATE;