}
if (mBluetoothMnsObexClient != null) {
- mBluetoothMnsObexClient.disconnect();
+ mBluetoothMnsObexClient.shutdown();
mBluetoothMnsObexClient = null;
}
mAcceptThread = null;
if(mBluetoothMnsObexClient != null) {
- mBluetoothMnsObexClient.disconnect();
+ mBluetoothMnsObexClient.shutdown();
mBluetoothMnsObexClient = null;
}
closeConnectionSocket();
mServerSession = null;
}
if(mBluetoothMnsObexClient != null) {
- mBluetoothMnsObexClient.disconnect(); //FIXME should use shutdown when implemented
+ mBluetoothMnsObexClient.shutdown();
mBluetoothMnsObexClient = null;
}
closeConnectionSocket();
return mConnected;
}
+ /**
+ * Disconnect the connection to MNS server.
+ * Call this when the MAS client requests a de-registration on events.
+ */
public void disconnect() {
- /* should shutdown handler thread first to make sure
- * handleRegistration won't be called when disconnet
- */
- if (mHandler != null) {
- // Shut down the thread
- mHandler.removeCallbacksAndMessages(null);
- Looper looper = mHandler.getLooper();
- if (looper != null) {
- looper.quit();
- }
- mHandler = null;
- }
try {
if (mClientSession != null) {
mClientSession.disconnect(null);
Log.e(TAG, "mTransport.close error: " + e.getMessage());
}
}
+ }
+
+ /**
+ * Shutdown the MNS.
+ */
+ public void shutdown() {
+ /* should shutdown handler thread first to make sure
+ * handleRegistration won't be called when disconnet
+ */
+ if (mHandler != null) {
+ // Shut down the thread
+ mHandler.removeCallbacksAndMessages(null);
+ Looper looper = mHandler.getLooper();
+ if (looper != null) {
+ looper.quit();
+ }
+ mHandler = null;
+ }
+
+ /* Disconnect if connected */
+ disconnect();
+
if(mObserverRegistered) {
mObserver.unregisterObserver();
mObserverRegistered = false;
if(mObserverRegistered == true) {
mObserver.unregisterObserver();
mObserverRegistered = false;
+ disconnect();
}
} else if(notificationStatus == BluetoothMapAppParams.NOTIFICATION_STATUS_YES) {
/* Connect if we do not have a connection, and start the content observers providing