Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7cab294b authored by Kausik Sinnaswamy's avatar Kausik Sinnaswamy Committed by Matthew Xie
Browse files

Terminate PBAP service cleanly during BT off

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: I81d2a559857eef9138ebca662ea28f1d3e358bb8
parent fa99828a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -347,6 +347,14 @@ public class BluetoothPbapService extends Service {
                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 ((state != BluetoothAdapter.STATE_TURNING_ON) &&
                    (state != 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");