Fix vts sco test fail for usb interface
[Description]
If bt controller device is usb interface,
sco loopback single pkt and bandwidth test can not pass
because pkt size is limited accroding to core spec
[Root Cause]
USB sco packet size is limited in spec
[Solution]
If is bt usb chip, continuous receive sco packets
from controller until size is enough
[Test Report]
Test Pass
Bug: 286355871
Change-Id: Idb150d8a72149f7e1dfaccfd7bc82a91710da59c
diff --git a/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp b/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp
index e5222a7..24eb4d0 100644
--- a/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp
+++ b/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp
@@ -222,6 +222,8 @@
int wait_for_completed_packets_event(uint16_t handle);
void send_and_wait_for_cmd_complete(std::unique_ptr<CommandBuilder> cmd,
std::vector<uint8_t>& cmd_complete);
+ void reassemble_sco_loopback_pkt(std::vector<uint8_t>& scoPackets,
+ size_t size);
// A simple test implementation of BluetoothHciCallbacks.
class BluetoothHciCallbacks
@@ -569,6 +571,11 @@
ASSERT_TRUE(
sco_queue.tryPopWithTimeout(sco_loopback, kWaitForScoDataTimeout));
+ if (sco_loopback.size() < size) {
+ // The packets may have been split for USB. Reassemble before checking.
+ reassemble_sco_loopback_pkt(sco_loopback, size);
+ }
+
ASSERT_EQ(sco_packet, sco_loopback);
}
logger.setTotalBytes(num_packets * size * 2);
@@ -703,6 +710,22 @@
wait_for_command_complete_event(view.GetOpCode(), cmd_complete));
}
+// Handle the loopback packet.
+void BluetoothAidlTest::reassemble_sco_loopback_pkt(std::vector<uint8_t>& scoPackets,
+ size_t size) {
+ std::vector<uint8_t> sco_packet_whole;
+ sco_packet_whole.assign(scoPackets.begin(), scoPackets.end());
+ while (size + 3 > sco_packet_whole.size()) {
+ std::vector<uint8_t> sco_packets;
+ ASSERT_TRUE(
+ sco_queue.tryPopWithTimeout(sco_packets, kWaitForScoDataTimeout));
+ sco_packet_whole.insert(sco_packet_whole.end(), sco_packets.begin() + 3,
+ sco_packets.end());
+ }
+ scoPackets.assign(sco_packet_whole.begin(), sco_packet_whole.end());
+ scoPackets[2] = size;
+}
+
// Empty test: Initialize()/Close() are called in SetUp()/TearDown().
TEST_P(BluetoothAidlTest, InitializeAndClose) {}