@@ -33,11 +33,11 @@ public class JsDebugger
3333 private static native void processDebugMessages ();
3434
3535 private static native void enable ();
36-
36+
3737 private static native void disable ();
38-
38+
3939 private static native void debugBreak ();
40-
40+
4141 private static native void sendCommand (byte [] command , int length );
4242
4343 private final Context context ;
@@ -51,9 +51,9 @@ public class JsDebugger
5151 private static final String portEnvOutputFile = "envDebug.out" ;
5252
5353 private static int currentPort = INVALID_PORT ;
54-
54+
5555 private static LinkedBlockingQueue <String > dbgMessages = new LinkedBlockingQueue <String >();
56-
56+
5757 private static void enqueueMessage (String message )
5858 {
5959 dbgMessages .add (message );
@@ -63,24 +63,24 @@ public JsDebugger(Context context)
6363 {
6464 this .context = context ;
6565 }
66-
66+
6767 private static ServerSocket serverSocket ;
6868 private static ServerThread serverThread = null ;
6969 private static Thread javaServerThread = null ;
70-
70+
7171 private static class ServerThread implements Runnable
7272 {
7373 private volatile boolean running ;
7474 private final int port ;
7575 private ResponseWorker responseWorker ;
7676 private ListenerWorker commThread ;
77-
77+
7878 public ServerThread (int port )
7979 {
8080 this .port = port ;
8181 this .running = false ;
8282 }
83-
83+
8484 public void stop ()
8585 {
8686 this .running = false ;
@@ -94,7 +94,7 @@ public void stop()
9494 e .printStackTrace ();
9595 }
9696 }
97-
97+
9898 public void run ()
9999 {
100100 try
@@ -113,10 +113,10 @@ public void run()
113113 try
114114 {
115115 Socket socket = serverSocket .accept ();
116-
116+
117117 this .responseWorker = new ResponseWorker (socket );
118118 new Thread (this .responseWorker ).start ();
119-
119+
120120 commThread = new ListenerWorker (socket .getInputStream ());
121121 new Thread (commThread ).start ();
122122 }
@@ -127,13 +127,12 @@ public void run()
127127 }
128128 }
129129 }
130-
130+
131131 private static class ListenerWorker implements Runnable
132132 {
133133 private enum State
134134 {
135- Header ,
136- Message
135+ Header , Message
137136 }
138137
139138 private BufferedReader input ;
@@ -142,20 +141,20 @@ public ListenerWorker(InputStream inputStream)
142141 {
143142 this .input = new BufferedReader (new InputStreamReader (inputStream ));
144143 }
145-
144+
146145 private volatile boolean running = true ;
147-
146+
148147 public void run ()
149148 {
150149 Scanner scanner = new Scanner (this .input );
151150 scanner .useDelimiter ("\r \n " );
152-
151+
153152 ArrayList <String > headers = new ArrayList <String >();
154153 String line ;
155154 State state = State .Header ;
156155 int messageLength = -1 ;
157156 String leftOver = null ;
158-
157+
159158 Runnable dispatchProcessDebugMessages = new Runnable ()
160159 {
161160 @ Override
@@ -196,7 +195,7 @@ public void run()
196195 leftOver = line .substring (messageLength );
197196 state = State .Header ;
198197 headers .clear ();
199-
198+
200199 try
201200 {
202201 byte [] cmdBytes = msg .getBytes ("UTF-16LE" );
@@ -237,32 +236,32 @@ public void run()
237236 }
238237 }
239238 }
240-
239+
241240 private static class ResponseWorker implements Runnable
242241 {
243242 private Socket socket ;
244-
243+
245244 private final static String END_MSG = "#end#" ;
246-
245+
247246 private OutputStream output ;
248-
247+
249248 public ResponseWorker (Socket clientSocket ) throws IOException
250249 {
251250 this .socket = clientSocket ;
252251 this .output = this .socket .getOutputStream ();
253252 }
254-
253+
255254 public void stop ()
256255 {
257256 dbgMessages .add (END_MSG );
258257 }
259-
258+
260259 @ Override
261260 public void run ()
262261 {
263262 byte [] LINE_END_BYTES = new byte [2 ];
264- LINE_END_BYTES [0 ] = (byte )'\r' ;
265- LINE_END_BYTES [1 ] = (byte )'\n' ;
263+ LINE_END_BYTES [0 ] = (byte ) '\r' ;
264+ LINE_END_BYTES [1 ] = (byte ) '\n' ;
266265 while (true )
267266 {
268267 try
@@ -271,7 +270,7 @@ public void run()
271270
272271 if (msg .equals (END_MSG ))
273272 break ;
274-
273+
275274 byte [] utf8 ;
276275 try
277276 {
@@ -282,7 +281,7 @@ public void run()
282281 utf8 = null ;
283282 e1 .printStackTrace ();
284283 }
285-
284+
286285 if (utf8 != null )
287286 {
288287 try
@@ -310,7 +309,6 @@ public void run()
310309 }
311310 }
312311
313-
314312 int getDebuggerPortFromEnvironment ()
315313 {
316314 int port = INVALID_PORT ;
@@ -345,7 +343,7 @@ int getDebuggerPortFromEnvironment()
345343 }
346344 w = null ;
347345 }
348-
346+
349347 try
350348 {
351349 Thread .sleep (3 * 1000 );
@@ -354,7 +352,7 @@ int getDebuggerPortFromEnvironment()
354352 {
355353 e1 .printStackTrace ();
356354 }
357-
355+
358356 File envInFile = new File (baseDir , portEnvInputFile );
359357 if (envInFile .exists ())
360358 {
@@ -372,7 +370,7 @@ int getDebuggerPortFromEnvironment()
372370 {
373371 requestedPort = INVALID_PORT ;
374372 }
375-
373+
376374 w = new OutputStreamWriter (new FileOutputStream (envOutFile , true ));
377375 int localPort = (requestedPort != INVALID_PORT ) ? requestedPort : getAvailablePort ();
378376 String strLocalPort = "PORT=" + localPort + "\n " ;
@@ -449,7 +447,7 @@ private static int getAvailablePort()
449447 return port ;
450448 }
451449
452- static void enableAgent (String packageName , int port , boolean waitForConnection )
450+ private static void enableAgent (String packageName , int port , boolean waitForConnection )
453451 {
454452 enable ();
455453 if (serverThread == null )
@@ -460,7 +458,7 @@ static void enableAgent(String packageName, int port, boolean waitForConnection)
460458 javaServerThread .start ();
461459 }
462460
463- static void disableAgent ()
461+ private static void disableAgent ()
464462 {
465463 disable ();
466464 if (serverThread != null )
0 commit comments