Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
whilu committed Jan 20, 2016
1 parent 1175ba6 commit 2712a78
Showing 1 changed file with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -205,9 +204,7 @@ public AcceptThread() {
BluetoothServerSocket tmp = null;
try {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(TAG, mAppUuid);
} catch (IOException e) {
Log.e(TAG, "listen() failed", e);
}
} catch (IOException e) {}
mmServerSocket = tmp;
}

Expand All @@ -217,7 +214,6 @@ public void run() {
try {
socket = mmServerSocket.accept();
} catch (IOException e) {
Log.e(TAG, "accept() failed", e);
break;
}
if (socket != null) {
Expand All @@ -231,9 +227,7 @@ public void run() {
case co.lujun.lmbluetoothsdk.base.State.STATE_CONNECTED:
try {
socket.close();
} catch (IOException e) {
Log.e(TAG, "Could not close unwanted socket", e);
}
} catch (IOException e) {}
break;
}
}
Expand All @@ -244,9 +238,7 @@ public void run() {
public void cancel() {
try {
mmServerSocket.close();
} catch (IOException e) {
Log.e(TAG, "close() of server failed", e);
}
} catch (IOException e) {}
}
}

Expand All @@ -263,9 +255,7 @@ public ConnectThread(BluetoothDevice device) {
BluetoothSocket tmp = null;
try {
tmp = device.createRfcommSocketToServiceRecord(mAppUuid);
} catch (IOException e) {
Log.e(TAG, "create() failed", e);
}
} catch (IOException e) {}
mmSocket = tmp;
}

Expand All @@ -277,9 +267,7 @@ public void run() {
setState(co.lujun.lmbluetoothsdk.base.State.STATE_LISTEN);
try {
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "unable to close() socket during connection failure", e2);
}
} catch (IOException e2) {}
BluetoothService.this.start();
return;
}
Expand All @@ -292,9 +280,7 @@ public void run() {
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "close() of connect socket failed", e);
}
} catch (IOException e) {}
}
}

Expand All @@ -315,9 +301,7 @@ public ConnectedThread(BluetoothSocket socket) {
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
Log.e(TAG, "temp sockets not created", e);
}
} catch (IOException e) {}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
Expand All @@ -332,7 +316,6 @@ public void run() {
mBluetoothListener.onReadData(mmSocket.getRemoteDevice(), buffer);
}
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
setState(co.lujun.lmbluetoothsdk.base.State.STATE_LISTEN);
break;
}
Expand All @@ -346,17 +329,13 @@ public void run() {
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);
} catch (IOException e) {
Log.e(TAG, "Exception during write", e);
}
} catch (IOException e) {}
}

public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "close() of connect socket failed", e);
}
} catch (IOException e) {}
}
}
}

0 comments on commit 2712a78

Please sign in to comment.