Mercurial > 510ConnectbotMonitor
comparison src/com/five_ten_sg/connectbot/monitor/MonitorService.java @ 3:2be5bca648ab
switch to static functions
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 23 Jun 2014 17:05:16 -0700 |
parents | f6a1aabf384f |
children | 46a9cdf018a1 |
comparison
equal
deleted
inserted
replaced
2:f6a1aabf384f | 3:2be5bca648ab |
---|---|
41 public static final char MONITOR_CMD_GETFIELD = 6; | 41 public static final char MONITOR_CMD_GETFIELD = 6; |
42 public static final char MONITOR_CMD_SCREENWATCH = 7; | 42 public static final char MONITOR_CMD_SCREENWATCH = 7; |
43 public static final char MONITOR_CMD_DEPRESS = 8; | 43 public static final char MONITOR_CMD_DEPRESS = 8; |
44 | 44 |
45 public static final int MONITORPORT = 6000; | 45 public static final int MONITORPORT = 6000; |
46 public static ConcurrentHashMap<Integer,CommunicationThread> clients = new ConcurrentHashMap<Integer,CommunicationThread>(); | |
47 public static int currentConnection = -1; | |
46 | 48 |
47 private boolean speech = false; | 49 private boolean speech = false; |
48 private TextToSpeech talker = null; | 50 private TextToSpeech talker = null; |
49 public Handler handler = null; | 51 public Handler handler = null; |
50 private ServerSocket serverSocket; | 52 private ServerSocket serverSocket; |
51 private Thread serverThread = null; | 53 private Thread serverThread = null; |
52 private ConcurrentHashMap<Integer,CommunicationThread> clients = new ConcurrentHashMap<Integer,CommunicationThread>(); | |
53 private WifiManager.WifiLock wifiLock; | 54 private WifiManager.WifiLock wifiLock; |
54 private PowerManager.WakeLock wakeLock; | 55 private PowerManager.WakeLock wakeLock; |
55 final private IBinder binder = new MonitorBinder(); | 56 final private IBinder binder = new MonitorBinder(); |
56 | 57 |
57 | 58 |
331 | 332 |
332 | 333 |
333 //////////////////////////////////////// | 334 //////////////////////////////////////// |
334 //// these functions are called from your monitoring code thread | 335 //// these functions are called from your monitoring code thread |
335 | 336 |
336 public void teSetField(int connection, int l, int c, char[] buf) { | 337 public static void teSetField(int connection, int l, int c, char[] buf) { |
337 int len = buf.length; | 338 int len = buf.length; |
338 Log.i(TAG, String.format("teSetField %d request line %d column %d len %d", connection, l, c, len)); | 339 Log.i(TAG, String.format("teSetField %d request line %d column %d len %d", connection, l, c, len)); |
339 CommunicationThread cm = clients.get(connection); | 340 CommunicationThread cm = clients.get(connection); |
340 if (cm != null) { | 341 if (cm != null) { |
341 char[] arg2 = new char[4 + len]; | 342 char[] arg2 = new char[4 + len]; |
345 System.arraycopy(buf, 0, arg2, base, len); | 346 System.arraycopy(buf, 0, arg2, base, len); |
346 cm.clientWrite(MONITOR_CMD_SETFIELD, arg2); | 347 cm.clientWrite(MONITOR_CMD_SETFIELD, arg2); |
347 } | 348 } |
348 } | 349 } |
349 | 350 |
350 public char[] teGetField(int connection, int l, int c, int len) { | 351 public static char[] teGetField(int connection, int l, int c, int len) { |
351 Log.i(TAG, String.format("teGetField %d request line %d column %d len %d", connection, l, c, len)); | 352 Log.i(TAG, String.format("teGetField %d request line %d column %d len %d", connection, l, c, len)); |
352 CommunicationThread cm = clients.get(connection); | 353 CommunicationThread cm = clients.get(connection); |
353 if (cm != null) { | 354 if (cm != null) { |
354 char[] arg = new char[5]; | 355 char[] arg = new char[5]; |
355 arg[2] = (char) (l & 0x0000ffff); | 356 arg[2] = (char) (l & 0x0000ffff); |
366 } | 367 } |
367 } | 368 } |
368 return new char[0]; | 369 return new char[0]; |
369 } | 370 } |
370 | 371 |
371 public void teScreenWatch(int connection, int l, int c, int len) { | 372 public static void teScreenWatch(int connection, int l, int c, int len) { |
372 Log.i(TAG, String.format("teScreenWatch %d request line %d column %d len %d", connection, l, c, len)); | 373 Log.i(TAG, String.format("teScreenWatch %d request line %d column %d len %d", connection, l, c, len)); |
373 CommunicationThread cm = clients.get(connection); | 374 CommunicationThread cm = clients.get(connection); |
374 if (cm != null) { | 375 if (cm != null) { |
375 char[] arg = new char[5]; | 376 char[] arg = new char[5]; |
376 arg[2] = (char) (l & 0x0000ffff); | 377 arg[2] = (char) (l & 0x0000ffff); |
378 arg[4] = (char) (len & 0x0000ffff); | 379 arg[4] = (char) (len & 0x0000ffff); |
379 cm.clientWrite(MONITOR_CMD_GETFIELD, arg); | 380 cm.clientWrite(MONITOR_CMD_GETFIELD, arg); |
380 } | 381 } |
381 } | 382 } |
382 | 383 |
383 public void teSpeak(int connection, String msg, boolean flush) { | 384 public static void teSpeak(int connection, String msg, boolean flush) { |
384 if (speech) talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null); | 385 if (speech) talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null); |
385 } | 386 } |
386 | 387 |
387 public static void teDepress(int connection, int vk_key) { | 388 public static void teDepress(int connection, int vk_key) { |
388 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 | 389 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 |