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

Commit 3008c9e7 authored by Suneesh Sasikumar's avatar Suneesh Sasikumar Committed by Gerrit Code Review
Browse files

Merge "Remove sniff_offload flag usage, make sysprop persist" into main

parents 006fc3d8 735551a9
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ static void bta_dm_adjust_roles(bool delay_role_switch);
tBTM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void);
static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result);

static const char kPropertySniffOffloadEnabled[] = "bluetooth.sniff_offload.enabled";
static const char kPropertySniffOffloadEnabled[] = "persist.bluetooth.sniff_offload.enabled";

#ifndef BTA_DM_BLE_ADV_CHNL_MAP
#define BTA_DM_BLE_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37 | BTM_BLE_ADV_CHNL_38 | BTM_BLE_ADV_CHNL_39)
@@ -288,8 +288,8 @@ void BTA_dm_on_hw_on() {
  bta_sys_rm_register(bta_dm_rm_cback);

  /* 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)) {
  if (osi_property_get_bool(kPropertySniffOffloadEnabled, false)) {
    log::info("Sniff offloaded. Skip bta_dm_init_pm.");
  } else {
    /* initialize bluetooth low power manager */
    bta_dm_init_pm();
@@ -322,9 +322,8 @@ void bta_dm_disable() {
  }

  /* 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.");
  if (osi_property_get_bool(kPropertySniffOffloadEnabled, false)) {
    log::info("Sniff offloaded. Skip bta_dm_disable_pm.");
  } else {
    /* Disable bluetooth low power manager */
    bta_dm_disable_pm();
+3 −23
Original line number Diff line number Diff line
@@ -461,20 +461,19 @@ TEST_F(BtaDmCustomAlarmTest, bta_dm_sniff_cback) {
  ASSERT_EQ(2, get_func_call_count("alarm_set_on_mloop"));
}

TEST_F_WITH_FLAGS(BtaDmCustomAlarmTest, sniff_offload_feature__enable_flag,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, enable_sniff_offload))) {
TEST_F(BtaDmCustomAlarmTest, sniff_offload_feature__test_sysprop) {
  bool is_property_enabled = true;
  test::mock::osi_properties::osi_property_get_bool.body =
          [&](const char* key, bool default_value) -> int { return is_property_enabled; };

  // Expect not to trigger bta_dm_init_pm due to both flag and prop are enabled
  // Expect not to trigger bta_dm_init_pm due to sysprop enabled
  // and reset the value of .srvc_id.
  is_property_enabled = true;
  bluetooth::legacy::testing::BTA_dm_on_hw_on();
  ASSERT_EQ(0, bta_dm_cb.pm_timer[0].srvc_id[0]);

  // Expect to trigger bta_dm_init_pm and init the value of .srvc_id to
  // BTA_ID_MAX.
  // BTA_ID_MAX due to sysprop disabled.
  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]);
@@ -485,22 +484,3 @@ TEST_F_WITH_FLAGS(BtaDmCustomAlarmTest, sniff_offload_feature__enable_flag,
  bta_dm_cb.pm_timer[0].srvc_id[0] = kUnusedTimer;
  bta_dm_disable_pm();
}

TEST_F_WITH_FLAGS(BtaDmCustomAlarmTest, sniff_offload_feature__disable_flag,
                  REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(TEST_BT, enable_sniff_offload))) {
  bool is_property_enabled = true;
  test::mock::osi_properties::osi_property_get_bool.body =
          [&](const char* key, bool default_value) -> int { return is_property_enabled; };

  // Expect to trigger bta_dm_init_pm and init the value of .srvc_id to
  // BTA_ID_MAX.
  is_property_enabled = true;
  bluetooth::legacy::testing::BTA_dm_on_hw_on();
  ASSERT_EQ((uint8_t)BTA_ID_MAX, bta_dm_cb.pm_timer[0].srvc_id[0]);

  // Expect to trigger bta_dm_init_pm and init the value of .srvc_id to
  // BTA_ID_MAX.
  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]);
}