aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs/ddmlib/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'ddms/libs/ddmlib/src/com')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/AdbHelper.java32
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/Device.java8
-rwxr-xr-xddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java7
3 files changed, 47 insertions, 0 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/AdbHelper.java b/ddms/libs/ddmlib/src/com/android/ddmlib/AdbHelper.java
index ce8d366..7b39076 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/AdbHelper.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/AdbHelper.java
@@ -728,4 +728,36 @@ final class AdbHelper {
}
}
+
+ /**
+ * Reboot the device.
+ *
+ * @param into what to reboot into (recovery, bootloader). Or null to just reboot.
+ */
+ public static void reboot(String into, InetSocketAddress adbSockAddr,
+ Device device) throws IOException {
+ byte[] request;
+ if (into == null) {
+ request = formAdbRequest("reboot:"); //$NON-NLS-1$
+ } else {
+ request = formAdbRequest("reboot:" + into); //$NON-NLS-1$
+ }
+
+ SocketChannel adbChan = null;
+ try {
+ adbChan = SocketChannel.open(adbSockAddr);
+ adbChan.configureBlocking(false);
+
+ // if the device is not -1, then we first tell adb we're looking to talk
+ // to a specific device
+ setDevice(adbChan, device);
+
+ if (write(adbChan, request) == false)
+ throw new IOException("failed asking for reboot");
+ } finally {
+ if (adbChan != null) {
+ adbChan.close();
+ }
+ }
+ }
}
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java b/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
index 4223248..a601c16 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
@@ -516,4 +516,12 @@ final class Device implements IDevice {
executeShellCommand("pm uninstall " + packageName, receiver);
return receiver.getErrorMessage();
}
+
+ /*
+ * (non-Javadoc)
+ * @see com.android.ddmlib.IDevice#reboot()
+ */
+ public void reboot(String into) throws IOException {
+ AdbHelper.reboot(into, AndroidDebugBridge.getSocketAddress(), this);
+ }
}
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java b/ddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java
index 47db08a..bd6f436 100755
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java
@@ -275,4 +275,11 @@ public interface IDevice {
*/
public String uninstallPackage(String packageName) throws IOException;
+ /**
+ * Reboot the device.
+ *
+ * @param into the bootloader name to reboot into, or null to just reboot the device.
+ * @throws IOException
+ */
+ public void reboot(String into) throws IOException;
}