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

Commit 8fbf21ed authored by pramod kotreshappa's avatar pramod kotreshappa Committed by Bruno Martins
Browse files

TWS_A2DP: Handle active device change between TWS+ earbuds

Check for TWS+ device switch in active device change. If
TWS+ device switch then remove disconnected device
and add peer pair device into connected devices list and
return.

CRs-fixed: 2446639
Change-Id: I97e66fba56fceb2e9b2e7c253119033bf34175bb
parent e824b902
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -636,6 +636,12 @@ public class AudioDeviceInventory {
                      mConnectedDevices.put(deviceKey, new DeviceInfo(
                                 AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, BtHelper.getName(device),
                                 address, a2dpCodec));
                      if (BtHelper.isTwsPlusSwitch(device, deviceInfo.mDeviceAddress)) {
                          if (AudioService.DEBUG_DEVICES) {
                              Log.d(TAG,"TWS+ device switch");
                          }
                          return;
                      }
                      mDeviceBroker.postA2dpActiveDeviceChange(
                                 new BtHelper.BluetoothA2dpDeviceInfo(
                                     device, a2dpVolume, a2dpCodec));
+15 −0
Original line number Diff line number Diff line
@@ -168,6 +168,21 @@ public class BtHelper {
        return deviceName;
    }

    /*packages*/ @NonNull static boolean isTwsPlusSwitch(@NonNull BluetoothDevice device,
                                                                 String address) {
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (device == null || adapter.getRemoteDevice(address) == null ||
            device.getTwsPlusPeerAddress() == null) {
            return false;
        }
        if (device.isTwsPlusDevice() &&
            adapter.getRemoteDevice(address).isTwsPlusDevice() &&
            device.getTwsPlusPeerAddress().equals(address)) {
            Log.i(TAG,"isTwsPlusSwitch true");
            return true;
         }
         return false;
    }
    //----------------------------------------------------------------------
    // Interface for AudioDeviceBroker