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

Commit 153541e9 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh Committed by Android (Google) Code Review
Browse files

Merge "Disconnect PAN and Input devices on BT disable."

parents 2c3c7dc4 7a0f8169
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -773,6 +773,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine

                case CONNECT_HFP_INCOMING:
                    transitionTo(mIncomingHandsfree);
                    break;
                case CONNECT_A2DP_INCOMING:
                    transitionTo(mIncomingA2dp);

+12 −0
Original line number Diff line number Diff line
@@ -385,11 +385,23 @@ public class BluetoothService extends IBluetooth.Stub {
        // Allow 3 seconds for profiles to gracefully disconnect
        // TODO: Introduce a callback mechanism so that each profile can notify
        // BluetoothService when it is done shutting down
        disconnectDevices();

        mHandler.sendMessageDelayed(
                mHandler.obtainMessage(MESSAGE_FINISH_DISABLE, saveSetting ? 1 : 0, 0), 3000);
        return true;
    }

    private synchronized void disconnectDevices() {
        // Disconnect devices handled by BluetoothService.
        for (BluetoothDevice device: getConnectedInputDevices()) {
            disconnectInputDevice(device);
        }

        for (BluetoothDevice device: getConnectedPanDevices()) {
            disconnectPanDevice(device);
        }
    }

    private synchronized void finishDisable(boolean saveSetting) {
        if (mBluetoothState != BluetoothAdapter.STATE_TURNING_OFF) {