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

Commit 910d6f42 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Automerger Merge Worker
Browse files

leaudio: Start using Targeted announcements am: fd9527dd

parents 1cb0b5d3 fd9527dd
Loading
Loading
Loading
Loading
+22 −5
Original line number Original line Diff line number Diff line
@@ -253,6 +253,15 @@ class LeAudioClientImpl : public LeAudioClient {
    LeAudioGroupStateMachine::Initialize(state_machine_callbacks_);
    LeAudioGroupStateMachine::Initialize(state_machine_callbacks_);
    groupStateMachine_ = LeAudioGroupStateMachine::Get();
    groupStateMachine_ = LeAudioGroupStateMachine::Get();


    if (bluetooth::common::InitFlags::
            IsTargetedAnnouncementReconnectionMode()) {
      LOG_INFO(" Reconnection mode: TARGETED_ANNOUNCEMENTS");
      reconnection_mode_ = BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS;
    } else {
      LOG_INFO(" Reconnection mode: ALLOW_LIST");
      reconnection_mode_ = BTM_BLE_BKG_CONNECT_ALLOW_LIST;
    }

    BTA_GATTC_AppRegister(
    BTA_GATTC_AppRegister(
        le_audio_gattc_callback,
        le_audio_gattc_callback,
        base::Bind(
        base::Bind(
@@ -1203,7 +1212,7 @@ class LeAudioClientImpl : public LeAudioClient {
      leAudioDevice->SetConnectionState(
      leAudioDevice->SetConnectionState(
          DeviceConnectState::CONNECTING_AUTOCONNECT);
          DeviceConnectState::CONNECTING_AUTOCONNECT);
      leAudioDevice->autoconnect_flag_ = true;
      leAudioDevice->autoconnect_flag_ = true;
      BTA_GATTC_Open(gatt_if_, address, BTM_BLE_BKG_CONNECT_ALLOW_LIST, false);
      BTA_GATTC_Open(gatt_if_, address, reconnection_mode_, false);
    }
    }
  }
  }


@@ -1250,8 +1259,8 @@ class LeAudioClientImpl : public LeAudioClient {


    leAudioDevice->SetConnectionState(
    leAudioDevice->SetConnectionState(
        DeviceConnectState::CONNECTING_AUTOCONNECT);
        DeviceConnectState::CONNECTING_AUTOCONNECT);
    BTA_GATTC_Open(gatt_if_, leAudioDevice->address_,
    BTA_GATTC_Open(gatt_if_, leAudioDevice->address_, reconnection_mode_,
                   BTM_BLE_BKG_CONNECT_ALLOW_LIST, false);
                   false);
  }
  }


  void Disconnect(const RawAddress& address) override {
  void Disconnect(const RawAddress& address) override {
@@ -1825,7 +1834,7 @@ class LeAudioClientImpl : public LeAudioClient {
        leAudioDevice->autoconnect_flag_) {
        leAudioDevice->autoconnect_flag_) {
      leAudioDevice->SetConnectionState(
      leAudioDevice->SetConnectionState(
          DeviceConnectState::CONNECTING_AUTOCONNECT);
          DeviceConnectState::CONNECTING_AUTOCONNECT);
      BTA_GATTC_Open(gatt_if_, address, BTM_BLE_BKG_CONNECT_ALLOW_LIST, false);
      BTA_GATTC_Open(gatt_if_, address, reconnection_mode_, false);
    } else {
    } else {
      leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED);
      leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED);
    }
    }
@@ -3026,6 +3035,10 @@ class LeAudioClientImpl : public LeAudioClient {


  void Dump(int fd) {
  void Dump(int fd) {
    dprintf(fd, "  Active group: %d\n", active_group_id_);
    dprintf(fd, "  Active group: %d\n", active_group_id_);
    dprintf(fd, "    reconnection mode: %s \n",
            (reconnection_mode_ == BTM_BLE_BKG_CONNECT_ALLOW_LIST
                 ? " Allow List"
                 : " Targeted Announcements"));
    dprintf(fd, "    configuration: %s  (0x%08hx)\n",
    dprintf(fd, "    configuration: %s  (0x%08hx)\n",
            bluetooth::common::ToString(configuration_context_type_).c_str(),
            bluetooth::common::ToString(configuration_context_type_).c_str(),
            configuration_context_type_);
            configuration_context_type_);
@@ -4295,6 +4308,10 @@ class LeAudioClientImpl : public LeAudioClient {
  AudioState audio_sender_state_;
  AudioState audio_sender_state_;
  /* Keep in call state. */
  /* Keep in call state. */
  bool in_call_;
  bool in_call_;

  /* Reconnection mode */
  tBTM_BLE_CONN_TYPE reconnection_mode_;

  static constexpr char kNotifyUpperLayerAboutGroupBeingInIdleDuringCall[] =
  static constexpr char kNotifyUpperLayerAboutGroupBeingInIdleDuringCall[] =
      "persist.bluetooth.leaudio.notify.idle.during.call";
      "persist.bluetooth.leaudio.notify.idle.during.call";


+13 −6
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ static constexpr char kNotifyUpperLayerAboutGroupBeingInIdleDuringCall[] =
    "persist.bluetooth.leaudio.notify.idle.during.call";
    "persist.bluetooth.leaudio.notify.idle.during.call";
const char* test_flags[] = {
const char* test_flags[] = {
    "INIT_logging_debug_enabled_for_all=true",
    "INIT_logging_debug_enabled_for_all=true",
    "INIT_leaudio_targeted_announcement_reconnection_mode=true",
    nullptr,
    nullptr,
};
};


@@ -2446,7 +2447,8 @@ TEST_F(UnicastTest, ConnectRemoteDisconnectOneEarbud) {
      .Times(1);
      .Times(1);
  /* For remote disconnection, expect stack to try background re-connect */
  /* For remote disconnection, expect stack to try background re-connect */
  EXPECT_CALL(mock_gatt_interface_,
  EXPECT_CALL(mock_gatt_interface_,
              Open(gatt_if, test_address0, BTM_BLE_BKG_CONNECT_ALLOW_LIST, _))
              Open(gatt_if, test_address0,
                   BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _))
      .Times(1);
      .Times(1);


  EXPECT_CALL(mock_audio_hal_client_callbacks_,
  EXPECT_CALL(mock_audio_hal_client_callbacks_,
@@ -2612,7 +2614,8 @@ TEST_F(UnicastTestNoInit, LoadStoredEarbudsCsisGrouped) {
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address0, _))
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address0, _))
      .WillByDefault(DoAll(Return(true)));
      .WillByDefault(DoAll(Return(true)));
  EXPECT_CALL(mock_gatt_interface_,
  EXPECT_CALL(mock_gatt_interface_,
              Open(gatt_if, test_address0, BTM_BLE_BKG_CONNECT_ALLOW_LIST, _))
              Open(gatt_if, test_address0,
                   BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _))
      .Times(1);
      .Times(1);


  // Expect stored device1 to connect automatically
  // Expect stored device1 to connect automatically
@@ -2622,7 +2625,8 @@ TEST_F(UnicastTestNoInit, LoadStoredEarbudsCsisGrouped) {
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address1, _))
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address1, _))
      .WillByDefault(DoAll(Return(true)));
      .WillByDefault(DoAll(Return(true)));
  EXPECT_CALL(mock_gatt_interface_,
  EXPECT_CALL(mock_gatt_interface_,
              Open(gatt_if, test_address1, BTM_BLE_BKG_CONNECT_ALLOW_LIST, _))
              Open(gatt_if, test_address1,
                   BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _))
      .Times(1);
      .Times(1);


  ON_CALL(mock_groups_module_, GetGroupId(_, _))
  ON_CALL(mock_groups_module_, GetGroupId(_, _))
@@ -2743,7 +2747,8 @@ TEST_F(UnicastTestNoInit, LoadStoredEarbudsCsisGroupedDifferently) {
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address0, _))
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address0, _))
      .WillByDefault(DoAll(Return(true)));
      .WillByDefault(DoAll(Return(true)));
  EXPECT_CALL(mock_gatt_interface_,
  EXPECT_CALL(mock_gatt_interface_,
              Open(gatt_if, test_address0, BTM_BLE_BKG_CONNECT_ALLOW_LIST, _))
              Open(gatt_if, test_address0,
                   BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _))
      .Times(1);
      .Times(1);


  // Expect stored device1 to NOT connect automatically
  // Expect stored device1 to NOT connect automatically
@@ -2753,7 +2758,8 @@ TEST_F(UnicastTestNoInit, LoadStoredEarbudsCsisGroupedDifferently) {
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address1, _))
  ON_CALL(mock_btm_interface_, BTM_IsEncrypted(test_address1, _))
      .WillByDefault(DoAll(Return(true)));
      .WillByDefault(DoAll(Return(true)));
  EXPECT_CALL(mock_gatt_interface_,
  EXPECT_CALL(mock_gatt_interface_,
              Open(gatt_if, test_address1, BTM_BLE_BKG_CONNECT_ALLOW_LIST, _))
              Open(gatt_if, test_address1,
                   BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _))
      .Times(0);
      .Times(0);


  // Initialize
  // Initialize
@@ -3729,7 +3735,8 @@ TEST_F(UnicastTest, TwoEarbuds2ndDisconnected) {
  }
  }


  EXPECT_CALL(mock_gatt_interface_,
  EXPECT_CALL(mock_gatt_interface_,
              Open(_, device->address_, BTM_BLE_BKG_CONNECT_ALLOW_LIST, false))
              Open(_, device->address_,
                   BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, false))
      .Times(1);
      .Times(1);


  auto conn_id = device->conn_id_;
  auto conn_id = device->conn_id_;
+1 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ table InitFlagsData {
    get_hci_adapter:int (privacy:"Any");
    get_hci_adapter:int (privacy:"Any");
    irk_rotation_is_enabled:bool (privacy:"Any");
    irk_rotation_is_enabled:bool (privacy:"Any");
    // is_debug_logging_enabled_for_tag -- skipped in dumpsys
    // is_debug_logging_enabled_for_tag -- skipped in dumpsys
    leaudio_targeted_announcement_reconnection_mode_is_enabled: bool (privacy:"Any");
    logging_debug_enabled_for_all_is_enabled:bool (privacy:"Any");
    logging_debug_enabled_for_all_is_enabled:bool (privacy:"Any");
    pass_phy_update_callback_is_enabled:bool (privacy:"Any");
    pass_phy_update_callback_is_enabled:bool (privacy:"Any");
    queue_l2cap_coc_while_encrypting_is_enabled:bool (privacy:"Any");
    queue_l2cap_coc_while_encrypting_is_enabled:bool (privacy:"Any");
+4 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,10 @@ class InitFlags final {
    return init_flags::btm_dm_flush_discovery_queue_on_search_cancel_is_enabled();
    return init_flags::btm_dm_flush_discovery_queue_on_search_cancel_is_enabled();
  }
  }


  inline static bool IsTargetedAnnouncementReconnectionMode() {
    return init_flags::leaudio_targeted_announcement_reconnection_mode_is_enabled();
  }

  inline static int GetAdapterIndex() {
  inline static int GetAdapterIndex() {
    return init_flags::get_hci_adapter();
    return init_flags::get_hci_adapter();
  }
  }
+6 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,12 @@ TEST(InitFlagsTest, test_enable_btm_flush_discovery_queue_on_search_cancel) {
  ASSERT_TRUE(InitFlags::IsBtmDmFlushDiscoveryQueueOnSearchCancel());
  ASSERT_TRUE(InitFlags::IsBtmDmFlushDiscoveryQueueOnSearchCancel());
}
}


TEST(InitFlagsTest, test_leaudio_targeted_announcement_reconnection_mode) {
  const char* input[] = {"INIT_leaudio_targeted_announcement_reconnection_mode=true", nullptr};
  InitFlags::Load(input);
  ASSERT_TRUE(InitFlags::IsTargetedAnnouncementReconnectionMode());
}

TEST(InitFlagsTest, test_enable_debug_logging_for_all) {
TEST(InitFlagsTest, test_enable_debug_logging_for_all) {
  const char* input[] = {"INIT_logging_debug_enabled_for_all=true", nullptr};
  const char* input[] = {"INIT_logging_debug_enabled_for_all=true", nullptr};
  InitFlags::Load(input);
  InitFlags::Load(input);
Loading