Mercurial > 510Connectbot
annotate src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 418:39533be5cbe9
remove unneeded catch
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 29 Oct 2014 13:28:59 -0700 |
parents | 4dcc071e1feb |
children | 660ac2d2003b |
rev | line source |
---|---|
0 | 1 package com.five_ten_sg.connectbot.service; |
2 | |
3 import android.content.ComponentName; | |
4 import android.content.Context; | |
5 import android.content.Intent; | |
6 import android.content.ServiceConnection; | |
155 | 7 import android.net.Uri; |
0 | 8 import android.os.IBinder; |
9 import android.util.Log; | |
10 import android.view.View; | |
11 import de.mud.terminal.vt320; | |
12 import java.io.IOException; | |
13 import java.io.InputStream; | |
14 import java.io.OutputStream; | |
15 import java.net.InetAddress; | |
16 import java.net.Socket; | |
17 import java.nio.charset.Charset; | |
252
932e34a11e9e
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
251
diff
changeset
|
18 import java.util.Arrays; |
0 | 19 import java.util.HashMap; |
15
1588e359a972
queue pending monitor commands until socket is open
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
20 import java.util.concurrent.ArrayBlockingQueue; |
1588e359a972
queue pending monitor commands until socket is open
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
21 import java.util.concurrent.BlockingQueue; |
1588e359a972
queue pending monitor commands until socket is open
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
22 import java.util.concurrent.ConcurrentHashMap; |
0 | 23 |
174
b010f9dc801f
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
173
diff
changeset
|
24 import com.five_ten_sg.connectbot.ConsoleActivity; |
b010f9dc801f
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
173
diff
changeset
|
25 import com.five_ten_sg.connectbot.bean.HostBean; |
b010f9dc801f
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
173
diff
changeset
|
26 |
b010f9dc801f
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
173
diff
changeset
|
27 |
0 | 28 public class TerminalMonitor { |
29 public final static String TAG = "ConnectBot.TerminalMonitor"; | |
30 | |
172
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
31 public static final char MONITOR_CMD_INIT = 0; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
32 public static final char MONITOR_CMD_ACTIVATE = 1; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
33 public static final char MONITOR_CMD_KEYSTATE = 2; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
34 public static final char MONITOR_CMD_CURSORMOVE = 3; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
35 public static final char MONITOR_CMD_SCREENCHANGE = 4; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
36 public static final char MONITOR_CMD_FIELDVALUE = 5; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
37 public static final char MONITOR_CMD_SETFIELD = 5; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
38 public static final char MONITOR_CMD_GETFIELD = 6; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
39 public static final char MONITOR_CMD_SCREENWATCH = 7; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
40 public static final char MONITOR_CMD_DEPRESS = 8; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
41 public static final char MONITOR_CMD_SHOWURL = 9; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
42 public static final char MONITOR_CMD_SWITCHSESSION = 10; |
205
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
43 public static final char MONITOR_CMD_CURSORREQUEST = 11; |
0 | 44 |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
45 public static final char CURSOR_REQUESTED = 0; |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
46 public static final char CURSOR_SCREEN_CHANGE = 1; |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
47 public static final char CURSOR_USER_KEY = 2; |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
48 |
0 | 49 private static final int MONITORPORT = 6000; |
50 private static final String LOCALHOST = "127.0.0.1"; | |
51 | |
52 private Context parent = null; | |
53 private vt320 buffer = null; | |
54 private View view = null; | |
174
b010f9dc801f
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
173
diff
changeset
|
55 private HostBean host = null; |
0 | 56 private String init = null; |
57 private int start_line = 0; // monitor part of the screen for changes | |
58 private int end_line = 500; // "" | |
59 private int start_column = 0; // "" | |
60 private int end_column = 500; // "" | |
16
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
61 private boolean modified = false; // used to delay screen change notifications |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
62 private boolean moved = false; // used to delay cursor moved notifications |
16
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
63 private int to_line = 0; // "" |
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
64 private int to_column = 0; // "" |
113
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
65 private HashMap<Integer, Integer> keymap = null; // map MS VK_ keys to vt320 virtual keys |
0 | 66 private IBinder bound = null; |
67 private Socket monitor_socket = null; | |
68 private InputStream monitor_in = null; | |
69 private OutputStream monitor_out = null; | |
70 private MyReader monitor_reader = null; | |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
71 private BlockingQueue<char[]> pending_commands = new ArrayBlockingQueue<char[]>(100); |
0 | 72 private MyServiceConnection monitor_connection = new MyServiceConnection(); |
73 | |
74 class MyReader extends Thread { | |
75 private InputStream monitor_in; | |
76 private byte[] b; | |
77 private boolean is_closing = false; | |
78 | |
79 public MyReader(InputStream monitor_in) { | |
80 this.monitor_in = monitor_in; | |
81 b = new byte[100]; | |
82 Log.i(TAG, "MyReader constructor"); | |
83 } | |
84 | |
85 public void closing() { | |
86 is_closing = true; | |
87 } | |
88 | |
89 private char[] forceRead(int len) throws IOException { | |
90 int len2 = len * 2; | |
91 int off = 0; | |
92 | |
93 if (b.length < len2) b = new byte[len2]; | |
94 | |
95 while (off < len2) { | |
96 int l = monitor_in.read(b, off, len2 - off); | |
97 | |
98 if (l < 0) throw new IOException("eof"); | |
99 | |
100 off += l; | |
101 } | |
102 | |
103 return bytesToChars(b, len2); | |
104 } | |
105 | |
106 public void run() { | |
107 while (true) { | |
108 try { | |
109 char[] len = forceRead(1); | |
110 char[] packet = forceRead(len[0]); | |
111 char cmd = packet[0]; | |
112 Log.i(TAG, String.format("received %d command", (int)cmd)); | |
113 | |
114 switch (cmd) { | |
115 case MONITOR_CMD_SETFIELD: | |
153
3ca280646f2d
allow zero length setfield
Carl Byington <carl@five-ten-sg.com>
parents:
148
diff
changeset
|
116 if (packet.length >= 3) |
0 | 117 setField(packet[1], packet[2], packet, 3); |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
118 |
0 | 119 break; |
120 | |
121 case MONITOR_CMD_GETFIELD: | |
122 if (packet.length == 4) | |
123 getField(packet[1], packet[2], packet[3]); | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
124 |
0 | 125 break; |
126 | |
127 case MONITOR_CMD_SCREENWATCH: | |
128 if (packet.length == 4) | |
129 screenWatch(packet[1], packet[2], packet[3]); | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
130 |
0 | 131 break; |
132 | |
133 case MONITOR_CMD_DEPRESS: | |
134 if (packet.length == 2) | |
135 depress(packet[1]); | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
136 |
0 | 137 break; |
138 | |
155 | 139 case MONITOR_CMD_SHOWURL: |
140 if (packet.length > 1) | |
141 showUrl(packet, 1); | |
142 | |
143 break; | |
144 | |
173
5f26d0ba6abd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
172
diff
changeset
|
145 case MONITOR_CMD_SWITCHSESSION: |
172
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
146 if (packet.length == 1) |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
147 switchSession(); |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
148 |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
149 break; |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
150 |
205
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
151 case MONITOR_CMD_CURSORREQUEST: |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
152 if (packet.length == 1) |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
153 cursorRequest(); |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
154 |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
155 break; |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
156 |
0 | 157 default: |
158 break; | |
159 } | |
160 } | |
161 catch (IOException e) { | |
162 if (!is_closing) Log.e(TAG, "exception in MyReader.run()", e); | |
163 | |
164 break; | |
165 } | |
166 } | |
167 } | |
168 } | |
169 | |
170 class MyServiceConnection implements ServiceConnection { | |
171 public void onServiceConnected(ComponentName className, IBinder service) { | |
172 bound = service; | |
173 Log.i(TAG, "bound to service"); | |
174 | |
175 try { | |
176 InetAddress serverAddr = InetAddress.getByName(LOCALHOST); | |
410
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
177 int tries = 0; |
411
8bff0bfaec3a
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
410
diff
changeset
|
178 while (tries < 10) { |
410
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
179 try { |
411
8bff0bfaec3a
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
410
diff
changeset
|
180 Thread.sleep(100); |
410
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
181 monitor_socket = new Socket(serverAddr, MONITORPORT); |
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
182 } |
412
057854c77217
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
411
diff
changeset
|
183 catch (Exception e) { |
417
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
184 monitor_socket = null; |
410
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
185 Log.e(TAG, "exception connecting to monitor socket", e); |
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
186 tries = tries + 1; |
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
187 } |
e2a56e383bad
wait for monitor socket to be created
Carl Byington <carl@five-ten-sg.com>
parents:
405
diff
changeset
|
188 } |
417
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
189 if (monitor_socket != null) { |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
190 Log.i(TAG, "connected to monitor socket, send init " + init); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
191 monitor_in = monitor_socket.getInputStream(); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
192 monitor_out = monitor_socket.getOutputStream(); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
193 monitor_reader = new MyReader(monitor_in); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
194 monitor_reader.start(); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
195 String x = " " + init; |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
196 monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
197 char [] c; |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
198 |
417
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
199 while (true) { |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
200 c = pending_commands.poll(); |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
201 |
417
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
202 if (c == null) break; |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
203 |
417
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
204 monitorWrite(c[1], c); |
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
205 } |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
206 } |
0 | 207 } |
208 catch (IOException e) { | |
209 Log.e(TAG, "exception in onServiceConnected()", e); | |
210 } | |
211 } | |
212 public void onServiceDisconnected(ComponentName classNam) { | |
213 bound = null; | |
214 Log.i(TAG, "unbound from service"); | |
215 } | |
216 }; | |
217 | |
218 | |
172
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
219 public TerminalMonitor(Context parent, vt320 buffer, View view, HostBean host, String init) { |
0 | 220 this.parent = parent; |
221 this.buffer = buffer; | |
222 this.view = view; | |
172
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
223 this.host = host; |
0 | 224 this.init = init; |
225 // setup the windows->android keymapping | |
19
b3d0d806cbe2
cleaner url for MS vk_ key documentation
Carl Byington <carl@five-ten-sg.com>
parents:
18
diff
changeset
|
226 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
227 keymap = new HashMap<Integer, Integer>(); |
113
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
228 keymap.put(0x08, vt320.KEY_BACK_SPACE); // vk_back |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
229 keymap.put(0x09, vt320.KEY_TAB); // vk_tab |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
230 keymap.put(0x0d, vt320.KEY_ENTER); // vk_return |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
231 keymap.put(0x1b, vt320.KEY_ESCAPE); // vk_escape |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
232 keymap.put(0x21, vt320.KEY_PAGE_UP); // vk_prior |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
233 keymap.put(0x22, vt320.KEY_PAGE_DOWN); // vk_next |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
234 keymap.put(0x23, vt320.KEY_END); // vk_end |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
235 keymap.put(0x24, vt320.KEY_HOME); // vk_home |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
236 keymap.put(0x25, vt320.KEY_LEFT); // vk_left |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
237 keymap.put(0x26, vt320.KEY_UP); // vk_up |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
238 keymap.put(0x27, vt320.KEY_RIGHT); // vk_right |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
239 keymap.put(0x28, vt320.KEY_DOWN); // vk_down |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
240 keymap.put(0x2d, vt320.KEY_INSERT); // vk_insert |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
241 keymap.put(0x2e, vt320.KEY_DELETE); // vk_delete |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
242 keymap.put(0x70, vt320.KEY_F1); // vk_f1 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
243 keymap.put(0x71, vt320.KEY_F2); // vk_f2 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
244 keymap.put(0x72, vt320.KEY_F3); // vk_f3 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
245 keymap.put(0x73, vt320.KEY_F4); // vk_f4 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
246 keymap.put(0x74, vt320.KEY_F5); // vk_f5 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
247 keymap.put(0x75, vt320.KEY_F6); // vk_f6 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
248 keymap.put(0x76, vt320.KEY_F7); // vk_f7 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
249 keymap.put(0x77, vt320.KEY_F8); // vk_f8 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
250 keymap.put(0x78, vt320.KEY_F9); // vk_f9 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
251 keymap.put(0x79, vt320.KEY_F10); // vk_f10 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
252 keymap.put(0x7a, vt320.KEY_F11); // vk_f11 |
cb3b9b660b3d
depress() keys from the terminal monitor go straight thru buffer.keyPressed() rather than detour though the key listener
Carl Byington <carl@five-ten-sg.com>
parents:
112
diff
changeset
|
253 keymap.put(0x7b, vt320.KEY_F12); // vk_f12 |
176 | 254 keymap.put(0x7c, vt320.KEY_F13); // vk_f13 |
255 keymap.put(0x7d, vt320.KEY_F14); // vk_f14 | |
256 keymap.put(0x7e, vt320.KEY_F15); // vk_f15 | |
257 keymap.put(0x7f, vt320.KEY_F16); // vk_f16 | |
258 keymap.put(0x80, vt320.KEY_F17); // vk_f17 | |
259 keymap.put(0x81, vt320.KEY_F18); // vk_f18 | |
260 keymap.put(0x82, vt320.KEY_F19); // vk_f19 | |
261 keymap.put(0x83, vt320.KEY_F20); // vk_f20 | |
262 keymap.put(0x84, vt320.KEY_F21); // vk_f21 | |
263 keymap.put(0x85, vt320.KEY_F22); // vk_f22 | |
264 keymap.put(0x86, vt320.KEY_F23); // vk_f23 | |
265 keymap.put(0x87, vt320.KEY_F24); // vk_f24 | |
0 | 266 // bind to the monitor service |
267 Intent intent = new Intent("com.five_ten_sg.connectbot.monitor.MonitorService"); | |
268 parent.bindService(intent, monitor_connection, Context.BIND_AUTO_CREATE); | |
269 Log.i(TAG, "constructor"); | |
270 } | |
271 | |
272 | |
273 public void Disconnect() { | |
274 if (monitor_reader != null) monitor_reader.closing(); | |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
275 |
0 | 276 try { |
277 if (monitor_out != null) monitor_out.close(); | |
278 | |
279 if (monitor_in != null) monitor_in.close(); | |
280 | |
281 if (monitor_socket != null) monitor_socket.close(); | |
282 | |
283 Log.i(TAG, "disconnected from monitor socket"); | |
284 } | |
285 catch (IOException e) { | |
286 Log.e(TAG, "exception in Disconnect() closing sockets", e); | |
287 } | |
288 | |
289 monitor_reader = null; | |
290 monitor_out = null; | |
291 monitor_in = null; | |
292 monitor_socket = null; | |
293 | |
294 if (bound != null) parent.unbindService(monitor_connection); | |
295 | |
296 monitor_connection = null; | |
297 } | |
298 | |
299 | |
300 public char[] bytesToChars(byte[] b, int len) { | |
301 char[] c = new char[len >> 1]; | |
302 int bp = 0; | |
303 | |
304 for (int i = 0; i < c.length; i++) { | |
305 byte b1 = b[bp++]; | |
306 byte b2 = b[bp++]; | |
307 c[i] = (char)(((b1 & 0x00FF) << 8) + (b2 & 0x00FF)); | |
308 } | |
309 | |
310 return c; | |
311 } | |
312 | |
313 | |
314 public byte[] charsToBytes(char[] c) { | |
315 byte[] b = new byte[c.length << 1]; | |
316 int bp = 0; | |
317 | |
318 for (int i = 0; i < c.length; i++) { | |
319 b[bp++] = (byte)((c[i] & 0xff00) >> 8); | |
320 b[bp++] = (byte)(c[i] & 0x00ff); | |
321 } | |
322 | |
323 return b; | |
324 } | |
325 | |
326 | |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
327 public synchronized void monitorWrite(char cmd, char[] c) { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
328 try { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
329 if (monitor_out != null) { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
330 c[0] = (char)(c.length - 1); // number of chars following |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
331 c[1] = cmd; |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
332 //Log.i(TAG, String.format("sending %d command", (int)cmd)); |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
333 monitor_out.write(charsToBytes(c)); |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
334 } |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
335 else { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
336 c[1] = cmd; |
417
4dcc071e1feb
monitor failure should not kill the TE
Carl Byington <carl@five-ten-sg.com>
parents:
412
diff
changeset
|
337 pending_commands.offer(c); |
402
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
338 } |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
339 } |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
340 catch (IOException e) { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
341 Log.i(TAG, "exception in monitorWrite(), monitor died or closed the socket", e); |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
342 |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
343 try { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
344 monitor_out.close(); |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
345 } |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
346 catch (IOException ee) { |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
347 Log.e(TAG, "exception in monitorWrite() closing output stream", ee); |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
348 } |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
349 |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
350 monitor_out = null; |
14aa0621aa7d
Backed out changeset 2f2b5a244a4d
Carl Byington <carl@five-ten-sg.com>
parents:
401
diff
changeset
|
351 } |
0 | 352 }; |
353 | |
227
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
354 public void resetWatch() { |
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
355 start_line = 0; |
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
356 end_line = 500; |
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
357 start_column = 0; |
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
358 end_column = 500; |
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
359 }; |
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
360 |
0 | 361 public void sendScreen(char cmd) { |
362 char lines = (char)(buffer.height & 0x0000ffff); | |
363 char columns = (char)(buffer.width & 0x0000ffff); | |
364 char[] arg = new char[4 + lines * columns]; | |
365 arg[2] = lines; | |
366 arg[3] = columns; | |
367 int base = 4; | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
368 |
0 | 369 for (int i = 0; i < lines; i++) { |
370 System.arraycopy(buffer.charArray[buffer.screenBase + i], 0, arg, base, columns); | |
371 base += columns; | |
372 } | |
112
77ac18bc1b2f
cleanup java formatting
Carl Byington <carl@five-ten-sg.com>
parents:
101
diff
changeset
|
373 |
0 | 374 monitorWrite(cmd, arg); |
227
2dd627df4dfb
delay testChanged() by 10ms for async transports; sendScreen resets watch area to the entire screen
Carl Byington <carl@five-ten-sg.com>
parents:
212
diff
changeset
|
375 resetWatch(); |
0 | 376 } |
377 | |
378 public synchronized void activate() { | |
379 sendScreen(MONITOR_CMD_ACTIVATE); | |
235
ea49747c5447
activate needs to send a cursor update
Carl Byington <carl@five-ten-sg.com>
parents:
229
diff
changeset
|
380 cursorMoved(CURSOR_SCREEN_CHANGE); |
0 | 381 } |
382 | |
148
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
383 public synchronized void keyState(boolean down) { |
0 | 384 char[] arg = new char[3]; |
148
69333ca1563c
add ptt button p2 preference
Carl Byington <carl@five-ten-sg.com>
parents:
147
diff
changeset
|
385 arg[2] = (char)((down) ? 1 : 0); |
147
1350adb077b1
monitor key state tracking
Carl Byington <carl@five-ten-sg.com>
parents:
145
diff
changeset
|
386 monitorWrite(MONITOR_CMD_KEYSTATE, arg); |
0 | 387 } |
388 | |
389 public synchronized void cursorMove(int l, int c) { | |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
390 if ((to_line != l) || (to_column != c)) moved = true; |
307 | 391 |
17
02717d15de9b
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
16
diff
changeset
|
392 to_line = l; |
16
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
393 to_column = c; |
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
394 } |
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
395 |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
396 public void cursorMoved(char why) { |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
397 char[] arg = new char[5]; |
18
49fc5fba28f3
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
17
diff
changeset
|
398 arg[2] = (char)(to_line & 0x0000ffff); |
49fc5fba28f3
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
17
diff
changeset
|
399 arg[3] = (char)(to_column & 0x0000ffff); |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
400 arg[4] = why; |
0 | 401 monitorWrite(MONITOR_CMD_CURSORMOVE, arg); |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
402 moved = false; |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
403 } |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
404 |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
405 public void testMoved() { |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
406 if (moved) cursorMoved(CURSOR_USER_KEY); |
0 | 407 } |
408 | |
409 public synchronized void testChanged() { | |
410 if (modified) { | |
411 modified = false; | |
412 sendScreen(MONITOR_CMD_SCREENCHANGE); | |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
413 cursorMoved(CURSOR_SCREEN_CHANGE); |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
414 } |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
415 else { |
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
416 if (moved) cursorMoved(CURSOR_SCREEN_CHANGE); |
16
48a8daea9221
delay sending cursor move notifications until the host is quiet
Carl Byington <carl@five-ten-sg.com>
parents:
15
diff
changeset
|
417 } |
0 | 418 } |
419 | |
420 public synchronized void screenChanged(int llow, int lhigh, int clow, int chigh) { | |
421 if ((start_line <= lhigh) && (llow <= end_line) && (start_column <= chigh) && (clow <= end_column)) { | |
422 modified = true; | |
423 } | |
424 } | |
425 | |
426 public synchronized void screenChanged(int l, int c) { | |
427 screenChanged(l, l, c, c); | |
428 } | |
429 | |
430 public synchronized void setField(int l, int c, char[] data, int offset) { | |
431 Log.i(TAG, "setField()"); | |
250
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
432 int len = data.length - offset; |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
433 char[] da = new char[len]; |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
434 System.arraycopy(data, offset, da, 0, len); |
307 | 435 |
250
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
436 if ((l > 60000) || (c > 60000)) { |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
437 l = -1; |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
438 c = -1; |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
439 } |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
440 else { |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
441 // ignore setfield outside screen boundaries |
405
d3c5480e8441
fix broken fillRegenerationBuffer/fillScreenArray attempt to handle missing attributes; fix setfield outside screen boundaries
Carl Byington <carl@five-ten-sg.com>
parents:
404
diff
changeset
|
442 if ((l >= buffer.height) || (c + len > buffer.width)) return; |
250
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
443 } |
307 | 444 |
100 | 445 buffer.setField(l, c, da); |
0 | 446 } |
447 | |
155 | 448 public synchronized void showUrl(char [] data, int offset) { |
449 Log.i(TAG, "setField()"); | |
450 char[] da = new char[data.length - offset]; | |
307 | 451 System.arraycopy(data, offset, da, 0, data.length - offset); |
155 | 452 String url = new String(da); |
453 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); | |
454 parent.startActivity(intent); | |
455 } | |
456 | |
0 | 457 public synchronized void getField(int l, int c, int len) { |
458 Log.i(TAG, "getField()"); | |
459 char[] arg2 = new char[4 + len]; | |
460 arg2[2] = (char)(l & 0x0000ffff); | |
461 arg2[3] = (char)(c & 0x0000ffff); | |
462 int base = 4; | |
307 | 463 |
404
ec74f347ab5f
fix bad args to arrays.fill(); bump version number
Carl Byington <carl@five-ten-sg.com>
parents:
402
diff
changeset
|
464 if ((l >= buffer.height) || (c + len > buffer.width)) { |
ec74f347ab5f
fix bad args to arrays.fill(); bump version number
Carl Byington <carl@five-ten-sg.com>
parents:
402
diff
changeset
|
465 Arrays.fill(arg2, base, base + len, ' '); |
250
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
466 } |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
467 else { |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
468 System.arraycopy(buffer.charArray[buffer.screenBase + l], c, arg2, base, len); |
2bf2724d8610
add range checking on get/set fields
Carl Byington <carl@five-ten-sg.com>
parents:
235
diff
changeset
|
469 } |
307 | 470 |
0 | 471 monitorWrite(MONITOR_CMD_FIELDVALUE, arg2); |
472 } | |
473 | |
474 public synchronized void screenWatch(int l, int c, int len) { | |
475 Log.i(TAG, "screenWatch()"); | |
476 start_line = l; | |
477 end_line = l; | |
478 start_column = c; | |
479 end_column = c + len - 1; | |
480 } | |
481 | |
482 public synchronized void depress(int vk_key) { | |
483 Log.i(TAG, String.format("depress() %d", vk_key)); | |
484 Integer x = keymap.get(new Integer(vk_key)); | |
307 | 485 |
175
2a7199ad90be
send cursor movement caused by user keystrokes to the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
174
diff
changeset
|
486 if (x != null) buffer.keyDepressed(x, ' ', 0); |
0 | 487 } |
172
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
488 |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
489 public synchronized void switchSession() { |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
490 Log.i(TAG, "switchSession()"); |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
491 Intent intent = new Intent(parent, ConsoleActivity.class); |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
492 intent.setAction(Intent.ACTION_VIEW); |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
493 intent.setData(host.getUri()); |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
494 parent.startActivity(intent); |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
495 } |
cb9e359ea2bd
add switch session command from the monitor
Carl Byington <carl@five-ten-sg.com>
parents:
155
diff
changeset
|
496 |
205
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
497 |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
498 public synchronized void cursorRequest() { |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
499 Log.i(TAG, "cursorRequest()"); |
229
594101a0876a
add why argument on cursor updates
Carl Byington <carl@five-ten-sg.com>
parents:
227
diff
changeset
|
500 cursorMoved(CURSOR_REQUESTED); |
205
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
501 } |
f86f1e37b504
add cursor request command to the TE
Carl Byington <carl@five-ten-sg.com>
parents:
176
diff
changeset
|
502 |
0 | 503 } |