Lines Matching refs:device

86     // mCurrentDevice is the device connected before the state changes
87 // mTargetDevice is the device to be connected
88 // mIncomingDevice is the device connecting to us, valid only in Pending state
99 // Connecting to a device, Pending
101 // Disconnecting device, Connecting to new device
104 // Disconnecting device Pending
177 BluetoothDevice device = (BluetoothDevice) message.obj;
178 broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTING,
181 if (!connectA2dpNative(getByteAddress(device)) ) {
182 broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
188 mTargetDevice = device;
202 processConnectionEvent(event.valueInt, event.device);
221 private void processConnectionEvent(int state, BluetoothDevice device) {
224 Log.w(TAG, "Ignore HF DISCONNECTED event, device: " + device);
227 if (okToConnect(device)){
229 broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTING,
232 mIncomingDevice = device;
238 disconnectA2dpNative(getByteAddress(device));
242 adapterService.connectOtherProfile(device,
249 if (okToConnect(device)){
251 broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTED,
254 mCurrentDevice = device;
260 disconnectA2dpNative(getByteAddress(device));
264 adapterService.connectOtherProfile(device,
270 Log.w(TAG, "Ignore HF DISCONNECTING event, device: " + device);
299 BluetoothDevice device = (BluetoothDevice) message.obj;
301 mTargetDevice.equals(device) ) {
303 broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
317 processConnectionEvent(event.valueInt, event.device);
331 private void processConnectionEvent(int state, BluetoothDevice device) {
334 if ((mCurrentDevice != null) && mCurrentDevice.equals(device)) {
358 } else if (mTargetDevice != null && mTargetDevice.equals(device)) {
366 } else if (mIncomingDevice != null && mIncomingDevice.equals(device)) {
375 Log.e(TAG, "Unknown device Disconnected: " + device);
379 if ((mCurrentDevice != null) && mCurrentDevice.equals(device)) {
391 } else if (mTargetDevice != null && mTargetDevice.equals(device)) {
399 } else if (mIncomingDevice != null && mIncomingDevice.equals(device)) {
408 Log.e(TAG, "Unknown device Connected: " + device);
410 broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTED,
413 mCurrentDevice = device;
421 if ((mCurrentDevice != null) && mCurrentDevice.equals(device)) {
422 log("current device tries to connect back");
424 } else if (mTargetDevice != null && mTargetDevice.equals(device)) {
425 // The stack is connecting to target device or
426 // there is an incoming connection from the target device at the same time
428 log("Stack and target device are connecting");
430 else if (mIncomingDevice != null && mIncomingDevice.equals(device)) {
431 Log.e(TAG, "Another connecting event on the incoming device");
439 if ((mCurrentDevice != null) && mCurrentDevice.equals(device)) {
444 } else if (mTargetDevice != null && mTargetDevice.equals(device)) {
446 } else if (mIncomingDevice != null && mIncomingDevice.equals(device)) {
449 Log.e(TAG, "Disconnecting unknow device: " + device);
481 BluetoothDevice device = (BluetoothDevice) message.obj;
482 if (mCurrentDevice.equals(device)) {
486 broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTING,
489 broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
495 mTargetDevice = device;
502 BluetoothDevice device = (BluetoothDevice) message.obj;
503 if (!mCurrentDevice.equals(device)) {
506 broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTING,
508 if (!disconnectA2dpNative(getByteAddress(device))) {
509 broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTED,
520 processConnectionEvent(event.valueInt, event.device);
523 processAudioStateEvent(event.valueInt, event.device);
537 private void processConnectionEvent(int state, BluetoothDevice device) {
540 if (mCurrentDevice.equals(device)) {
548 Log.e(TAG, "Disconnected from unknown device: " + device);
552 Log.e(TAG, "Connection State Device: " + device + " bad state: " + state);
556 private void processAudioStateEvent(int state, BluetoothDevice device) {
557 if (!mCurrentDevice.equals(device)) {
558 Log.e(TAG, "Audio State Device:" + device + "is different from ConnectedDevice:" +
565 mPlayingA2dpDevice = device;
566 broadcastAudioState(device, BluetoothA2dp.STATE_PLAYING,
573 broadcastAudioState(device, BluetoothA2dp.STATE_NOT_PLAYING,
578 Log.e(TAG, "Audio State Device: " + device + " bad state: " + state);
584 int getConnectionState(BluetoothDevice device) {
592 if ((mTargetDevice != null) && mTargetDevice.equals(device)) {
595 if ((mCurrentDevice != null) && mCurrentDevice.equals(device)) {
598 if ((mIncomingDevice != null) && mIncomingDevice.equals(device)) {
605 if (mCurrentDevice.equals(device)) {
626 boolean isPlaying(BluetoothDevice device) {
628 if (device.equals(mPlayingA2dpDevice)) {
635 boolean okToConnect(BluetoothDevice device) {
637 int priority = mService.getPriority(device);
647 // connection. Allow this connection, provided the device is bonded
650 (device.getBondState() != BluetoothDevice.BOND_NONE))){
661 for (BluetoothDevice device : bondedDevices) {
662 ParcelUuid[] featureUuids = device.getUuids();
666 connectionState = getConnectionState(device);
669 deviceList.add(device);
678 private void broadcastConnectionState(BluetoothDevice device, int newState, int prevState) {
680 int delay = mAudioManager.setBluetoothA2dpDeviceConnectionState(device, newState);
687 device),
691 private void broadcastAudioState(BluetoothDevice device, int state, int prevState) {
693 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
699 log("A2DP Playing state : device: " + device + " State:" + prevState + "->" + state);
702 private byte[] getByteAddress(BluetoothDevice device) {
703 return Utils.getBytesFromAddress(device.getAddress());
709 event.device = getDevice(address);
716 event.device = getDevice(address);
730 BluetoothDevice device = null;
739 private void onConnectionStateChanged(BluetoothDevice device, int prevState, int state) {
743 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
746 log("Connection state " + device + ": " + prevState + "->" + state);
747 mService.notifyProfileConnectionStateChanged(device, BluetoothProfile.A2DP, state, prevState);