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

Commit e82e07ed authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Handle unbonding in Hearing Aid profile

Bug: 69623109
Change-Id: I3b1f778e414511a3748cebd2b0e233d638cd4d43
Fixes: 79207134
Test: unbond from Hearing Aid when connected or disconnected from it
parent e6736aa0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -951,6 +951,7 @@ class HearingAidImpl : public HearingAid {

    VLOG(2) << __func__ << ": " << address;

    bool connected = hearingDevice->accepting_audio;
    hearingDevice->accepting_audio = false;

    if (hearingDevice->connecting_actively) {
@@ -972,6 +973,7 @@ class HearingAidImpl : public HearingAid {

    hearingDevices.Remove(address);

    if (connected)
      callbacks->OnConnectionState(ConnectionState::DISCONNECTED, address);
  }

+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <base/callback_forward.h>
#include <hardware/bt_hearing_aid.h>

using bluetooth::Uuid;

/** Implementations of HearingAid will also implement this interface */
class HearingAidAudioReceiver {
+4 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@

#include <bluetooth/uuid.h>
#include <hardware/bluetooth.h>
#include <hardware/bt_hearing_aid.h>

#include "advertise_data_parser.h"
#include "bt_common.h"
@@ -244,6 +245,8 @@ extern bt_status_t btif_hf_client_execute_service(bool b_enable);
extern bt_status_t btif_sdp_execute_service(bool b_enable);
extern int btif_hh_connect(const RawAddress* bd_addr);
extern bt_status_t btif_hd_execute_service(bool b_enable);
extern bluetooth::hearing_aid::HearingAidInterface*
btif_hearing_aid_get_interface();

/******************************************************************************
 *  Functions
@@ -1648,6 +1651,7 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
#if (defined(BTA_HD_INCLUDED) && (BTA_HD_INCLUDED == TRUE))
      btif_hd_remove_device(bd_addr);
#endif
      btif_hearing_aid_get_interface()->RemoveDevice(bd_addr);
      btif_storage_remove_bonded_device(&bd_addr);
      bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_NONE);
      break;
+8 −0
Original line number Diff line number Diff line
@@ -101,6 +101,14 @@ class HearingAidInterfaceImpl
                                     Unretained(HearingAid::Get()), volume));
  }

  void RemoveDevice(const RawAddress& address) override {
    DVLOG(2) << __func__ << " address: " << address;
    do_in_bta_thread(FROM_HERE, Bind(&HearingAid::Disconnect,
                                     Unretained(HearingAid::Get()), address));
    do_in_jni_thread(FROM_HERE,
                     Bind(&btif_storage_remove_hearing_aid, address));
  }

  void Cleanup(void) {
    DVLOG(2) << __func__;
    do_in_bta_thread(FROM_HERE, Bind(&HearingAid::CleanUp));
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ class HearingAidInterface {

  /** Closes the interface. */
  virtual void Cleanup(void) = 0;

  /* Called when Hearing Aid is unbonded. */
  virtual void RemoveDevice(const RawAddress& address) = 0;
};

}  // namespace hearing_aid