Beispiel #1
0
 public boolean disconnect(BluetoothDevice device) {
   if (mService == null) return false;
   // Downgrade priority as user is disconnecting the headset.
   if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) {
     mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
   }
   return mService.disconnect(device);
 }
Beispiel #2
0
 boolean isA2dpPlaying() {
   if (mService == null) return false;
   List<BluetoothDevice> sinks = mService.getConnectedDevices();
   if (!sinks.isEmpty()) {
     if (mService.isA2dpPlaying(sinks.get(0))) {
       return true;
     }
   }
   return false;
 }
Beispiel #3
0
 public void setPreferred(BluetoothDevice device, boolean preferred) {
   if (mService == null) return;
   if (preferred) {
     if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) {
       mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
     }
   } else {
     mService.setPriority(device, BluetoothProfile.PRIORITY_OFF);
   }
 }
Beispiel #4
0
 public boolean connect(BluetoothDevice device) {
   if (mService == null) return false;
   List<BluetoothDevice> sinks = getConnectedDevices();
   if (sinks != null) {
     if (sinks.contains(device)) {
       Log.d(
           TAG,
           "The attempt connecting device is the already in the connected device list, do not need disconnect, connect, just return true");
       return true;
     }
     for (BluetoothDevice sink : sinks) {
       mService.disconnect(sink);
     }
   }
   return mService.connect(device);
 }
Beispiel #5
0
 public List<BluetoothDevice> getConnectedDevices() {
   if (mService == null) return new ArrayList<BluetoothDevice>(0);
   return mService.getDevicesMatchingConnectionStates(
       new int[] {
         BluetoothProfile.STATE_CONNECTED,
         BluetoothProfile.STATE_CONNECTING,
         BluetoothProfile.STATE_DISCONNECTING
       });
 }
Beispiel #6
0
 public int getPreferred(BluetoothDevice device) {
   if (mService == null) return BluetoothProfile.PRIORITY_OFF;
   return mService.getPriority(device);
 }
Beispiel #7
0
 public boolean isPreferred(BluetoothDevice device) {
   if (mService == null) return false;
   return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
 }
Beispiel #8
0
 public int getConnectionStatus(BluetoothDevice device) {
   if (mService == null) {
     return BluetoothProfile.STATE_DISCONNECTED;
   }
   return mService.getConnectionState(device);
 }