Lines Matching defs:device

124        for (BluetoothDevice device : mRemoteHeadsets.keySet()) {
125 int state = mRemoteHeadsets.get(device).mState;
128 return device;
137 Log.w(TAG, "Stopping BluetoothHeadsetService: device does not have BT");
191 BluetoothDevice device = getCurrentDevice();
194 if (device != null) {
195 state = mRemoteHeadsets.get(device).mState;
212 if (!info.mRemoteDevice.equals(device)) {
214 Log.i(TAG, "Already attempting connect to " + device +
239 Log.i(TAG, "Already connected to " + device + ", disconnecting " +
260 BluetoothDevice device =
272 device.equals(currDevice)) {
301 if (device.equals(mDeviceSdpQuery) && device.equals(currDevice)) {
302 // We have got SDP records for the device we are interested in.
303 getSdpRecordsAndConnect(device);
315 BluetoothDevice device = (BluetoothDevice) msg.obj;
316 getSdpRecordsAndConnect(device);
341 private BluetoothDevice device;
348 public RfcommConnectThread(BluetoothDevice device, int channel, int type) {
350 this.device = device;
375 device, channel);
384 device.fetchUuidsWithSdp();
426 BluetoothDevice device = getCurrentDevice();
427 if (device == null ||
428 mRemoteHeadsets.get(device).mState != BluetoothProfile.STATE_CONNECTING) {
436 setState(device, BluetoothProfile.STATE_DISCONNECTED);
442 setState(device, BluetoothProfile.STATE_CONNECTED);
444 mRemoteHeadsets.get(device).mHeadset = headset;
445 mBtHandsfree.connectHeadset(headset, mRemoteHeadsets.get(device).mHeadsetType);
461 BluetoothDevice device = getCurrentDevice();
462 if (device != null) {
463 setState(device, BluetoothProfile.STATE_DISCONNECTED);
470 private synchronized void setState(BluetoothDevice device, int state) {
471 int prevState = mRemoteHeadsets.get(device).mState;
473 if (DBG) log("Device: " + device +
482 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
484 mRemoteHeadsets.get(device).mHeadset = null;
485 mRemoteHeadsets.get(device).mHeadsetType = BluetoothHandsfree.TYPE_UNKNOWN;
488 mRemoteHeadsets.get(device).mState = state;
493 setPriority(device, BluetoothHeadset.PRIORITY_AUTO_CONNECT);
494 adjustOtherHeadsetPriorities(device);
497 mBluetoothService.sendConnectionStateChange(device, BluetoothProfile.HEADSET,
506 for (BluetoothDevice device : mAdapter.getBondedDevices()) {
507 if (getPriority(device) >= BluetoothHeadset.PRIORITY_AUTO_CONNECT &&
508 !device.equals(connectedDevice)) {
509 setPriority(device, BluetoothHeadset.PRIORITY_ON);
514 private void setPriority(BluetoothDevice device, int priority) {
516 mBinder.setPriority(device, priority);
518 Log.e(TAG, "Error while setting priority for: " + device);
522 private int getPriority(BluetoothDevice device) {
524 return mBinder.getPriority(device);
526 Log.e(TAG, "Error while getting priority for: " + device);
531 private synchronized void getSdpRecordsAndConnect(BluetoothDevice device) {
532 if (!device.equals(getCurrentDevice())) {
538 if (mRemoteHeadsets.get(device).mState == BluetoothProfile.STATE_CONNECTED) {
542 ParcelUuid[] uuids = device.getUuids();
550 mRemoteHeadsets.get(device).mHeadsetType = type;
551 int channel = device.getServiceChannel(BluetoothUuid.Handsfree);
552 mConnectThread = new RfcommConnectThread(device, channel, type);
557 if (getPriority(device) < BluetoothHeadset.PRIORITY_AUTO_CONNECT) {
558 setPriority(device, BluetoothHeadset.PRIORITY_AUTO_CONNECT);
565 mRemoteHeadsets.get(device).mHeadsetType = type;
566 int channel = device.getServiceChannel(BluetoothUuid.HSP);
567 mConnectThread = new RfcommConnectThread(device, channel, type);
572 if (getPriority(device) < BluetoothHeadset.PRIORITY_AUTO_CONNECT) {
573 setPriority(device, BluetoothHeadset.PRIORITY_AUTO_CONNECT);
579 mRemoteHeadsets.get(device).mHeadsetType = type;
580 setState(device, BluetoothProfile.STATE_DISCONNECTED);
588 public int getConnectionState(BluetoothDevice device) {
590 BluetoothRemoteHeadset headset = mRemoteHeadsets.get(device);
603 public boolean connect(BluetoothDevice device) {
609 if (currDevice == device ||
610 getPriority(device) == BluetoothProfile.PRIORITY_OFF) {
617 return mBluetoothService.connectHeadset(device.getAddress());
625 public boolean disconnect(BluetoothDevice device) {
629 BluetoothRemoteHeadset headset = mRemoteHeadsets.get(device);
636 return mBluetoothService.disconnectHeadset(device.getAddress());
644 public synchronized boolean isAudioConnected(BluetoothDevice device) {
646 if (device.equals(mAudioConnectedDevice)) return true;
653 for (BluetoothDevice device: mRemoteHeadsets.keySet()) {
654 int headsetState = getConnectionState(device);
657 headsets.add(device);
665 public boolean startVoiceRecognition(BluetoothDevice device) {
668 if (device == null ||
669 mRemoteHeadsets.get(device) == null ||
670 mRemoteHeadsets.get(device).mState != BluetoothProfile.STATE_CONNECTED) {
677 public boolean stopVoiceRecognition(BluetoothDevice device) {
680 if (device == null ||
681 mRemoteHeadsets.get(device) == null ||
682 mRemoteHeadsets.get(device).mState != BluetoothProfile.STATE_CONNECTED) {
690 public int getBatteryUsageHint(BluetoothDevice device) {
696 public int getPriority(BluetoothDevice device) {
701 Settings.Secure.getBluetoothHeadsetPriorityKey(device.getAddress()),
707 public boolean setPriority(BluetoothDevice device, int priority) {
712 Settings.Secure.getBluetoothHeadsetPriorityKey(device.getAddress()),
714 if (DBG) log("Saved priority " + device + " = " + priority);
719 public boolean createIncomingConnect(BluetoothDevice device) {
722 setState(device, BluetoothProfile.STATE_CONNECTING);
724 IncomingConnectionInfo info = mRemoteHeadsets.get(device).mIncomingInfo;
726 device,
730 mRemoteHeadsets.get(device).mHeadset = headset;
737 public boolean startScoUsingVirtualVoiceCall(BluetoothDevice device) {
740 if (device == null ||
741 mRemoteHeadsets.get(device) == null ||
742 mRemoteHeadsets.get(device).mState != BluetoothProfile.STATE_CONNECTED ||
743 getAudioState(device) != BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
750 public boolean stopScoUsingVirtualVoiceCall(BluetoothDevice device) {
753 if (device == null ||
754 mRemoteHeadsets.get(device) == null ||
755 mRemoteHeadsets.get(device).mState != BluetoothProfile.STATE_CONNECTED ||
756 getAudioState(device) == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
763 public boolean rejectIncomingConnect(BluetoothDevice device) {
765 BluetoothRemoteHeadset headset = mRemoteHeadsets.get(device);
776 public boolean acceptIncomingConnect(BluetoothDevice device) {
779 BluetoothRemoteHeadset cachedHeadset = mRemoteHeadsets.get(device);
786 device,
790 setState(device, BluetoothProfile.STATE_CONNECTED);
816 public boolean connectHeadsetInternal(BluetoothDevice device) {
821 mRemoteHeadsets.put(device, headset);
823 setState(device, BluetoothProfile.STATE_CONNECTING);
824 if (device.getUuids() == null) {
829 msg.obj = device;
832 getSdpRecordsAndConnect(device);
836 Log.w(TAG, "connectHeadset(" + device + "): failed: already in state " +
844 public boolean disconnectHeadsetInternal(BluetoothDevice device) {
846 BluetoothRemoteHeadset remoteHeadset = mRemoteHeadsets.get(device);
857 setState(device, BluetoothProfile.STATE_DISCONNECTING);
868 setState(device, BluetoothProfile.STATE_DISCONNECTED);
873 setState(device, BluetoothProfile.STATE_DISCONNECTED);
880 public boolean setAudioState(BluetoothDevice device, int state) {
882 int prevState = mRemoteHeadsets.get(device).mAudioState;
883 mRemoteHeadsets.get(device).mAudioState = state;
885 mAudioConnectedDevice = device;
892 intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
894 if (DBG) log("AudioStateIntent: " + device + " State: " + state
899 public int getAudioState(BluetoothDevice device) {
901 BluetoothRemoteHeadset headset = mRemoteHeadsets.get(device);
916 BluetoothDevice device = getCurrentDevice();
917 if (device != null) {
918 setState(device, BluetoothProfile.STATE_DISCONNECTED);