import com.google.common.collect.Maps;
import com.android.ddmlib.IDevice;
+import com.android.ddmlib.InstallException;
+import com.android.ddmlib.ShellCommandUnresponsiveException;
import com.android.ddmlib.TimeoutException;
import com.android.ddmlib.AdbCommandRejectedException;
import com.android.monkeyrunner.MonkeyDevice;
public void run() {
try {
device.executeShellCommand(command, logger);
+ } catch (TimeoutException e) {
+ LOG.log(Level.SEVERE, "Error starting command: " + command, e);
+ throw new RuntimeException(e);
+ } catch (AdbCommandRejectedException e) {
+ LOG.log(Level.SEVERE, "Error starting command: " + command, e);
+ throw new RuntimeException(e);
+ } catch (ShellCommandUnresponsiveException e) {
+ LOG.log(Level.SEVERE, "Error starting command: " + command, e);
+ throw new RuntimeException(e);
} catch (IOException e) {
LOG.log(Level.SEVERE, "Error starting command: " + command, e);
throw new RuntimeException(e);
public MonkeyImage takeSnapshot() {
try {
return new AdbMonkeyImage(device.getScreenshot());
+ } catch (TimeoutException e) {
+ LOG.log(Level.SEVERE, "Unable to take snapshot", e);
+ return null;
+ } catch (AdbCommandRejectedException e) {
+ LOG.log(Level.SEVERE, "Unable to take snapshot", e);
+ return null;
} catch (IOException e) {
LOG.log(Level.SEVERE, "Unable to take snapshot", e);
return null;
CommandOutputCapture capture = new CommandOutputCapture();
try {
device.executeShellCommand(cmd, capture);
+ } catch (TimeoutException e) {
+ LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
+ return null;
+ } catch (ShellCommandUnresponsiveException e) {
+ LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
+ return null;
+ } catch (AdbCommandRejectedException e) {
+ LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
+ return null;
} catch (IOException e) {
LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
return null;
return false;
}
return true;
- } catch (IOException e) {
+ } catch (InstallException e) {
LOG.log(Level.SEVERE, "Error installing package: " + path, e);
return false;
}
return false;
}
return true;
- } catch (IOException e) {
+ } catch (InstallException e) {
LOG.log(Level.SEVERE, "Error installing package: " + packageName, e);
return false;
}
protected void reboot(String into) {
try {
device.reboot(into);
+ } catch (TimeoutException e) {
+ LOG.log(Level.SEVERE, "Unable to reboot device", e);
+ } catch (AdbCommandRejectedException e) {
+ LOG.log(Level.SEVERE, "Unable to reboot device", e);
} catch (IOException e) {
LOG.log(Level.SEVERE, "Unable to reboot device", e);
}