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

Commit 88585ad5 authored by Grzegorz Kolodziejczyk's avatar Grzegorz Kolodziejczyk Committed by Gerrit Code Review
Browse files

Merge "Disconnect also connecting Bluetooth device"

parents e3125b3d cabf64d0
Loading
Loading
Loading
Loading
+72 −36
Original line number Original line Diff line number Diff line
@@ -4543,95 +4543,131 @@ public class AdapterService extends Service {
            return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
            return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
        }
        }


        if (mA2dpService != null && mA2dpService.getConnectionState(device)
        if (mA2dpService != null && (mA2dpService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mA2dpService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting A2dp");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting A2dp");
            mA2dpService.disconnect(device);
            mA2dpService.disconnect(device);
        }
        }
        if (mA2dpSinkService != null && mA2dpSinkService.getConnectionState(device)
        if (mA2dpSinkService != null && (mA2dpSinkService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mA2dpSinkService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting A2dp Sink");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting A2dp Sink");
            mA2dpSinkService.disconnect(device);
            mA2dpSinkService.disconnect(device);
        }
        }
        if (mHeadsetService != null && mHeadsetService.getConnectionState(device)
        if (mHeadsetService != null && (mHeadsetService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                ||  mHeadsetService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG,
            Log.i(TAG,
                    "disconnectAllEnabledProfiles: Disconnecting Headset Profile");
                    "disconnectAllEnabledProfiles: Disconnecting Headset Profile");
            mHeadsetService.disconnect(device);
            mHeadsetService.disconnect(device);
        }
        }
        if (mHeadsetClientService != null && mHeadsetClientService.getConnectionState(device)
        if (mHeadsetClientService != null && (mHeadsetClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mHeadsetClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting HFP");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting HFP");
            mHeadsetClientService.disconnect(device);
            mHeadsetClientService.disconnect(device);
        }
        }
        if (mMapClientService != null && mMapClientService.getConnectionState(device)
        if (mMapClientService != null && (mMapClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mMapClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting MAP Client");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting MAP Client");
            mMapClientService.disconnect(device);
            mMapClientService.disconnect(device);
        }
        }
        if (mMapService != null && mMapService.getConnectionState(device)
        if (mMapService != null && (mMapService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mMapService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting MAP");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting MAP");
            mMapService.disconnect(device);
            mMapService.disconnect(device);
        }
        }
        if (mHidDeviceService != null && mHidDeviceService.getConnectionState(device)
        if (mHidDeviceService != null && (mHidDeviceService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mHidDeviceService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hid Device Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hid Device Profile");
            mHidDeviceService.disconnect(device);
            mHidDeviceService.disconnect(device);
        }
        }
        if (mHidHostService != null && mHidHostService.getConnectionState(device)
        if (mHidHostService != null && (mHidHostService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mHidHostService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hid Host Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hid Host Profile");
            mHidHostService.disconnect(device);
            mHidHostService.disconnect(device);
        }
        }
        if (mPanService != null && mPanService.getConnectionState(device)
        if (mPanService != null && (mPanService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mPanService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Pan Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Pan Profile");
            mPanService.disconnect(device);
            mPanService.disconnect(device);
        }
        }
        if (mPbapClientService != null && mPbapClientService.getConnectionState(device)
        if (mPbapClientService != null && (mPbapClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mPbapClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Pbap Client");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Pbap Client");
            mPbapClientService.disconnect(device);
            mPbapClientService.disconnect(device);
        }
        }
        if (mPbapService != null && mPbapService.getConnectionState(device)
        if (mPbapService != null && (mPbapService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mPbapService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Pbap Server");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Pbap Server");
            mPbapService.disconnect(device);
            mPbapService.disconnect(device);
        }
        }
        if (mHearingAidService != null && mHearingAidService.getConnectionState(device)
        if (mHearingAidService != null && (mHearingAidService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mHearingAidService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hearing Aid Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hearing Aid Profile");
            mHearingAidService.disconnect(device);
            mHearingAidService.disconnect(device);
        }
        }
        if (mHapClientService != null && mHapClientService.getConnectionState(device)
        if (mHapClientService != null && (mHapClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mHapClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hearing Access Profile Client");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Hearing Access Profile Client");
            mHapClientService.disconnect(device);
            mHapClientService.disconnect(device);
        }
        }
        if (mVolumeControlService != null && mVolumeControlService.getConnectionState(device)
        if (mVolumeControlService != null && (mVolumeControlService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mVolumeControlService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Volume Control Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Volume Control Profile");
            mVolumeControlService.disconnect(device);
            mVolumeControlService.disconnect(device);
        }
        }
        if (mSapService != null && mSapService.getConnectionState(device)
        if (mSapService != null && (mSapService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mSapService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Sap Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Sap Profile");
            mSapService.disconnect(device);
            mSapService.disconnect(device);
        }
        }
        if (mCsipSetCoordinatorService != null
        if (mCsipSetCoordinatorService != null
                && mCsipSetCoordinatorService.getConnectionState(device)
                && (mCsipSetCoordinatorService.getConnectionState(device)
                        == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mCsipSetCoordinatorService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Coordinater Set Profile");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting Coordinater Set Profile");
            mCsipSetCoordinatorService.disconnect(device);
            mCsipSetCoordinatorService.disconnect(device);
        }
        }
        if (mLeAudioService != null && mLeAudioService.getConnectionState(device)
        if (mLeAudioService != null && (mLeAudioService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mLeAudioService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting LeAudio profile (BAP)");
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting LeAudio profile (BAP)");
            mLeAudioService.disconnect(device);
            mLeAudioService.disconnect(device);
        }
        }
        if (mBassClientService != null && mBassClientService.getConnectionState(device)
        if (mBassClientService != null && (mBassClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTED) {
                == BluetoothProfile.STATE_CONNECTED
                || mBassClientService.getConnectionState(device)
                == BluetoothProfile.STATE_CONNECTING)) {
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting "
            Log.i(TAG, "disconnectAllEnabledProfiles: Disconnecting "
                            + "LE Broadcast Assistant Profile");
                            + "LE Broadcast Assistant Profile");
            mBassClientService.disconnect(device);
            mBassClientService.disconnect(device);