+ /* Notify other waiting threads that we're connected now
+ */
+ notifyAll();
+ }
+ }
+ } catch (IOException io) {
+ connect_failed();
+ }
+ }
+
+ private void connect_failed() {
+ if (closed()) {
+ if (D) Log.d(TAG, "connect_failed after closed");
+ return;
+ }
+
+ close_socket();
+ input = null;
+ output = null;
+ handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED, this).sendToTarget();
+ if (D) Log.e(TAG, "ConnectThread: Failed to establish connection");
+ }
+
+ private void disconnected() {
+ if (closed()) {
+ if (D) Log.d(TAG, "disconnected after closed");
+ return;
+ }
+
+ if (D) Log.d(TAG, "Sending disconnected message");
+ handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget();
+ }