public final class FileListingService
extends java.lang.Object
Device
side file listing service.
To get an instance for a known Device
, call Device.getFileListingService()
.
Modifier and Type | Class and Description |
---|---|
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. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DIRECTORY_APP
Application folder.
|
static java.lang.String |
DIRECTORY_DATA
Top level data folder.
|
static java.lang.String |
DIRECTORY_MNT
Top level mount folder.
|
static java.lang.String |
DIRECTORY_SDCARD
Top level sdcard folder.
|
static java.lang.String |
DIRECTORY_SYSTEM
Top level system folder.
|
static java.lang.String |
DIRECTORY_TEMP
Top level temp folder.
|
static java.lang.String |
FILE_SEPARATOR
Device side file separator.
|
static java.util.regex.Pattern |
LS_L_PATTERN
Regexp pattern to parse the result from ls.
|
static java.util.regex.Pattern |
LS_LD_PATTERN |
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
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final java.lang.String DIRECTORY_DATA
public static final java.lang.String DIRECTORY_SDCARD
public static final java.lang.String DIRECTORY_MNT
public static final java.lang.String DIRECTORY_SYSTEM
public static final java.lang.String DIRECTORY_TEMP
public static final java.lang.String DIRECTORY_APP
public static final long REFRESH_RATE
public static final int TYPE_FILE
public static final int TYPE_DIRECTORY
public static final int TYPE_DIRECTORY_LINK
public static final int TYPE_BLOCK
public static final int TYPE_CHARACTER
public static final int TYPE_LINK
public static final int TYPE_SOCKET
public static final int TYPE_FIFO
public static final int TYPE_OTHER
public static final java.lang.String FILE_SEPARATOR
public static final java.util.regex.Pattern LS_L_PATTERN
public static final java.util.regex.Pattern LS_LD_PATTERN
public FileListingService.FileEntry getRoot()
FileListingService.FileEntry
object representing the root element or
null
if the device is invalid.public FileListingService.FileEntry[] getChildren(FileListingService.FileEntry entry, boolean useCache, FileListingService.IListingReceiver receiver)
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.
entry
- The parent entry.useCache
- A flag to use the cache or to force a new ls command.receiver
- A receiver for asynchronous calls.null
for asynchronous calls.FileListingService.FileEntry.getCachedChildren()
public FileListingService.FileEntry[] getChildrenSync(FileListingService.FileEntry entry) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, java.io.IOException
FileListingService.FileEntry
.
This method is the explicit synchronous version of
getChildren(FileEntry, boolean, IListingReceiver)
. It is roughly equivalent to
calling
getChildren(FileEntry, false, null)
entry
- The parent entry.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.java.io.IOException
- in case of I/O error on the connection.