summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothSocket.java
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2017-01-06 11:29:15 +0000
committerNeil Fuller <nfuller@google.com>2017-01-06 14:18:07 +0000
commit3dfe08b1ceefb805341b04c48ec9f8f460f47a65 (patch)
tree361783c028e6f185a02cd51e4029f989e7e5f87d /framework/java/android/bluetooth/BluetoothSocket.java
parentd7315477a519ea0adc315fefe38142f41c8b6d79 (diff)
Refactor RFCOMM / BluetoothSocket usage of LocalSocket
LocalSocket is used by BluetoothSocket. BluetoothSocket passes a pre-created file descriptor to LocalSocket that is then given to the LocalSocketImpl. Commit b08c7bc0bdc48ae95be2697ca27ea89a9dd92c3e broke the behavior. Commit 7a8c36aa4e6a1b5e48f0ee5a787f10bcfece7587 put in a minimal fix. This change tidies up LocalSocket and associated classes and replaces a specialist constructor with a factory method to highlight the special case. While there an unnecessary exception has been removed. Bug: 34111534 Test: Boot device Test: vogar --mode app_process tests/tests/net/src/android/net/cts/LocalSocketTest.java Change-Id: I4ba2f2d9ea361a950ff8bc8d64fc800d998c3210
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothSocket.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothSocket.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/framework/java/android/bluetooth/BluetoothSocket.java b/framework/java/android/bluetooth/BluetoothSocket.java
index b68693880a..98a5341b30 100644
--- a/framework/java/android/bluetooth/BluetoothSocket.java
+++ b/framework/java/android/bluetooth/BluetoothSocket.java
@@ -243,7 +243,7 @@ public final class BluetoothSocket implements Closeable {
}
as.mPfd = new ParcelFileDescriptor(fds[0]);
- as.mSocket = new LocalSocket(fds[0]);
+ as.mSocket = LocalSocket.createConnectedLocalSocket(fds[0]);
as.mSocketIS = as.mSocket.getInputStream();
as.mSocketOS = as.mSocket.getOutputStream();
as.mAddress = RemoteAddr;
@@ -367,7 +367,7 @@ public final class BluetoothSocket implements Closeable {
if (mSocketState == SocketState.CLOSED) throw new IOException("socket closed");
if (mPfd == null) throw new IOException("bt socket connect failed");
FileDescriptor fd = mPfd.getFileDescriptor();
- mSocket = new LocalSocket(fd);
+ mSocket = LocalSocket.createConnectedLocalSocket(fd);
mSocketIS = mSocket.getInputStream();
mSocketOS = mSocket.getOutputStream();
}
@@ -416,9 +416,9 @@ public final class BluetoothSocket implements Closeable {
if(mSocketState != SocketState.INIT) return EBADFD;
if(mPfd == null) return -1;
FileDescriptor fd = mPfd.getFileDescriptor();
- if (DBG) Log.d(TAG, "bindListen(), new LocalSocket ");
- mSocket = new LocalSocket(fd);
- if (DBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream() ");
+ if (DBG) Log.d(TAG, "bindListen(), Create LocalSocket");
+ mSocket = LocalSocket.createConnectedLocalSocket(fd);
+ if (DBG) Log.d(TAG, "bindListen(), new LocalSocket.getInputStream()");
mSocketIS = mSocket.getInputStream();
mSocketOS = mSocket.getOutputStream();
}