aboutsummaryrefslogtreecommitdiffstats
path: root/hierarchyviewer
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-07-14 20:17:50 -0700
committerXavier Ducrohet <xav@android.com>2010-07-15 16:45:10 -0700
commita6e573c897b84f21802a7bccad817552c32364e7 (patch)
tree086bfe0836fa7e9d03e0f7fd10cb83ba3b5f5293 /hierarchyviewer
parentee549ef4b9452802c1e7b47ad592a1c9875dbea2 (diff)
downloadsdk-a6e573c897b84f21802a7bccad817552c32364e7.zip
sdk-a6e573c897b84f21802a7bccad817552c32364e7.tar.gz
sdk-a6e573c897b84f21802a7bccad817552c32364e7.tar.bz2
Add new exceptions to ddmlib.
- AdbCommandRejectedException is thrown when adb doesn't respond to the command with OKAY. This used to throw a normal IOException but it can be useful to throw a different type. The message of the exception is the error string returned by adb. - ShellCommandUnresponsiveException is the new "timeout" exception for output received by shell command running on devices. This makes the distinction between timeout when talking to adb and issue with shell command not outputting anything. Also made the javadoc for the IDevice.executeShellCommand clearer to what the "timeout" (renamed to maxTimeToOutputResponse) does. Also added a better timeout to the IDevice methods to install/uninstall apps as the default 5sec timeout was likely to be too low. Current default value is 2min. Change-Id: I4ecb9498926295a4e801e71b33df5d611e8120b8
Diffstat (limited to 'hierarchyviewer')
-rw-r--r--hierarchyviewer/src/com/android/hierarchyviewer/device/DeviceBridge.java34
1 files changed, 30 insertions, 4 deletions
diff --git a/hierarchyviewer/src/com/android/hierarchyviewer/device/DeviceBridge.java b/hierarchyviewer/src/com/android/hierarchyviewer/device/DeviceBridge.java
index 0f60be6..209577d 100644
--- a/hierarchyviewer/src/com/android/hierarchyviewer/device/DeviceBridge.java
+++ b/hierarchyviewer/src/com/android/hierarchyviewer/device/DeviceBridge.java
@@ -16,10 +16,12 @@
package com.android.hierarchyviewer.device;
+import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log;
import com.android.ddmlib.MultiLineReceiver;
+import com.android.ddmlib.TimeoutException;
import java.io.IOException;
import java.io.File;
@@ -120,8 +122,20 @@ public class DeviceBridge {
synchronized (devicePortMap) {
if (device.getState() == IDevice.DeviceState.ONLINE) {
int localPort = nextLocalPort++;
- device.createForward(localPort, Configuration.DEFAULT_SERVER_PORT);
- devicePortMap.put(device, localPort);
+ try {
+ device.createForward(localPort, Configuration.DEFAULT_SERVER_PORT);
+ devicePortMap.put(device, localPort);
+ } catch (TimeoutException e) {
+ Log.e("hierarchy", "Timeout setting up port forwarding for " + device);
+ } catch (AdbCommandRejectedException e) {
+ Log.e("hierarchy", String.format(
+ "Adb rejected forward command for device %1$s: %2$s",
+ device, e.getMessage()));
+ } catch (IOException e) {
+ Log.e("hierarchy", String.format(
+ "Failed to create forward for device %1$s: %2$s",
+ device, e.getMessage()));
+ }
}
}
}
@@ -130,8 +144,20 @@ public class DeviceBridge {
synchronized (devicePortMap) {
final Integer localPort = devicePortMap.get(device);
if (localPort != null) {
- device.removeForward(localPort, Configuration.DEFAULT_SERVER_PORT);
- devicePortMap.remove(device);
+ try {
+ device.removeForward(localPort, Configuration.DEFAULT_SERVER_PORT);
+ devicePortMap.remove(device);
+ } catch (TimeoutException e) {
+ Log.e("hierarchy", "Timeout removing port forwarding for " + device);
+ } catch (AdbCommandRejectedException e) {
+ Log.e("hierarchy", String.format(
+ "Adb rejected remove-forward command for device %1$s: %2$s",
+ device, e.getMessage()));
+ } catch (IOException e) {
+ Log.e("hierarchy", String.format(
+ "Failed to remove forward for device %1$s: %2$s",
+ device, e.getMessage()));
+ }
}
}
}