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

Commit 3f402c34 authored by Chris Manton's avatar Chris Manton
Browse files

Return bool=>void stack/btm/btm_ble::BTM_SecAddBleKey

Toward readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: Iee8f8c0981c3084945365974ea77e91c38d57dbf
parent b616445f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -3390,9 +3390,7 @@ static void bta_dm_ble_id_key_cback(uint8_t key_type,
 ******************************************************************************/
void bta_dm_add_blekey(const RawAddress& bd_addr, tBTA_LE_KEY_VALUE blekey,
                       tBTM_LE_KEY_TYPE key_type) {
  if (!BTM_SecAddBleKey(bd_addr, (tBTM_LE_KEY_VALUE*)&blekey, key_type)) {
    LOG(ERROR) << "BTA_DM: Error adding BLE Key for device " << bd_addr;
  }
  BTM_SecAddBleKey(bd_addr, (tBTM_LE_KEY_VALUE*)&blekey, key_type);
}

/*******************************************************************************
+1 −2
Original line number Diff line number Diff line
@@ -914,12 +914,11 @@ void bluetooth::shim::BTM_SecAddBleDevice(const RawAddress& bd_addr,
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

bool bluetooth::shim::BTM_SecAddBleKey(const RawAddress& bd_addr,
void bluetooth::shim::BTM_SecAddBleKey(const RawAddress& bd_addr,
                                       tBTM_LE_KEY_VALUE* p_le_key,
                                       tBTM_LE_KEY_TYPE key_type) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_le_key != nullptr);
  return false;
}

void bluetooth::shim::BTM_BleLoadLocalKeys(uint8_t key_type,
+1 −3
Original line number Diff line number Diff line
@@ -413,10 +413,8 @@ void BTM_SecAddBleDevice(const RawAddress& bd_addr, tBT_DEVICE_TYPE dev_type,
 *                  p_le_key         - LE key values.
 *                  key_type         - LE SMP key type.
 *
 * Returns          true if added OK, else false
 *
 ******************************************************************************/
bool BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
void BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
                      tBTM_LE_KEY_TYPE key_type);

/*******************************************************************************
+4 −5
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ void BTM_SecAddBleDevice(const RawAddress& bd_addr, tBT_DEVICE_TYPE dev_type,
 * Returns          true if added OK, else false
 *
 ******************************************************************************/
bool BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
void BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
                      tBTM_LE_KEY_TYPE key_type) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_SecAddBleKey(bd_addr, p_le_key, key_type);
@@ -127,17 +127,16 @@ bool BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
    LOG(WARNING) << __func__
                 << " Wrong Type, or No Device record for bdaddr: " << bd_addr
                 << ", Type: " << key_type;
    return (false);
    return;
  }

  VLOG(1) << __func__ << " BDA: " << bd_addr << ", Type: " << key_type;

  btm_sec_save_le_key(bd_addr, key_type, p_le_key, false);

  if (key_type == BTM_LE_KEY_PID || key_type == BTM_LE_KEY_LID)
  if (key_type == BTM_LE_KEY_PID || key_type == BTM_LE_KEY_LID) {
    btm_ble_resolving_list_load_dev(p_dev_rec);

  return (true);
  }
}

/*******************************************************************************
+1 −3
Original line number Diff line number Diff line
@@ -66,11 +66,9 @@ extern void BTM_SecAddBleDevice(const RawAddress& bd_addr,
 * Parameters:      bd_addr          - BD address of the peer
 *                  p_le_key         - LE key values.
 *                  key_type         - LE SMP key type.
*
 * Returns          true if added OK, else false
*
 ******************************************************************************/
extern bool BTM_SecAddBleKey(const RawAddress& bd_addr,
extern void BTM_SecAddBleKey(const RawAddress& bd_addr,
                             tBTM_LE_KEY_VALUE* p_le_key,
                             tBTM_LE_KEY_TYPE key_type);