boolean okToConnect(BluetoothDevice device) {
   AdapterService adapterService = AdapterService.getAdapterService();
   int priority = mService.getPriority(device);
   boolean ret = false;
   // check if this is an incoming connection in Quiet mode.
   if ((adapterService == null)
       || ((adapterService.isQuietModeEnabled() == true) && (mTargetDevice == null))) {
     ret = false;
   }
   // check priority and accept or reject the connection. if priority is undefined
   // it is likely that our SDP has not completed and peer is initiating the
   // connection. Allow this connection, provided the device is bonded
   else if ((BluetoothProfile.PRIORITY_OFF < priority)
       || ((BluetoothProfile.PRIORITY_UNDEFINED == priority)
           && (device.getBondState() != BluetoothDevice.BOND_NONE))) {
     ret = true;
   }
   return ret;
 }
 public int getPriority(BluetoothDevice device) {
   A2dpService service = getService();
   if (service == null) return BluetoothProfile.PRIORITY_UNDEFINED;
   return service.getPriority(device);
 }