MCPcopy Create free account
hub / github.com/XCSoar/XCSoar / run

Method run

android/src/BluetoothServerPort.java:78–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76 }
77
78 @Override public void run() {
79 while (true) {
80 try {
81 /* copy serverSocket to a local variable, so we can compare it
82 with null without risking a race condition with the thread
83 calling close() */
84 BluetoothServerSocket ss = serverSocket;
85 if (ss == null)
86 /* close() is being called by another thread, which now
87 waits for this thread to quit */
88 break;
89
90 BluetoothSocket socket = ss.accept();
91 Log.i(TAG, "Accepted Bluetooth connection from " +
92 BluetoothHelper.getDisplayString(socket));
93 BluetoothPort port = new BluetoothPort(socket);
94
95 /* make writes non-blocking and potentially lossy, to avoid
96 blocking when one of the peers doesn't receive quickly
97 enough */
98 port.setWriteTimeout(0);
99
100 add(port);
101 } catch (IOException e) {
102 Log.e(TAG, "Bluetooth server socket has failed", e);
103 closeServerSocket();
104 error(e.getMessage());
105 break;
106 }
107 }
108 }
109
110 @Override public void close() {
111 closeServerSocket();

Callers

nothing calls this directly

Calls 5

getDisplayStringMethod · 0.95
closeServerSocketMethod · 0.95
setWriteTimeoutMethod · 0.80
addMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected