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:
@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
|
||||
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;
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.bluetooth;
|
||||
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;
|
||||
|
@@ -21,7 +21,6 @@ import android.bluetooth.BluetoothAdapter;
|
||||
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 @@ public class BluetoothEventRedirector {
|
||||
}
|
||||
|
||||
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 @@ public class BluetoothEventRedirector {
|
||||
}
|
||||
}
|
||||
|
||||
} 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 @@ public class BluetoothEventRedirector {
|
||||
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 @@ public class BluetoothEventRedirector {
|
||||
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 @@ public class BluetoothEventRedirector {
|
||||
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);
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ import android.app.AlertDialog;
|
||||
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 @@ public class BluetoothNamePreference extends EditTextPreference implements TextW
|
||||
@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 class BluetoothNamePreference extends EditTextPreference implements TextW
|
||||
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
|
||||
|
@@ -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 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
|
||||
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 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
|
||||
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 @@ public class BluetoothPairingDialog extends AlertActivity implements DialogInter
|
||||
* 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() {
|
||||
|
@@ -23,7 +23,6 @@ import android.app.NotificationManager;
|
||||
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 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
|
||||
@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 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
|
||||
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 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
|
||||
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
|
||||
|
@@ -25,7 +25,7 @@ import java.util.WeakHashMap;
|
||||
|
||||
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 @@ public class BluetoothSettings extends PreferenceActivity
|
||||
|
||||
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 @@ public class BluetoothSettings extends PreferenceActivity
|
||||
// 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 @@ public class BluetoothSettings extends PreferenceActivity
|
||||
|
||||
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 @@ public class BluetoothSettings extends PreferenceActivity
|
||||
}
|
||||
|
||||
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 @@ public class BluetoothSettings extends PreferenceActivity
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
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 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
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 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
}
|
||||
|
||||
private boolean ensurePaired() {
|
||||
if (getBondState() == BluetoothDevice.BOND_NOT_BONDED) {
|
||||
if (getBondState() == BluetoothDevice.BOND_NONE) {
|
||||
pair();
|
||||
return false;
|
||||
} else {
|
||||
@@ -577,7 +577,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
}
|
||||
|
||||
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 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
*/
|
||||
private void fetchBtClass() {
|
||||
mBtClass = mDevice.getBluetoothClass();
|
||||
if (mBtClass != BluetoothClass.ERROR) {
|
||||
if (mBtClass != null) {
|
||||
LocalBluetoothProfileManager.fill(mBtClass, mProfiles);
|
||||
}
|
||||
}
|
||||
@@ -613,8 +613,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
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 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
|
||||
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
|
||||
|
@@ -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 class CachedBluetoothDeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public class CachedBluetoothDeviceManager {
|
||||
}
|
||||
|
||||
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);
|
||||
|
@@ -27,7 +27,6 @@ import android.app.AlertDialog;
|
||||
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;
|
||||
|
@@ -81,18 +81,18 @@ public abstract class LocalBluetoothProfileManager {
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ public class SettingsBtStatus {
|
||||
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;
|
||||
|
Reference in New Issue
Block a user