* limitations under the License.
*/
-package org.tizen.sdblib;
+package org.tizen.sdblib.exception;
import java.io.IOException;
/**
* Exception thrown when sdb refuses a command.
*/
-public class SdbCommandRejectedException extends IOException {
- private static final long serialVersionUID = 1L;
- private final boolean mIsDeviceOffline;
- private final boolean mErrorDuringDeviceSelection;
+public class
+SdbCommandRejectedException
+extends IOException
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3466997028942667337L;
+
+ private final boolean bDeviceOffline;
+ private final boolean bErrorDuringDeviceSelection;
- SdbCommandRejectedException(String message) {
- super(message);
- mIsDeviceOffline = "device offline".equals(message);
- mErrorDuringDeviceSelection = false;
+ public
+ SdbCommandRejectedException(
+ final String message
+ )
+ {
+ this( message, false );
}
- SdbCommandRejectedException(String message, boolean errorDuringDeviceSelection) {
- super(message);
- mErrorDuringDeviceSelection = errorDuringDeviceSelection;
- mIsDeviceOffline = "device offline".equals(message);
+ public
+ SdbCommandRejectedException(
+ final String message,
+ final boolean errorDuringDeviceSelection
+ )
+ {
+ super( message );
+ bErrorDuringDeviceSelection = errorDuringDeviceSelection;
+ bDeviceOffline = "device offline".equals(message);
}
/**
* Returns true if the error is due to the device being offline.
*/
- public boolean isDeviceOffline() {
- return mIsDeviceOffline;
+ public
+ boolean
+ isDeviceOffline()
+ {
+ return bDeviceOffline;
}
/**
* <p/>If false, sdb refused the command itself, if true, it refused to target the given
* device.
*/
- public boolean wasErrorDuringDeviceSelection() {
- return mErrorDuringDeviceSelection;
+ public
+ boolean
+ wasErrorDuringDeviceSelection()
+ {
+ return bErrorDuringDeviceSelection;
}
}
* limitations under the License.
*/
-package org.tizen.sdblib;
+package org.tizen.sdblib.exception;
import java.io.IOException;
* <p/>The command may not actually be unresponsive, it just has spent too much time not outputting
* any thing to the console.
*/
-public class ShellCommandUnresponsiveException extends IOException {
- private static final long serialVersionUID = 1L;
+public class
+ShellCommandUnresponsiveException
+extends IOException
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8123258430753698798L;
}
* limitations under the License.
*/
-package org.tizen.sdblib;
+package org.tizen.sdblib.exception;
import java.io.IOException;
* Exception thrown when a connection to sdb failed with a timeout.
*
*/
-public class TimeoutException extends IOException {
- private static final long serialVersionUID = 1L;
+public class
+TimeoutException
+extends IOException
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4311065054176283079L;
+
}
* limitations under the License.
*/
-package org.tizen.sdblib;
+package org.tizen.sdblib.util;
/**
* Utility class providing array to int/long conversion for data received from devices through sdb.
*/
-public final class ArrayHelper {
+public final class
+ArrayHelper
+{
+
+ protected ArrayHelper() {}
/**
* Swaps an unsigned value around, and puts the result in an array that can be sent to a device.
* @param offset the offset in the array where to put the swapped value.
* Array length must be at least offset + 4
*/
- public static void swap32bitsToArray(int value, byte[] dest, int offset) {
+ public static
+ void
+ swap32bitsToArray(
+ final int value,
+ final byte[] dest,
+ final int offset
+ )
+ {
dest[offset] = (byte)(value & 0x000000FF);
dest[offset + 1] = (byte)((value & 0x0000FF00) >> 8);
dest[offset + 2] = (byte)((value & 0x00FF0000) >> 16);
* @param offset the offset in the array at which the int starts
* @return the integer read from the array
*/
- public static int swap32bitFromArray(byte[] value, int offset) {
- int v = 0;
- v |= ((int)value[offset]) & 0x000000FF;
- v |= (((int)value[offset + 1]) & 0x000000FF) << 8;
- v |= (((int)value[offset + 2]) & 0x000000FF) << 16;
- v |= (((int)value[offset + 3]) & 0x000000FF) << 24;
-
- return v;
+ public static
+ int
+ swap32bitFromArray(
+ final byte[] value,
+ final int offset
+ )
+ {
+ return (((int)value[offset]) & 0x000000FF)
+ | ((((int)value[offset + 1]) & 0x000000FF) << 8)
+ | ((((int)value[offset + 2]) & 0x000000FF) << 16)
+ | ((((int)value[offset + 3]) & 0x000000FF) << 24);
}
/**
* Array length must be at least offset + 2
* @return the integer read from the array.
*/
- public static int swapU16bitFromArray(byte[] value, int offset) {
- int v = 0;
- v |= ((int)value[offset]) & 0x000000FF;
- v |= (((int)value[offset + 1]) & 0x000000FF) << 8;
-
- return v;
+ public static
+ int
+ swapU16bitFromArray(
+ final byte[] value,
+ final int offset
+ )
+ {
+ return (((int)value[offset]) & 0x000000FF )
+ | ((((int)value[offset + 1]) & 0x000000FF) << 8);
}
/**
* Array length must be at least offset + 8
* @return the integer read from the array
*/
- public static long swap64bitFromArray(byte[] value, int offset) {
- long v = 0;
- v |= ((long)value[offset]) & 0x00000000000000FFL;
- v |= (((long)value[offset + 1]) & 0x00000000000000FFL) << 8;
- v |= (((long)value[offset + 2]) & 0x00000000000000FFL) << 16;
- v |= (((long)value[offset + 3]) & 0x00000000000000FFL) << 24;
- v |= (((long)value[offset + 4]) & 0x00000000000000FFL) << 32;
- v |= (((long)value[offset + 5]) & 0x00000000000000FFL) << 40;
- v |= (((long)value[offset + 6]) & 0x00000000000000FFL) << 48;
- v |= (((long)value[offset + 7]) & 0x00000000000000FFL) << 56;
-
- return v;
+ public static
+ long
+ swap64bitFromArray(
+ final byte[] value,
+ final int offset
+ )
+ {
+ return (((long)value[offset]) & 0x00000000000000FFL)
+ | ((((long)value[offset + 1]) & 0x00000000000000FFL) << 8)
+ | ((((long)value[offset + 2]) & 0x00000000000000FFL) << 16)
+ | ((((long)value[offset + 3]) & 0x00000000000000FFL) << 24)
+ | ((((long)value[offset + 4]) & 0x00000000000000FFL) << 32)
+ | ((((long)value[offset + 5]) & 0x00000000000000FFL) << 40)
+ | ((((long)value[offset + 6]) & 0x00000000000000FFL) << 48)
+ | ((((long)value[offset + 7]) & 0x00000000000000FFL) << 56);
}
}
* - S-Core Co., Ltd
*
*/
-package org.tizen.sdblib;
+package org.tizen.sdblib.util;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import org.tizen.sdblib.Log;
+
public class SdbShellProcess extends Process {
public Process process = null;
}
private void interrupt() {
- if (bw == null)
- return;
-
char c = 0x03; //standard code representing "Ctrl-C" sequence
try {
bw.write(c);
interrupt();
try {
process.exitValue();
- } catch (IllegalThreadStateException e) {
+ }
+ catch ( final IllegalThreadStateException e )
+ {
process.destroy();
}
}