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

Commit 5d74c817 authored by Hui Peng's avatar Hui Peng Committed by Gerrit Code Review
Browse files

Merge "[Invisalign2] Move ble_ctr_cb from btm_sec_cb to btm_cb" into main

parents 3c46c4b6 48a889ae
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "main/shim/shim.h"
#include "os/log.h"
#include "stack/btm/btm_int_types.h"
#include "stack/btm/btm_sec_cb.h"
#include "stack/include/btm_log_history.h"
#include "storage/device.h"
#include "storage/le_device.h"
@@ -169,14 +168,14 @@ void BleScannerInterfaceImpl::Unregister(int scanner_id) {
void BleScannerInterfaceImpl::Scan(bool start) {
  LOG(INFO) << __func__ << " in shim layer " <<  ((start) ? "started" : "stopped");
  bluetooth::shim::GetScanning()->Scan(start);
  if (start && !btm_sec_cb.ble_ctr_cb.is_ble_observe_active()) {
  if (start && !btm_cb.ble_ctr_cb.is_ble_observe_active()) {
    btm_cb.neighbor.le_scan = {
        .start_time_ms = timestamper_in_milliseconds.GetTimestamp(),
        .results = 0,
    };
    BTM_LogHistory(kBtmLogTag, RawAddress::kEmpty, "Le scan started");
    btm_sec_cb.ble_ctr_cb.set_ble_observe_active();
  } else if (!start && btm_sec_cb.ble_ctr_cb.is_ble_observe_active()) {
    btm_cb.ble_ctr_cb.set_ble_observe_active();
  } else if (!start && btm_cb.ble_ctr_cb.is_ble_observe_active()) {
    // stopped
    const unsigned long long duration_timestamp =
        timestamper_in_milliseconds.GetTimestamp() -
@@ -185,11 +184,11 @@ void BleScannerInterfaceImpl::Scan(bool start) {
                   base::StringPrintf("duration_s:%6.3f results:%-3lu",
                                      (double)duration_timestamp / 1000.0,
                                      btm_cb.neighbor.le_scan.results));
    btm_sec_cb.ble_ctr_cb.reset_ble_observe();
    btm_cb.ble_ctr_cb.reset_ble_observe();
    btm_cb.neighbor.le_scan = {};
  } else {
    LOG_WARN("Invalid state: start:%d, current scan state: %d", start,
             btm_sec_cb.ble_ctr_cb.is_ble_observe_active());
             btm_cb.ble_ctr_cb.is_ble_observe_active());
    return;
  }

@@ -346,7 +345,7 @@ void BleScannerInterfaceImpl::SetScanParameters(int scanner_id,
                                                int scan_interval,
                                                int scan_window, Callback cb) {
  LOG(INFO) << __func__ << " in shim layer";
  tBTM_BLE_INQ_CB* p_cb = &btm_sec_cb.ble_ctr_cb.inq_var;
  tBTM_BLE_INQ_CB* p_cb = &btm_cb.ble_ctr_cb.inq_var;
  if (BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN,
                            BTM_BLE_EXT_SCAN_INT_MAX) &&
      BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN,
+3 −4
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_sec.h"
#include "stack/btm/btm_sec_cb.h"
#include "stack/gatt/connection_manager.h"
#include "stack/include/acl_api.h"
#include "stack/include/l2cap_hci_link_interface.h"
@@ -42,7 +41,7 @@ static bool acl_ble_common_connection(
    bool is_in_security_db, uint16_t conn_interval, uint16_t conn_latency,
    uint16_t conn_timeout, bool can_read_discoverable_characteristics) {
  if (role == HCI_ROLE_CENTRAL) {
    btm_sec_cb.ble_ctr_cb.set_connection_state_idle();
    btm_cb.ble_ctr_cb.set_connection_state_idle();
    btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
  }

@@ -140,7 +139,7 @@ void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type,
  btm_acl_create_failed(address_with_type.bda, BT_TRANSPORT_LE, status);

  if (status != HCI_ERR_ADVERTISING_TIMEOUT) {
    btm_sec_cb.ble_ctr_cb.set_connection_state_idle();
    btm_cb.ble_ctr_cb.set_connection_state_idle();
    btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
    tBLE_BD_ADDR resolved_address_with_type;
    maybe_resolve_received_address(address_with_type,
@@ -155,7 +154,7 @@ void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type,
             ADDRESS_TO_LOGGABLE_CSTR(resolved_address_with_type.bda),
             hci_status_code_text(status).c_str());
  } else {
    btm_sec_cb.ble_ctr_cb.inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
    btm_cb.ble_ctr_cb.inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
  }
  btm_ble_update_mode_operation(HCI_ROLE_UNKNOWN, &address_with_type.bda,
                                status);
+5 −3
Original line number Diff line number Diff line
@@ -20,12 +20,14 @@
#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>
#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h>

#include "btm_sec_cb.h"
#include "stack/btm/btm_ble_int.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/acl_api.h"
#include "stack/include/ble_hci_link_interface.h"
#include "types/raw_address.h"

extern tBTM_CB btm_cb;

void btm_ble_advertiser_notify_terminated_legacy(uint8_t status,
                                                 uint16_t connection_handle);

@@ -39,11 +41,11 @@ void btm_ble_create_ll_conn_complete(tHCI_STATUS status) {
               << hci_error_code_text(status);

  if (status == HCI_ERR_COMMAND_DISALLOWED) {
    btm_sec_cb.ble_ctr_cb.set_connection_state_connecting();
    btm_cb.ble_ctr_cb.set_connection_state_connecting();
    btm_ble_set_topology_mask(BTM_BLE_STATE_INIT_BIT);
    LOG(ERROR) << "LE Create Connection - command disallowed";
  } else {
    btm_sec_cb.ble_ctr_cb.set_connection_state_idle();
    btm_cb.ble_ctr_cb.set_connection_state_idle();
    btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
    btm_ble_update_mode_operation(HCI_ROLE_UNKNOWN, NULL, status);
  }
+1 −2
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "osi/include/stack_power_telemetry.h"
#include "stack/btm/btm_int_types.h"
#include "stack/btm/btm_sec_cb.h"
#include "stack/include/btm_api.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/btm_log_history.h"
@@ -843,7 +842,7 @@ static bool btm_pm_device_in_active_or_sniff_mode(void) {
  }

  /* Check BLE states */
  if (!btm_sec_cb.ble_ctr_cb.is_connection_state_idle()) {
  if (!btm_cb.ble_ctr_cb.is_connection_state_idle()) {
    LOG_VERBOSE("%s - BLE state is not idle", __func__);
    return true;
  }
+3 −3
Original line number Diff line number Diff line
@@ -1736,7 +1736,7 @@ void btm_ble_connected(const RawAddress& bda, uint16_t handle, uint8_t enc_mode,
      p_dev_rec->ble.cur_rand_addr = bda;
    }
  }
  btm_sec_cb.ble_ctr_cb.inq_var.directed_conn = BTM_BLE_ADV_IND_EVT;
  btm_cb.ble_ctr_cb.inq_var.directed_conn = BTM_BLE_ADV_IND_EVT;
}

/*****************************************************************************
@@ -2084,7 +2084,7 @@ static void btm_ble_reset_id_impl(const Octet16& rand1, const Octet16& rand2) {
  btm_notify_new_key(BTM_BLE_KEY_TYPE_ID);

  /* if privacy is enabled, new RPA should be calculated */
  if (btm_sec_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
  if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
    btm_gen_resolvable_private_addr(base::Bind(&btm_gen_resolve_paddr_low));
  }

@@ -2093,7 +2093,7 @@ static void btm_ble_reset_id_impl(const Octet16& rand1, const Octet16& rand2) {
  btm_notify_new_key(BTM_BLE_KEY_TYPE_ER);

  /* if privacy is enabled, update the irk and RPA in the LE address manager */
  if (btm_sec_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
  if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
    BTM_BleConfigPrivacy(true);
  }
}
Loading