예제 #1
0
  /** Disconnect Android from USB */
  public void disconnect() {
    if (m_connected) {
      m_connected = false;
    }

    if (m_handler != null) {
      m_handler.stop();
    }

    if (m_sender != null && m_sender.is_active()) {
      if (m_sender.stop()) {
        Log.d(LinkManager.class.getSimpleName(), "There was non-send message !");
        // TODO : autre traitement ?
      }
    }
    if (m_receiver != null && m_receiver.is_active()) {
      if (m_receiver.stop()) {
        Log.d(LinkManager.class.getSimpleName(), "All the message were not handled !");
        // TODO : autre traitement ?
      }
    }

    if (m_device != null) {
      /*    try {
          m_device.close();
      } catch (IOException e) { }*/
      m_device = null;
    }

    m_listener.UsbStop();
  }
예제 #2
0
 public void stop() {
   try {
     flush();
   } catch (Exception ex) {
     logger.warn("Unable to flush before stop", ex);
   }
   sender.stop();
 }
예제 #3
0
  public void start() {
    if (receiver != null) receiver.stop();
    receiver = new Receiver(server.factory).start();

    if (isSenderUsed()) {
      if (sender != null) sender.stop();
      sender = new Sender(server.factory, server.sendQueueSize()).start();
    }
  }
예제 #4
0
 public void close() throws IOException {
   // can close even if start was never called...
   send_lock.lock();
   try {
     connectionPeerReceiver.stop();
     if (isSenderUsed()) {
       sender.stop();
     }
     Util.close(sock);
     Util.close(out);
     Util.close(in);
   } finally {
     send_lock.unlock();
   }
   mapper.notifyConnectionClosed(peer_addr);
 }
예제 #5
0
 public void close() throws IOException {
   send_lock.lock();
   try {
     Util.close(out, in, sock);
     if (receiver != null) {
       receiver.stop();
       receiver = null;
     }
     if (sender != null) {
       sender.stop();
       sender = null;
     }
   } finally {
     send_lock.unlock();
   }
 }