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

Commit 333a6b04 authored by Weichin Weng's avatar Weichin Weng Committed by android-build-merger
Browse files

Merge "Don't read HearingAid properties if already have properties value."

am: f3ce080c

Change-Id: I6a8a532978d441b8cc5494d204ba5970aff073cc
parents 177f4b89 f3ce080c
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@ constexpr uint16_t CONNECTION_INTERVAL_10MS_PARAM = 0x0008;
constexpr uint16_t CONNECTION_INTERVAL_20MS_PARAM = 0x0010;

void btif_storage_add_hearing_aid(const HearingDevice& dev_info);
bool btif_storage_get_hearing_aid_prop(
    const RawAddress& address, uint8_t* capabilities, uint64_t* hi_sync_id,
    uint16_t* render_delay, uint16_t* preparation_delay, uint16_t* codecs);

constexpr uint8_t CODEC_G722_16KHZ = 0x01;
constexpr uint8_t CODEC_G722_24KHZ = 0x02;
@@ -626,11 +629,16 @@ class HearingAidImpl : public HearingAid {

    for (const gatt::Characteristic& charac : service->characteristics) {
      if (charac.uuid == READ_ONLY_PROPERTIES_UUID) {
        DVLOG(2) << "Reading read only properties "
        if (!btif_storage_get_hearing_aid_prop(
                hearingDevice->address, &hearingDevice->capabilities,
                &hearingDevice->hi_sync_id, &hearingDevice->render_delay,
                &hearingDevice->preparation_delay, &hearingDevice->codecs)) {
          VLOG(2) << "Reading read only properties "
                  << loghex(charac.value_handle);
          BtaGattQueue::ReadCharacteristic(
              conn_id, charac.value_handle,
              HearingAidImpl::OnReadOnlyPropertiesReadStatic, nullptr);
        }
      } else if (charac.uuid == AUDIO_CONTROL_POINT_UUID) {
        hearingDevice->audio_control_point_handle = charac.value_handle;
        // store audio control point!
+5 −0
Original line number Diff line number Diff line
@@ -177,6 +177,11 @@ struct HearingDevice {
        audio_status_ccc_handle(0),
        service_changed_ccc_handle(0),
        read_psm_handle(0),
        capabilities(0),
        hi_sync_id(0),
        render_delay(0),
        preparation_delay(0),
        codecs(0),
        playback_started(false),
        command_acked(false),
        read_rssi_count(0) {}
+5 −0
Original line number Diff line number Diff line
@@ -231,6 +231,11 @@ void btif_storage_remove_hearing_aid(const RawAddress& address);
void btif_storage_set_hearing_aid_white_list(const RawAddress& address,
                                             bool add_to_whitelist);

/** Get the hearing aid device properties. */
bool btif_storage_get_hearing_aid_prop(
    const RawAddress& address, uint8_t* capabilities, uint64_t* hi_sync_id,
    uint16_t* render_delay, uint16_t* preparation_delay, uint16_t* codecs);

/*******************************************************************************
 *
 * Function         btif_storage_is_retricted_device
+41 −0
Original line number Diff line number Diff line
@@ -1603,6 +1603,47 @@ void btif_storage_set_hearing_aid_white_list(const RawAddress& address,
  btif_config_save();
}

/** Get the hearing aid device properties. */
bool btif_storage_get_hearing_aid_prop(
    const RawAddress& address, uint8_t* capabilities, uint64_t* hi_sync_id,
    uint16_t* render_delay, uint16_t* preparation_delay, uint16_t* codecs) {
  std::string addrstr = address.ToString();

  int value;
  if (btif_config_get_int(addrstr, HEARING_AID_CAPABILITIES, &value)) {
    *capabilities = value;
  } else {
    return false;
  }

  if (btif_config_get_int(addrstr, HEARING_AID_CODECS, &value)) {
    *codecs = value;
  } else {
    return false;
  }

  if (btif_config_get_int(addrstr, HEARING_AID_RENDER_DELAY, &value)) {
    *render_delay = value;
  } else {
    return false;
  }

  if (btif_config_get_int(addrstr, HEARING_AID_PREPARATION_DELAY, &value)) {
    *preparation_delay = value;
  } else {
    return false;
  }

  uint64_t lvalue;
  if (btif_config_get_uint64(addrstr, HEARING_AID_SYNC_ID, &lvalue)) {
    *hi_sync_id = lvalue;
  } else {
    return false;
  }

  return true;
}

/*******************************************************************************
 *
 * Function         btif_storage_is_restricted_device