Lines Matching refs:device

73             BluetoothDevice device =
88 if (mAudioDevices.containsKey(device)) {
89 int state = mAudioDevices.get(device);
90 handleSinkStateChange(device, state, BluetoothA2dp.STATE_DISCONNECTED);
116 private boolean isPhoneDocked(BluetoothDevice device) {
123 if (dockDevice != null && device.equals(dockDevice)) {
182 private boolean isSinkDevice(BluetoothDevice device) {
183 ParcelUuid[] uuids = mBluetoothService.getRemoteUuids(device.getAddress());
190 private synchronized void addAudioSink(BluetoothDevice device) {
191 if (mAudioDevices.get(device) == null) {
192 mAudioDevices.put(device, BluetoothA2dp.STATE_DISCONNECTED);
202 BluetoothDevice device = mAdapter.getRemoteDevice(address);
208 addAudioSink(device);
220 for (BluetoothDevice device : devices) {
221 int state = getConnectionState(device);
227 device.getAddress()));
228 handleSinkStateChange(device, state, BluetoothA2dp.STATE_DISCONNECTED);
231 handleSinkStateChange(device, BluetoothA2dp.STATE_DISCONNECTING,
242 private synchronized boolean isConnectSinkFeasible(BluetoothDevice device) {
243 if (!mBluetoothService.isEnabled() || !isSinkDevice(device) ||
244 getPriority(device) == BluetoothA2dp.PRIORITY_OFF) {
248 addAudioSink(device);
250 String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
257 public synchronized boolean isA2dpPlaying(BluetoothDevice device) {
260 if (DBG) log("isA2dpPlaying(" + device + ")");
261 if (device.equals(mPlayingA2dpDevice)) return true;
265 public synchronized boolean connect(BluetoothDevice device) {
268 if (DBG) log("connectSink(" + device + ")");
269 if (!isConnectSinkFeasible(device)) return false;
277 return mBluetoothService.connectSink(device.getAddress());
280 public synchronized boolean connectSinkInternal(BluetoothDevice device) {
283 int state = mAudioDevices.get(device);
301 String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
304 if (getPriority(device) < BluetoothA2dp.PRIORITY_AUTO_CONNECT) {
305 setPriority(device, BluetoothA2dp.PRIORITY_AUTO_CONNECT);
307 handleSinkStateChange(device, state, BluetoothA2dp.STATE_CONNECTING);
311 handleSinkStateChange(device, mAudioDevices.get(device), state);
317 private synchronized boolean isDisconnectSinkFeasible(BluetoothDevice device) {
318 String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
323 int state = getConnectionState(device);
332 public synchronized boolean disconnect(BluetoothDevice device) {
335 if (DBG) log("disconnectSink(" + device + ")");
336 if (!isDisconnectSinkFeasible(device)) return false;
337 return mBluetoothService.disconnectSink(device.getAddress());
340 public synchronized boolean disconnectSinkInternal(BluetoothDevice device) {
341 int state = getConnectionState(device);
342 String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
350 handleSinkStateChange(device, state, BluetoothA2dp.STATE_DISCONNECTING);
353 handleSinkStateChange(device, mAudioDevices.get(device), state);
359 public synchronized boolean suspendSink(BluetoothDevice device) {
362 if (DBG) log("suspendSink(" + device + "), mTargetA2dpState: "+mTargetA2dpState);
363 if (device == null || mAudioDevices == null) {
366 String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
367 Integer state = mAudioDevices.get(device);
376 public synchronized boolean resumeSink(BluetoothDevice device) {
379 if (DBG) log("resumeSink(" + device + "), mTargetA2dpState: "+mTargetA2dpState);
380 if (device == null || mAudioDevices == null) {
383 String path = mBluetoothService.getObjectPathFromAddress(device.getAddress());
384 Integer state = mAudioDevices.get(device);
392 public synchronized int getConnectionState(BluetoothDevice device) {
394 Integer state = mAudioDevices.get(device);
410 for (BluetoothDevice device: mAudioDevices.keySet()) {
411 int sinkState = getConnectionState(device);
414 sinks.add(device);
422 public synchronized int getPriority(BluetoothDevice device) {
425 Settings.Secure.getBluetoothA2dpSinkPriorityKey(device.getAddress()),
429 public synchronized boolean setPriority(BluetoothDevice device, int priority) {
433 Settings.Secure.getBluetoothA2dpSinkPriorityKey(device.getAddress()), priority);
436 public synchronized boolean allowIncomingConnect(BluetoothDevice device, boolean value) {
439 String address = device.getAddress();
445 Log.w(TAG, "allowIncomingConnect(" + device + ") called but no native data available");
448 log("allowIncomingConnect: A2DP: " + device + ":" + value);
456 * @param path the object path for the changed device
468 Log.e(TAG, "onSinkPropertyChanged: Address of the remote device in null");
472 BluetoothDevice device = mAdapter.getRemoteDevice(address);
478 if (mAudioDevices.get(device) == null) {
479 // This is for an incoming connection for a device not known to us.
481 addAudioSink(device);
482 handleSinkStateChange(device, BluetoothA2dp.STATE_DISCONNECTED, state);
485 mPlayingA2dpDevice = device;
486 handleSinkPlayingStateChange(device, state, BluetoothA2dp.STATE_NOT_PLAYING);
489 handleSinkPlayingStateChange(device, BluetoothA2dp.STATE_NOT_PLAYING,
493 int prevState = mAudioDevices.get(device);
494 handleSinkStateChange(device, prevState, state);
500 private void handleSinkStateChange(BluetoothDevice device, int prevState, int state) {
502 mAudioDevices.put(device, state);
507 if (getPriority(device) > BluetoothA2dp.PRIORITY_OFF &&
511 setPriority(device, BluetoothA2dp.PRIORITY_AUTO_CONNECT);
512 // We will only have 1 device with AUTO_CONNECT priority
514 adjustOtherSinkPriorities(device);
518 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
524 if (DBG) log("A2DP state : device: " + device + " State:" + prevState + "->" + state);
526 mBluetoothService.sendConnectionStateChange(device, BluetoothProfile.A2DP, state,
531 private void handleSinkPlayingStateChange(BluetoothDevice device, int state, int prevState) {
533 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
539 if (DBG) log("A2DP Playing state : device: " + device + " State:" + prevState + "->" + state);
543 for (BluetoothDevice device : mAdapter.getBondedDevices()) {
544 if (getPriority(device) >= BluetoothA2dp.PRIORITY_AUTO_CONNECT &&
545 !device.equals(connectedDevice)) {
546 setPriority(device, BluetoothA2dp.PRIORITY_ON);
572 * @param deviceObjectPath the object path for the connecting device
582 BluetoothDevice device = mAdapter.getRemoteDevice(address);
583 int state = getConnectionState(device);
584 handleSinkStateChange(device, state, BluetoothA2dp.STATE_DISCONNECTED);
593 for (BluetoothDevice device : mAudioDevices.keySet()) {
594 int state = mAudioDevices.get(device);
595 pw.println(device + " " + BluetoothA2dp.stateToString(state));