BluetoothMnsServicepublic class BluetoothMnsService extends Object
Fields Summary |
---|
private static final String | TAG | private static final android.os.ParcelUuid | MAP_MNS | static final int | MSG_EVENT | static final int | EVENT_REPORT | private static android.util.SparseArray | mCallbacks | private static SocketAcceptThread | mAcceptThread | private static android.os.Handler | mSessionHandler | private static android.bluetooth.BluetoothServerSocket | mServerSocket |
Constructors Summary |
---|
BluetoothMnsService()
Log.v(TAG, "BluetoothMnsService()");
if (mCallbacks == null) {
Log.v(TAG, "BluetoothMnsService(): allocating callbacks");
mCallbacks = new SparseArray<Handler>();
}
if (mSessionHandler == null) {
Log.v(TAG, "BluetoothMnsService(): allocating session handler");
mSessionHandler = new SessionHandler(this);
}
|
Methods Summary |
---|
public void | registerCallback(int instanceId, android.os.Handler callback)
Log.v(TAG, "registerCallback()");
synchronized (mCallbacks) {
mCallbacks.put(instanceId, callback);
if (mAcceptThread == null) {
Log.v(TAG, "registerCallback(): starting MNS server");
mAcceptThread = new SocketAcceptThread();
mAcceptThread.setName("BluetoothMnsAcceptThread");
mAcceptThread.start();
}
}
| public void | unregisterCallback(int instanceId)
Log.v(TAG, "unregisterCallback()");
synchronized (mCallbacks) {
mCallbacks.remove(instanceId);
if (mCallbacks.size() == 0) {
Log.v(TAG, "unregisterCallback(): shutting down MNS server");
if (mServerSocket != null) {
try {
mServerSocket.close();
} catch (IOException e) {
}
mServerSocket = null;
}
mAcceptThread.interrupt();
try {
mAcceptThread.join(5000);
} catch (InterruptedException e) {
}
mAcceptThread = null;
}
}
|
|