private void doPushFile(String localPath,String remotePath,ISyncProgressMonitor monitor) throws SyncException, IOException, TimeoutException {
  FileInputStream fis=null;
  byte[] msg;
  final int timeOut=DdmPreferences.getTimeOut();
  File f=new File(localPath);
  try {
    byte[] remotePathContent=remotePath.getBytes(AdbHelper.DEFAULT_ENCODING);
    if (remotePathContent.length > REMOTE_PATH_MAX_LENGTH) {
      throw new SyncException(SyncError.REMOTE_PATH_LENGTH);
    }
    fis=new FileInputStream(f);
    msg=createSendFileReq(ID_SEND,remotePathContent,0644);
    AdbHelper.write(mChannel,msg,-1,timeOut);
    System.arraycopy(ID_DATA,0,getBuffer(),0,ID_DATA.length);
    while (true) {
      if (monitor.isCanceled()) {
        throw new SyncException(SyncError.CANCELED);
      }
      int readCount=fis.read(getBuffer(),8,SYNC_DATA_MAX);
      if (readCount == -1) {
        break;
      }
      ArrayHelper.swap32bitsToArray(readCount,getBuffer(),4);
      AdbHelper.write(mChannel,getBuffer(),readCount + 8,timeOut);
      monitor.advance(readCount);
    }
  }
 catch (  UnsupportedEncodingException e) {
    throw new SyncException(SyncError.REMOTE_PATH_ENCODING,e);
  }
 finally {
    if (fis != null) {
      fis.close();
    }
  }
  long time=f.lastModified() / 1000;
  msg=createReq(ID_DONE,(int)time);
  AdbHelper.write(mChannel,msg,-1,timeOut);
  byte[] result=new byte[8];
  AdbHelper.read(mChannel,result,-1,timeOut);
  if (!checkResult(result,ID_OKAY)) {
    throw new SyncException(SyncError.TRANSFER_PROTOCOL_ERROR,readErrorMessage(result,timeOut));
  }
}

private void doPushFile ( String localPath , String remotePath , ISyncProgressMonitor monitor ) throws SyncException , IOException , TimeoutException { FileInputStream fis = null ; byte [ ] msg ; final int timeOut = DdmPreferences . getTimeOut ( ) ; File f = new File ( localPath ) ; try { byte [ ] remotePathContent = remotePath . getBytes ( AdbHelper . DEFAULT_ENCODING ) ; if ( remotePathContent . length > REMOTE_PATH_MAX_LENGTH ) { throw new SyncException ( SyncError . REMOTE_PATH_LENGTH ) ; } fis = new FileInputStream ( f ) ; msg = createSendFileReq ( ID_SEND , remotePathContent , 0644 ) ; AdbHelper . write ( mChannel , msg , - 1 , timeOut ) ; System . arraycopy ( ID_DATA , 0 , getBuffer ( ) , 0 , ID_DATA . length ) ; while ( true ) { if ( monitor . isCanceled ( ) ) { throw new SyncException ( SyncError . CANCELED ) ; } int readCount = fis . read ( getBuffer ( ) , 8 , SYNC_DATA_MAX ) ; if ( readCount == - 1 ) { break ; } ArrayHelper . swap32bitsToArray ( readCount , getBuffer ( ) , 4 ) ; AdbHelper . write ( mChannel , getBuffer ( ) , readCount + 8 , timeOut ) ; monitor . advance ( readCount ) ; } } catch ( UnsupportedEncodingException e ) { throw new SyncException ( SyncError . REMOTE_PATH_ENCODING , e ) ; } finally { if ( fis != null ) { fis . close ( ) ; } } long time = f . lastModified ( ) / 1000 ; msg = createReq ( ID_DONE , ( int ) time ) ; AdbHelper . write ( mChannel , msg , - 1 , timeOut ) ; byte [ ] result = new byte [ 8 ] ; AdbHelper . read ( mChannel , result , - 1 , timeOut ) ; if ( ! checkResult ( result , ID_OKAY ) ) { throw new SyncException ( SyncError . TRANSFER_PROTOCOL_ERROR , readErrorMessage ( result , timeOut ) ) ; } }
push a single file
