com.android.ddmlib
Class SyncService

java.lang.Object
  extended by com.android.ddmlib.SyncService

public final class SyncService
extends Object

Sync service class to push/pull to/from devices/emulators, through the debug bridge.

To get a SyncService object, use Device.getSyncService().


Nested Class Summary
static interface SyncService.ISyncProgressMonitor
          Classes which implement this interface provide methods that deal with displaying transfer progress.
 
Method Summary
 void close()
          Closes the connection.
static SyncService.ISyncProgressMonitor getNullProgressMonitor()
          Returns a sync progress monitor that does nothing.
 void pull(FileListingService.FileEntry[] entries, String localPath, SyncService.ISyncProgressMonitor monitor)
          Pulls file(s) or folder(s).
 void pullFile(FileListingService.FileEntry remote, String localFilename, SyncService.ISyncProgressMonitor monitor)
          Pulls a single file.
 void pullFile(String remoteFilepath, String localFilename, SyncService.ISyncProgressMonitor monitor)
          Pulls a single file.
 void push(String[] local, FileListingService.FileEntry remote, SyncService.ISyncProgressMonitor monitor)
          Push several files.
 void pushFile(String local, String remote, SyncService.ISyncProgressMonitor monitor)
          Push a single file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
Closes the connection.


getNullProgressMonitor

public static SyncService.ISyncProgressMonitor getNullProgressMonitor()
Returns a sync progress monitor that does nothing. This allows background tasks that don't want/need to display ui, to pass a valid SyncService.ISyncProgressMonitor.

This object can be reused multiple times and can be used by concurrent threads.


pull

public void pull(FileListingService.FileEntry[] entries,
                 String localPath,
                 SyncService.ISyncProgressMonitor monitor)
          throws SyncException,
                 IOException,
                 TimeoutException
Pulls file(s) or folder(s).

Parameters:
entries - the remote item(s) to pull
localPath - The local destination. If the entries count is > 1 or if the unique entry is a folder, this should be a folder.
monitor - The progress monitor. Cannot be null.
Throws:
SyncException
IOException
TimeoutException
See Also:
FileListingService.FileEntry, getNullProgressMonitor()

pullFile

public void pullFile(FileListingService.FileEntry remote,
                     String localFilename,
                     SyncService.ISyncProgressMonitor monitor)
              throws IOException,
                     SyncException,
                     TimeoutException
Pulls a single file.

Parameters:
remote - the remote file
localFilename - The local destination.
monitor - The progress monitor. Cannot be null.
Throws:
IOException - in case of an IO exception.
TimeoutException - in case of a timeout reading responses from the device.
SyncException - in case of a sync exception.
See Also:
FileListingService.FileEntry, getNullProgressMonitor()

pullFile

public void pullFile(String remoteFilepath,
                     String localFilename,
                     SyncService.ISyncProgressMonitor monitor)
              throws TimeoutException,
                     IOException,
                     SyncException
Pulls a single file.

Because this method just deals with a String for the remote file instead of a FileListingService.FileEntry, the size of the file being pulled is unknown and the SyncService.ISyncProgressMonitor will not properly show the progress

Parameters:
remoteFilepath - the full path to the remote file
localFilename - The local destination.
monitor - The progress monitor. Cannot be null.
Throws:
IOException - in case of an IO exception.
TimeoutException - in case of a timeout reading responses from the device.
SyncException - in case of a sync exception.
See Also:
getNullProgressMonitor()

push

public void push(String[] local,
                 FileListingService.FileEntry remote,
                 SyncService.ISyncProgressMonitor monitor)
          throws SyncException,
                 IOException,
                 TimeoutException
Push several files.

Parameters:
local - An array of loca files to push
remote - the remote FileListingService.FileEntry representing a directory.
monitor - The progress monitor. Cannot be null.
Throws:
SyncException - if file could not be pushed
IOException - in case of I/O error on the connection.
TimeoutException - in case of a timeout reading responses from the device.

pushFile

public void pushFile(String local,
                     String remote,
                     SyncService.ISyncProgressMonitor monitor)
              throws SyncException,
                     IOException,
                     TimeoutException
Push a single file.

Parameters:
local - the local filepath.
remote - The remote filepath.
monitor - The progress monitor. Cannot be null.
Throws:
SyncException - if file could not be pushed
IOException - in case of I/O error on the connection.
TimeoutException - in case of a timeout reading responses from the device.


Copyright © 2008-2012. All Rights Reserved.