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

Commit 0861b3ef authored by Hansong Zhang's avatar Hansong Zhang
Browse files

DO NOT MERGE Hearing Aid: Add JNI API for add/remove whitelist

Allow Java layer to add a hearing aid device to white list or remove
from white list

Bug: 116317072
Bug: 115365334
Test: connect to a pair with one device off
Change-Id: Iac5df8f371fb39fade4493d2da8226f026545fb3
parent 33087461
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -325,6 +325,18 @@ class HearingAidImpl : public HearingAid {
    BTA_GATTC_Open(gatt_if, address, true, GATT_TRANSPORT_LE, false);
  }

  void AddToWhiteList(const RawAddress& address) override {
    VLOG(2) << __func__ << " address: " << address;
    hearingDevices.Add(HearingDevice(address, true));
    BTA_GATTC_Open(gatt_if, address, false, GATT_TRANSPORT_LE, false);
    BTA_DmBleStartAutoConn();
  }

  void RemoveFromWhiteList(const RawAddress& address) override {
    VLOG(2) << __func__ << " address: " << address;
    BTA_GATTC_CancelOpen(gatt_if, address, false);
  }

  void AddFromStorage(const RawAddress& address, uint16_t psm,
                      uint8_t capabilities, uint16_t codecs,
                      uint16_t audio_control_point_handle,
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ class HearingAid {

  virtual void Connect(const RawAddress& address) = 0;
  virtual void Disconnect(const RawAddress& address) = 0;
  virtual void AddToWhiteList(const RawAddress& address) = 0;
  virtual void RemoveFromWhiteList(const RawAddress& address) = 0;
  virtual void SetVolume(int8_t volume) = 0;
};

+3 −0
Original line number Diff line number Diff line
@@ -201,6 +201,9 @@ void btif_storage_load_bonded_hearing_aids();
/** Deletes the bonded hearing aid device info from NVRAM */
void btif_storage_remove_hearing_aid(const RawAddress& address);

/** Add the hearing aid device to white list */
void btif_storage_add_hearing_aid_to_white_list(const RawAddress& address);

/** Remove the hearing aid device from white list */
void btif_storage_remove_hearing_aid_white_list(const RawAddress& address);

+16 −0
Original line number Diff line number Diff line
@@ -95,6 +95,22 @@ class HearingAidInterfaceImpl
        FROM_HERE, Bind(&btif_storage_remove_hearing_aid_white_list, address));
  }

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

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

  void SetVolume(int8_t volume) override {
    DVLOG(2) << __func__ << " volume: " << +volume;
    do_in_bta_thread(FROM_HERE, Bind(&HearingAid::SetVolume,
+7 −0
Original line number Diff line number Diff line
@@ -1477,6 +1477,13 @@ void btif_storage_remove_hearing_aid(const RawAddress& address) {
  btif_config_save();
}

/** Add the hearing aid device to white list */
void btif_storage_add_hearing_aid_to_white_list(const RawAddress& address) {
  std::string addrstr = address.ToString();

  btif_config_set_int(addrstr, HEARING_AID_IS_WHITE_LISTED, true);
}

/** Remove the hearing aid device from white list */
void btif_storage_remove_hearing_aid_white_list(const RawAddress& address) {
  std::string addrstr = address.ToString();
Loading