summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothServerSocket.java
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2009-10-02 20:34:18 -0700
committerNick Pelly <npelly@google.com>2009-10-06 05:57:50 -0700
commitee1402d8d697be3aa2858ee35e57db8c3e845a12 (patch)
tree33f893b05ef1e22ee554bcae350fec7fbcf0f8ab /framework/java/android/bluetooth/BluetoothServerSocket.java
parent32759957bbc90136b768a2e83ed5e413289ef9bd (diff)
Provide an API for apps to use a dynamic RFCOMM channel and SDP record.
Hide listenUsingRfcommOn(int channel) Add listenUsingRfcomm(String name, ParcelUuid uuid) The new API automatically finds a free RFCOMM channel and registers an SDP record with the given uuid and name. The SDP record is automatically removed when the socket is closed, or if the application dies. Apps are prevented from registering SDP records with the uuid of system Bluetooth profiles, such as A2DP, HFP and OPP. Apps are prevented from removing SDP records that they did not create. This is tracked by pid. TODO: Provide an API for the connecting app to look up an SDP record. Bug: 2158900 DrNo: eastham Joke: "What did the dog say to the tree? bark." Change-Id: Ia92f51c34615a7270a403255ad2b8faa98c4a3f5
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothServerSocket.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothServerSocket.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothServerSocket.java b/framework/java/android/bluetooth/BluetoothServerSocket.java
index 45dc432d33..c14e4c0761 100644
--- a/framework/java/android/bluetooth/BluetoothServerSocket.java
+++ b/framework/java/android/bluetooth/BluetoothServerSocket.java
@@ -16,6 +16,8 @@
package android.bluetooth;
+import android.os.Handler;
+
import java.io.Closeable;
import java.io.IOException;
@@ -52,6 +54,8 @@ import java.io.IOException;
public final class BluetoothServerSocket implements Closeable {
/*package*/ final BluetoothSocket mSocket;
+ private Handler mHandler;
+ private int mMessage;
/**
* Construct a socket for incoming connections.
@@ -101,6 +105,16 @@ public final class BluetoothServerSocket implements Closeable {
* throw an IOException.
*/
public void close() throws IOException {
+ synchronized (this) {
+ if (mHandler != null) {
+ mHandler.obtainMessage(mMessage).sendToTarget();
+ }
+ }
mSocket.close();
}
+
+ /*package*/ synchronized void setCloseHandler(Handler handler, int message) {
+ mHandler = handler;
+ mMessage = message;
+ }
}