am 16cc8631: Update application for Bluetooth API changes.

Merge commit '16cc86315d7a8e1f6a0f3083d0a810a7cb097832' into eclair-plus-aosp

* commit '16cc86315d7a8e1f6a0f3083d0a810a7cb097832':
  Update application for Bluetooth API changes.
This commit is contained in:
Nick Pelly
2009-09-10 19:01:20 -07:00
committed by Android Git Automerger
12 changed files with 84 additions and 90 deletions

View File

@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
import com.android.settings.R; import com.android.settings.R;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;

View File

@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
import com.android.settings.R; import com.android.settings.R;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;

View File

@@ -21,7 +21,6 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -49,36 +48,36 @@ public class BluetoothEventRedirector {
} }
String action = intent.getAction(); String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
BluetoothAdapter.ERROR); BluetoothAdapter.ERROR);
mManager.setBluetoothStateInt(state); mManager.setBluetoothStateInt(state);
} else if (action.equals(BluetoothIntent.DISCOVERY_STARTED_ACTION)) { } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED)) {
mManager.onScanningStateChanged(true); mManager.onScanningStateChanged(true);
} else if (action.equals(BluetoothIntent.DISCOVERY_COMPLETED_ACTION)) { } else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
mManager.onScanningStateChanged(false); mManager.onScanningStateChanged(false);
} else if (action.equals(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION)) { } else if (action.equals(BluetoothDevice.ACTION_FOUND)) {
short rssi = intent.getShortExtra(BluetoothIntent.RSSI, Short.MIN_VALUE); short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
int btClass = intent.getIntExtra(BluetoothIntent.CLASS, BluetoothClass.ERROR); BluetoothClass btClass = intent.getParcelableExtra(BluetoothDevice.EXTRA_CLASS);
String name = intent.getStringExtra(BluetoothIntent.NAME); String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
mManager.getCachedDeviceManager().onDeviceAppeared(device, rssi, btClass, 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); 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); mManager.getCachedDeviceManager().onDeviceNameUpdated(device);
} else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) { } else if (action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE, int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
BluetoothDevice.ERROR); BluetoothDevice.ERROR);
mManager.getCachedDeviceManager().onBondingStateChanged(device, bondState); mManager.getCachedDeviceManager().onBondingStateChanged(device, bondState);
if (bondState == BluetoothDevice.BOND_NOT_BONDED) { if (bondState == BluetoothDevice.BOND_NONE) {
int reason = intent.getIntExtra(BluetoothIntent.REASON, BluetoothDevice.ERROR); int reason = intent.getIntExtra(BluetoothDevice.EXTRA_REASON, BluetoothDevice.ERROR);
if (reason == BluetoothDevice.UNBOND_REASON_AUTH_REJECTED || if (reason == BluetoothDevice.UNBOND_REASON_AUTH_REJECTED ||
reason == BluetoothDevice.UNBOND_REASON_AUTH_FAILED || reason == BluetoothDevice.UNBOND_REASON_AUTH_FAILED ||
reason == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN) { reason == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN) {
@@ -86,9 +85,9 @@ public class BluetoothEventRedirector {
} }
} }
} else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) { } else if (action.equals(BluetoothHeadset.ACTION_STATE_CHANGED)) {
int newState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, 0); int newState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, 0);
int oldState = intent.getIntExtra(BluetoothIntent.HEADSET_PREVIOUS_STATE, 0); int oldState = intent.getIntExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE, 0);
if (newState == BluetoothHeadset.STATE_DISCONNECTED && if (newState == BluetoothHeadset.STATE_DISCONNECTED &&
oldState == BluetoothHeadset.STATE_CONNECTING) { oldState == BluetoothHeadset.STATE_CONNECTING) {
Log.i(TAG, "Failed to connect BT headset"); Log.i(TAG, "Failed to connect BT headset");
@@ -97,9 +96,9 @@ public class BluetoothEventRedirector {
mManager.getCachedDeviceManager().onProfileStateChanged(device, mManager.getCachedDeviceManager().onProfileStateChanged(device,
Profile.HEADSET, newState); Profile.HEADSET, newState);
} else if (action.equals(BluetoothA2dp.SINK_STATE_CHANGED_ACTION)) { } else if (action.equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
int newState = intent.getIntExtra(BluetoothA2dp.SINK_STATE, 0); int newState = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE, 0);
int oldState = intent.getIntExtra(BluetoothA2dp.SINK_PREVIOUS_STATE, 0); int oldState = intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE, 0);
if (newState == BluetoothA2dp.STATE_DISCONNECTED && if (newState == BluetoothA2dp.STATE_DISCONNECTED &&
oldState == BluetoothA2dp.STATE_CONNECTING) { oldState == BluetoothA2dp.STATE_CONNECTING) {
Log.i(TAG, "Failed to connect BT A2DP"); Log.i(TAG, "Failed to connect BT A2DP");
@@ -108,7 +107,7 @@ public class BluetoothEventRedirector {
mManager.getCachedDeviceManager().onProfileStateChanged(device, mManager.getCachedDeviceManager().onProfileStateChanged(device,
Profile.A2DP, newState); 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); mManager.getCachedDeviceManager().onBtClassChanged(device);
} }
@@ -126,19 +125,19 @@ public class BluetoothEventRedirector {
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
// Discovery broadcasts // Discovery broadcasts
filter.addAction(BluetoothIntent.DISCOVERY_STARTED_ACTION); filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
filter.addAction(BluetoothIntent.DISCOVERY_COMPLETED_ACTION); filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
filter.addAction(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION); filter.addAction(BluetoothDevice.ACTION_DISAPPEARED);
filter.addAction(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION); filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION); filter.addAction(BluetoothDevice.ACTION_NAME_CHANGED);
// Pairing broadcasts // Pairing broadcasts
filter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION); filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
// Fine-grained state broadcasts // Fine-grained state broadcasts
filter.addAction(BluetoothA2dp.SINK_STATE_CHANGED_ACTION); filter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
filter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION); filter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
filter.addAction(BluetoothIntent.REMOTE_DEVICE_CLASS_UPDATED_ACTION); filter.addAction(BluetoothDevice.ACTION_CLASS_CHANGED);
mManager.getContext().registerReceiver(mBroadcastReceiver, filter); mManager.getContext().registerReceiver(mBroadcastReceiver, filter);
} }

View File

@@ -20,7 +20,6 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -46,7 +45,7 @@ public class BluetoothNamePreference extends EditTextPreference implements TextW
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
if (action.equals(BluetoothIntent.NAME_CHANGED_ACTION)) { if (action.equals(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) {
setSummaryToName(); setSummaryToName();
} else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) && } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) &&
(intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR) == (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR) ==
@@ -67,7 +66,7 @@ public class BluetoothNamePreference extends EditTextPreference implements TextW
public void resume() { public void resume() {
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
filter.addAction(BluetoothIntent.NAME_CHANGED_ACTION); filter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
getContext().registerReceiver(mReceiver, filter); getContext().registerReceiver(mReceiver, filter);
// Make sure the OK button is disabled (if necessary) after rotation // Make sure the OK button is disabled (if necessary) after rotation

View File

@@ -16,9 +16,7 @@
package com.android.settings.bluetooth; package com.android.settings.bluetooth;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@@ -63,11 +61,11 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
private BroadcastReceiver mReceiver = new BroadcastReceiver() { private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (!BluetoothIntent.PAIRING_CANCEL_ACTION.equals(intent.getAction())) { if (!BluetoothDevice.ACTION_PAIRING_CANCEL.equals(intent.getAction())) {
return; return;
} }
BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device == null || device.equals(mDevice)) { if (device == null || device.equals(mDevice)) {
onReceivedPairingCanceled(); onReceivedPairingCanceled();
} }
@@ -79,25 +77,25 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Intent intent = getIntent(); Intent intent = getIntent();
if (!intent.getAction().equals(BluetoothIntent.PAIRING_REQUEST_ACTION)) if (!intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST))
{ {
Log.e(TAG, Log.e(TAG,
"Error: this activity may be started only with intent " + "Error: this activity may be started only with intent " +
BluetoothIntent.PAIRING_REQUEST_ACTION); BluetoothDevice.ACTION_PAIRING_REQUEST);
finish(); finish();
} }
mLocalManager = LocalBluetoothManager.getInstance(this); mLocalManager = LocalBluetoothManager.getInstance(this);
mDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE); mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
mType = intent.getIntExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothClass.ERROR); mType = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.ERROR);
if (mType == BluetoothDevice.PAIRING_VARIANT_PIN) { if (mType == BluetoothDevice.PAIRING_VARIANT_PIN) {
createUserEntryDialog(); createUserEntryDialog();
} else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY) { } else if (mType == BluetoothDevice.PAIRING_VARIANT_PASSKEY) {
createUserEntryDialog(); createUserEntryDialog();
} else if (mType == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION){ } else if (mType == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION){
int passkey = int passkey =
intent.getIntExtra(BluetoothIntent.PASSKEY, BluetoothClass.ERROR); intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR);
if (passkey == BluetoothClass.ERROR) { if (passkey == BluetoothDevice.ERROR) {
Log.e(TAG, "Invalid ConfirmationPasskey received, not showing any dialog"); Log.e(TAG, "Invalid ConfirmationPasskey received, not showing any dialog");
return; return;
} }
@@ -111,7 +109,7 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
* Leave this registered through pause/resume since we still want to * Leave this registered through pause/resume since we still want to
* finish the activity in the background if pairing is canceled. * 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() { private void createUserEntryDialog() {

View File

@@ -23,7 +23,6 @@ import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -43,22 +42,23 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
if (action.equals(BluetoothIntent.PAIRING_REQUEST_ACTION)) { if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
LocalBluetoothManager localManager = LocalBluetoothManager.getInstance(context); LocalBluetoothManager localManager = LocalBluetoothManager.getInstance(context);
BluetoothDevice device = BluetoothDevice device =
intent.getParcelableExtra(BluetoothIntent.DEVICE); intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int type = intent.getIntExtra(BluetoothIntent.PAIRING_VARIANT, BluetoothClass.ERROR); int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.ERROR);
Intent pairingIntent = new Intent(); Intent pairingIntent = new Intent();
pairingIntent.setClass(context, BluetoothPairingDialog.class); pairingIntent.setClass(context, BluetoothPairingDialog.class);
pairingIntent.putExtra(BluetoothIntent.DEVICE, device); pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
pairingIntent.putExtra(BluetoothIntent.PAIRING_VARIANT, type); pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
if (type == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION) { if (type == BluetoothDevice.PAIRING_VARIANT_CONFIRMATION) {
int passkey = intent.getIntExtra(BluetoothIntent.PASSKEY, BluetoothClass.ERROR); int passkey = intent.getIntExtra(BluetoothDevice.EXTRA_PASSKEY, BluetoothDevice.ERROR);
pairingIntent.putExtra(BluetoothIntent.PASSKEY, passkey); 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); pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (localManager.getForegroundActivity() != null) { if (localManager.getForegroundActivity() != null) {
@@ -77,7 +77,7 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
PendingIntent pending = PendingIntent.getActivity(context, 0, PendingIntent pending = PendingIntent.getActivity(context, 0,
pairingIntent, PendingIntent.FLAG_ONE_SHOT); pairingIntent, PendingIntent.FLAG_ONE_SHOT);
String name = intent.getStringExtra(BluetoothIntent.NAME); String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
if (TextUtils.isEmpty(name)) { if (TextUtils.isEmpty(name)) {
name = device.getName(); name = device.getName();
} }
@@ -93,7 +93,7 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
manager.notify(NOTIFICATION_ID, notification); manager.notify(NOTIFICATION_ID, notification);
} }
} else if (action.equals(BluetoothIntent.PAIRING_CANCEL_ACTION)) { } else if (action.equals(BluetoothDevice.ACTION_PAIRING_CANCEL)) {
// Remove the notification // Remove the notification
NotificationManager manager = (NotificationManager) context NotificationManager manager = (NotificationManager) context

View File

@@ -25,7 +25,7 @@ import java.util.WeakHashMap;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothIntent; import android.bluetooth.BluetoothDevicePicker;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -88,12 +88,12 @@ public class BluetoothSettings extends PreferenceActivity
if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
onBluetoothStateChanged(mLocalManager.getBluetoothState()); 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) { && mScreenType == SCREEN_TYPE_DEVICEPICKER) {
int bondState = intent int bondState = intent
.getIntExtra(BluetoothIntent.BOND_STATE, BluetoothDevice.ERROR); .getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
if (bondState == BluetoothDevice.BOND_BONDED) { if (bondState == BluetoothDevice.BOND_BONDED) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothIntent.DEVICE); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
sendDevicePickedIntent(device); sendDevicePickedIntent(device);
finish(); finish();
} }
@@ -117,17 +117,17 @@ public class BluetoothSettings extends PreferenceActivity
// result from the BT list. // result from the BT list.
// -DEVICE_PICKER_NEED_AUTH: to show if bonding procedure needed. // -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(); Intent intent = getIntent();
String action = intent.getAction(); String action = intent.getAction();
if (action.equals(BluetoothIntent.DEVICE_PICKER_DEVICE_PICKER)) { if (action.equals(BluetoothDevicePicker.ACTION_LAUNCH)) {
mScreenType = SCREEN_TYPE_DEVICEPICKER; mScreenType = SCREEN_TYPE_DEVICEPICKER;
mNeedAuth = intent.getBooleanExtra(BluetoothIntent.DEVICE_PICKER_NEED_AUTH, false); mNeedAuth = intent.getBooleanExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false);
mFilterType = intent.getIntExtra(BluetoothIntent.DEVICE_PICKER_FILTER_TYPE, mFilterType = intent.getIntExtra(BluetoothDevicePicker.EXTRA_FILTER_TYPE,
BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_ALL); BluetoothDevicePicker.FILTER_TYPE_ALL);
mLaunchPackage = intent.getStringExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_PACKAGE); mLaunchPackage = intent.getStringExtra(BluetoothDevicePicker.EXTRA_LAUNCH_PACKAGE);
mLaunchClass = intent.getStringExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_CLASS); mLaunchClass = intent.getStringExtra(BluetoothDevicePicker.EXTRA_LAUNCH_CLASS);
setTitle(getString(R.string.device_picker)); setTitle(getString(R.string.device_picker));
addPreferencesFromResource(R.xml.device_picker); addPreferencesFromResource(R.xml.device_picker);
@@ -175,7 +175,7 @@ public class BluetoothSettings extends PreferenceActivity
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
intentFilter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION); intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
registerReceiver(mReceiver, intentFilter); registerReceiver(mReceiver, intentFilter);
mLocalManager.setForegroundActivity(this); mLocalManager.setForegroundActivity(this);
} }
@@ -305,11 +305,11 @@ public class BluetoothSettings extends PreferenceActivity
} }
List<Profile> profiles = cachedDevice.getProfiles(); List<Profile> profiles = cachedDevice.getProfiles();
if (mFilterType == BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_TRANSFER){ if (mFilterType == BluetoothDevicePicker.FILTER_TYPE_TRANSFER){
if(profiles.contains(Profile.OPP)){ if(profiles.contains(Profile.OPP)){
createDevicePreference(cachedDevice); 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))){ if((profiles.contains(Profile.A2DP)) || (profiles.contains(Profile.HEADSET))){
createDevicePreference(cachedDevice); createDevicePreference(cachedDevice);
} }
@@ -346,11 +346,11 @@ public class BluetoothSettings extends PreferenceActivity
} }
private void sendDevicePickedIntent(BluetoothDevice device) { 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) { if (mLaunchPackage != null && mLaunchClass != null) {
intent.setClassName(mLaunchPackage, mLaunchClass); intent.setClassName(mLaunchPackage, mLaunchClass);
} }
intent.putExtra(BluetoothIntent.DEVICE, device); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
sendBroadcast(intent); sendBroadcast(intent);
} }
} }

View File

@@ -59,7 +59,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
private final BluetoothDevice mDevice; private final BluetoothDevice mDevice;
private String mName; private String mName;
private short mRssi; private short mRssi;
private int mBtClass = BluetoothClass.ERROR; private BluetoothClass mBtClass;
private List<Profile> mProfiles = new ArrayList<Profile>(); private List<Profile> mProfiles = new ArrayList<Profile>();
@@ -301,7 +301,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
askDisconnect(); askDisconnect();
} else if (bondState == BluetoothDevice.BOND_BONDED) { } else if (bondState == BluetoothDevice.BOND_BONDED) {
connect(); connect();
} else if (bondState == BluetoothDevice.BOND_NOT_BONDED) { } else if (bondState == BluetoothDevice.BOND_NONE) {
pair(); pair();
} }
} }
@@ -424,7 +424,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
} }
private boolean ensurePaired() { private boolean ensurePaired() {
if (getBondState() == BluetoothDevice.BOND_NOT_BONDED) { if (getBondState() == BluetoothDevice.BOND_NONE) {
pair(); pair();
return false; return false;
} else { } else {
@@ -577,7 +577,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
} }
public int getBtClassDrawable() { public int getBtClassDrawable() {
switch (BluetoothClass.Device.Major.getDeviceMajor(mBtClass)) { switch (mBtClass.getMajorDeviceClass()) {
case BluetoothClass.Device.Major.COMPUTER: case BluetoothClass.Device.Major.COMPUTER:
return R.drawable.ic_bt_laptop; return R.drawable.ic_bt_laptop;
@@ -599,7 +599,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
*/ */
private void fetchBtClass() { private void fetchBtClass() {
mBtClass = mDevice.getBluetoothClass(); mBtClass = mDevice.getBluetoothClass();
if (mBtClass != BluetoothClass.ERROR) { if (mBtClass != null) {
LocalBluetoothProfileManager.fill(mBtClass, mProfiles); LocalBluetoothProfileManager.fill(mBtClass, mProfiles);
} }
} }
@@ -613,8 +613,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
dispatchAttributesChanged(); dispatchAttributesChanged();
} }
public void setBtClass(int btClass) { public void setBtClass(BluetoothClass btClass) {
if (mBtClass != btClass && btClass != BluetoothClass.ERROR) { if (btClass != null && mBtClass != btClass) {
mBtClass = btClass; mBtClass = btClass;
LocalBluetoothProfileManager.fill(mBtClass, mProfiles); LocalBluetoothProfileManager.fill(mBtClass, mProfiles);
dispatchAttributesChanged(); dispatchAttributesChanged();
@@ -699,7 +699,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
menu.setHeaderTitle(getName()); 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); menu.add(0, CONTEXT_ITEM_CONNECT, 0, R.string.bluetooth_device_context_pair_connect);
} else { // Paired } else { // Paired
if (isConnected) { // Paired and connected if (isConnected) { // Paired and connected

View File

@@ -17,6 +17,7 @@
package com.android.settings.bluetooth; package com.android.settings.bluetooth;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.util.Log; import android.util.Log;
@@ -74,8 +75,8 @@ public class CachedBluetoothDeviceManager {
} }
} }
public synchronized void onDeviceAppeared(BluetoothDevice device, short rssi, int btClass, public synchronized void onDeviceAppeared(BluetoothDevice device, short rssi,
String name) { BluetoothClass btClass, String name) {
boolean deviceAdded = false; boolean deviceAdded = false;
CachedBluetoothDevice cachedDevice = findDevice(device); CachedBluetoothDevice cachedDevice = findDevice(device);
@@ -104,7 +105,7 @@ public class CachedBluetoothDeviceManager {
} }
private void checkForDeviceRemoval(CachedBluetoothDevice cachedDevice) { private void checkForDeviceRemoval(CachedBluetoothDevice cachedDevice) {
if (cachedDevice.getBondState() == BluetoothDevice.BOND_NOT_BONDED && if (cachedDevice.getBondState() == BluetoothDevice.BOND_NONE &&
!cachedDevice.isVisible()) { !cachedDevice.isVisible()) {
// If device isn't paired, remove it altogether // If device isn't paired, remove it altogether
mCachedDevices.remove(cachedDevice); mCachedDevices.remove(cachedDevice);

View File

@@ -27,7 +27,6 @@ import android.app.AlertDialog;
import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;

View File

@@ -81,18 +81,18 @@ public abstract class LocalBluetoothProfileManager {
* @param btClass The class * @param btClass The class
* @param profiles The list of profiles to fill * @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(); profiles.clear();
if (BluetoothClass.doesClassMatch(btClass, BluetoothClass.PROFILE_HEADSET)) { if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
profiles.add(Profile.HEADSET); profiles.add(Profile.HEADSET);
} }
if (BluetoothClass.doesClassMatch(btClass, BluetoothClass.PROFILE_A2DP)) { if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
profiles.add(Profile.A2DP); profiles.add(Profile.A2DP);
} }
if (BluetoothClass.doesClassMatch(btClass, BluetoothClass.PROFILE_OPP)) { if (btClass.doesClassMatch(BluetoothClass.PROFILE_OPP)) {
profiles.add(Profile.OPP); profiles.add(Profile.OPP);
} }
} }

View File

@@ -72,7 +72,7 @@ public class SettingsBtStatus {
return R.string.bluetooth_paired; return R.string.bluetooth_paired;
case BluetoothDevice.BOND_BONDING: case BluetoothDevice.BOND_BONDING:
return R.string.bluetooth_pairing; return R.string.bluetooth_pairing;
case BluetoothDevice.BOND_NOT_BONDED: case BluetoothDevice.BOND_NONE:
return R.string.bluetooth_not_connected; return R.string.bluetooth_not_connected;
default: default:
return 0; return 0;