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

Commit 10ca56cb authored by Chris Manton's avatar Chris Manton
Browse files

legacy: Remove btif/src/btif_metrics_logging::is_any_gd_enabled

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

Change-Id: I4b0321da5d9ed77f026733ec8b166e96132853cf
parent 21d29e1b
Loading
Loading
Loading
Loading
+19 −78
Original line number Original line Diff line number Diff line
@@ -27,13 +27,8 @@
void log_a2dp_audio_underrun_event(const RawAddress& address,
void log_a2dp_audio_underrun_event(const RawAddress& address,
                                   uint64_t encoding_interval_millis,
                                   uint64_t encoding_interval_millis,
                                   int num_missing_pcm_bytes) {
                                   int num_missing_pcm_bytes) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::LogMetricA2dpAudioUnderrunEvent(
  bluetooth::shim::LogMetricA2dpAudioUnderrunEvent(
      address, encoding_interval_millis, num_missing_pcm_bytes);
      address, encoding_interval_millis, num_missing_pcm_bytes);
  } else {
    bluetooth::common::LogA2dpAudioUnderrunEvent(
        address, encoding_interval_millis, num_missing_pcm_bytes);
  }
}
}


void log_a2dp_audio_overrun_event(const RawAddress& address,
void log_a2dp_audio_overrun_event(const RawAddress& address,
@@ -41,126 +36,72 @@ void log_a2dp_audio_overrun_event(const RawAddress& address,
                                  int num_dropped_buffers,
                                  int num_dropped_buffers,
                                  int num_dropped_encoded_frames,
                                  int num_dropped_encoded_frames,
                                  int num_dropped_encoded_bytes) {
                                  int num_dropped_encoded_bytes) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::LogMetricA2dpAudioOverrunEvent(
  bluetooth::shim::LogMetricA2dpAudioOverrunEvent(
      address, encoding_interval_millis, num_dropped_buffers,
      address, encoding_interval_millis, num_dropped_buffers,
      num_dropped_encoded_frames, num_dropped_encoded_bytes);
      num_dropped_encoded_frames, num_dropped_encoded_bytes);
  } else {
    bluetooth::common::LogA2dpAudioOverrunEvent(
        address, encoding_interval_millis, num_dropped_buffers,
        num_dropped_encoded_frames, num_dropped_encoded_bytes);
  }
}
}


void log_a2dp_playback_event(const RawAddress& address, int playback_state,
void log_a2dp_playback_event(const RawAddress& address, int playback_state,
                             int audio_coding_mode) {
                             int audio_coding_mode) {
  if (bluetooth::shim::is_any_gd_enabled()) {
    bluetooth::shim::LogMetricA2dpPlaybackEvent(address, playback_state,
    bluetooth::shim::LogMetricA2dpPlaybackEvent(address, playback_state,
                                                audio_coding_mode);
                                                audio_coding_mode);
  } else {
    bluetooth::common::LogA2dpPlaybackEvent(address, playback_state,
                                            audio_coding_mode);
  }
}
}


void log_read_rssi_result(const RawAddress& address, uint16_t handle,
void log_read_rssi_result(const RawAddress& address, uint16_t handle,
                          uint32_t cmd_status, int8_t rssi) {
                          uint32_t cmd_status, int8_t rssi) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::LogMetricReadRssiResult(address, handle, cmd_status, rssi);
  bluetooth::shim::LogMetricReadRssiResult(address, handle, cmd_status, rssi);
  } else {
    bluetooth::common::LogReadRssiResult(address, handle, cmd_status, rssi);
  }
}
}


void log_read_failed_contact_counter_result(const RawAddress& address,
void log_read_failed_contact_counter_result(const RawAddress& address,
                                            uint16_t handle,
                                            uint16_t handle,
                                            uint32_t cmd_status,
                                            uint32_t cmd_status,
                                            int32_t failed_contact_counter) {
                                            int32_t failed_contact_counter) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::LogMetricReadFailedContactCounterResult(
  bluetooth::shim::LogMetricReadFailedContactCounterResult(
      address, handle, cmd_status, failed_contact_counter);
      address, handle, cmd_status, failed_contact_counter);
  } else {
    bluetooth::common::LogReadFailedContactCounterResult(
        address, handle, cmd_status, failed_contact_counter);
  }
}
}


void log_read_tx_power_level_result(const RawAddress& address, uint16_t handle,
void log_read_tx_power_level_result(const RawAddress& address, uint16_t handle,
                                    uint32_t cmd_status,
                                    uint32_t cmd_status,
                                    int32_t transmit_power_level) {
                                    int32_t transmit_power_level) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::LogMetricReadTxPowerLevelResult(address, handle, cmd_status,
    bluetooth::shim::LogMetricReadTxPowerLevelResult(
        address, handle, cmd_status, transmit_power_level);
  } else {
    bluetooth::common::LogReadTxPowerLevelResult(address, handle, cmd_status,
                                                   transmit_power_level);
                                                   transmit_power_level);
}
}
}


void log_socket_connection_state(
void log_socket_connection_state(
    const RawAddress& address, int port, int type,
    const RawAddress& address, int port, int type,
    android::bluetooth::SocketConnectionstateEnum connection_state,
    android::bluetooth::SocketConnectionstateEnum connection_state,
    int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port,
    int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port,
    android::bluetooth::SocketRoleEnum socket_role) {
    android::bluetooth::SocketRoleEnum socket_role) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::LogMetricSocketConnectionState(
  bluetooth::shim::LogMetricSocketConnectionState(
      address, port, type, connection_state, tx_bytes, rx_bytes, uid,
      address, port, type, connection_state, tx_bytes, rx_bytes, uid,
      server_port, socket_role);
      server_port, socket_role);
  } else {
    bluetooth::common::LogSocketConnectionState(
        address, port, type, connection_state, tx_bytes, rx_bytes, uid,
        server_port, socket_role);
  }
}
}


bool init_metric_id_allocator(
bool init_metric_id_allocator(
    const std::unordered_map<RawAddress, int>& paired_device_map,
    const std::unordered_map<RawAddress, int>& paired_device_map,
    bluetooth::shim::CallbackLegacy save_device_callback,
    bluetooth::shim::CallbackLegacy save_device_callback,
    bluetooth::shim::CallbackLegacy forget_device_callback) {
    bluetooth::shim::CallbackLegacy forget_device_callback) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  return bluetooth::shim::InitMetricIdAllocator(
  return bluetooth::shim::InitMetricIdAllocator(
      paired_device_map, std::move(save_device_callback),
      paired_device_map, std::move(save_device_callback),
      std::move(forget_device_callback));
      std::move(forget_device_callback));
}
}
  return bluetooth::common::MetricIdAllocator::GetInstance().Init(
      paired_device_map, std::move(save_device_callback),
      std::move(forget_device_callback));
}


bool close_metric_id_allocator() {
bool close_metric_id_allocator() {
  if (bluetooth::shim::is_any_gd_enabled()) {
  return bluetooth::shim::CloseMetricIdAllocator();
  return bluetooth::shim::CloseMetricIdAllocator();
}
}
  return bluetooth::common::MetricIdAllocator::GetInstance().Close();
}


int allocate_metric_id_from_metric_id_allocator(const RawAddress& address) {
int allocate_metric_id_from_metric_id_allocator(const RawAddress& address) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  return bluetooth::shim::AllocateIdFromMetricIdAllocator(address);
  return bluetooth::shim::AllocateIdFromMetricIdAllocator(address);
}
}
  return bluetooth::common::MetricIdAllocator::GetInstance().AllocateId(
      address);
}


int save_metric_id_from_metric_id_allocator(const RawAddress& address) {
int save_metric_id_from_metric_id_allocator(const RawAddress& address) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  return bluetooth::shim::SaveDeviceOnMetricIdAllocator(address);
  return bluetooth::shim::SaveDeviceOnMetricIdAllocator(address);
}
}
  return bluetooth::common::MetricIdAllocator::GetInstance().SaveDevice(
      address);
}


void forget_device_from_metric_id_allocator(const RawAddress& address) {
void forget_device_from_metric_id_allocator(const RawAddress& address) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  bluetooth::shim::ForgetDeviceFromMetricIdAllocator(address);
  bluetooth::shim::ForgetDeviceFromMetricIdAllocator(address);
  } else {
    bluetooth::common::MetricIdAllocator::GetInstance().ForgetDevice(address);
  }
}
}


bool is_valid_id_from_metric_id_allocator(const int id) {
bool is_valid_id_from_metric_id_allocator(const int id) {
  if (bluetooth::shim::is_any_gd_enabled()) {
  return bluetooth::shim::IsValidIdFromMetricIdAllocator(id);
  return bluetooth::shim::IsValidIdFromMetricIdAllocator(id);
}
}
  return bluetooth::common::MetricIdAllocator::IsValidId(id);
}