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

Commit 1814ad66 authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Automerger Merge Worker
Browse files

Merge "Temporary LE keys are possible only through ctkd" into main am: 5c1f570d am: 9e68b265

parents a46e6cc6 9e68b265
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include <mutex>
#include <optional>

#include <android_bluetooth_flags.h>
#include "advertise_data_parser.h"
#include "android_bluetooth_flags.h"
#include "bta/dm/bta_dm_disc.h"
@@ -3476,6 +3477,18 @@ static void btif_dm_ble_key_notif_evt(tBTA_DM_SP_KEY_NOTIF* p_ssp_key_notif) {
      p_ssp_key_notif->passkey);
}

static bool btif_dm_ble_is_temp_pairing(RawAddress& bd_addr, bool ctkd) {
  if (btm_get_bond_type_dev(bd_addr) == BOND_TYPE_TEMPORARY) {
    if (!IS_FLAG_ENABLED(ignore_bond_type_for_le)) {
      return true;
    }

    return ctkd;
  }

  return false;
}

/*******************************************************************************
 *
 * Function         btif_dm_ble_auth_cmpl_evt
@@ -3508,7 +3521,7 @@ static void btif_dm_ble_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
      btif_storage_set_remote_addr_type(&bd_addr, p_auth_cmpl->addr_type);

    /* Test for temporary bonding */
    if (btm_get_bond_type_dev(bd_addr) == BOND_TYPE_TEMPORARY) {
    if (btif_dm_ble_is_temp_pairing(bd_addr, p_auth_cmpl->is_ctkd)) {
      LOG_DEBUG("sending BT_BOND_STATE_NONE for Temp pairing");
      btif_storage_remove_bonded_device(&bd_addr);
      state = BT_BOND_STATE_NONE;