# HG changeset patch # User Carl Byington # Date 1414609968 25200 # Node ID 4dcc071e1feb11cc9ec0f2f7a150d02a115d99d5 # Parent 07c1da90deab96bcee841f34ccdd581b5a362fa8 monitor failure should not kill the TE diff -r 07c1da90deab -r 4dcc071e1feb src/com/five_ten_sg/connectbot/TerminalView.java --- a/src/com/five_ten_sg/connectbot/TerminalView.java Mon Oct 27 13:58:42 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/TerminalView.java Wed Oct 29 12:12:48 2014 -0700 @@ -72,7 +72,6 @@ private Matrix scaleMatrix; private static final Matrix.ScaleToFit scaleType = Matrix.ScaleToFit.FILL; - private Toast notification = null; private String lastNotification = null; private volatile boolean notifications = true; @@ -242,22 +241,11 @@ } public void notifyUser(String message) { - if (!notifications) - return; - - if (notification != null) { - // Don't keep telling the user the same thing. - if (lastNotification != null && lastNotification.equals(message)) - return; - - notification.setText(message); - notification.show(); - } - else { - notification = Toast.makeText(context, message, Toast.LENGTH_SHORT); - notification.show(); - } - + if (!notifications) return; + // Don't keep telling the user the same thing. + if (lastNotification != null && lastNotification.equals(message)) return; + Toast notification = Toast.makeText(context, message, Toast.LENGTH_SHORT); + notification.show(); lastNotification = message; } diff -r 07c1da90deab -r 4dcc071e1feb src/com/five_ten_sg/connectbot/service/TerminalMonitor.java --- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Mon Oct 27 13:58:42 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Wed Oct 29 12:12:48 2014 -0700 @@ -181,25 +181,28 @@ monitor_socket = new Socket(serverAddr, MONITORPORT); } catch (Exception e) { + monitor_socket = null; Log.e(TAG, "exception connecting to monitor socket", e); tries = tries + 1; } } - Log.i(TAG, "connected to monitor socket, send init " + init); - monitor_in = monitor_socket.getInputStream(); - monitor_out = monitor_socket.getOutputStream(); - monitor_reader = new MyReader(monitor_in); - monitor_reader.start(); - String x = " " + init; - monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); - char [] c; + if (monitor_socket != null) { + Log.i(TAG, "connected to monitor socket, send init " + init); + monitor_in = monitor_socket.getInputStream(); + monitor_out = monitor_socket.getOutputStream(); + monitor_reader = new MyReader(monitor_in); + monitor_reader.start(); + String x = " " + init; + monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); + char [] c; - while (true) { - c = pending_commands.poll(); + while (true) { + c = pending_commands.poll(); - if (c == null) break; + if (c == null) break; - monitorWrite(c[1], c); + monitorWrite(c[1], c); + } } } catch (IOException e) { @@ -331,7 +334,7 @@ } else { c[1] = cmd; - pending_commands.put(c); + pending_commands.offer(c); } } catch (InterruptedException e) {