OSDN Git Service

DO NOT MERGE RootCanal: Always add default devices
authorMyles Watson <mylesgw@google.com>
Fri, 21 Jun 2019 13:04:08 +0000 (06:04 -0700)
committerMyles Watson <mylesgw@google.com>
Thu, 27 Jun 2019 17:13:54 +0000 (17:13 +0000)
Fixes: 129546852
Test: android.bluetooth.cts.BluetoothLeScanTest#testBasicBleScan
Change-Id: I9912dc7a98155972483e1e1dca812ebbae806bdd
(cherry picked from commit 38767e7f973616ecd020e90572d6ddc73e24c5e3)
Merged-In: I9912dc7a98155972483e1e1dca812ebbae806bdd

test/rootcanal/bluetooth_hci.cc

index 3e4297b..384da73 100644 (file)
@@ -120,6 +120,11 @@ Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {
   // Add the controller as a device in the model.
   test_model_.Add(controller_);
 
+  // Send responses to logcat if the test channel is not configured.
+  test_channel_.RegisterSendResponse([](const std::string& response) {
+    ALOGI("No test channel yet: %s", response.c_str());
+  });
+
   if (BtTestConsoleEnabled()) {
     SetUpTestChannel(6111);
     SetUpHciServer(6211,
@@ -128,6 +133,16 @@ Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {
         6311, [this](int fd) { test_model_.IncomingLinkLayerConnection(fd); });
   }
 
+  // Add some default devices for easier debugging
+  test_channel_.AddDefaults();
+
+  // This should be configurable in the future.
+  ALOGI("Adding Beacons so the scan list is not empty.");
+  test_channel_.Add({"beacon", "be:ac:10:00:00:01", "1000"});
+  test_channel_.AddDeviceToPhy({"1", "0"});
+  test_channel_.Add({"beacon", "be:ac:10:00:00:02", "1000"});
+  test_channel_.AddDeviceToPhy({"2", "0"});
+
   unlink_cb_ = [cb](sp<BluetoothDeathRecipient>& death_recipient) {
     if (death_recipient->getHasDied())
       ALOGI("Skipping unlink call, service died.");
@@ -261,16 +276,6 @@ void BluetoothHci::SetUpTestChannel(int port) {
   test_channel_.RegisterSendResponse(
       [](const std::string& response) { ALOGI("No test channel: %s", response.c_str()); });
 
-  // Add some default devices for easier debugging
-  test_channel_.AddDefaults();
-
-  // This should be configurable in the future.
-  ALOGI("Adding Beacons so the scan list is not empty.");
-  test_channel_.Add({"beacon", "be:ac:10:00:00:01", "1000"});
-  test_channel_.AddDeviceToPhy({"1", "0"});
-  test_channel_.Add({"beacon", "be:ac:10:00:00:02", "1000"});
-  test_channel_.AddDeviceToPhy({"2", "0"});
-
   if (socket_fd == -1) {
     ALOGE("Test channel SetUp(%d) failed.", port);
     return;