static AdbResponse readAdbResponse(SocketChannel chan,boolean readDiagString) throws TimeoutException, IOException {
  AdbResponse resp=new AdbResponse();
  byte[] reply=new byte[4];
  read(chan,reply);
  if (isOkay(reply)) {
    resp.okay=true;
  }
 else {
    readDiagString=true;
    resp.okay=false;
  }
  try {
    while (readDiagString) {
      byte[] lenBuf=new byte[4];
      read(chan,lenBuf);
      String lenStr=replyToString(lenBuf);
      int len;
      try {
        len=Integer.parseInt(lenStr,16);
      }
 catch (      NumberFormatException nfe) {
        Log.w("ddms","Expected digits, got '" + lenStr + "': "+ lenBuf[0]+ " "+ lenBuf[1]+ " "+ lenBuf[2]+ " "+ lenBuf[3]);
        Log.w("ddms","reply was " + replyToString(reply));
        break;
      }
      byte[] msg=new byte[len];
      read(chan,msg);
      resp.message=replyToString(msg);
      Log.v("ddms","Got reply '" + replyToString(reply) + "', diag='"+ resp.message+ "'");
      break;
    }
  }
 catch (  Exception e) {
  }
  return resp;
}

static AdbResponse readAdbResponse ( SocketChannel chan , boolean readDiagString ) throws TimeoutException , IOException { AdbResponse resp = new AdbResponse ( ) ; byte [ ] reply = new byte [ 4 ] ; read ( chan , reply ) ; if ( isOkay ( reply ) ) { resp . okay = true ; } else { readDiagString = true ; resp . okay = false ; } try { while ( readDiagString ) { byte [ ] lenBuf = new byte [ 4 ] ; read ( chan , lenBuf ) ; String lenStr = replyToString ( lenBuf ) ; int len ; try { len = Integer . parseInt ( lenStr , 16 ) ; } catch ( NumberFormatException nfe ) { Log . w ( "ddms" , "Expected digits, got '" + lenStr + "': " + lenBuf [ 0 ] + " " + lenBuf [ 1 ] + " " + lenBuf [ 2 ] + " " + lenBuf [ 3 ] ) ; Log . w ( "ddms" , "reply was " + replyToString ( reply ) ) ; break ; } byte [ ] msg = new byte [ len ] ; read ( chan , msg ) ; resp . message = replyToString ( msg ) ; Log . v ( "ddms" , "Got reply '" + replyToString ( reply ) + "', diag='" + resp . message + "'" ) ; break ; } } catch ( Exception e ) { } return resp ; }
reads the response from adb after a command .
