/** * Write until all data in "data" is written or the connection fails or times out. * <p>This uses the default time out value. * @param chan the opened socket to write to. * @param data the buffer to send. * @throws TimeoutException in case of timeout on the connection. * @throws IOException in case of I/O error on the connection. */ static void write(SocketChannel chan, byte[] data) throws TimeoutException, IOException { write(chan, data, -1, DdmPreferences.getTimeOut()); }
/** * Write until all data in "data" is written or the connection fails or times out. * <p/>This uses the default time out value. * @param chan the opened socket to write to. * @param data the buffer to send. * @throws TimeoutException in case of timeout on the connection. * @throws IOException in case of I/O error on the connection. */ static void write(SocketChannel chan, byte[] data) throws TimeoutException, IOException { write(chan, data, -1, DdmPreferences.getTimeOut()); }
/** * Write until all data in "data" is written or the connection fails or times out. * <p/>This uses the default time out value. * @param chan the opened socket to write to. * @param data the buffer to send. * @throws TimeoutException in case of timeout on the connection. * @throws IOException in case of I/O error on the connection. */ static void write(SocketChannel chan, byte[] data) throws TimeoutException, IOException { write(chan, data, -1, DdmPreferences.getTimeOut()); }
/** * Reads from the socket until the array is filled, or no more data is coming (because * the socket closed or the timeout expired). * <p>This uses the default time out value. * * @param chan the opened socket to read from. It must be in non-blocking * mode for timeouts to work * @param data the buffer to store the read data into. * @throws TimeoutException in case of timeout on the connection. * @throws IOException in case of I/O error on the connection. */ static void read(SocketChannel chan, byte[] data) throws TimeoutException, IOException { read(chan, data, -1, DdmPreferences.getTimeOut()); }
/** * Reads from the socket until the array is filled, or no more data is coming (because * the socket closed or the timeout expired). * <p/>This uses the default time out value. * * @param chan the opened socket to read from. It must be in non-blocking * mode for timeouts to work * @param data the buffer to store the read data into. * @throws TimeoutException in case of timeout on the connection. * @throws IOException in case of I/O error on the connection. */ static void read(SocketChannel chan, byte[] data) throws TimeoutException, IOException { read(chan, data, -1, DdmPreferences.getTimeOut()); }
/** * Reads from the socket until the array is filled, or no more data is coming (because * the socket closed or the timeout expired). * <p/>This uses the default time out value. * * @param chan the opened socket to read from. It must be in non-blocking * mode for timeouts to work * @param data the buffer to store the read data into. * @throws TimeoutException in case of timeout on the connection. * @throws IOException in case of I/O error on the connection. */ static void read(SocketChannel chan, byte[] data) throws TimeoutException, IOException { read(chan, data, -1, DdmPreferences.getTimeOut()); }
@Override public void executeShellCommand(String command, IShellOutputReceiver receiver) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException { AdbHelper.executeRemoteCommand(AndroidDebugBridge.getSocketAddress(), command, this, receiver, DdmPreferences.getTimeOut()); }
public void executeShellCommand(String command, IShellOutputReceiver receiver) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException { AdbHelper.executeRemoteCommand(AndroidDebugBridge.getSocketAddress(), command, this, receiver, DdmPreferences.getTimeOut()); }
/** * Sends a command to the emulator console. * @param command The command string. <b>MUST BE TERMINATED BY \n</b>. * @return true if success */ private boolean sendCommand(String command) { boolean result = false; try { byte[] bCommand; try { bCommand = command.getBytes(DEFAULT_ENCODING); } catch (UnsupportedEncodingException e) { // wrong encoding... return result; } // write the command AdbHelper.write(mSocketChannel, bCommand, bCommand.length, DdmPreferences.getTimeOut()); result = true; } catch (Exception e) { return false; } finally { if (result == false) { // FIXME connection failed somehow, we need to disconnect the console. RemoveConsole(mPort); } } return result; }
/** * Returns the mode of the remote file. * @param path the remote file * @return an Integer containing the mode if all went well or null * otherwise * @throws IOException * @throws TimeoutException in case of a timeout reading responses from the device. */ private Integer readMode(String path) throws TimeoutException, IOException { // create the stat request message. byte[] msg = createFileReq(ID_STAT, path); AdbHelper.write(mChannel, msg, -1 /* full length */, DdmPreferences.getTimeOut()); // read the result, in a byte array containing 4 ints // (id, mode, size, time) byte[] statResult = new byte[16]; AdbHelper.read(mChannel, statResult, -1 /* full length */, DdmPreferences.getTimeOut()); // check we have the proper data back if (checkResult(statResult, ID_STAT) == false) { return null; } // we return the mode (2nd int in the array) return ArrayHelper.swap32bitFromArray(statResult, 4); }
/** * Returns the mode of the remote file. * @param path the remote file * @return an Integer containing the mode if all went well or null * otherwise * @throws IOException * @throws TimeoutException in case of a timeout reading responses from the device. */ private Integer readMode(String path) throws TimeoutException, IOException { // create the stat request message. byte[] msg = createFileReq(ID_STAT, path); AdbHelper.write(mChannel, msg, -1 /* full length */, DdmPreferences.getTimeOut()); // read the result, in a byte array containing 4 ints // (id, mode, size, time) byte[] statResult = new byte[16]; AdbHelper.read(mChannel, statResult, -1 /* full length */, DdmPreferences.getTimeOut()); // check we have the proper data back if (!checkResult(statResult, ID_STAT)) { return null; } // we return the mode (2nd int in the array) return ArrayHelper.swap32bitFromArray(statResult, 4); }
AdbHelper.write(mSocketChannel, bCommand, bCommand.length, DdmPreferences.getTimeOut());
AdbHelper.write(mChannel, request, -1, DdmPreferences.getTimeOut());
AdbHelper.write(mChannel, request, -1, DdmPreferences.getTimeOut());
AdbHelper.write(mChannel, request, -1, DdmPreferences.getTimeOut());
/** * Returns the stat info of the remote file. * @param path the remote file * @return an FileStat containing the mode, size and last modified info if all went well or null * otherwise * @throws IOException * @throws TimeoutException in case of a timeout reading responses from the device. */ @Nullable public FileStat statFile(@NonNull String path) throws TimeoutException, IOException { // create the stat request message. byte[] msg = createFileReq(ID_STAT, path); AdbHelper.write(mChannel, msg, -1 /* full length */, DdmPreferences.getTimeOut()); // read the result, in a byte array containing 4 ints // (id, mode, size, time) byte[] statResult = new byte[16]; AdbHelper.read(mChannel, statResult, -1 /* full length */, DdmPreferences.getTimeOut()); // check we have the proper data back if (!checkResult(statResult, ID_STAT)) { return null; } final int mode = ArrayHelper.swap32bitFromArray(statResult, 4); final int size = ArrayHelper.swap32bitFromArray(statResult, 8); final int lastModifiedSecs = ArrayHelper.swap32bitFromArray(statResult, 12); return new FileStat(mode, size, lastModifiedSecs); }
byte[] msg; final int timeOut = DdmPreferences.getTimeOut();
byte[] pullResult = new byte[8]; final int timeOut = DdmPreferences.getTimeOut();
byte[] msg; final int timeOut = DdmPreferences.getTimeOut(); File f = new File(localPath);
byte[] msg; final int timeOut = DdmPreferences.getTimeOut(); File f = new File(localPath);