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

Commit 289c87ef authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Pretify initialization of callback" into main

parents 7cb0440a 7578fdcf
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -67,8 +67,6 @@ struct EventCallbacks {
                                        int packets_not_receive_count,
                                        int negative_acknowledgement_count);

  EventCallbacks() = default;
  EventCallbacks(const EventCallbacks&) = delete;
  EventCallbacks& operator=(const EventCallbacks&) = delete;
};

@@ -127,8 +125,6 @@ struct HACK_ProfileInterface {
  // AVRCP hacks
  uint16_t (*AVRC_GetProfileVersion)();

  HACK_ProfileInterface() = default;
  HACK_ProfileInterface(const HACK_ProfileInterface&) = delete;
  HACK_ProfileInterface& operator=(const HACK_ProfileInterface&) = delete;
};

+38 −52
Original line number Diff line number Diff line
@@ -328,61 +328,47 @@ struct CoreInterfaceImpl : bluetooth::core::CoreInterface {
};

static bluetooth::core::CoreInterface* CreateInterfaceToProfiles() {
  static auto eventCallbacks = bluetooth::core::EventCallbacks();
  static bool eventCallbacks_initialized;
  if (!eventCallbacks_initialized) {
    eventCallbacks.invoke_adapter_state_changed_cb =
        invoke_adapter_state_changed_cb;
    eventCallbacks.invoke_adapter_properties_cb = invoke_adapter_properties_cb;
    eventCallbacks.invoke_remote_device_properties_cb =
        invoke_remote_device_properties_cb;
    eventCallbacks.invoke_device_found_cb = invoke_device_found_cb;
    eventCallbacks.invoke_discovery_state_changed_cb =
        invoke_discovery_state_changed_cb;
    eventCallbacks.invoke_pin_request_cb = invoke_pin_request_cb;
    eventCallbacks.invoke_ssp_request_cb = invoke_ssp_request_cb;
    eventCallbacks.invoke_oob_data_request_cb = invoke_oob_data_request_cb;
    eventCallbacks.invoke_bond_state_changed_cb = invoke_bond_state_changed_cb;
    eventCallbacks.invoke_address_consolidate_cb =
        invoke_address_consolidate_cb;
    eventCallbacks.invoke_le_address_associate_cb =
        invoke_le_address_associate_cb;
    eventCallbacks.invoke_acl_state_changed_cb = invoke_acl_state_changed_cb;
    eventCallbacks.invoke_thread_evt_cb = invoke_thread_evt_cb;
    eventCallbacks.invoke_le_test_mode_cb = invoke_le_test_mode_cb;
    eventCallbacks.invoke_energy_info_cb = invoke_energy_info_cb;
    eventCallbacks.invoke_link_quality_report_cb =
        invoke_link_quality_report_cb;

    eventCallbacks_initialized = true;
  }
  static auto configInterface = ConfigInterfaceImpl();
  static auto msbcCodecInterface = MSBCCodec();
  static auto lc3CodecInterface = LC3Codec();
  static auto profileInterface = bluetooth::core::HACK_ProfileInterface();
  static bool profileInterface_initialized;
  if (!profileInterface_initialized) {
  static bluetooth::core::EventCallbacks eventCallbacks{
      .invoke_adapter_state_changed_cb = invoke_adapter_state_changed_cb,
      .invoke_adapter_properties_cb = invoke_adapter_properties_cb,
      .invoke_remote_device_properties_cb = invoke_remote_device_properties_cb,
      .invoke_device_found_cb = invoke_device_found_cb,
      .invoke_discovery_state_changed_cb = invoke_discovery_state_changed_cb,
      .invoke_pin_request_cb = invoke_pin_request_cb,
      .invoke_ssp_request_cb = invoke_ssp_request_cb,
      .invoke_oob_data_request_cb = invoke_oob_data_request_cb,
      .invoke_bond_state_changed_cb = invoke_bond_state_changed_cb,
      .invoke_address_consolidate_cb = invoke_address_consolidate_cb,
      .invoke_le_address_associate_cb = invoke_le_address_associate_cb,
      .invoke_acl_state_changed_cb = invoke_acl_state_changed_cb,
      .invoke_thread_evt_cb = invoke_thread_evt_cb,
      .invoke_le_test_mode_cb = invoke_le_test_mode_cb,
      .invoke_energy_info_cb = invoke_energy_info_cb,
      .invoke_link_quality_report_cb = invoke_link_quality_report_cb,
  };
  static bluetooth::core::HACK_ProfileInterface profileInterface{
      // HID
    profileInterface.btif_hh_connect = btif_hh_connect;
    profileInterface.btif_hh_virtual_unplug = btif_hh_virtual_unplug;
    profileInterface.bta_hh_read_ssr_param = bta_hh_read_ssr_param;
      .btif_hh_connect = btif_hh_connect,
      .btif_hh_virtual_unplug = btif_hh_virtual_unplug,
      .bta_hh_read_ssr_param = bta_hh_read_ssr_param,

      // AVDTP
    profileInterface.btif_av_set_dynamic_audio_buffer_size =
        btif_av_set_dynamic_audio_buffer_size;
      .btif_av_set_dynamic_audio_buffer_size =
          btif_av_set_dynamic_audio_buffer_size,

      // ASHA
    profileInterface.GetHearingAidDeviceCount = HearingAid::GetDeviceCount;
      .GetHearingAidDeviceCount = HearingAid::GetDeviceCount,

      // LE Audio
    profileInterface.IsLeAudioClientRunning =
        LeAudioClient::IsLeAudioClientRunning;
      .IsLeAudioClientRunning = LeAudioClient::IsLeAudioClientRunning,

      // AVRCP
    profileInterface.AVRC_GetProfileVersion = AVRC_GetProfileVersion;
      .AVRC_GetProfileVersion = AVRC_GetProfileVersion,
  };

    profileInterface_initialized = true;
  }
  static auto configInterface = ConfigInterfaceImpl();
  static auto msbcCodecInterface = MSBCCodec();
  static auto lc3CodecInterface = LC3Codec();

  static auto interfaceForCore =
      CoreInterfaceImpl(&eventCallbacks, &configInterface, &msbcCodecInterface,