Update application for Bluetooth API changes.
Change-Id: I8351611f0f0c5eda3e423dbe7e7b53e52d75ac36
diff --git a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
index 98d387c..166088f 100644
--- a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
@@ -19,7 +19,6 @@
import com.android.settings.R;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index c1b6de3..3189810 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -19,7 +19,6 @@
import com.android.settings.R;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
index 6459950..44bc640 100644
--- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
+++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
@@ -21,7 +21,6 @@
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
-import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -49,36 +48,36 @@
}
String action = intent.getAction();
- BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE);
+ BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
BluetoothAdapter.ERROR);
mManager.setBluetoothStateInt(state);
- } else if (action.equals(BluetoothIntent.DISCOVERY_STARTED_ACTION)) {
+ } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED)) {
mManager.onScanningStateChanged(true);
- } else if (action.equals(BluetoothIntent.DISCOVERY_COMPLETED_ACTION)) {
+ } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
mManager.onScanningStateChanged(false);
- } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION)) {
- short rssi = intent.getShortExtra(BluetoothIntent.RSSI, Short.MIN_VALUE);
- int btClass = intent.getIntExtra(BluetoothIntent.CLASS, BluetoothClass.ERROR);
- String name = intent.getStringExtra(BluetoothIntent.NAME);
+ } else if (action.equals(BluetoothDevice.ACTION_FOUND)) {
+ short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
+ BluetoothClass btClass = intent.getParcelableExtra(BluetoothDevice.EXTRA_CLASS);
+ String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
mManager.getCachedDeviceManager().onDeviceAppeared(device, rssi, btClass, name);
- } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION)) {
+ } else if (action.equals(BluetoothDevice.ACTION_DISAPPEARED)) {
mManager.getCachedDeviceManager().onDeviceDisappeared(device);
- } else if (action.equals(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION)) {
+ } else if (action.equals(BluetoothDevice.ACTION_NAME_CHANGED)) {
mManager.getCachedDeviceManager().onDeviceNameUpdated(device);
- } else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) {
- int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE,
+ } else if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
+ int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
BluetoothDevice.ERROR);
mManager.getCachedDeviceManager().onBondingStateChanged(device, bondState);
- if (bondState == BluetoothDevice.BOND_NOT_BONDED) {
- int reason = intent.getIntExtra(BluetoothIntent.REASON, BluetoothDevice.ERROR);
+ if (bondState == BluetoothDevice.BOND_NONE) {
+ int reason = intent.getIntExtra(BluetoothDevice.EXTRA_REASON, BluetoothDevice.ERROR);
if (reason == BluetoothDevice.UNBOND_REASON_AUTH_REJECTED ||
reason == BluetoothDevice.UNBOND_REASON_AUTH_FAILED ||
reason == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN) {
@@ -86,9 +85,9 @@
}
}
- } else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) {
- int newState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, 0);
- int oldState = intent.getIntExtra(BluetoothIntent.HEADSET_PREVIOUS_STATE, 0);
+ } else if (action.equals(BluetoothHeadset.ACTION_STATE_CHANGED)) {
+ int newState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, 0);
+ int oldState = intent.getIntExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE, 0);
if (newState == BluetoothHeadset.STATE_DISCONNECTED &&
oldState == BluetoothHeadset.STATE_CONNECTING) {
Log.i(TAG, "Failed to connect BT headset");
@@ -97,9 +96,9 @@
mManager.getCachedDeviceManager().onProfileStateChanged(device,
Profile.HEADSET, newState);
- } else if (action.equals(BluetoothA2dp.SINK_STATE_CHANGED_ACTION)) {
- int newState = intent.getIntExtra(BluetoothA2dp.SINK_STATE, 0);
- int oldState = intent.getIntExtra(BluetoothA2dp.SINK_PREVIOUS_STATE, 0);
+ } else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
+ int newState = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE, 0);
+ int oldState = intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE, 0);
if (newState == BluetoothA2dp.STATE_DISCONNECTED &&
oldState == BluetoothA2dp.STATE_CONNECTING) {
Log.i(TAG, "Failed to connect BT A2DP");
@@ -108,7 +107,7 @@
mManager.getCachedDeviceManager().onProfileStateChanged(device,
Profile.A2DP, newState);
- } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_CLASS_UPDATED_ACTION)) {
+ } else if (action.equals(BluetoothDevice.ACTION_CLASS_CHANGED)) {
mManager.getCachedDeviceManager().onBtClassChanged(device);
}
@@ -126,19 +125,19 @@
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
// Discovery broadcasts
- filter.addAction(BluetoothIntent.DISCOVERY_STARTED_ACTION);
- filter.addAction(BluetoothIntent.DISCOVERY_COMPLETED_ACTION);
- filter.addAction(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION);
- filter.addAction(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION);
- filter.addAction(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION);
+ filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
+ filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
+ filter.addAction(BluetoothDevice.ACTION_DISAPPEARED);
+ filter.addAction(BluetoothDevice.ACTION_FOUND);
+ filter.addAction(BluetoothDevice.ACTION_NAME_CHANGED);
// Pairing broadcasts
- filter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION);
+ filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
// Fine-grained state broadcasts
- filter.addAction(BluetoothA2dp.SINK_STATE_CHANGED_ACTION);
- filter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION);
- filter.addAction(BluetoothIntent.REMOTE_DEVICE_CLASS_UPDATED_ACTION);
+ filter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
+ filter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
+ filter.addAction(BluetoothDevice.ACTION_CLASS_CHANGED);
mManager.getContext().registerReceiver(mBroadcastReceiver, filter);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothNamePreference.java b/src/com/android/settings/bluetooth/BluetoothNamePreference.java
index 4a2358f..89f801b 100644
--- a/src/com/android/settings/bluetooth/BluetoothNamePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothNamePreference.java
@@ -20,7 +20,6 @@
import android.app.Dialog;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -46,7 +45,7 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(BluetoothIntent.NAME_CHANGED_ACTION)) {
+ if (action.equals(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) {
setSummaryToName();
} else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) &&
(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR) ==
@@ -67,7 +66,7 @@
public void resume() {
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
- filter.addAction(BluetoothIntent.NAME_CHANGED_ACTION);
+ filter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
getContext().registerReceiver(mReceiver, filter);
// Make sure the OK button is disabled (if necessary) after rotation
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
index 091ad27..04b3b6e 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
@@ -16,9 +16,7 @@
package com.android.settings.bluetooth;
-import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -63,11 +61,11 @@
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (!BluetoothIntent.PAIRING_CANCEL_ACTION.equals(intent.getAction())) {
+ if (!BluetoothDevice.ACTION_PAIRING_CANCEL.equals(intent.getAction())) {
return;
}
- BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE);
+ BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device == null || device.equals(mDevice)) {
onReceivedPairingCanceled();
}
@@ -79,25 +77,25 @@
super.onCreate(savedInstanceState);
Intent intent = getIntent();
- if (!intent.getAction().equals(BluetoothIntent.PAIRING_REQUEST_ACTION))
+ if (!intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST))
{
Log.e(TAG,
"Error: this activity may be started only with intent " +
- BluetoothIntent.PAIRING_REQUEST_ACTION);
+ BluetoothDevice.ACTION_PAIRING_REQUEST);
finish();
}
mLocalManager = LocalBluetoothManager.getInstance(this);
- mDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE);
- mType = intent.getIntExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothClass.ERROR);
+ mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ mType = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR);
if (mType == BluetoothDevice.PAIRING_VARIANT_PIN) {
createUserEntryDialog();
} else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY) {
createUserEntryDialog();
} else if (mType == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION){
int passkey =
- intent.getIntExtra(BluetoothIntent.PASSKEY, BluetoothClass.ERROR);
- if (passkey == BluetoothClass.ERROR) {
+ intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR);
+ if (passkey == BluetoothDevice.ERROR) {
Log.e(TAG, "Invalid ConfirmationPasskey received, not showing any dialog");
return;
}
@@ -111,7 +109,7 @@
* Leave this registered through pause/resume since we still want to
* finish the activity in the background if pairing is canceled.
*/
- registerReceiver(mReceiver, new IntentFilter(BluetoothIntent.PAIRING_CANCEL_ACTION));
+ registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_PAIRING_CANCEL));
}
private void createUserEntryDialog() {
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
index e938709..8727806 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
@@ -23,7 +23,6 @@
import android.app.PendingIntent;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -43,22 +42,23 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(BluetoothIntent.PAIRING_REQUEST_ACTION)) {
+ if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
LocalBluetoothManager localManager = LocalBluetoothManager.getInstance(context);
BluetoothDevice device =
- intent.getParcelableExtra(BluetoothIntent.DEVICE);
- int type = intent.getIntExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothClass.ERROR);
+ intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
+ BluetoothDevice.ERROR);
Intent pairingIntent = new Intent();
pairingIntent.setClass(context, BluetoothPairingDialog.class);
- pairingIntent.putExtra(BluetoothIntent.DEVICE, device);
- pairingIntent.putExtra(BluetoothIntent.PAIRING_VARIANT, type);
+ pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+ pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
if (type == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION) {
- int passkey = intent.getIntExtra(BluetoothIntent.PASSKEY, BluetoothClass.ERROR);
- pairingIntent.putExtra(BluetoothIntent.PASSKEY, passkey);
+ int passkey = intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR);
+ pairingIntent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey);
}
- pairingIntent.setAction(BluetoothIntent.PAIRING_REQUEST_ACTION);
+ pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (localManager.getForegroundActivity() != null) {
@@ -77,7 +77,7 @@
PendingIntent pending = PendingIntent.getActivity(context, 0,
pairingIntent, PendingIntent.FLAG_ONE_SHOT);
- String name = intent.getStringExtra(BluetoothIntent.NAME);
+ String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
if (TextUtils.isEmpty(name)) {
name = device.getName();
}
@@ -93,7 +93,7 @@
manager.notify(NOTIFICATION_ID, notification);
}
- } else if (action.equals(BluetoothIntent.PAIRING_CANCEL_ACTION)) {
+ } else if (action.equals(BluetoothDevice.ACTION_PAIRING_CANCEL)) {
// Remove the notification
NotificationManager manager = (NotificationManager) context
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 0d2ebd7..9999e1c 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -25,7 +25,7 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothIntent;
+import android.bluetooth.BluetoothDevicePicker;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -88,12 +88,12 @@
if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
onBluetoothStateChanged(mLocalManager.getBluetoothState());
- } else if (intent.getAction().equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)
+ } else if (intent.getAction().equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)
&& mScreenType == SCREEN_TYPE_DEVICEPICKER) {
int bondState = intent
- .getIntExtra(BluetoothIntent.BOND_STATE, BluetoothDevice.ERROR);
+ .getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
if (bondState == BluetoothDevice.BOND_BONDED) {
- BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE);
+ BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
sendDevicePickedIntent(device);
finish();
}
@@ -117,17 +117,17 @@
// result from the BT list.
// -DEVICE_PICKER_NEED_AUTH: to show if bonding procedure needed.
- mFilterType = BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_ALL;
+ mFilterType = BluetoothDevicePicker.FILTER_TYPE_ALL;
Intent intent = getIntent();
String action = intent.getAction();
- if (action.equals(BluetoothIntent.DEVICE_PICKER_DEVICE_PICKER)) {
+ if (action.equals(BluetoothDevicePicker.ACTION_LAUNCH)) {
mScreenType = SCREEN_TYPE_DEVICEPICKER;
- mNeedAuth = intent.getBooleanExtra(BluetoothIntent.DEVICE_PICKER_NEED_AUTH, false);
- mFilterType = intent.getIntExtra(BluetoothIntent.DEVICE_PICKER_FILTER_TYPE,
- BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_ALL);
- mLaunchPackage = intent.getStringExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_PACKAGE);
- mLaunchClass = intent.getStringExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_CLASS);
+ mNeedAuth = intent.getBooleanExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false);
+ mFilterType = intent.getIntExtra(BluetoothDevicePicker.EXTRA_FILTER_TYPE,
+ BluetoothDevicePicker.FILTER_TYPE_ALL);
+ mLaunchPackage = intent.getStringExtra(BluetoothDevicePicker.EXTRA_LAUNCH_PACKAGE);
+ mLaunchClass = intent.getStringExtra(BluetoothDevicePicker.EXTRA_LAUNCH_CLASS);
setTitle(getString(R.string.device_picker));
addPreferencesFromResource(R.xml.device_picker);
@@ -175,7 +175,7 @@
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
- intentFilter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION);
+ intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
registerReceiver(mReceiver, intentFilter);
mLocalManager.setForegroundActivity(this);
}
@@ -305,11 +305,11 @@
}
List<Profile> profiles = cachedDevice.getProfiles();
- if (mFilterType == BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_TRANSFER){
+ if (mFilterType == BluetoothDevicePicker.FILTER_TYPE_TRANSFER){
if(profiles.contains(Profile.OPP)){
createDevicePreference(cachedDevice);
}
- } else if (mFilterType == BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_AUDIO) {
+ } else if (mFilterType == BluetoothDevicePicker.FILTER_TYPE_AUDIO) {
if((profiles.contains(Profile.A2DP)) || (profiles.contains(Profile.HEADSET))){
createDevicePreference(cachedDevice);
}
@@ -346,11 +346,11 @@
}
private void sendDevicePickedIntent(BluetoothDevice device) {
- Intent intent = new Intent(BluetoothIntent.DEVICE_PICKER_DEVICE_SELECTED);
+ Intent intent = new Intent(BluetoothDevicePicker.ACTION_DEVICE_SELECTED);
if (mLaunchPackage != null && mLaunchClass != null) {
intent.setClassName(mLaunchPackage, mLaunchClass);
}
- intent.putExtra(BluetoothIntent.DEVICE, device);
+ intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
sendBroadcast(intent);
}
}
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 9ee2f36..fdba11b 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -59,7 +59,7 @@
private final BluetoothDevice mDevice;
private String mName;
private short mRssi;
- private int mBtClass = BluetoothClass.ERROR;
+ private BluetoothClass mBtClass;
private List<Profile> mProfiles = new ArrayList<Profile>();
@@ -301,7 +301,7 @@
askDisconnect();
} else if (bondState == BluetoothDevice.BOND_BONDED) {
connect();
- } else if (bondState == BluetoothDevice.BOND_NOT_BONDED) {
+ } else if (bondState == BluetoothDevice.BOND_NONE) {
pair();
}
}
@@ -424,7 +424,7 @@
}
private boolean ensurePaired() {
- if (getBondState() == BluetoothDevice.BOND_NOT_BONDED) {
+ if (getBondState() == BluetoothDevice.BOND_NONE) {
pair();
return false;
} else {
@@ -577,7 +577,7 @@
}
public int getBtClassDrawable() {
- switch (BluetoothClass.Device.Major.getDeviceMajor(mBtClass)) {
+ switch (mBtClass.getMajorDeviceClass()) {
case BluetoothClass.Device.Major.COMPUTER:
return R.drawable.ic_bt_laptop;
@@ -599,7 +599,7 @@
*/
private void fetchBtClass() {
mBtClass = mDevice.getBluetoothClass();
- if (mBtClass != BluetoothClass.ERROR) {
+ if (mBtClass != null) {
LocalBluetoothProfileManager.fill(mBtClass, mProfiles);
}
}
@@ -613,8 +613,8 @@
dispatchAttributesChanged();
}
- public void setBtClass(int btClass) {
- if (mBtClass != btClass && btClass != BluetoothClass.ERROR) {
+ public void setBtClass(BluetoothClass btClass) {
+ if (btClass != null && mBtClass != btClass) {
mBtClass = btClass;
LocalBluetoothProfileManager.fill(mBtClass, mProfiles);
dispatchAttributesChanged();
@@ -699,7 +699,7 @@
menu.setHeaderTitle(getName());
- if (bondState == BluetoothDevice.BOND_NOT_BONDED) { // Not paired and not connected
+ if (bondState == BluetoothDevice.BOND_NONE) { // Not paired and not connected
menu.add(0, CONTEXT_ITEM_CONNECT, 0, R.string.bluetooth_device_context_pair_connect);
} else { // Paired
if (isConnected) { // Paired and connected
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
index c79f2b4..e3f048a 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
@@ -17,6 +17,7 @@
package com.android.settings.bluetooth;
import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.util.Log;
@@ -74,8 +75,8 @@
}
}
- public synchronized void onDeviceAppeared(BluetoothDevice device, short rssi, int btClass,
- String name) {
+ public synchronized void onDeviceAppeared(BluetoothDevice device, short rssi,
+ BluetoothClass btClass, String name) {
boolean deviceAdded = false;
CachedBluetoothDevice cachedDevice = findDevice(device);
@@ -104,7 +105,7 @@
}
private void checkForDeviceRemoval(CachedBluetoothDevice cachedDevice) {
- if (cachedDevice.getBondState() == BluetoothDevice.BOND_NOT_BONDED &&
+ if (cachedDevice.getBondState() == BluetoothDevice.BOND_NONE &&
!cachedDevice.isVisible()) {
// If device isn't paired, remove it altogether
mCachedDevices.remove(cachedDevice);
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
index a5a0140..9ec95ab 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
@@ -27,7 +27,6 @@
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
index 6f343c1..a59d229 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
@@ -81,18 +81,18 @@
* @param btClass The class
* @param profiles The list of profiles to fill
*/
- public static void fill(int btClass, List<Profile> profiles) {
+ public static void fill(BluetoothClass btClass, List<Profile> profiles) {
profiles.clear();
- if (BluetoothClass.doesClassMatch(btClass, BluetoothClass.PROFILE_HEADSET)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
profiles.add(Profile.HEADSET);
}
- if (BluetoothClass.doesClassMatch(btClass, BluetoothClass.PROFILE_A2DP)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
profiles.add(Profile.A2DP);
}
- if (BluetoothClass.doesClassMatch(btClass, BluetoothClass.PROFILE_OPP)) {
+ if (btClass.doesClassMatch(BluetoothClass.PROFILE_OPP)) {
profiles.add(Profile.OPP);
}
}
diff --git a/src/com/android/settings/bluetooth/SettingsBtStatus.java b/src/com/android/settings/bluetooth/SettingsBtStatus.java
index d2cbef5..3a93931 100644
--- a/src/com/android/settings/bluetooth/SettingsBtStatus.java
+++ b/src/com/android/settings/bluetooth/SettingsBtStatus.java
@@ -72,7 +72,7 @@
return R.string.bluetooth_paired;
case BluetoothDevice.BOND_BONDING:
return R.string.bluetooth_pairing;
- case BluetoothDevice.BOND_NOT_BONDED:
+ case BluetoothDevice.BOND_NONE:
return R.string.bluetooth_not_connected;
default:
return 0;