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

Commit d7e9e827 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Clear locally tracked BT device for non-BT devices.

Ensures that the locally tracked BT device is cleared when a non-BT device is being set for communication. This occurred due to a race condition of multiple threads accessing setCommunicationDevice, which would be solved by using a lock. This just adds additional safety to ensure that BT device is indeed cleared when setting the communication device for non-BT devices.

Bug: 309922824
Test: atest TelecomUnitTests

Change-Id: I2f8e895e9e2d783935896c7b0a416b0917ff1e83
parent d9422cca
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -159,6 +159,11 @@ public class CallAudioCommunicationDeviceTracker {
                if (audioDeviceType == AudioDeviceInfo.TYPE_BLE_HEADSET) {
                    mBluetoothRouteManager.onAudioOn(mBtAudioDevice);
                }
            } else if (Flags.communicationDeviceProtectedByLock()) {
                // Clear BT device if it's still stored. Handles race condition for when a non-BT
                // device is set for communication shortly after a BT (LE) device is set for
                // communication but the selection hasn't been cleared yet.
                mBtAudioDevice = null;
            }
        }
        if (Flags.communicationDeviceProtectedByLock()) {