public boolean tasks(){
  log.info("Starting BluetoothSpeaker tasks.");
  log.info("mServerSocket:" + (mServerSocket == null) + " mBluetoothAdapter:"+ (mBluetoothAdapter != null)+ " mConnectionAcceptingThread:"+ (mBluetoothAdapter != null));
  if (mServerSocket == null && mBluetoothAdapter != null && mBluetoothAdapter.isEnabled() && (mConnectionAcceptingThread == null || !mConnectionAcceptingThread.isAlive())) {
    try {
      log.info("No ServerSocket, creating a new one.");
      createListeningSocket();
      spawnConnectionAcceptingThread();
    }
 catch (    IOException e) {
      log.error("Tasks: failed to create listening BT server socket. ",e);
      log.error("Can't receive incoming connections.");
      return false;
    }
  }
  if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
    log.info("bluetooth tasks failed, bluetooth disabled");
    return false;
  }
  log.info("finished BluetoothSpeaker tasks.");
  return true;
}

public boolean tasks ( ) { log . info ( "Starting BluetoothSpeaker tasks." ) ; log . info ( "mServerSocket:" + ( mServerSocket == null ) + " mBluetoothAdapter:" + ( mBluetoothAdapter != null ) + " mConnectionAcceptingThread:" + ( mBluetoothAdapter != null ) ) ; if ( mServerSocket == null && mBluetoothAdapter != null && mBluetoothAdapter . isEnabled ( ) && ( mConnectionAcceptingThread == null || ! mConnectionAcceptingThread . isAlive ( ) ) ) { try { log . info ( "No ServerSocket, creating a new one." ) ; createListeningSocket ( ) ; spawnConnectionAcceptingThread ( ) ; } catch ( IOException e ) { log . error ( "Tasks: failed to create listening BT server socket. " , e ) ; log . error ( "Can't receive incoming connections." ) ; return false ; } } if ( mBluetoothAdapter == null || ! mBluetoothAdapter . isEnabled ( ) ) { log . info ( "bluetooth tasks failed, bluetooth disabled" ) ; return false ; } log . info ( "finished BluetoothSpeaker tasks." ) ; return true ; }
called periodically by the background tasks method of the murmur service . recreates the listening socket and thread if they ' re not active . the listening thread might be inactive if bluetooth was turned off previously . return true if state allow for proper bluetooth handling or false if process should be terminated
