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

Commit 65526e45 authored by Chris Manton's avatar Chris Manton
Browse files

Remove cpp is_gd_controller_enabled because It Is Known

Bug: 197513926
Tag: #refactor
Test: gd/cert/run

Change-Id: Ie0fc5a7977f1ca9de2756448d9d0f9d4b99fa629
parent 6488527a
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -299,11 +299,7 @@ static void event_start_up_stack(UNUSED_ATTR void* context) {


  bta_set_forward_hw_failures(true);
  bta_set_forward_hw_failures(true);
  btm_acl_device_down();
  btm_acl_device_down();
  if (bluetooth::shim::is_gd_controller_enabled()) {
  CHECK(module_start_up(get_local_module(GD_CONTROLLER_MODULE)));
  CHECK(module_start_up(get_local_module(GD_CONTROLLER_MODULE)));
  } else {
    CHECK(module_start_up(get_local_module(CONTROLLER_MODULE)));
  }
  BTM_reset_complete();
  BTM_reset_complete();


  BTA_dm_on_hw_on();
  BTA_dm_on_hw_on();
+1 −508
Original line number Original line Diff line number Diff line
@@ -326,513 +326,6 @@ EXPORT_SYMBOL extern const module_t controller_module = {


// Interface functions
// Interface functions


static bool get_is_ready(void) { return readable; }

static const RawAddress* get_address(void) {
  CHECK(readable);
  return &address;
}

static const bt_version_t* get_bt_version(void) {
  CHECK(readable);
  return &bt_version;
}

static uint8_t* get_local_supported_codecs(uint8_t* number_of_codecs) {
  CHECK(readable);
  if (number_of_local_supported_codecs) {
    *number_of_codecs = number_of_local_supported_codecs;
    return local_supported_codecs;
  }
  return NULL;
}

static const uint8_t* get_ble_supported_states(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_supported_states;
}

static bool supports_simple_pairing(void) {
  CHECK(readable);
  return simple_pairing_supported;
}

static bool supports_secure_connections(void) {
  CHECK(readable);
  return secure_connections_supported;
}

static bool supports_simultaneous_le_bredr(void) {
  CHECK(readable);
  return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array);
}

static bool supports_reading_remote_extended_features(void) {
  CHECK(readable);
  return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands);
}

static bool supports_interlaced_inquiry_scan(void) {
  CHECK(readable);
  return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array);
}

static bool supports_rssi_with_inquiry_results(void) {
  CHECK(readable);
  return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array);
}

static bool supports_extended_inquiry_response(void) {
  CHECK(readable);
  return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array);
}

static bool supports_central_peripheral_role_switch(void) {
  CHECK(readable);
  return HCI_SWITCH_SUPPORTED(features_classic[0].as_array);
}

static bool supports_enhanced_setup_synchronous_connection(void) {
  assert(readable);
  return HCI_ENH_SETUP_SYNCH_CONN_SUPPORTED(supported_commands);
}

static bool supports_enhanced_accept_synchronous_connection(void) {
  assert(readable);
  return HCI_ENH_ACCEPT_SYNCH_CONN_SUPPORTED(supported_commands);
}

static bool supports_3_slot_packets(void) {
  CHECK(readable);
  return HCI_3_SLOT_PACKETS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_5_slot_packets(void) {
  CHECK(readable);
  return HCI_5_SLOT_PACKETS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_classic_2m_phy(void) {
  CHECK(readable);
  return HCI_EDR_ACL_2MPS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_classic_3m_phy(void) {
  CHECK(readable);
  return HCI_EDR_ACL_3MPS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_3_slot_edr_packets(void) {
  CHECK(readable);
  return HCI_3_SLOT_EDR_ACL_SUPPORTED(features_classic[0].as_array);
}

static bool supports_5_slot_edr_packets(void) {
  CHECK(readable);
  return HCI_5_SLOT_EDR_ACL_SUPPORTED(features_classic[0].as_array);
}

static bool supports_sco(void) {
  CHECK(readable);
  return HCI_SCO_LINK_SUPPORTED(features_classic[0].as_array);
}

static bool supports_hv2_packets(void) {
  CHECK(readable);
  return HCI_HV2_PACKETS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_hv3_packets(void) {
  CHECK(readable);
  return HCI_HV3_PACKETS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_ev3_packets(void) {
  CHECK(readable);
  return HCI_ESCO_EV3_SUPPORTED(features_classic[0].as_array);
}

static bool supports_ev4_packets(void) {
  CHECK(readable);
  return HCI_ESCO_EV4_SUPPORTED(features_classic[0].as_array);
}

static bool supports_ev5_packets(void) {
  CHECK(readable);
  return HCI_ESCO_EV5_SUPPORTED(features_classic[0].as_array);
}

static bool supports_esco_2m_phy(void) {
  CHECK(readable);
  return HCI_EDR_ESCO_2MPS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_esco_3m_phy(void) {
  CHECK(readable);
  return HCI_EDR_ESCO_3MPS_SUPPORTED(features_classic[0].as_array);
}

static bool supports_3_slot_esco_edr_packets(void) {
  CHECK(readable);
  return HCI_3_SLOT_EDR_ESCO_SUPPORTED(features_classic[0].as_array);
}

static bool supports_role_switch(void) {
  CHECK(readable);
  return HCI_SWITCH_SUPPORTED(features_classic[0].as_array);
}

static bool supports_hold_mode(void) {
  CHECK(readable);
  return HCI_HOLD_MODE_SUPPORTED(features_classic[0].as_array);
}

static bool supports_sniff_mode(void) {
  CHECK(readable);
  return HCI_SNIFF_MODE_SUPPORTED(features_classic[0].as_array);
}

static bool supports_park_mode(void) {
  CHECK(readable);
  return HCI_PARK_MODE_SUPPORTED(features_classic[0].as_array);
}

static bool supports_non_flushable_pb(void) {
  CHECK(readable);
  return HCI_NON_FLUSHABLE_PB_SUPPORTED(features_classic[0].as_array);
}

static bool supports_sniff_subrating(void) {
  CHECK(readable);
  return HCI_SNIFF_SUB_RATE_SUPPORTED(features_classic[0].as_array);
}

static bool supports_encryption_pause(void) {
  CHECK(readable);
  return HCI_ATOMIC_ENCRYPT_SUPPORTED(features_classic[0].as_array);
}

static bool supports_ble(void) {
  CHECK(readable);
  return ble_supported;
}

static bool supports_ble_privacy(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_set_privacy_mode() {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array) &&
         HCI_LE_SET_PRIVACY_MODE_SUPPORTED(supported_commands);
}

static bool supports_ble_packet_extension(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_connection_parameters_request(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_2m_phy(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_2M_PHY_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_coded_phy(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_CODED_PHY_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_extended_advertising(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_EXTENDED_ADVERTISING_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_periodic_advertising(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_PERIODIC_ADVERTISING_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_peripheral_initiated_feature_exchange(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_PERIPHERAL_INIT_FEAT_EXC_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_connection_parameter_request(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array);
}

static bool supports_ble_periodic_advertising_sync_transfer_sender(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_SENDER(
      features_ble.as_array);
}

static bool supports_ble_periodic_advertising_sync_transfer_recipient(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_RECIPIENT(
      features_ble.as_array);
}

static bool supports_ble_connected_isochronous_stream_central(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_CIS_CENTRAL(features_ble.as_array);
}

static bool supports_ble_connected_isochronous_stream_peripheral(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_CIS_PERIPHERAL(features_ble.as_array);
}

static bool supports_ble_isochronous_broadcaster(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_ISO_BROADCASTER(features_ble.as_array);
}

static bool supports_ble_synchronized_receiver(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return HCI_LE_SYNCHRONIZED_RECEIVER(features_ble.as_array);
}

static uint16_t get_acl_data_size_classic(void) {
  CHECK(readable);
  return acl_data_size_classic;
}

static uint16_t get_acl_data_size_ble(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return acl_data_size_ble;
}

static uint16_t get_iso_data_size(void) {
  CHECK(readable);
  return iso_data_size;
}

static uint16_t get_acl_packet_size_classic(void) {
  CHECK(readable);
  return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE;
}

static uint16_t get_acl_packet_size_ble(void) {
  CHECK(readable);
  return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE;
}

static uint16_t get_iso_packet_size(void) {
  CHECK(readable);
  return iso_data_size + HCI_DATA_PREAMBLE_SIZE;
}

static uint16_t get_ble_suggested_default_data_length(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_suggested_default_data_length;
}

static uint16_t get_ble_maximum_tx_data_length(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_supported_max_tx_octets;
}

static uint16_t get_ble_maximum_tx_time(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_supported_max_tx_time;
}

static uint16_t get_ble_maximum_advertising_data_length(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_maximum_advertising_data_length;
}

static uint8_t get_ble_number_of_supported_advertising_sets(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_number_of_supported_advertising_sets;
}

static uint8_t get_ble_periodic_advertiser_list_size(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_periodic_advertiser_list_size;
}

static uint16_t get_acl_buffer_count_classic(void) {
  CHECK(readable);
  return acl_buffer_count_classic;
}

static uint8_t get_acl_buffer_count_ble(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return acl_buffer_count_ble;
}

static uint8_t get_iso_buffer_count(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return iso_buffer_count;
}

static uint8_t get_ble_acceptlist_size(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_acceptlist_size;
}

static uint8_t get_ble_resolving_list_max_size(void) {
  CHECK(readable);
  CHECK(ble_supported);
  return ble_resolving_list_max_size;
}

static void set_ble_resolving_list_max_size(int resolving_list_max_size) {
  // Setting "resolving_list_max_size" to 0 is done during cleanup,
  // hence we ignore the "readable" flag already set to false during shutdown.
  if (resolving_list_max_size != 0) {
    CHECK(readable);
  }
  CHECK(ble_supported);
  ble_resolving_list_max_size = resolving_list_max_size;
}

static uint8_t get_le_all_initiating_phys() {
  uint8_t phy = PHY_LE_1M;
  // TODO(jpawlowski): uncomment after next FW udpate
  // if (supports_ble_2m_phy()) phy |= PHY_LE_2M;
  // if (supports_ble_coded_phy()) phy |= PHY_LE_CODED;
  return phy;
}

static const controller_t interface = {
    get_is_ready,

    get_address,
    get_bt_version,

    get_ble_supported_states,

    supports_simple_pairing,
    supports_secure_connections,
    supports_simultaneous_le_bredr,
    supports_reading_remote_extended_features,
    supports_interlaced_inquiry_scan,
    supports_rssi_with_inquiry_results,
    supports_extended_inquiry_response,
    supports_central_peripheral_role_switch,
    supports_enhanced_setup_synchronous_connection,
    supports_enhanced_accept_synchronous_connection,
    supports_3_slot_packets,
    supports_5_slot_packets,
    supports_classic_2m_phy,
    supports_classic_3m_phy,
    supports_3_slot_edr_packets,
    supports_5_slot_edr_packets,
    supports_sco,
    supports_hv2_packets,
    supports_hv3_packets,
    supports_ev3_packets,
    supports_ev4_packets,
    supports_ev5_packets,
    supports_esco_2m_phy,
    supports_esco_3m_phy,
    supports_3_slot_esco_edr_packets,
    supports_role_switch,
    supports_hold_mode,
    supports_sniff_mode,
    supports_park_mode,
    supports_non_flushable_pb,
    supports_sniff_subrating,
    supports_encryption_pause,

    supports_ble,
    supports_ble_packet_extension,
    supports_ble_connection_parameters_request,
    supports_ble_privacy,
    supports_ble_set_privacy_mode,
    supports_ble_2m_phy,
    supports_ble_coded_phy,
    supports_ble_extended_advertising,
    supports_ble_periodic_advertising,
    supports_ble_peripheral_initiated_feature_exchange,
    supports_ble_connection_parameter_request,
    supports_ble_periodic_advertising_sync_transfer_sender,
    supports_ble_periodic_advertising_sync_transfer_recipient,
    supports_ble_connected_isochronous_stream_central,
    supports_ble_connected_isochronous_stream_peripheral,
    supports_ble_isochronous_broadcaster,
    supports_ble_synchronized_receiver,

    get_acl_data_size_classic,
    get_acl_data_size_ble,
    get_iso_data_size,

    get_acl_packet_size_classic,
    get_acl_packet_size_ble,
    get_iso_packet_size,

    get_ble_suggested_default_data_length,
    get_ble_maximum_tx_data_length,
    get_ble_maximum_tx_time,
    get_ble_maximum_advertising_data_length,
    get_ble_number_of_supported_advertising_sets,
    get_ble_periodic_advertiser_list_size,

    get_acl_buffer_count_classic,
    get_acl_buffer_count_ble,
    get_iso_buffer_count,

    get_ble_acceptlist_size,

    get_ble_resolving_list_max_size,
    set_ble_resolving_list_max_size,
    get_local_supported_codecs,
    get_le_all_initiating_phys};

static const controller_t* controller_get_interface_legacy() {
  static bool loaded = false;
  if (!loaded) {
    loaded = true;

    local_hci = bluetooth::shim::hci_layer_get_interface();
    packet_factory = hci_packet_factory_get_interface();
    packet_parser = hci_packet_parser_get_interface();
  }

  return &interface;
}

const controller_t* controller_get_interface() {
const controller_t* controller_get_interface() {
  if (bluetooth::shim::is_gd_controller_enabled()) {
  return bluetooth::shim::controller_get_interface();
  return bluetooth::shim::controller_get_interface();
  } else {
    return controller_get_interface_legacy();
  }
}
}
+0 −4
Original line number Original line Diff line number Diff line
@@ -74,10 +74,6 @@ bool bluetooth::shim::is_gd_link_policy_enabled() {
  return bluetooth::common::init_flags::gd_link_policy_is_enabled();
  return bluetooth::common::init_flags::gd_link_policy_is_enabled();
}
}


bool bluetooth::shim::is_gd_controller_enabled() {
  return bluetooth::common::init_flags::gd_controller_is_enabled();
}

bool bluetooth::shim::is_gd_l2cap_enabled() {
bool bluetooth::shim::is_gd_l2cap_enabled() {
  return bluetooth::common::init_flags::gd_l2cap_is_enabled();
  return bluetooth::common::init_flags::gd_l2cap_is_enabled();
}
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -50,7 +50,6 @@ bool is_gd_scanning_enabled();
bool is_gd_security_enabled();
bool is_gd_security_enabled();
bool is_gd_acl_enabled();
bool is_gd_acl_enabled();
bool is_gd_link_policy_enabled();
bool is_gd_link_policy_enabled();
bool is_gd_controller_enabled();
bool is_gd_l2cap_enabled();
bool is_gd_l2cap_enabled();
bool is_gd_shim_enabled();
bool is_gd_shim_enabled();
bool is_gd_btaa_enabled();
bool is_gd_btaa_enabled();
+0 −4
Original line number Original line Diff line number Diff line
@@ -51,10 +51,6 @@ bool bluetooth::shim::is_gd_scanning_enabled() {
  mock_function_count_map[__func__]++;
  mock_function_count_map[__func__]++;
  return false;
  return false;
}
}
bool bluetooth::shim::is_gd_controller_enabled() {
  mock_function_count_map[__func__]++;
  return false;
}
bool bluetooth::shim::is_gd_l2cap_enabled() {
bool bluetooth::shim::is_gd_l2cap_enabled() {
  mock_function_count_map[__func__]++;
  mock_function_count_map[__func__]++;
  return false;
  return false;
Loading