PBAP service runs in a loop of 10 trials to create the RFCOMM listener
thread; this loop is not getting interrupted during BT off, due to which
we end up delaying PBAP stop by 3 seconds (10 * 300ms). The fix is to
check for BT state after RFCOMM listener failure and break out of the
loop if BT is being turned off.
bug
7134544
Change-Id: I35db2221be30980bec973253cdd888e0ce8cc36b
initSocketOK = false;
}
if (!initSocketOK) {
+ // Need to break out of this loop if BT is being turned off.
+ if (mAdapter == null) break;
+ int state = mAdapter.getState();
+ if ((mAdapter.getState() != BluetoothAdapter.STATE_TURNING_ON) &&
+ (mAdapter.getState() != BluetoothAdapter.STATE_ON)) {
+ Log.w(TAG, "initServerSocket failed as BT is (being) turned off");
+ break;
+ }
synchronized (this) {
try {
if (VERBOSE) Log.v(TAG, "wait 300 ms");