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

Commit 1ff49fa4 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Fix notifing Java layer about DISCONNECTED state

With this patch we make sure that if during connection,
user decide to disconnect device, the DISCONNECTED state will be sent
imidiatelly.

Bug: 265094193
Test: atest BluetoothInstrumentationTests
Test: atest bluetooth_le_audio_test bluetooth_vc_test
Test: atest bluetooth_csis_client test bluetooth_has_client_test

Tag: #feature
Change-Id: I0619e3396db8b542aac3c8c7bc28ccc0ea55518f
parent 7f6d6d19
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -250,8 +250,9 @@ class CsisClientImpl : public CsisClient {

    auto device = FindDeviceByAddress(addr);
    if (device == nullptr) {
      LOG(WARNING) << "Device not connected to profile"
                   << ADDRESS_TO_LOGGABLE_STR(addr);
      LOG_WARN("Device not connected to profile %s",
               ADDRESS_TO_LOGGABLE_CSTR(addr));
      callbacks_->OnConnectionState(addr, ConnectionState::DISCONNECTED);
      return;
    }

@@ -261,6 +262,7 @@ class CsisClientImpl : public CsisClient {
    } else {
      BTA_GATTC_CancelOpen(gatt_if_, addr, false);
      DoDisconnectCleanUp(device);
      callbacks_->OnConnectionState(addr, ConnectionState::DISCONNECTED);
    }
  }

+4 −1
Original line number Diff line number Diff line
@@ -233,7 +233,10 @@ class HasClientImpl : public HasClient {
        callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, addr);
      } else {
        /* Removes active connection. */
        if (is_connecting_actively) BTA_GATTC_CancelOpen(gatt_if_, addr, true);
        if (is_connecting_actively) {
          BTA_GATTC_CancelOpen(gatt_if_, addr, true);
          callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, addr);
        }
      }

      /* Removes all registrations for connection. */
+3 −2
Original line number Diff line number Diff line
@@ -1290,8 +1290,9 @@ class LeAudioClientImpl : public LeAudioClient {
    LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address);

    if (!leAudioDevice) {
      LOG(ERROR) << __func__ << ", leAudioDevice not connected ("
                 << ADDRESS_TO_LOGGABLE_STR(address) << ")";
      LOG_WARN("leAudioDevice not connected ( %s )",
               ADDRESS_TO_LOGGABLE_CSTR(address));
      callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address);
      return;
    }

+3 −2
Original line number Diff line number Diff line
@@ -630,8 +630,9 @@ class VolumeControlImpl : public VolumeControl {
    VolumeControlDevice* device =
        volume_control_devices_.FindByAddress(address);
    if (!device) {
      LOG(INFO) << "Device not connected to profile "
                << ADDRESS_TO_LOGGABLE_STR(address);
      LOG_WARN("Device not connected to profile %s",
               ADDRESS_TO_LOGGABLE_CSTR(address));
      callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address);
      return;
    }