aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2011-09-29 14:56:11 -0700
committerBrett Chabot <brettchabot@android.com>2011-09-29 14:56:11 -0700
commit9b5b7c1634e16dd056b584ebb1b39ce40d9bdf60 (patch)
tree38fd239d57a97777c7d6a65ccad35c125099c4d8 /ddms/libs
parente75776f6d0fb63ff2d8a56eebe5ed9fd90bfdfd6 (diff)
downloadsdk-9b5b7c1634e16dd056b584ebb1b39ce40d9bdf60.zip
sdk-9b5b7c1634e16dd056b584ebb1b39ce40d9bdf60.tar.gz
sdk-9b5b7c1634e16dd056b584ebb1b39ce40d9bdf60.tar.bz2
Create FileListingService#getChildrenSync
Useful for cases where callers want to be informed of adb communication errors when retrieving child files. Bug 5392097 Change-Id: I82087d24d08f4e1b2fcda67156835367dc1bb824
Diffstat (limited to 'ddms/libs')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/FileListingService.java50
1 files changed, 40 insertions, 10 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/FileListingService.java b/ddms/libs/ddmlib/src/com/android/ddmlib/FileListingService.java
index 5ef5428..15a9fd2 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/FileListingService.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/FileListingService.java
@@ -16,6 +16,7 @@
package com.android.ddmlib;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -736,7 +737,38 @@ public final class FileListingService {
return null;
}
+ /**
+ * Returns the children of a {@link FileEntry}.
+ * <p/>
+ * This method is the explicit synchronous version of
+ * {@link #getChildren(FileEntry, boolean, IListingReceiver)}. It is roughly equivalent to
+ * calling
+ * getChildren(FileEntry, false, null)
+ *
+ * @param entry The parent entry.
+ * @return The list of children
+ * @throws TimeoutException in case of timeout on the connection when sending the command.
+ * @throws AdbCommandRejectedException if adb rejects the command.
+ * @throws ShellCommandUnresponsiveException in case the shell command doesn't send any output
+ * for a period longer than <var>maxTimeToOutputResponse</var>.
+ * @throws IOException in case of I/O error on the connection.
+ */
+ public FileEntry[] getChildrenSync(final FileEntry entry) throws TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
+ doLsAndThrow(entry);
+ return entry.getCachedChildren();
+ }
+
private void doLs(FileEntry entry) {
+ try {
+ doLsAndThrow(entry);
+ } catch (Exception e) {
+ // do nothing
+ }
+ }
+
+ private void doLsAndThrow(FileEntry entry) throws TimeoutException,
+ AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
// create a list that will receive the list of the entries
ArrayList<FileEntry> entryList = new ArrayList<FileEntry>();
@@ -755,16 +787,14 @@ public final class FileListingService {
// finish the process of the receiver to handle links
receiver.finishLinks();
- } catch (Exception e) {
- // catch all and do nothing.
- }
+ } finally {
+ // at this point we need to refresh the viewer
+ entry.fetchTime = System.currentTimeMillis();
-
- // at this point we need to refresh the viewer
- entry.fetchTime = System.currentTimeMillis();
-
- // sort the children and set them as the new children
- Collections.sort(entryList, FileEntry.sEntryComparator);
- entry.setChildren(entryList);
+ // sort the children and set them as the new children
+ Collections.sort(entryList, FileEntry.sEntryComparator);
+ entry.setChildren(entryList);
+ }
}
+
}