com.android.ddmlib
Class FileListingService

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

public final class FileListingService
extends Object

Provides Device side file listing service.

To get an instance for a known Device, call Device.getFileListingService().


Nested Class Summary
static class FileListingService.FileEntry
          Represents an entry in a directory.
static interface FileListingService.IListingReceiver
          Classes which implement this interface provide a method that deals with asynchronous result from ls command on the device.
 
Field Summary
static String DIRECTORY_APP
          Application folder.
static String DIRECTORY_DATA
          Top level data folder.
static String DIRECTORY_MNT
          Top level mount folder.
static String DIRECTORY_SDCARD
          Top level sdcard folder.
static String DIRECTORY_SYSTEM
          Top level system folder.
static String DIRECTORY_TEMP
          Top level temp folder.
static String FILE_SEPARATOR
          Device side file separator.
static long REFRESH_RATE
           
static int TYPE_BLOCK
          Entry type: Block
static int TYPE_CHARACTER
          Entry type: Character
static int TYPE_DIRECTORY
          Entry type: Directory
static int TYPE_DIRECTORY_LINK
          Entry type: Directory Link
static int TYPE_FIFO
          Entry type: FIFO
static int TYPE_FILE
          Entry type: File
static int TYPE_LINK
          Entry type: Link
static int TYPE_OTHER
          Entry type: Other
static int TYPE_SOCKET
          Entry type: Socket
 
Method Summary
 FileListingService.FileEntry[] getChildren(FileListingService.FileEntry entry, boolean useCache, FileListingService.IListingReceiver receiver)
          Returns the children of a FileListingService.FileEntry.
 FileListingService.FileEntry[] getChildrenSync(FileListingService.FileEntry entry)
          Returns the children of a FileListingService.FileEntry.
 FileListingService.FileEntry getRoot()
          Returns the root element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_DATA

public static final String DIRECTORY_DATA
Top level data folder.

See Also:
Constant Field Values

DIRECTORY_SDCARD

public static final String DIRECTORY_SDCARD
Top level sdcard folder.

See Also:
Constant Field Values

DIRECTORY_MNT

public static final String DIRECTORY_MNT
Top level mount folder.

See Also:
Constant Field Values

DIRECTORY_SYSTEM

public static final String DIRECTORY_SYSTEM
Top level system folder.

See Also:
Constant Field Values

DIRECTORY_TEMP

public static final String DIRECTORY_TEMP
Top level temp folder.

See Also:
Constant Field Values

DIRECTORY_APP

public static final String DIRECTORY_APP
Application folder.

See Also:
Constant Field Values

REFRESH_RATE

public static final long REFRESH_RATE
See Also:
Constant Field Values

TYPE_FILE

public static final int TYPE_FILE
Entry type: File

See Also:
Constant Field Values

TYPE_DIRECTORY

public static final int TYPE_DIRECTORY
Entry type: Directory

See Also:
Constant Field Values

TYPE_DIRECTORY_LINK

public static final int TYPE_DIRECTORY_LINK
Entry type: Directory Link

See Also:
Constant Field Values

TYPE_BLOCK

public static final int TYPE_BLOCK
Entry type: Block

See Also:
Constant Field Values

TYPE_CHARACTER

public static final int TYPE_CHARACTER
Entry type: Character

See Also:
Constant Field Values

TYPE_LINK

public static final int TYPE_LINK
Entry type: Link

See Also:
Constant Field Values

TYPE_SOCKET

public static final int TYPE_SOCKET
Entry type: Socket

See Also:
Constant Field Values

TYPE_FIFO

public static final int TYPE_FIFO
Entry type: FIFO

See Also:
Constant Field Values

TYPE_OTHER

public static final int TYPE_OTHER
Entry type: Other

See Also:
Constant Field Values

FILE_SEPARATOR

public static final String FILE_SEPARATOR
Device side file separator.

See Also:
Constant Field Values
Method Detail

getRoot

public FileListingService.FileEntry getRoot()
Returns the root element.

Returns:
the FileListingService.FileEntry object representing the root element or null if the device is invalid.

getChildren

public FileListingService.FileEntry[] getChildren(FileListingService.FileEntry entry,
                                                  boolean useCache,
                                                  FileListingService.IListingReceiver receiver)
Returns the children of a FileListingService.FileEntry.

This method supports a cache mechanism and synchronous and asynchronous modes.

If receiver is null, the device side ls command is done synchronously, and the method will return upon completion of the command.
If receiver is non null, the command is launched is a separate thread and upon completion, the receiver will be notified of the result.

The result for each ls command is cached in the parent FileEntry. useCache allows usage of this cache, but only if the cache is valid. The cache is valid only for REFRESH_RATE ms. After that a new ls command is always executed.

If the cache is valid and useCache == true, the method will always simply return the value of the cache, whether a FileListingService.IListingReceiver has been provided or not.

Parameters:
entry - The parent entry.
useCache - A flag to use the cache or to force a new ls command.
receiver - A receiver for asynchronous calls.
Returns:
The list of children or null for asynchronous calls.
See Also:
FileListingService.FileEntry.getCachedChildren()

getChildrenSync

public FileListingService.FileEntry[] getChildrenSync(FileListingService.FileEntry entry)
                                               throws TimeoutException,
                                                      AdbCommandRejectedException,
                                                      ShellCommandUnresponsiveException,
                                                      IOException
Returns the children of a FileListingService.FileEntry.

This method is the explicit synchronous version of getChildren(FileEntry, boolean, IListingReceiver). It is roughly equivalent to calling getChildren(FileEntry, false, null)

Parameters:
entry - The parent entry.
Returns:
The list of children
Throws:
TimeoutException - in case of timeout on the connection when sending the command.
AdbCommandRejectedException - if adb rejects the command.
ShellCommandUnresponsiveException - in case the shell command doesn't send any output for a period longer than maxTimeToOutputResponse.
IOException - in case of I/O error on the connection.


Copyright © 2008-2012. All Rights Reserved.