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

Commit 5886e259 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Remove active device handling for HAP devices" am: 544d05bc

parents 9a4a6ecc 544d05bc
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -220,9 +220,6 @@ class ActiveDeviceManager {
                case BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED:
                    mHandler.post(() -> handleLeAudioActiveDeviceChanged(device));
                    break;
                case BluetoothHapClient.ACTION_HAP_DEVICE_AVAILABLE:
                    mHandler.post(() -> handleHapActiveDeviceChanged(device));
                    break;
                default:
                    Log.e(TAG, "Received unexpected intent, action=" + action);
                    break;
@@ -509,26 +506,12 @@ class ActiveDeviceManager {
                setHfpActiveDevice(null);
                setHearingAidActiveDevice(null);
            }
            mLeAudioActiveDevice = device;
        }
    }

    private void handleHapActiveDeviceChanged(BluetoothDevice device) {
        synchronized (mLock) {
            if (DBG) {
                Log.d(TAG, "handleHapActiveDeviceChanged: " + device);
            }
            if (device != null && !mLeHearingAidConnectedDevices.contains(device)) {
                mLeHearingAidConnectedDevices.add(device);
            }
            // Just assign locally the new value
            if (device != null && !Objects.equals(mLeHearingAidActiveDevice, device)) {
                setA2dpActiveDevice(null, true);
                setHfpActiveDevice(null);
                setHearingAidActiveDevice(null);
            if (mLeHearingAidConnectedDevices.contains(device)) {
                mLeHearingAidActiveDevice = device;
            }

            mLeAudioActiveDevice = device;
            mLeHearingAidActiveDevice = device;
        }
    }

@@ -600,7 +583,6 @@ class ActiveDeviceManager {
        filter.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED);
        filter.addAction(BluetoothHapClient.ACTION_HAP_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHapClient.ACTION_HAP_DEVICE_AVAILABLE);
        mAdapterService.registerReceiver(mReceiver, filter, Context.RECEIVER_EXPORTED);

        mAudioManager.registerAudioDeviceCallback(mAudioManagerAudioDeviceCallback, mHandler);