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

Commit 0e566611 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Upstream - Masking DM1 DH1 bit" am: e417c31b

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1842420

Change-Id: I4299e5d2406e65411667289b03a4c4e3ba900da0
parents b66b9686 e417c31b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class PeerPacketTypes {
  struct {
    uint16_t supported{0};
    uint16_t unsupported{0};
  } acl, sco;
  } acl{.supported = (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1)}, sco{};

  PeerPacketTypes(const BD_FEATURES& features) {
    /* 3 and 5 slot packets? */
+5 −5
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ TEST_F(PeerPacketTest, all_ones) {
  const BD_FEATURES bd_features = {0xff, 0xff, 0xff, 0xff,
                                   0xff, 0xff, 0xff, 0xff};
  PeerPacketTypes peer_packet_types(bd_features);
  ASSERT_EQ(peer_packet_types.acl.supported, 0xcc00);
  ASSERT_EQ(peer_packet_types.acl.supported, 0xcc18);
  ASSERT_EQ(peer_packet_types.acl.unsupported, 0x0);
}

@@ -55,7 +55,7 @@ TEST_F(PeerPacketTest, 3SLOT_DH3_DM3) {
  const BD_FEATURES bd_features = {0x01, 0x00, 0x00, 0x00,
                                   0x00, 0x00, 0x00, 0x00};
  PeerPacketTypes peer_packet_types(bd_features);
  ASSERT_EQ(peer_packet_types.acl.supported, 0x0c00);
  ASSERT_EQ(peer_packet_types.acl.supported, 0x0c18);
  ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3306);
}

@@ -63,7 +63,7 @@ TEST_F(PeerPacketTest, 5SLOT_DH5_DM5) {
  const BD_FEATURES bd_features = {0x02, 0x00, 0x00, 0x00,
                                   0x00, 0x00, 0x00, 0x00};
  PeerPacketTypes peer_packet_types(bd_features);
  ASSERT_EQ(peer_packet_types.acl.supported, 0xc000);
  ASSERT_EQ(peer_packet_types.acl.supported, 0xc018);
  ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3306);
}

@@ -71,7 +71,7 @@ TEST_F(PeerPacketTest, 2Mb_support) {
  const BD_FEATURES bd_features = {0x00, 0x00, 0x00, 0x02,
                                   0x00, 0x00, 0x00, 0x00};
  PeerPacketTypes peer_packet_types(bd_features);
  ASSERT_EQ(peer_packet_types.acl.supported, 0x0000);
  ASSERT_EQ(peer_packet_types.acl.supported, 0x0018);
  ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3304);
}

@@ -79,7 +79,7 @@ TEST_F(PeerPacketTest, 3Mb_support) {
  const BD_FEATURES bd_features = {0x00, 0x00, 0x00, 0x04,
                                   0x00, 0x00, 0x00, 0x00};
  PeerPacketTypes peer_packet_types(bd_features);
  ASSERT_EQ(peer_packet_types.acl.supported, 0x0000);
  ASSERT_EQ(peer_packet_types.acl.supported, 0x0018);
  ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3302);
}

+14 −4
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

@@ -33,6 +35,7 @@
#include "stack/include/acl_api.h"
#include "stack/include/acl_hci_link_interface.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/hcidefs.h"
#include "stack/l2cap/l2c_int.h"
#include "test/mock/mock_hcic_hcicmds.h"
#include "types/raw_address.h"
@@ -95,6 +98,12 @@ using testing::StrEq;
using testing::StrictMock;
using testing::Test;

std::string Hex16(int n) {
  std::ostringstream oss;
  oss << "0x" << std::hex << std::setw(4) << std::setfill('0') << n;
  return oss.str();
}

class StackBtmTest : public Test {
 public:
 protected:
@@ -168,20 +177,21 @@ TEST_F(StackBtmTest, change_packet_type) {
  btm_set_packet_types_from_address(bda, pkt_types);
  ASSERT_EQ(++cnt, mock_function_count_map["btsnd_hcic_change_conn_type"]);
  ASSERT_EQ(0x123, mock::btsnd_hcic_change_conn_type.handle);
  ASSERT_EQ(0x4400, mock::btsnd_hcic_change_conn_type.packet_types);
  ASSERT_EQ(Hex16(0x4400 | HCI_PKT_TYPES_MASK_DM1),
            Hex16(mock::btsnd_hcic_change_conn_type.packet_types));

  mock::btsnd_hcic_change_conn_type = {};
  btm_set_packet_types_from_address(bda, 0xffff);
  ASSERT_EQ(++cnt, mock_function_count_map["btsnd_hcic_change_conn_type"]);
  ASSERT_EQ(0x123, mock::btsnd_hcic_change_conn_type.handle);
  ASSERT_EQ(0xcc00, mock::btsnd_hcic_change_conn_type.packet_types);
  ASSERT_EQ(Hex16(0xcc00 | HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1),
            Hex16(mock::btsnd_hcic_change_conn_type.packet_types));

  mock::btsnd_hcic_change_conn_type = {};
  btm_set_packet_types_from_address(bda, 0x0);
  // NOTE: The call should not be executed with no bits set
  ASSERT_EQ(0x0, mock::btsnd_hcic_change_conn_type.handle);
  ASSERT_EQ(0x0, mock::btsnd_hcic_change_conn_type.packet_types);

  ASSERT_EQ(Hex16(0x0), Hex16(mock::btsnd_hcic_change_conn_type.packet_types));
  get_btm_client_interface().lifecycle.btm_free();
}