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

Commit 07dab5d1 authored by Eric Shih's avatar Eric Shih
Browse files

Check whether to do or stop timer in bta_dm_disable_pm

Bug: 354546755
Test: atest net_test_bta
Flag: EXEMPT, refactor
Change-Id: I847785958e8984b7de5d31454a2452380f4fa78a
parent 1b652bd8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -321,7 +321,15 @@ void bta_dm_disable() {
    log::warn("Unable to disable classic BR/EDR connectability");
  }

  /* if sniff is offload, no need to handle it in the stack */
  if (com::android::bluetooth::flags::enable_sniff_offload() &&
      osi_property_get_bool(kPropertySniffOffloadEnabled, false)) {
    log::info("Sniff offloading. Skip bta_dm_disable_pm.");
  } else {
    /* Disable bluetooth low power manager */
    bta_dm_disable_pm();
  }

  if (com::android::bluetooth::flags::separate_service_and_device_discovery()) {
    bta_dm_disc_disable_search();
    bta_dm_disc_disable_disc();
+3 −1
Original line number Diff line number Diff line
@@ -137,7 +137,9 @@ void bta_dm_disable_pm(void) {
  /* Need to stop all active timers. */
  for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
    for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
      if (bta_dm_cb.pm_timer[i].in_use) {
        bta_dm_pm_stop_timer_by_index(&bta_dm_cb.pm_timer[i], j);
      }
      bta_dm_cb.pm_timer[i].pm_action[j] = BTA_DM_PM_NO_ACTION;
    }
  }
+6 −0
Original line number Diff line number Diff line
@@ -478,6 +478,12 @@ TEST_F_WITH_FLAGS(BtaDmCustomAlarmTest, sniff_offload_feature__enable_flag,
  is_property_enabled = false;
  bluetooth::legacy::testing::BTA_dm_on_hw_on();
  ASSERT_EQ((uint8_t)BTA_ID_MAX, bta_dm_cb.pm_timer[0].srvc_id[0]);

  // Shouldn't crash even there's no active timer when calling
  // bta_dm_disable_pm.
  bta_dm_cb.pm_timer[0].in_use = false;
  bta_dm_cb.pm_timer[0].srvc_id[0] = kUnusedTimer;
  bta_dm_disable_pm();
}

TEST_F_WITH_FLAGS(BtaDmCustomAlarmTest, sniff_offload_feature__disable_flag,