Loading src/com/android/bluetooth/map/BluetoothMapMasInstance.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -410,8 +410,9 @@ public class BluetoothMapMasInstance implements IObexConnectionHandler { removeSdpRecord(); removeSdpRecord(); closeConnectionSocket(); closeConnectionSocket(); // Do not block for Accept thread cleanup. closeServerSockets(true); // Fix Handler Thread block during BT Turn OFF. closeServerSockets(false); } } /** /** Loading src/com/android/bluetooth/map/BluetoothMapService.java +44 −12 Original line number Original line Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class BluetoothMapService extends ProfileService { private boolean mSdpSearchInitiated = false; private boolean mSdpSearchInitiated = false; SdpMnsRecord mMnsRecord = null; SdpMnsRecord mMnsRecord = null; private MapServiceMessageHandler mSessionStatusHandler; private MapServiceMessageHandler mSessionStatusHandler; private boolean mStartError = true; private boolean mServiceStarted = false; private boolean mSmsCapable = true; private boolean mSmsCapable = true; Loading @@ -165,7 +165,8 @@ public class BluetoothMapService extends ProfileService { if (DEBUG) { if (DEBUG) { Log.d(TAG, "MAP Service closeService in"); Log.d(TAG, "MAP Service closeService in"); } } // Mark MapService Started as false while shutdown ongoing. mServiceStarted = false; if (mBluetoothMnsObexClient != null) { if (mBluetoothMnsObexClient != null) { mBluetoothMnsObexClient.shutdown(); mBluetoothMnsObexClient.shutdown(); mBluetoothMnsObexClient = null; mBluetoothMnsObexClient = null; Loading Loading @@ -505,7 +506,7 @@ public class BluetoothMapService extends ProfileService { } } protected boolean isMapStarted() { protected boolean isMapStarted() { return !mStartError; return mServiceStarted; } } public static BluetoothDevice getRemoteDevice() { public static BluetoothDevice getRemoteDevice() { Loading Loading @@ -672,8 +673,8 @@ public class BluetoothMapService extends ProfileService { // start RFCOMM listener // start RFCOMM listener sendStartListenerMessage(-1); sendStartListenerMessage(-1); mStartError = false; mServiceStarted = true; return !mStartError; return mServiceStarted; } } /** /** Loading Loading @@ -844,7 +845,8 @@ public class BluetoothMapService extends ProfileService { //TODO: Check if the profile state can be retreived from ProfileService or AdapterService. //TODO: Check if the profile state can be retreived from ProfileService or AdapterService. if (!isMapStarted()) { if (!isMapStarted()) { if (DEBUG) { if (DEBUG) { Log.d(TAG, "Service Not Available to STOP, ignoring"); Log.d(TAG, "Service Not Available to STOP or Shutdown already" + " in progress - Ignoring"); } } return true; return true; } else { } else { Loading @@ -852,11 +854,13 @@ public class BluetoothMapService extends ProfileService { Log.d(TAG, "Service Stoping()"); Log.d(TAG, "Service Stoping()"); } } } } // setState Disconnect already handled from closeService. // Handle it otherwise - Redundant for backup? setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); if (mSessionStatusHandler != null) { if (mSessionStatusHandler != null) { sendShutdownMessage(); sendShutdownMessage(); } } mStartError = true; mServiceStarted = false; setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); return true; return true; } } Loading @@ -865,10 +869,26 @@ public class BluetoothMapService extends ProfileService { if (DEBUG) { if (DEBUG) { Log.d(TAG, "cleanup()"); Log.d(TAG, "cleanup()"); } } // Stop MapProfile if already started. // TODO: Check if the profile state can be retreived from ProfileService or AdapterService. if (!isMapStarted()) { if (DEBUG) { Log.d(TAG, "Service Not Available to STOP or Shutdown already" + " in progress - Ignoring"); } return true; } else { if (VERBOSE) Log.d(TAG, "Service Stoping()"); } // SetState Disconnect already handled from closeService. // Handle it otherwise. Redundant for backup ? setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); //Cleanup already handled in Stop(). //Cleanup already handled in Stop(). //Move this extra check to Handler. //Move this extra check to Handler. if (mSessionStatusHandler != null) { sendShutdownMessage(); sendShutdownMessage(); } mServiceStarted = false; return true; return true; } } Loading Loading @@ -1057,10 +1077,22 @@ public class BluetoothMapService extends ProfileService { int state = int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); if (state == BluetoothAdapter.STATE_TURNING_OFF) { if (state == BluetoothAdapter.STATE_TURNING_OFF) { if (DEBUG) Log.d(TAG, "STATE_TURNING_OFF"); // Stop MapProfile if already started. if (!isMapStarted()) { if (DEBUG) { if (DEBUG) { Log.d(TAG, "STATE_TURNING_OFF"); Log.d(TAG, "Service Not Available to STOP or Shutdown already" + " in progress - Ignoring"); } } } else if (mSessionStatusHandler != null) { if (VERBOSE) Log.d(TAG, "Service Stoping()"); sendShutdownMessage(); sendShutdownMessage(); } else { if (DEBUG) { Log.d(TAG, "Unable to perform STOP or Shutdown already" + " in progress - Ignoring"); } } } else if (state == BluetoothAdapter.STATE_ON) { } else if (state == BluetoothAdapter.STATE_ON) { if (DEBUG) { if (DEBUG) { Log.d(TAG, "STATE_ON"); Log.d(TAG, "STATE_ON"); Loading Loading
src/com/android/bluetooth/map/BluetoothMapMasInstance.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -410,8 +410,9 @@ public class BluetoothMapMasInstance implements IObexConnectionHandler { removeSdpRecord(); removeSdpRecord(); closeConnectionSocket(); closeConnectionSocket(); // Do not block for Accept thread cleanup. closeServerSockets(true); // Fix Handler Thread block during BT Turn OFF. closeServerSockets(false); } } /** /** Loading
src/com/android/bluetooth/map/BluetoothMapService.java +44 −12 Original line number Original line Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class BluetoothMapService extends ProfileService { private boolean mSdpSearchInitiated = false; private boolean mSdpSearchInitiated = false; SdpMnsRecord mMnsRecord = null; SdpMnsRecord mMnsRecord = null; private MapServiceMessageHandler mSessionStatusHandler; private MapServiceMessageHandler mSessionStatusHandler; private boolean mStartError = true; private boolean mServiceStarted = false; private boolean mSmsCapable = true; private boolean mSmsCapable = true; Loading @@ -165,7 +165,8 @@ public class BluetoothMapService extends ProfileService { if (DEBUG) { if (DEBUG) { Log.d(TAG, "MAP Service closeService in"); Log.d(TAG, "MAP Service closeService in"); } } // Mark MapService Started as false while shutdown ongoing. mServiceStarted = false; if (mBluetoothMnsObexClient != null) { if (mBluetoothMnsObexClient != null) { mBluetoothMnsObexClient.shutdown(); mBluetoothMnsObexClient.shutdown(); mBluetoothMnsObexClient = null; mBluetoothMnsObexClient = null; Loading Loading @@ -505,7 +506,7 @@ public class BluetoothMapService extends ProfileService { } } protected boolean isMapStarted() { protected boolean isMapStarted() { return !mStartError; return mServiceStarted; } } public static BluetoothDevice getRemoteDevice() { public static BluetoothDevice getRemoteDevice() { Loading Loading @@ -672,8 +673,8 @@ public class BluetoothMapService extends ProfileService { // start RFCOMM listener // start RFCOMM listener sendStartListenerMessage(-1); sendStartListenerMessage(-1); mStartError = false; mServiceStarted = true; return !mStartError; return mServiceStarted; } } /** /** Loading Loading @@ -844,7 +845,8 @@ public class BluetoothMapService extends ProfileService { //TODO: Check if the profile state can be retreived from ProfileService or AdapterService. //TODO: Check if the profile state can be retreived from ProfileService or AdapterService. if (!isMapStarted()) { if (!isMapStarted()) { if (DEBUG) { if (DEBUG) { Log.d(TAG, "Service Not Available to STOP, ignoring"); Log.d(TAG, "Service Not Available to STOP or Shutdown already" + " in progress - Ignoring"); } } return true; return true; } else { } else { Loading @@ -852,11 +854,13 @@ public class BluetoothMapService extends ProfileService { Log.d(TAG, "Service Stoping()"); Log.d(TAG, "Service Stoping()"); } } } } // setState Disconnect already handled from closeService. // Handle it otherwise - Redundant for backup? setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); if (mSessionStatusHandler != null) { if (mSessionStatusHandler != null) { sendShutdownMessage(); sendShutdownMessage(); } } mStartError = true; mServiceStarted = false; setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); return true; return true; } } Loading @@ -865,10 +869,26 @@ public class BluetoothMapService extends ProfileService { if (DEBUG) { if (DEBUG) { Log.d(TAG, "cleanup()"); Log.d(TAG, "cleanup()"); } } // Stop MapProfile if already started. // TODO: Check if the profile state can be retreived from ProfileService or AdapterService. if (!isMapStarted()) { if (DEBUG) { Log.d(TAG, "Service Not Available to STOP or Shutdown already" + " in progress - Ignoring"); } return true; } else { if (VERBOSE) Log.d(TAG, "Service Stoping()"); } // SetState Disconnect already handled from closeService. // Handle it otherwise. Redundant for backup ? setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); setState(BluetoothMap.STATE_DISCONNECTED, BluetoothMap.RESULT_CANCELED); //Cleanup already handled in Stop(). //Cleanup already handled in Stop(). //Move this extra check to Handler. //Move this extra check to Handler. if (mSessionStatusHandler != null) { sendShutdownMessage(); sendShutdownMessage(); } mServiceStarted = false; return true; return true; } } Loading Loading @@ -1057,10 +1077,22 @@ public class BluetoothMapService extends ProfileService { int state = int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR); if (state == BluetoothAdapter.STATE_TURNING_OFF) { if (state == BluetoothAdapter.STATE_TURNING_OFF) { if (DEBUG) Log.d(TAG, "STATE_TURNING_OFF"); // Stop MapProfile if already started. if (!isMapStarted()) { if (DEBUG) { if (DEBUG) { Log.d(TAG, "STATE_TURNING_OFF"); Log.d(TAG, "Service Not Available to STOP or Shutdown already" + " in progress - Ignoring"); } } } else if (mSessionStatusHandler != null) { if (VERBOSE) Log.d(TAG, "Service Stoping()"); sendShutdownMessage(); sendShutdownMessage(); } else { if (DEBUG) { Log.d(TAG, "Unable to perform STOP or Shutdown already" + " in progress - Ignoring"); } } } else if (state == BluetoothAdapter.STATE_ON) { } else if (state == BluetoothAdapter.STATE_ON) { if (DEBUG) { if (DEBUG) { Log.d(TAG, "STATE_ON"); Log.d(TAG, "STATE_ON"); Loading