diff options
author | Bill Napier <napier@google.com> | 2010-05-17 16:59:29 -0700 |
---|---|---|
committer | Bill Napier <napier@google.com> | 2010-05-17 17:22:47 -0700 |
commit | 3cf7a66c2837c858c74aeab7a660162855e034c2 (patch) | |
tree | 92d621242c5233d00682b01fde09590ed1938cc7 /ddms/libs/ddmlib/src/com | |
parent | a51d4ddc3cc08e445eb426a6a6108fad3fa842b9 (diff) | |
download | sdk-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
Diffstat (limited to 'ddms/libs/ddmlib/src/com')
-rw-r--r-- | ddms/libs/ddmlib/src/com/android/ddmlib/AdbHelper.java | 32 | ||||
-rw-r--r-- | ddms/libs/ddmlib/src/com/android/ddmlib/Device.java | 8 | ||||
-rwxr-xr-x | ddms/libs/ddmlib/src/com/android/ddmlib/IDevice.java | 7 |
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; } |