am 45734b4a: Merge "Log accept and close debug statements in BluetoothSocket." into klp-modular-dev
* commit '45734b4ae180ea3c34f92575b3ed362bbf4f20e5': Log accept and close debug statements in BluetoothSocket.
This commit is contained in:
@@ -86,8 +86,8 @@ import java.nio.ByteBuffer;
|
|||||||
*/
|
*/
|
||||||
public final class BluetoothSocket implements Closeable {
|
public final class BluetoothSocket implements Closeable {
|
||||||
private static final String TAG = "BluetoothSocket";
|
private static final String TAG = "BluetoothSocket";
|
||||||
private static final boolean DBG = true;
|
private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
private static final boolean VDBG = false;
|
private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE);
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int MAX_RFCOMM_CHANNEL = 30;
|
public static final int MAX_RFCOMM_CHANNEL = 30;
|
||||||
@@ -190,7 +190,7 @@ public final class BluetoothSocket implements Closeable {
|
|||||||
BluetoothSocket as = new BluetoothSocket(this);
|
BluetoothSocket as = new BluetoothSocket(this);
|
||||||
as.mSocketState = SocketState.CONNECTED;
|
as.mSocketState = SocketState.CONNECTED;
|
||||||
FileDescriptor[] fds = mSocket.getAncillaryFileDescriptors();
|
FileDescriptor[] fds = mSocket.getAncillaryFileDescriptors();
|
||||||
if (VDBG) Log.d(TAG, "socket fd passed by stack fds: " + fds);
|
if (DBG) Log.d(TAG, "socket fd passed by stack fds: " + fds);
|
||||||
if(fds == null || fds.length != 1) {
|
if(fds == null || fds.length != 1) {
|
||||||
Log.e(TAG, "socket fd passed from stack failed, fds: " + fds);
|
Log.e(TAG, "socket fd passed from stack failed, fds: " + fds);
|
||||||
as.close();
|
as.close();
|
||||||
@@ -356,24 +356,24 @@ public final class BluetoothSocket implements Closeable {
|
|||||||
// read out port number
|
// read out port number
|
||||||
try {
|
try {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (VDBG) Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
|
if (DBG) Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
|
||||||
mPfd);
|
mPfd);
|
||||||
if(mSocketState != SocketState.INIT) return EBADFD;
|
if(mSocketState != SocketState.INIT) return EBADFD;
|
||||||
if(mPfd == null) return -1;
|
if(mPfd == null) return -1;
|
||||||
FileDescriptor fd = mPfd.getFileDescriptor();
|
FileDescriptor fd = mPfd.getFileDescriptor();
|
||||||
if (VDBG) Log.d(TAG, "bindListen(), new LocalSocket ");
|
if (DBG) Log.d(TAG, "bindListen(), new LocalSocket ");
|
||||||
mSocket = new LocalSocket(fd);
|
mSocket = new LocalSocket(fd);
|
||||||
if (VDBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() ");
|
if (DBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() ");
|
||||||
mSocketIS = mSocket.getInputStream();
|
mSocketIS = mSocket.getInputStream();
|
||||||
mSocketOS = mSocket.getOutputStream();
|
mSocketOS = mSocket.getOutputStream();
|
||||||
}
|
}
|
||||||
if (VDBG) Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS);
|
if (DBG) Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS);
|
||||||
int channel = readInt(mSocketIS);
|
int channel = readInt(mSocketIS);
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if(mSocketState == SocketState.INIT)
|
if(mSocketState == SocketState.INIT)
|
||||||
mSocketState = SocketState.LISTENING;
|
mSocketState = SocketState.LISTENING;
|
||||||
}
|
}
|
||||||
if (VDBG) Log.d(TAG, "channel: " + channel);
|
if (DBG) Log.d(TAG, "channel: " + channel);
|
||||||
if (mPort == -1) {
|
if (mPort == -1) {
|
||||||
mPort = channel;
|
mPort = channel;
|
||||||
} // else ASSERT(mPort == channel)
|
} // else ASSERT(mPort == channel)
|
||||||
@@ -443,7 +443,7 @@ public final class BluetoothSocket implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (VDBG) Log.d(TAG, "close() in, this: " + this + ", channel: " + mPort + ", state: " + mSocketState);
|
if (DBG) Log.d(TAG, "close() in, this: " + this + ", channel: " + mPort + ", state: " + mSocketState);
|
||||||
if(mSocketState == SocketState.CLOSED)
|
if(mSocketState == SocketState.CLOSED)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
@@ -453,10 +453,10 @@ public final class BluetoothSocket implements Closeable {
|
|||||||
if(mSocketState == SocketState.CLOSED)
|
if(mSocketState == SocketState.CLOSED)
|
||||||
return;
|
return;
|
||||||
mSocketState = SocketState.CLOSED;
|
mSocketState = SocketState.CLOSED;
|
||||||
if (VDBG) Log.d(TAG, "close() this: " + this + ", channel: " + mPort + ", mSocketIS: " + mSocketIS +
|
if (DBG) Log.d(TAG, "close() this: " + this + ", channel: " + mPort + ", mSocketIS: " + mSocketIS +
|
||||||
", mSocketOS: " + mSocketOS + "mSocket: " + mSocket);
|
", mSocketOS: " + mSocketOS + "mSocket: " + mSocket);
|
||||||
if(mSocket != null) {
|
if(mSocket != null) {
|
||||||
if (VDBG) Log.d(TAG, "Closing mSocket: " + mSocket);
|
if (DBG) Log.d(TAG, "Closing mSocket: " + mSocket);
|
||||||
mSocket.shutdownInput();
|
mSocket.shutdownInput();
|
||||||
mSocket.shutdownOutput();
|
mSocket.shutdownOutput();
|
||||||
mSocket.close();
|
mSocket.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user