Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Try to avoid NullPointerException #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public AcceptThread(boolean isAndroid) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
else
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
} catch (IOException e) { }
} catch (Exception e) { }
mmServerSocket = tmp;
}

Expand All @@ -229,7 +229,7 @@ public void run() {
// This is a blocking call and will only return on a
// successful connection or an exception
socket = mmServerSocket.accept();
} catch (IOException e) {
} catch (Exception e) {
break;
}

Expand All @@ -248,7 +248,7 @@ public void run() {
// Either not ready or already connected. Terminate new socket.
try {
socket.close();
} catch (IOException e) { }
} catch (Exception e) { }
break;
}
}
Expand All @@ -260,7 +260,7 @@ public void cancel() {
try {
mmServerSocket.close();
mmServerSocket = null;
} catch (IOException e) { }
} catch (Exception e) { }
}

public void kill() {
Expand Down Expand Up @@ -288,7 +288,7 @@ public ConnectThread(BluetoothDevice device) {
tmp = device.createRfcommSocketToServiceRecord(UUID_ANDROID_DEVICE);
else
tmp = device.createRfcommSocketToServiceRecord(UUID_OTHER_DEVICE);
} catch (IOException e) { }
} catch (Exception e) { }
mmSocket = tmp;
}

Expand All @@ -301,11 +301,11 @@ public void run() {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
} catch (Exception e) {
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) { }
} catch (Exception e2) { }
connectionFailed();
return;
}
Expand All @@ -322,7 +322,7 @@ public void run() {
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
} catch (Exception e) { }
}
}

Expand All @@ -342,7 +342,7 @@ public ConnectedThread(BluetoothSocket socket, String socketType) {
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) { }
} catch (Exception e) { }

mmInStream = tmpIn;
mmOutStream = tmpOut;
Expand All @@ -369,7 +369,7 @@ public void run() {
} else {
arr_byte.add(data);
}
} catch (IOException e) {
} catch (Exception e) {
connectionLost();
// Start the service over to restart listening mode
BluetoothService.this.start(BluetoothService.this.isAndroid);
Expand All @@ -391,13 +391,13 @@ public void write(byte[] buffer) {
// Share the sent message back to the UI Activity
mHandler.obtainMessage(BluetoothState.MESSAGE_WRITE
, -1, -1, buffer).sendToTarget();
} catch (IOException e) { }
} catch (Exception e) { }
}

public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
} catch (Exception e) { }
}
}
}
}