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

Commit 505b6435 authored by Henri Chataing's avatar Henri Chataing
Browse files

system: Migrate ASSERT_LOG to log::assert_that

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: I5c9257dcbaae4d045df9d4009a8951e8dee17715
parent a5656534
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -937,10 +937,10 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, tBTA_SYS_ID id,
        if (((p_bta_dm_rm_cfg[j].app_id == app_id) ||
             (p_bta_dm_rm_cfg[j].app_id == BTA_ALL_APP_ID)) &&
            (p_bta_dm_rm_cfg[j].id == id)) {
          ASSERT_LOG(p_bta_dm_rm_cfg[j].cfg <= BTA_PERIPHERAL_ROLE_ONLY,
                     "Passing illegal preferred role:0x%02x [0x%02x<=>0x%02x]",
                     p_bta_dm_rm_cfg[j].cfg, BTA_ANY_ROLE,
                     BTA_PERIPHERAL_ROLE_ONLY);
          log::assert_that(
              p_bta_dm_rm_cfg[j].cfg <= BTA_PERIPHERAL_ROLE_ONLY,
              "Passing illegal preferred role:0x{:02x} [0x{:02x}<=>0x{:02x}]",
              p_bta_dm_rm_cfg[j].cfg, BTA_ANY_ROLE, BTA_PERIPHERAL_ROLE_ONLY);
          role = static_cast<tBTA_PREF_ROLES>(p_bta_dm_rm_cfg[j].cfg);
          if (role > p_dev->pref_role) p_dev->pref_role = role;
          break;
+4 −4
Original line number Diff line number Diff line
@@ -330,10 +330,10 @@ static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER* p_timer,
    return;
  } /* The timer was not scheduled */

  ASSERT_LOG(p_timer->in_use,
             "Timer was not scheduled p_timer->srvc_id[timer_idx]:%hhu",
  log::assert_that(p_timer->in_use,
                   "Timer was not scheduled p_timer->srvc_id[timer_idx]:{}",
                   p_timer->srvc_id[timer_idx]);
  ASSERT_LOG(p_timer->active > 0, "No tasks on timer are active");
  log::assert_that(p_timer->active > 0, "No tasks on timer are active");

  p_timer->srvc_id[timer_idx] = BTA_ID_MAX;
  /* NOTE: pm_action[timer_idx] intentionally not reset */
+6 −3
Original line number Diff line number Diff line
@@ -121,9 +121,10 @@ typedef enum : uint8_t {
} tBTA_PREF_ROLES;

inline tBTA_PREF_ROLES toBTA_PREF_ROLES(uint8_t role) {
  ASSERT_LOG(role <= BTA_PERIPHERAL_ROLE_ONLY,
             "Passing illegal preferred role:0x%02x [0x%02x<=>0x%02x]", role,
             BTA_ANY_ROLE, BTA_PERIPHERAL_ROLE_ONLY);
  bluetooth::log::assert_that(
      role <= BTA_PERIPHERAL_ROLE_ONLY,
      "Passing illegal preferred role:0x{:02x} [0x{:02x}<=>0x{:02x}]", role,
      int(BTA_ANY_ROLE), int(BTA_PERIPHERAL_ROLE_ONLY));
  return static_cast<tBTA_PREF_ROLES>(role);
}

@@ -954,6 +955,8 @@ template <>
struct formatter<tBTA_DM_SEARCH_EVT> : enum_formatter<tBTA_DM_SEARCH_EVT> {};
template <>
struct formatter<tBTA_DM_ACL_EVT> : enum_formatter<tBTA_DM_ACL_EVT> {};
template <>
struct formatter<tBTA_PREF_ROLES> : enum_formatter<tBTA_PREF_ROLES> {};
}  // namespace fmt

#endif /* BTA_API_H */
+4 −5
Original line number Diff line number Diff line
@@ -173,11 +173,10 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks {
    /* Prepare the announcement */
    announcement.presentation_delay_us = 40000; /* us */

    ASSERT_LOG(
        subgroup_configs.size() == metadata_group.size(),
        "The number of metadata subgroups %zu does not match the number of "
        "subgroup configurations %zu.",
        +metadata_group.size(), +subgroup_configs.size());
    log::assert_that(subgroup_configs.size() == metadata_group.size(),
                     "The number of metadata subgroups {} does not match the "
                     "number of subgroup configurations {}.",
                     metadata_group.size(), subgroup_configs.size());

    uint8_t subgroup_idx = 0;
    uint8_t bis_index = 0;
+14 −12
Original line number Diff line number Diff line
@@ -672,8 +672,8 @@ class LeAudioClientImpl : public LeAudioClient {
        return;
      }
    } else {
      ASSERT_LOG(id == group_id,
                 " group id missmatch? leaudio id: %d, groups module %d",
      log::assert_that(id == group_id,
                       "group id missmatch? leaudio id: {}, groups module {}",
                       group_id, id);
      new_group = aseGroups_.FindById(group_id);
      if (!new_group) {
@@ -1114,10 +1114,12 @@ class LeAudioClientImpl : public LeAudioClient {
     * This is why we don't have to check if session is started already.
     * Just check if it is acquired.
     */
    ASSERT_LOG(active_group_id_ == bluetooth::groups::kGroupUnknown,
    log::assert_that(active_group_id_ == bluetooth::groups::kGroupUnknown,
                     "Active group is not set.");
    ASSERT_LOG(le_audio_source_hal_client_, "Source session not acquired");
    ASSERT_LOG(le_audio_sink_hal_client_, "Sink session not acquired");
    log::assert_that(le_audio_source_hal_client_ != nullptr,
                     "Source session not acquired");
    log::assert_that(le_audio_sink_hal_client_ != nullptr,
                     "Sink session not acquired");

    DsaModes dsa_modes = {DsaMode::DISABLED};
    if (IS_FLAG_ENABLED(leaudio_dynamic_spatial_audio)) {
@@ -1131,7 +1133,7 @@ class LeAudioClientImpl : public LeAudioClient {
    } else if (!sink_config->IsInvalid()) {
      frame_duration_us = sink_config->data_interval_us;
    } else {
      ASSERT_LOG(true, "Both configs are invalid");
      log::assert_that(true, "Both configs are invalid");
    }

    audio_framework_source_config.data_interval_us = frame_duration_us;
@@ -5267,14 +5269,14 @@ class LeAudioClientImpl : public LeAudioClient {
      case bluetooth::hci::iso_manager::kIsoEventCigOnCreateCmpl: {
        auto* evt = static_cast<cig_create_cmpl_evt*>(data);
        LeAudioDeviceGroup* group = aseGroups_.FindById(evt->cig_id);
        ASSERT_LOG(group, "Group id: %d is null", evt->cig_id);
        log::assert_that(group, "Group id: {} is null", evt->cig_id);
        groupStateMachine_->ProcessHciNotifOnCigCreate(
            group, evt->status, evt->cig_id, evt->conn_handles);
      } break;
      case bluetooth::hci::iso_manager::kIsoEventCigOnRemoveCmpl: {
        auto* evt = static_cast<cig_remove_cmpl_evt*>(data);
        LeAudioDeviceGroup* group = aseGroups_.FindById(evt->cig_id);
        ASSERT_LOG(group, "Group id: %d is null", evt->cig_id);
        log::assert_that(group, "Group id: {} is null", evt->cig_id);
        groupStateMachine_->ProcessHciNotifOnCigRemove(evt->status, group);
        remove_group_if_possible(group);
      } break;
@@ -5554,8 +5556,8 @@ class LeAudioClientImpl : public LeAudioClient {

    switch (status) {
      case GroupStreamStatus::STREAMING: {
        ASSERT_LOG(group_id == active_group_id_, "invalid group id %d!=%d",
                   group_id, active_group_id_);
        log::assert_that(group_id == active_group_id_,
                         "invalid group id {}!={}", group_id, active_group_id_);

        take_stream_time();

Loading