/* Description:Disconnect MAS connection if exist*/ private synchronized int disconnectServer() { log("disconnectServer()"); int index; ArrayList<Instance> instances = mManager.getAllInstances(); clearAuthorizingDevices(); if (instances == null || instances.size() == 0) { return SUCCESS; } for (index = 0; index < instances.size(); index++) { if (instances.get(index).isMasConnected()) { if (PENDING == disconnectMasSession(instances.get(index))) { mHandler.sendMessageDelayed( mHandler.obtainMessage(MAP_DISCONNECT_INSTANCE_TIMEOUT, instances.get(index)), DISCONNECT_INSTANCE_DELAY_DURATION); return PENDING; } } } /*wait MNS connection is disconnected*/ for (index = 0; index < instances.size(); index++) { if (instances.get(index).isMnsConnected()) { return PENDING; } } return SUCCESS; }
private void disable(boolean checkState) { int index = 0; Instance instance; BluetoothDevice[] devices; log("disableServer()"); if (checkState && (mState == BluetoothMap.STATE_DISABLING || mState == BluetoothMap.STATE_DISABLED)) { log("the serive is disabling or disabled"); onStateChanged(mState); return; } setState(BluetoothMap.STATE_DISABLING); if (PENDING == disconnectServer()) { return; } // MAS has to be deregistered before disabling service ArrayList<Instance> instances = mManager.getAllInstances(); for (index = 0; index < instances.size(); index++) { instance = instances.get(index); deregisterInstance(instance); } // mManager.removeAllInstances(); InstanceUtil.reset(); disableNative(); }