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

Commit 7578fdcf authored by William Escande's avatar William Escande
Browse files

Pretify initialization of callback

Bug: 311772251
Test: m Bluetooht | build only as no-op change
Change-Id: I5780b0c9127f9a54b1ebaeb6784d56811b49af40
parent b831bd25
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -67,8 +67,6 @@ struct EventCallbacks {
                                        int packets_not_receive_count,
                                        int packets_not_receive_count,
                                        int negative_acknowledgement_count);
                                        int negative_acknowledgement_count);


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


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


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


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


static bluetooth::core::CoreInterface* CreateInterfaceToProfiles() {
static bluetooth::core::CoreInterface* CreateInterfaceToProfiles() {
  static auto eventCallbacks = bluetooth::core::EventCallbacks();
  static bluetooth::core::EventCallbacks eventCallbacks{
  static bool eventCallbacks_initialized;
      .invoke_adapter_state_changed_cb = invoke_adapter_state_changed_cb,
  if (!eventCallbacks_initialized) {
      .invoke_adapter_properties_cb = invoke_adapter_properties_cb,
    eventCallbacks.invoke_adapter_state_changed_cb =
      .invoke_remote_device_properties_cb = invoke_remote_device_properties_cb,
        invoke_adapter_state_changed_cb;
      .invoke_device_found_cb = invoke_device_found_cb,
    eventCallbacks.invoke_adapter_properties_cb = invoke_adapter_properties_cb;
      .invoke_discovery_state_changed_cb = invoke_discovery_state_changed_cb,
    eventCallbacks.invoke_remote_device_properties_cb =
      .invoke_pin_request_cb = invoke_pin_request_cb,
        invoke_remote_device_properties_cb;
      .invoke_ssp_request_cb = invoke_ssp_request_cb,
    eventCallbacks.invoke_device_found_cb = invoke_device_found_cb;
      .invoke_oob_data_request_cb = invoke_oob_data_request_cb,
    eventCallbacks.invoke_discovery_state_changed_cb =
      .invoke_bond_state_changed_cb = invoke_bond_state_changed_cb,
        invoke_discovery_state_changed_cb;
      .invoke_address_consolidate_cb = invoke_address_consolidate_cb,
    eventCallbacks.invoke_pin_request_cb = invoke_pin_request_cb;
      .invoke_le_address_associate_cb = invoke_le_address_associate_cb,
    eventCallbacks.invoke_ssp_request_cb = invoke_ssp_request_cb;
      .invoke_acl_state_changed_cb = invoke_acl_state_changed_cb,
    eventCallbacks.invoke_oob_data_request_cb = invoke_oob_data_request_cb;
      .invoke_thread_evt_cb = invoke_thread_evt_cb,
    eventCallbacks.invoke_bond_state_changed_cb = invoke_bond_state_changed_cb;
      .invoke_le_test_mode_cb = invoke_le_test_mode_cb,
    eventCallbacks.invoke_address_consolidate_cb =
      .invoke_energy_info_cb = invoke_energy_info_cb,
        invoke_address_consolidate_cb;
      .invoke_link_quality_report_cb = invoke_link_quality_report_cb,
    eventCallbacks.invoke_le_address_associate_cb =
  };
        invoke_le_address_associate_cb;
  static bluetooth::core::HACK_ProfileInterface profileInterface{
    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) {
      // HID
      // HID
    profileInterface.btif_hh_connect = btif_hh_connect;
      .btif_hh_connect = btif_hh_connect,
    profileInterface.btif_hh_virtual_unplug = btif_hh_virtual_unplug;
      .btif_hh_virtual_unplug = btif_hh_virtual_unplug,
    profileInterface.bta_hh_read_ssr_param = bta_hh_read_ssr_param;
      .bta_hh_read_ssr_param = bta_hh_read_ssr_param,


      // AVDTP
      // 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
      // ASHA
    profileInterface.GetHearingAidDeviceCount = HearingAid::GetDeviceCount;
      .GetHearingAidDeviceCount = HearingAid::GetDeviceCount,


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


      // AVRCP
      // 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 =
  static auto interfaceForCore =
      CoreInterfaceImpl(&eventCallbacks, &configInterface, &msbcCodecInterface,
      CoreInterfaceImpl(&eventCallbacks, &configInterface, &msbcCodecInterface,