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

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

Merge "Hearingaid: Handle the data channel open fail case during connecting" am: bd0c5ed2

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1994030

Change-Id: I9941b3006a0334af1492791bffd248334a01c87f
parents f639b397 bd0c5ed2
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -1331,9 +1331,20 @@ class HearingAidImpl : public HearingAid {
      case GAP_EVT_CONN_CLOSED:
        LOG(INFO) << __func__
                  << ": GAP_EVT_CONN_CLOSED: " << hearingDevice->address
                  << ", playback_started=" << hearingDevice->playback_started;
        /* Disconnect profile when data channel is not available */
        Disconnect(hearingDevice->address);
                  << ", playback_started=" << hearingDevice->playback_started
                  << ", connecting_actively="
                  << hearingDevice->connecting_actively;
        if (hearingDevice->connecting_actively) {
          /* Disconnect connection when data channel is not available */
          BTA_GATTC_Close(hearingDevice->conn_id);
        } else {
          /* Just clean data channel related parameter when data channel is
           * available */
          hearingDevice->gap_handle = GAP_INVALID_HANDLE;
          hearingDevice->accepting_audio = false;
          hearingDevice->playback_started = false;
          hearingDevice->command_acked = false;
        }
        break;
      case GAP_EVT_CONN_DATA_AVAIL: {
        DVLOG(2) << "GAP_EVT_CONN_DATA_AVAIL";
@@ -1460,7 +1471,7 @@ class HearingAidImpl : public HearingAid {
    bool connected = hearingDevice->accepting_audio;
    bool connecting_by_user = hearingDevice->connecting_actively;

    LOG(INFO) << "GAP_EVT_CONN_CLOSED: " << hearingDevice->address
    LOG(INFO) << __func__ << ": " << hearingDevice->address
              << ", playback_started=" << hearingDevice->playback_started
              << ", accepting_audio=" << hearingDevice->accepting_audio;

@@ -1479,17 +1490,19 @@ class HearingAidImpl : public HearingAid {

    DoDisconnectCleanUp(hearingDevice);

    hearingDevices.Remove(address);

    if (!connected) {
      /* In case user wanted to connect, sent DISCONNECTED state */
      if (connecting_by_user)
      if (connecting_by_user) {
        callbacks->OnConnectionState(ConnectionState::DISCONNECTED, address);

      }
      /* Do remove device when the address is useless. */
      hearingDevices.Remove(address);
      return;
    }

    callbacks->OnConnectionState(ConnectionState::DISCONNECTED, address);
    /* Do remove device when the address is useless. */
    hearingDevices.Remove(address);
    for (const auto& device : hearingDevices.devices) {
      if (device.accepting_audio) return;
    }