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

Commit 89eb4b04 authored by Hansong Zhang's avatar Hansong Zhang Committed by android-build-merger
Browse files

Merge "Hearing Aid: Clean up GATT on disconnect"

am: 4b0f544c

Change-Id: I6caf6bc8bef9324f1675f5aa62024b97c6f6b5de
parents 91f54af3 4b0f544c
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -1105,6 +1105,8 @@ class HearingAidImpl : public HearingAid {
    // cancel autoconnect
    BTA_GATTC_CancelOpen(gatt_if, address, false);

    DoDisconnectCleanUp(hearingDevice);

    hearingDevices.Remove(address);

    if (connected)
@@ -1121,22 +1123,26 @@ class HearingAidImpl : public HearingAid {
      return;
    }

    DoDisconnectCleanUp(hearingDevice);

    callbacks->OnConnectionState(ConnectionState::DISCONNECTED, remote_bda);
  }

  void DoDisconnectCleanUp(HearingDevice* hearingDevice) {
    if (hearingDevice->connection_update_status != NONE) {
      LOG(INFO) << __func__ << ": connection update not completed. Current="
                << hearingDevice->connection_update_status;

      if (hearingDevice->connection_update_status == STARTED) {
        OnConnectionUpdateComplete(conn_id);
        OnConnectionUpdateComplete(hearingDevice->conn_id);
      }
      hearingDevice->connection_update_status = NONE;
    }

    BtaGattQueue::Clean(hearingDevice->conn_id);

    hearingDevice->accepting_audio = false;
    hearingDevice->conn_id = 0;

    BtaGattQueue::Clean(conn_id);

    callbacks->OnConnectionState(ConnectionState::DISCONNECTED, remote_bda);
  }

  void SetVolume(int8_t volume) override {