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

Commit 707c3659 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Wire Security UI callback for pin entry cases"

parents bad14dfd d2b65c19
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -300,6 +300,12 @@ void btif_dm_init(uid_set_t* set) {
        //TODO: java BondStateMachine requires change into bonding state. If we ever send this event separately, consider removing this line
        HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, BT_STATUS_SUCCESS, &address, BT_BOND_STATE_BONDING);

        if(BT_SSP_VARIANT_PASSKEY_ENTRY) {
          // For passkey entry we must actually use pin request, due to BluetoothPairingController (in Settings)
          HAL_CBACK(bt_hal_cbacks, pin_request_cb, &address, &bd_name, cod, false);
          return;
        }

        HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &address, &bd_name, cod, pairing_variant, pass_key);
      }, address, bd_name, cod, pairing_variant, pass_key));
    });
@@ -2390,6 +2396,16 @@ bt_status_t btif_dm_remove_bond(const RawAddress* bd_addr) {
bt_status_t btif_dm_pin_reply(const RawAddress* bd_addr, uint8_t accept,
                              uint8_t pin_len, bt_pin_code_t* pin_code) {
  BTIF_TRACE_EVENT("%s: accept=%d", __func__, accept);

  if (bluetooth::shim::is_gd_shim_enabled()) {
    uint8_t tmp_dev_type = 0;
    uint8_t tmp_addr_type = 0;
    BTM_ReadDevInfo(*bd_addr, &tmp_dev_type, &tmp_addr_type);

    do_in_main_thread(FROM_HERE, base::Bind(&bluetooth::shim::BTIF_DM_pin_reply, *bd_addr, tmp_addr_type, accept, pin_len, *pin_code));
    return BT_STATUS_SUCCESS;
  }

  if (pin_code == NULL || pin_len > PIN_CODE_LEN) return BT_STATUS_FAIL;
  if (pairing_cb.is_le_only) {
    int i;
@@ -2421,7 +2437,6 @@ bt_status_t btif_dm_pin_reply(const RawAddress* bd_addr, uint8_t accept,
bt_status_t btif_dm_ssp_reply(const RawAddress* bd_addr,
                              bt_ssp_variant_t variant, uint8_t accept,
                              UNUSED_ATTR uint32_t passkey) {

  if (bluetooth::shim::is_gd_shim_enabled()) {
    uint8_t tmp_dev_type = 0;
    uint8_t tmp_addr_type = 0;
+18 −3
Original line number Diff line number Diff line
@@ -88,10 +88,7 @@ void BTIF_DM_SetUiCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t,
}

void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t addr_type, bt_ssp_variant_t variant, uint8_t accept) {
  LOG_WARN(LOG_TAG, "%s", __func__);

  hci::AddressWithType address = ToAddressWithType(bd_addr, addr_type);

  auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager();

  if (variant == BT_SSP_VARIANT_PASSKEY_CONFIRMATION || variant == BT_SSP_VARIANT_CONSENT) {
@@ -104,5 +101,23 @@ void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t addr_type, bt_ssp_varia
  }
}

void BTIF_DM_pin_reply(const RawAddress bd_addr, uint8_t addr_type, uint8_t accept, uint8_t pin_len, bt_pin_code_t pin_code) {
  hci::AddressWithType address = ToAddressWithType(bd_addr, addr_type);
  auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager();

  if (!accept) {
    LOG_WARN(LOG_TAG, "This case is not implemented!!");
    return;
  }

  uint32_t passkey = 0;
  int multi[] = {100000, 10000, 1000, 100, 10, 1};
  for (int i = 0; i < pin_len; i++) {
    passkey += (multi[i] * (pin_code.pin[i] - '0'));
  }

  security_manager->OnPasskeyEntry(address, passkey);
}

}  // namespace shim
}  // namespace bluetooth
+1 −0
Original line number Diff line number Diff line
@@ -30,5 +30,6 @@ namespace shim {
 */
void BTIF_DM_SetUiCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback);
void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t, bt_ssp_variant_t variant, uint8_t accept);
void BTIF_DM_pin_reply(const RawAddress bd_addr, uint8_t, uint8_t, uint8_t, bt_pin_code_t);
}  // namespace shim
}  // namespace bluetooth