aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Napier <napier@google.com>2010-05-17 16:59:29 -0700
committerBill Napier <napier@google.com>2010-05-17 17:22:47 -0700
commit3cf7a66c2837c858c74aeab7a660162855e034c2 (patch)
tree92d621242c5233d00682b01fde09590ed1938cc7
parenta51d4ddc3cc08e445eb426a6a6108fad3fa842b9 (diff)
downloadsdk-3cf7a66c2837c858c74aeab7a660162855e034c2.zip
sdk-3cf7a66c2837c858c74aeab7a660162855e034c2.tar.gz
sdk-3cf7a66c2837c858c74aeab7a660162855e034c2.tar.bz2
Add a reboot command to IDevice to allow ddmlib users to reboot devices.
Change-Id: I8f8b792c68ec869980805c06aecf249558c6dc3f
-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
-rw-r--r--ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunnerTest.java3
4 files changed, 50 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;
}
diff --git a/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunnerTest.java b/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunnerTest.java
index 4727153..d365248 100644
--- a/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunnerTest.java
+++ b/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunnerTest.java
@@ -248,6 +248,9 @@ public class RemoteAndroidTestRunnerTest extends TestCase {
throw new UnsupportedOperationException();
}
+ public void reboot(String into) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
/**