# HG changeset patch # User Carl Byington # Date 1401392427 25200 # Node ID 1588e359a97223ae95d742cf7a4ffd6d11ead27d # Parent ab7313512aba0e758edeade32ddf2450c76619f2 queue pending monitor commands until socket is open diff -r ab7313512aba -r 1588e359a972 libs/armeabi/libcom_google_ase_Exec.so Binary file libs/armeabi/libcom_google_ase_Exec.so has changed diff -r ab7313512aba -r 1588e359a972 libs/x86/libcom_google_ase_Exec.so Binary file libs/x86/libcom_google_ase_Exec.so has changed diff -r ab7313512aba -r 1588e359a972 res/values/version.xml --- a/res/values/version.xml Thu May 22 10:46:17 2014 -0700 +++ b/res/values/version.xml Thu May 29 12:40:27 2014 -0700 @@ -1,4 +1,4 @@ - 510 ConnectBot 1.7.2-1 (e11983ee7321+ 2014-04-20) + 510Connectbot 1.7.2-1 (ab7313512aba+ 2014-05-29) diff -r ab7313512aba -r 1588e359a972 src/com/five_ten_sg/connectbot/service/TerminalBridge.java --- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Thu May 22 10:46:17 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Thu May 29 12:40:27 2014 -0700 @@ -214,10 +214,10 @@ @Override public void write(byte[] b) { try { - if (b != null && transport != null) + if (b != null && transport != null) { if (monitor != null) monitor.hostData(b); - - transport.write(b); + transport.write(b); + } } catch (IOException e) { Log.e(TAG, "Problem writing outgoing data in vt320() thread", e); @@ -226,10 +226,10 @@ @Override public void write(int b) { try { - if (transport != null) + if (transport != null) { if (monitor != null) monitor.hostData(b); - - transport.write(b); + transport.write(b); + } } catch (IOException e) { Log.e(TAG, "Problem writing outgoing data in vt320() thread", e); diff -r ab7313512aba -r 1588e359a972 src/com/five_ten_sg/connectbot/service/TerminalMonitor.java --- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Thu May 22 10:46:17 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Thu May 29 12:40:27 2014 -0700 @@ -16,6 +16,9 @@ import java.net.Socket; import java.nio.charset.Charset; import java.util.HashMap; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; public class TerminalMonitor { public final static String TAG = "ConnectBot.TerminalMonitor"; @@ -50,6 +53,7 @@ private InputStream monitor_in = null; private OutputStream monitor_out = null; private MyReader monitor_reader = null; + private BlockingQueue pending_commands = new ArrayBlockingQueue(100); private MyServiceConnection monitor_connection = new MyServiceConnection(); class MyReader extends Thread { @@ -141,6 +145,12 @@ monitor_reader.start(); String x = " " + init; monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); + char [] c; + while (true) { + c = pending_commands.poll(); + if (c == null) break; + monitorWrite(c[1], c); + } } catch (IOException e) { Log.e(TAG, "exception in onServiceConnected()", e); @@ -260,6 +270,13 @@ //Log.i(TAG, String.format("sending %d command", (int)cmd)); monitor_out.write(charsToBytes(c)); } + else { + c[1] = cmd; + pending_commands.put(c); + } + } + catch (InterruptedException e) { + Log.e(TAG, "exception in monitorWrite()", e); } catch (IOException e) { Log.i(TAG, "exception in monitorWrite(), monitor died or closed the socket", e); @@ -331,9 +348,11 @@ public synchronized void setField(int l, int c, char[] data, int offset) { Log.i(TAG, "setField()"); - byte[] d = charsToBytes(data); - byte[] b = new byte[d.length - offset]; - System.arraycopy(d, offset, b, 0, d.length - offset); + byte[] b = new byte[data.length - offset]; + int i; + for (i=0; i